Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

COMPUTER SCIENCE PROJECT

FUN WITH PYTHON

Name: Sananda Sengupta


Class: XI-C (HUMANITIES)
Roll no.05

Q1) Input a welcome message and display it


a=input(“welcome to python”)
print(a)

Q2) Input three numbers and display the largest and smallest number
n=3
list=[]
i=1
print("enter values:-")
while i<=n:
b=int(input("enter numbers:"))
list.append(b)
i=i+1
print(list)
print(min(list))
print(max(list))

Q3) Determine whether a number is a perfect number , an armstrong


number or a palindrome number
list1=[]
list2=[]
list3=[]
list4=[]
c=int(input("enter number:"))
b=str(c)
for h in range(1,c):
if c%h==0:
list4.append(h)
if sum(list4)==c:
print("it is a perfect number:")
for i in b:
list2.append(i)
print(list2)
for j in list2:
e=list2[-1]
f=int(e)
d=int(j)
z=d**f
list1.append(z)
a=sum(list1)
print(a)
if a==c:
print("it is an armstrong number")
list3=list2[::-1]
print(list3)
print(list2)
if list2==list3:
print("it is a palindrome")

Q4) Input a number if the number is a prime and composite number


list1=[]
a=int(input("enter number:"))
for i in range(1,a+1):
if a%i==0:
list1.append(i)
if len(list1)==2:
print("it is a prime number")
else:
print("it is a composite number")

Q5) Display the terms of Fibonacci series


a=int(input("enter the maximum limit"))
b=0
c=1
d=1
print(b)
print(c)
while (d<=a):
print(d)
b=c
c=d
d=b+c

Q6) Count and Display the number of vowels, consonants, uppercase,


lowercase characters in string
list=["a","e","i","o","u","A","E","I","O","U"]
list1=[]
list2=[]
a=input("enter the word or phrase:")
for i in a:
if i in list:
list1.append(i)
else:
list2.append(i)
print("number of consonants present are:",len(list2))
print("number of vowels present are:",len(list1))
lower=0
upper=0
for j in a:
if j.islower():
lower=lower+1
if j.isupper():
upper=upper+1
print("number of uppercase are:",upper)
print("number of lowercase are:",lower)

Q7) Find the largest and smallest number in list/tuple


list=[]
a=int(input("enter how many terms:"))
for i in range(1,a+1):
b=int(input("enter terms:"))
list.append(b)
print(list)
print("largest digit is:",max(list))
print("smallest digit is:",min(list))
Q8) Input a list of numbers and find the smallest and largest number from
the list
list=[]
a=int(input("enter how many terms:"))
for i in range(1,a+1):
b=int(input("enter terms:"))
list.append(b)
print(list)
print("largest digit is:",max(list))
print("smallest digit is:",min(list))

Q9) Create a dictionary with the roll number and names of n students
in a class and display the names of students who have scored above 75
dict={"ria":63,"pia":56,"sia":78,"lia":93}
for i in dict:
if dict[i]>75:
print(i,dict[i])

You might also like