Python
Python
CLASS : XI-A
COMPUTER SCIENCE
INDEX
1
COMPUTER SCIENCE
2
COMPUTER SCIENCE
Marks Grade
>=90 A
75-90 B
60-75 C
Below 60 D
23) Write a program to enter a number and
check if it is a prime number or not.
3
COMPUTER SCIENCE
4
COMPUTER SCIENCE
Sum=a+b
OUTPUT:-
5
COMPUTER SCIENCE
Area=3.14*r**2
print('The area of the circle is:', Area)
OUTPUT:-
Area=(1/2)*b*h
OUTPUT:-
6
COMPUTER SCIENCE
P=(a+b+c)/3
print('The percentage marks are:', P,'%')
OUTPUT:-
5. Write a program to compute area of square and
triangle.
A=a**2
T=((3**0.5)/4)*a**2
OUTPUT:-
7
COMPUTER SCIENCE
SI=(P*R*T)/100
OUTPUT:-
7. Write a program to read two numbers and prints their
quotient and reminder.
a=float(input('Enter the dividend:'))
b=float(input('Enter the divisor:'))
Q=a//b
R=a%b
8
COMPUTER SCIENCE
OUTPUT:-
if a%2==0:
print('The number is even')
else:
print('The number is odd')
OUTPUT:-
9
COMPUTER SCIENCE
OUTPUT:-
10
COMPUTER SCIENCE
OUTPUT:-
print('Rectangle Specifications')
print('Length=',l)
print('Breadth=', b)
print('Area=', area)
11
COMPUTER SCIENCE
OUTPUT:-
OUTPUT:-
12
COMPUTER SCIENCE
13
COMPUTER SCIENCE
OUTPUT:-
14
COMPUTER SCIENCE
OUTPUT:-
Feet=a*0.032
Inch=a*0.393
15
COMPUTER SCIENCE
OUTPUT:-
16
COMPUTER SCIENCE
OUTPUT:-
17
COMPUTER SCIENCE
OUTPUT:-
Area=b*h
Perimeter=2*(b+w)
18
COMPUTER SCIENCE
OUTPUT:-
19
COMPUTER SCIENCE
OUTPUT:-
20
COMPUTER SCIENCE
OUTPUT:-
21
COMPUTER SCIENCE
OUTPUT:-
22
COMPUTER SCIENCE
23
COMPUTER SCIENCE
OUTPUT:-
24
COMPUTER SCIENCE
OUTPUT:-
25
COMPUTER SCIENCE
26
COMPUTER SCIENCE
27
COMPUTER SCIENCE
28
COMPUTER SCIENCE
OUTPUT:-
29
COMPUTER SCIENCE
num=int(input('Enter a number:'))
fact=1
a=1
while a<=num:
fact*=a
a+=1
print('The factorial of',num,'is',fact)
OUTPUT:-
30
COMPUTER SCIENCE
print()
for j in range(1,i):
print('*',end=' ')
OUTPUT:-
30.Write a Python script to print Fibonacci series’ first 20
elements.
first=0
second=1
print(first, end=' ')
print(second,end=' ')
for a in range(1,19):
third=first+second
print(third,end=' ')
first,second=second,third
31
COMPUTER SCIENCE
OUTPUT:-
31.Write a program to read an integer>1000 and reverse
the number.
num=int(input('Enter a number (>1000):'))
tnum=num
reverse=0
while tnum>0:
digit=tnum%10
reverse=reverse*10+digit
tnum=tnum//10
print('Reverse of',num,'is',reverse)
OUTPUT:-
32
COMPUTER SCIENCE
if angle1+angle2+angle3==180:
print('The angles form a triangle')
else:
print('The angles do not form a triangle')
33
COMPUTER SCIENCE
OUTPUT:-
34
COMPUTER SCIENCE
print()
OUTPUT:-
35
COMPUTER SCIENCE
for a in range(5):
print(n)
print()
n=n*10+1
OUTPUT :-
36
COMPUTER SCIENCE
print(j,end=' ')
else:
print()
OUTPUT:-
37
COMPUTER SCIENCE
line=input('Enter a line:')
lowercount=uppercount=0
digitcount=alphacount=0
for a in line:
if a.islower():
lowercount+=1
elif a.isupper():
uppercount+=1
elif a.isdigit():
digitcount+=1
if a.isalpha():
alphacount+=1
OUTPUT:-
38
COMPUTER SCIENCE
39
COMPUTER SCIENCE
OUTPUT:-
40