PIKA
PIKA
PUBLIC SCHOOL
TEACHER SIGNATURE:
AKNOWLEDGEMENT
CODING :
sum = 0
count = 0
while True:
num = int(input())
if num == 0:
break
sum += num
count += 1
if count > 0:
print("Average:", avg)
else:
OUTPUT :
15
Average: 10.0
PROBLEM 2 : write a program to check whether
a number is palindrome or not.
CODING :
num=int(input("Enter a number:"))
temp=num
rev=0
while (num>0):
dig=num%10
rev=rev*10+dig
num=num//10
if(temp==rev):
else:
OUTPUT :
CODING :
p = float(input("Enter Principal amount: "))
si =p*r*t/100
OUTPUT :
Enter time :5
CODING:
sum = 0
i=0
if i % 2 == 0:
sum+=i
i+=1
OUTPUT:
Enter a number: 64
CODING :
i=0
sum = 0
while i<=100:
sum = sum + i
i = i+1
print("Sum = ",sum)
OUTPUT :
Sum = 5050
PROBLRM 5 : write a program to swap two
numbers without using the third variable
CODING :
x = int(input("Enter the value of x:"))
x = x+y
y = x-y
x = x-y
OUTPUT:
CODING :
n = int(input("Enter any Number :"))
i=1
value = n * i
i=i+1
OUTPUT:
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
PROBLRM 7 : write a progam to print whether a
given character is an uppercase or lowercase
character or digit or any other character.
CODING :
char = input("Enter a character: ")
if char.isupper():
print("Uppercase letter")
elifchar.islower():
print("Lowercase letter")
elifchar.isdigit():
print("Digit")
else:
print("Other character")
OUTPUT :
Digit
Uppercase letter
Lowercase letter
PROBLEM 9 : write a program to count the
number of vowels in a string using for loop.
CODING:
str = input("Please enter a string as you wish :")
vowels = 0
for i in str :
if i in 'aeiouAEIOU':
vowels += 1
OUTPUT :
GOOD MORNING
CODING :
n = int(input("enter the number:"))
factorial = 1
if n < 0 :
elif n == 0:
else:
factorial = factorial*i
OUTPUT :
*
**
***
****
*****
CODING :
rows = int(input("Enter number of rows: "))
for i in range(rows):
for j in range(i+1):
print()
OUTPUT :
**
***
****
*****
PROBLEM 8 : write a program to display all
numbers within a range except the prime numbers.
CODING :
start_range = int(input("Enter the start of the range: "))
if num <= 1:
print(num)
else:
is_prime = True
if num % i == 0:
is_prime = False
if not is_prime:
print(num)
OUTPUT :
15 16 18 20
PROBLEM 12 :write a program to input two
numbers and swap both the numbers by using third
number.
CODING :
temp = x
x=y
y = temp
print("Value of x:",x)
print("Value of y:",y)
OUTPUT:
Value of x: 876
Value of y: 564
PROBLEM 13: write a program to print the
following pattern .
4321
432
43
CODING :
for i in range(1, 5):
print(j, end="")
print()
OUTPUT :
4321
432
43
4
PROBLEM 11 : write a program to calculate
the area of circle, rectangle and triangle
depending upon user choice. The choice should be
entered by the user in the form of a menu. Wrong
choice should be addressed.
CODING :
while True:
print("\nMenu:")
print("1. Circle")
print("2. Rectangle")
print("3. Triangle")
print("4. Exit")
if choice == '1':
print("Exiting.")
break
else:
OUTPUT :
Menu:
1. Circle
2. Rectangle
3. Triangle
4. Exit
Enter radius: 4
Menu:
1. Circle
2. Rectangle
3. Triangle
4. Exit
Enter length: 25
Enter width: 15
1. Circle
2. Rectangle
3. Triangle
4. Exit
Enter base: 15
Enter height: 20
Menu:
1. Circle
2. Rectangle
3. Triangle
4. Exit