Professional Documents
Culture Documents
NAME:
ROLL NO:
CLASS: XI
STREAM:
NERUL, NAVI MUMBAI
CERTIFICATE
Roll No. :
__________________
Internal Examiner
Date:
__________________ ___________________
SCHOOL SEAL PRINCIPAL
Date:
SR. PROGRAM DAT PAG TEACHERS
SIGNATUR
NO E E E&
. NO. REMARKS
WAP to Input a welcome message and
01.
display it.
WAP to Input two numbers and display the
02.
smaller number.
09.
**
***
****
*****
WAP to Generate the following pattern using
nested loop.
10. 1
123
1234
12345
WAP to generate the following pattern using
nested loop.
A
11. AB
ABC
ABCD
ABCDE
WAP to input the value of x and n and print
the sum of the following series
12.
25.
PYTHON PROGRAMS
1. WAP to Input a welcome message and display it.
Code:
print(msg)
SAMPLE OUTPUT:
Code:
SAMPLE OUTPUT:
PI=3.14
area = PI*radius**2
SAMPLE OUTPUT:
Code:
avg=(sub1+sub2+sub3+sub4+sub4)/5
SAMPLE OUTPUT:
5. Write a short program that asks for your height in
centimetres and then converts your height to feet and inches. (1
foot = 12 inches, 1 inch = 2.54 cm).
Code:
SAMPLE OUTPUT:
Code:
#simple interest
P = float(input("enter amount"))
R = float(input("enter rate"))
T = float(input("enter time"))
SI = (P * R * T) / 100
print("simple interest is", SI)
#Compound Interest
principle=float(input("Enter principle amount:"))
time=int(input("Enter time duration:"))
rate=float(input("Enter rate of interest:"))
Code:
area = (b * h) / 2
SAMPLE OUTPUT:
Code:
SAMPLE OUTPUT:
9. WAP to Generate the following pattern using nested loop.
*
**
***
****
*****
Code:
n=int(input("Enter a no"))
# printing stars
print("*",end="")
print("\r")
SAMPLE OUTPUT:
10. WAP to Generate the following pattern using nested loop.
1
123
1234
12345
Code:
n=int(input("Enter a no"))
print(j,end=" ")
# ending line after each row
print("\r")
SAMPLE OUTPUT:
val=65
print(chr(val),end=" ")
val=val+1
print("\r")
SAMPLE OUTPUT:
12. WAP to input the value of x and n and print the sum of the
following series:
Code:
Series 1:
s=1
s += x**a
s=1
if a%2==0:
s += x**a
else:
s -= x**a
Series 3:
s=0
if a%2==0:
s += (x**a)/a
else:
s -= (x**a)/a
s=0
fact=1
fact=fact*a
if a%2==0:
s += (x**a)/fact
else:
s -= (x**a)/fact
SAMPLE OUTPUT:
13. WAP to Determine whether a number is a perfect number.
Code:
sum1 = 0
if(n % i == 0):
sum1 = sum1 + i
if (sum1 == n):
else:
SAMPLE OUTPUT:
14. WAP to determine whether a number is an armstrong
number.
Code:
import math
print ("Enter the a number")
number = int(input())
#to calculate the number of digits in a number
number_of_digits = int(math.log10(number))+1
sum_arm = 0
temp = number
while temp != 0:
sum_arm = sum_arm + int(math.pow (temp%10,number_of_digits))
temp = temp//10
if sum_arm == number:
print ("Yes an Armstrong number")
else:
print ("No")
SAMPLE OUTPUT:
15. WAP to determine whether a number is a palindrome.
Code:
n=int(input("Enter number:"))
temp=n
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
if(temp==rev):
else:
SAMPLE OUTPUT:
16. WAPto Input a number and check if the number is a prime
or composite number.
Code:
import math
number = int(input())
i=2
prime = True
#if the number is not divisible by any number less than the
#square root of the number
#then it is prime
if number%i == 0:
prime = False
break
i = i+1
if number < 2:
prime = False
if prime:
else:
SAMPLE OUTPUT:
17. WAP to Display the terms of a Fibonacci series.
Code:
First_Value = 0
Second_Value = 1
Next = Num
else:
First_Value = Second_Value
Second_Value = Next
print(Next)
SAMPLE OUTPUT:
18. WAP
to compute the greatest common divisor and least
common multiple of two integers.
Code:
def gcd(x,y):
if(y==0):
return x
else:
r=x%y
return(gcd(y,r))
def lcm(x,y):
p=x*y
l=p/gcd(x,y)
return l
print("GCD is",gcd(x,y))
print("LCM is",lcm(x,y))
SAMPLE OUTPUT:
19. WAPto Count and display the number of vowels, consonants,
uppercase, lowercase characters in string.
Code:
vowels_list = ['a','e','i','o','u',’A’,’E’,’I’,’O’,U’]
for i in string:
if i in vowels_list:
vowels += 1
if i not in vowels_list:
consonants += 1
if i.isupper():
uppercase += 1
if i.islower():
lowercase += 1
SAMPLE OUTPUT:
20. WAP to Input a string and determine whether it is a
palindrome or not.
Code:
string=input(("Enter a string:"))
if(string==string[::-1]):
else:
print("Not a palindrome")
SAMPLE OUTPUT:
Code:
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
else:
else:
else:
SAMPLE OUTPUT:
22. WAP to print the following series:
(i) 1 4 7 10. . . . . . . 40
(ii) 1 -4 7 -10 . . . . . . . - 40
Code:
print("First Series:")
print("\nSecond Series:")
x=1
x *= -1
SAMPLE OUTPUT:
Code:
n=int(input("Enter number:"))
fact=1
while(n>0):
fact=fact*n
n=n-1
print("Factorial of the number is: ")
print(fact)
SAMPLE OUTPUT:
24. Write a Menu-Driven Program to create a simple calculator
Code:
while True:
print("\nMENU")
print("5. Exit")
if choice == 1:
print( "\nADDITION\n")
sum = a + b
elif choice == 2:
print( "\nSUBTRACTION\n")
difference = a - b
elif choice == 3:
print( "\nMULTIPLICATION\n")
product = a * b
elif choice == 4:
print( "\nDIVISION\n")
division = a / b
elif choice == 5:
break
else:
SAMPLE OUTPUT:
25. Write a Program to take in the marks of 5 subjects and display
the grade.
Code:
SAMPLE OUTPUT: