Class XI Computer Science Holiday H
Class XI Computer Science Holiday H
W
1.Python Program to Calculate the Average of Numbers in a Given List
3.Python Program to Take in the Marks of 5 Subjects and Display the Grade
4.Python Program to Read Two Numbers and Print Their Quotient and Remainder
5.Python Program to Accept Three Digits and Print all Possible Combinations from the Digits
"1+2+…..+n= "
12.Python Program to Read a Number n and Print the Natural Numbers Summation Pattern
Solved programs
Write a lot of programs: interest calculation, primarily testing, and factorials.
1. Write a program to input principal amount, rate and time and calculate the simple interest and
amount after each of the year.
interest= (p*r*i)/100
amount= p+ interest
"AMOUNT = ",amount)
2. Write a program to input principal amount, rate and time and calculate the compound interest and
amount after each of the year.
interest= (p*r*1)/100
p= p+ interest
"AMOUNT = ",p)
3. Write a program to input a number and print the factorial of the number.
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
else:
factorial = factorial*i
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
else:
else:
5. Write a program in python to display all the prime numbers within an interval .
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
else:
print(num)
num = 12
print(num,'x',i,'=',num*i)
7. Write a Program to display the Fibonacci sequence up to n-th term where n is provided by the user.
n1 = 0
n2 = 1
count = 0
if nterms <= 0:
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print(n1,end=' ')
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
sum=0
temp= num
while temp>0:
digit = temp % 10
sum += digit**3
temp //=10
if num == sum:
else:
order = len(str(num))
sum = 0
temp = num
digit = temp % 10
temp //= 10
if num == sum:
print(num)
if num < 0:
else:
sum = 0
sum += num
num -= 1
number
x= int(input(―enter first no ―)
y= int(input(―enter second no ―)
if x > y:
greater = x
else:
greater = y
while(True):
lcm = greater
break
greater += 1
return lcm
x= int(input(―enter no ―)
if x % i == 0:
print(i)
string
vowels = 'aeiou'
ip_str = ip_str.casefold()
count = 0
if char in count:
count[char] += 1
print(count)
22
333
4444
55555
for j in range(i):
print()
**
***
****
*****
n=6
for i in range(1,n):
for j in range(i):
print(j, end=‘ ‗)
print()
included).
print (x)
import random
print target_num
print('Well guessed!')
18. Write a Python program that accepts a word from the user and
reverse it.
print(word[char], end="")
print("\n")
count_odd = 0
count_even = 0
for x in range(1,101):
if not x % 2:
count_even+=1
else:
count_odd+=1
20. Write a Python program that accepts a string and calculate the
s = input("Input a string")
d=l=0
for c in s:
if c.isdigit():
d=d+1
elif c.isalpha():
l=l+1
else:
pass
print("Letters", l)
print("Digits", d)
s = str(i)
if (int(s[0])%2==0) and (int(s[1])%2==0) and (int(s[2])%2==0):
print( i))