Python file 2-3
Python file 2-3
This is to certify that this project had been successfully completed by Rishvi Mishra of Class 10A under the
guidance of Mrs. Chandana Channappa, in particular fulfillment of the curriculum of Central Board of Secondary
Education (CBSE) leading to the award of annual examination of the year 2024-2025.
_________________ _____________________
Signature of the Teacher Signature of the Principal
___________________________ ____________________________
Signature of the Internal Examiner Signature of the External Examiner
Page 1 of 26
ACKNOWLEDGEMENT
At the very outset I am very much grateful to our beloved and respected teacher Mrs. Chandana Channappa for her
kind support and guidance that she has been providing during the preparation of this Project.
I express my sincere gratitude to the principal of GIIS, Tokyo for her kind guidance in this project.
Page 2 of 26
INDEX
1.Write a code to assign value 15 to the variable ‘s’
Page 3 of 26
subtract 2999 from 466850.
19.Write a code to write a code for finding perimeter and area of a rectangle
with length and breadth of measurements 62 cm and 26 cm respectively.
Page 4 of 26
12 respectively.
25.Karry was reading a book today. She did not know a certain word
meanings and now wants to make a dictionary with them to help her get the
meaning of them in a instant .Help her by
making the dictionary on python.
26.Create a tuple to tell the name,age and grade for Riya,who is a 15 year
old,9th grader.Also access and unpack the tuple.
Page 5 of 26
1.Write a code to assign value 15 to the variable ‘s’
Code:
s=15
print(s)
Output:
Code:
A=11
B=float(A)
print(B)
Output:
Page 6 of 26
3.Write a code to convert the float value 11.26 to integer number .
Code:
A=11.26
B=int(A)
print(B)
Output:
Output:
Page 7 of 26
5.Write a code to make a tuple with different boy names.
Code:
names=('karthik','sahil','himanshu')
print(names)
Output:
Code:
X={10,11,12,13}
Y={12,13,14,15}
print(X|Y)
Output:
Page 8 of 26
7.Write a code to make and intersection of the same variables (X
and Y )as above .
Code:
X={10,11,12,13}
Y={12,13,14,15}
print(X&Y)
Output:
Code :
X={10,11,12,13,14}.
Y={13,14,15,16,17}
print(X-Y)
Output:
Page 9 of 26
9.Write a code to list the symmetric difference of the variables X
and Y of value 11-15 and 14-18 respectively.
Code:
X={11,12,13,14,15}
Y={14,15,16,17,18}
print(X^Y)
Output:
Code:
A=5649
B=22345
print(A+B)
Output:
Page 10 of 26
11.Write a code to subtract 2999 from 466850.
Code :
A=2999
B=466850
print(B-A).
Output:
Code:
A=123456789
B=987654321
print(A*B)
Output:
Page 11 of 26
13.Write a code to divide 2424 by 2.
Code:
A=2424
B=2
print(A/B)
Output:
Code:
A=34567
B=3
print(A%B)
Output:
Page 12 of 26
15.Write a code to list the value of 58648 raised to power 9.
Code:
A=58648
B=9
print(A**B)
Output:
Code:
a=10
b=8
c=0
c=a+b
print(c)
c=a-b
print(c)
c=a*b
print(c)
c=a/b
Page 13 of 26
print(c)
c=a%b
print(c)
c=a**b
print(c)
Output:
Code:
A = 100
B = 80
if A == B:
print("A is equal to B")
else:
print("A is not equal to B")
if A != B:
print("A is not equal to B")
else:
print("A is equal to B")
Page 14 of 26
if A < B:
print("A is less than B")
else:
print("A is not less than B")
if A > B:
print("A is greater than B")
else:
print("A is not greater than B")
Output:
Code:
X=True
Y=False
print('X and Y is',X and Y)
print('X or Y is',X or Y)
print('not X is',not X)
Page 15 of 26
Output:
19.Write a code to write a code for finding perimeter and area of a rectangle
with length and breadth of measurements 62 cm and 26 cm respectively.
Code:
length = 62
breadth = 26
perimeter = 2 * (length + breadth)
area = length * breadth
print("Perimeter of the rectangle:", perimeter, "cm")
print("Area of the rectangle:", area, "square cm")
Output:
Page 16 of 26
20.Write a code to give a code with membership operators.
Code:
my_list = [1, 2, 3, 4, 5]
output_1 = 3 in my_list
output_2 = 6 in my_list
print(output_1)
print(output_2)
Output:
Code:
X1='Welcome to GIIS!'
X2=1234
Y1='Welcome to GIIS!'
Y2=1234
print(X1 is Y1)
print(X1 is not Y1)
print(X1 is not Y2)
print(X1 is X2)
Page 17 of 26
Output:
Code:
X = 10
Y = 12
if X < Y:
print('X is less than Y')
elif X > Y:
print('X is greater than Y')
else:
print('X and Y are equal')
Output:
Page 18 of 26
23.Write a while loop code .
Code:
count=0
while(count<10):
print(count)
count=count+1
print("Thank You!")
Output:
Page 19 of 26
24.Write a nested loop code.
Code:
count=1
for i in range(10):
print(str(i)*i)
for j in range(0,i):
count=count+1
Output:
Page 20 of 26
25.Karry was reading a book today. She did not know a certain
word meanings and now wants to make a dictionary with them to
help her get the meaning of them in a instant .Help her by
making the dictionary on python.
a)chockablock - at point of overflow
b)Mordant-sarcastic
c)Polymecize-to engage in a contentious debate
d) Agog-state of eager anticipation e)Resplendent
-richly colourful
Code:
word_meanings =
{ "chockablock": "at point of overflow", "mordant": "sarcastic",
"polemicize": "to engage in a contentious debate",
"agog": "state of eager anticipation", "resplendent": "richly
colourful" }
print("Word meaning of 'agog':",
word_meanings["agog"])
Output:
Page 21 of 26
26.Create a tuple to tell the name,age and grade for Riya,who is a
15 year old,9th grader.Also access and unpack the tuple.
Code:
student=('Riya',15,'9th Grade')
print(student)
name=student[0]
age=student[1]
grade=student[2]
print(name,age,grade)
student=('Riya',15,'9th grade')
name,age,grade=student
print(name)
print(age)
print(grade)
Output:
Page 22 of 26
27.Check if an element exists in a tuple, consisting of
apple,banana,orange and pear,or not.
Code:
fruits=('apple','banana','orange','pear')
contains_apple='apple' in fruits
print(contains_apple)
contains_pear='pear' in fruits
print(contains_pear)
Output:
Page 23 of 26
28.Neena is writing a program to print numbers from 1 to 9.
However, Neena wants to stop the printing process when the
number 7 is reached. She also wants to print all odd numbers from
1 to 14, skipping the even numbers. Help Neena by writing codes
to achieve these.
Code:
for i in range(1,10):
if i==7:
print("Loop finishing early!")
break
print(i)
for i in range(1,15):
if i%2==0:
continue
print(i)
Output:
Page 24 of 26
29.Write a program for allotting Grades based on scores,to a student named
Alina,if her score was 85.
Code:
score=85
if score>=90:
grade="A"
elif score>=80:
grade="B"
elif score>=70:
grade="C"
else:
grade="D"
print("Alina's grade is:",grade)
Output:
Page 25 of 26
30.Print a double triangular pattern using nested loops.
Code:
rows=5
for i in range(rows):
for j in range(i+1):
print("*",end=" ")
print()
for i in range(rows,0,-1):
for j in range(i-1):
print("*",end=" ")
print()
Output:
Page 26 of 26
Page 27 of 26