Professional Documents
Culture Documents
In [2]: x = input()
y = input()
5
6
In [3]: x = int(x)
y = int(y)
x+y
Out[3]: 11
25
In [5]: #remainder
print(5%2)
In [10]: if x>y:
print("nice")
else:
print("not so nice")
not so nice
In [11]: num = 10
if (x==y and y==num): #and / or
print("correct")
else:
print("incorrect")
incorrect
10 5 7 2 7 8 5 1 4
49
i like pop
i like 2.33
i like hiphop
i like lofi
i like pop
i like 2.33
i like hiphop
i like lofi
The sum is 55
[4, 5, 6, 7, 8]
[5, 6, 7]
[3, 4, 5, 6, 7, 8, 9]
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, [11, 12]]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, [11, 12], 13, 14]
[1, 2, 3, 55, 4, 5, 6, 7, 8, 9, 10, [11, 12], 13, 14]
1
4
<class 'tuple'>
In [63]: #dictionary
my_dict={}
#dictionary with integer keys
my_dict = {1:'apple',2:'ball','age': 26}
print(my_dict[1])
print(my_dict[2])
my_dict['age'] = 27
print(my_dict['age'])
apple
ball
27
In [72]: #SETS
my_set = {1,2,3,3,5}
print(my_set)
my_set.add(6)
print(my_set)
my_set.update([7,8,1])
print(my_set)
my_set.update([9,10],{11,22})
print(my_set)
my_set.remove(1)
print(my_set)
my_set.discard(2)
print(my_set)
#sets cannot have duplicates
#we can make set from a list
#set function
#we use set funciton to remove duplicates from a list
my_set = set([1,2,3,4,3,2])
print(my_set)
{1, 2, 3, 5}
{1, 2, 3, 5, 6}
{1, 2, 3, 5, 6, 7, 8}
{1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 22}
{2, 3, 5, 6, 7, 8, 9, 10, 11, 22}
{3, 5, 6, 7, 8, 9, 10, 11, 22}
{1, 2, 3, 4}
In [ ]: