Python Exam
Python Exam
print(z)
sentence = '''this is a
sentence which goes
into multiple lines'''
print(sentence)
print(sentence.capitalize())
print(sentence.upper())
score = 91
if score >= 90 and score <= 100:
grade = 'A'
else:
grade = 'B'
print(grade)
score = 89
grade = 'A'
elif score >= 80:
grade = 'B'
dir(names)
# It gives us what operations can be done on the data.
names.append('Dinesh')
print(names)
#To add names we use append
#set - Set operations: Union (|), intersection (&), difference (-), Xor(^)
digits = [0, 0, 1, 1, 2, 3, 4, 5]
type(digits)
#Iterations
#for loop
for x in [1,2,3,4]:
print(x)
animals = ['cat','dog','bird']
print(animals)
3
8
17
numbers = [3,5,9,-1,3,1]
result = 0
for item in numbers:
if item >= 9:
continue
result = result + item
print(result)
3
8
7
10
11
print(ages)
ages.get('Suresh')
add_2(100)
def add_2_num(x,y):
result = x+y
return (result)