diff --git a/python_sandbox_starter/lists.py b/python_sandbox_starter/lists.py index 6cd3bbd..0a4c68b 100644 --- a/python_sandbox_starter/lists.py +++ b/python_sandbox_starter/lists.py @@ -1 +1,22 @@ # A List is a collection which is ordered and changeable. Allows duplicate members. + +# create list +numbers = [1, 2, 3, 4, 5, 6] +fruits = ['apples', 'oranges', 'grapes', 'pears'] + +#use constructor +numbers2 = list((9, 8, 7, 6, 5, 4, 3)) + +print(numbers, numbers2) +print(len(fruits)) +print(fruits[2]) + +#append item to list +fruits.append('mangoes') + +#insert into position of list +fruits.insert(0, 'strawberries') + +# remove item from list +fruits.remove(fruits[2]) +print(fruits) \ No newline at end of file diff --git a/python_sandbox_starter/strings.py b/python_sandbox_starter/strings.py index 0942500..dbeb3bc 100644 --- a/python_sandbox_starter/strings.py +++ b/python_sandbox_starter/strings.py @@ -1,6 +1,19 @@ # Strings in python are surrounded by either single or double quotation marks. Let's look at string formatting and some string methods +name = 'Askhat' +age = 37 + +# Concatenate +print('Hello my name is '+ name + ' i`am ' + str(age) +'.') # String Formatting +# arguments by position +print('my name is {name} i am {age}'.format(name = name, age = age)) + +#F-Strings +print(f'hello, my name is {name} and i am {age}') + # String Methods +s = 'hello, world!' +print(s.capitalize()) diff --git a/python_sandbox_starter/tuples_sets.py b/python_sandbox_starter/tuples_sets.py index 90d2fc4..48c9ada 100644 --- a/python_sandbox_starter/tuples_sets.py +++ b/python_sandbox_starter/tuples_sets.py @@ -1,5 +1,10 @@ # A Tuple is a collection which is ordered and unchangeable. Allows duplicate members. +fruits = ('apples', 'oranges', 'grapes') +fruits2 = ('apples',) - +print(fruits2, type(fruits2)) +print(fruits[2]) +fruits[0] = 'strawberry' # A Set is a collection which is unordered and unindexed. No duplicate members. + diff --git a/python_sandbox_starter/variables.py b/python_sandbox_starter/variables.py index 7ffc3e4..4122765 100644 --- a/python_sandbox_starter/variables.py +++ b/python_sandbox_starter/variables.py @@ -13,3 +13,14 @@ - Must start with a letter or an underscore - Can have numbers but can not start with one """ +x=1 +y = 2.1 +name = "askhat" +is_cool = True + +x, y, name, is_cool = (1, 2.5, 'askhat', True) +a = x + y + +print(x, y, name, is_cool, a) + +print(type(y)) \ No newline at end of file