0% found this document useful (0 votes)
0 views

Python Programs for class 8 SET 3

The document contains a series of Python programs that perform various tasks, including checking if a number is a palindrome, doubling a number, dividing numbers in a range, performing mathematical operations, calculating the sum of input numbers, determining age status, checking temperature states, weather forecasts, analyzing string characteristics, and converting time to seconds. Each program prompts user input and outputs the result based on the specified logic. The examples demonstrate basic programming concepts and control structures in Python.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Python Programs for class 8 SET 3

The document contains a series of Python programs that perform various tasks, including checking if a number is a palindrome, doubling a number, dividing numbers in a range, performing mathematical operations, calculating the sum of input numbers, determining age status, checking temperature states, weather forecasts, analyzing string characteristics, and converting time to seconds. Each program prompts user input and outputs the result based on the specified logic. The examples demonstrate basic programming concepts and control structures in Python.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

# 36 WAP display of number palindrome or not

num=int(input("Enter number:"))
wnum=num
rev=0
while(wnum>0):
dig=wnum%10
rev=rev*10+dig
wnum=wnum//10
if (num==rev):
print("Number",num,"is a palindrome!")
else:
print("Number",num,"is not a palindrome!")

# 37 WAP to double the number


n=int(input("Enter the value:"))
Doublethenumber=n*2
print(Doublethenumber)

# 38 WAP to divide the number by given range of number


for i in range(1,200):
if i%3==0:
print(i)

# 39 WAP mathematical operations


a,b=10,15
x=20
y=25
a=x+y-b
x=a+b-y+10
z=y+b*3+a
x=50
a=x+y+z
print("a :",a)
print("b :",b)
print("x :",x)
print("y :",y)
print("z :",z)
# 40 WAP to print sum of the of the given numbers by using choices.

ch="Y"
sum=0
while ch.upper()=="Y":
num=int(input("Enter any number :"))
sum=sum+num
ch=input("Do you wish to continue(Y,N)?:")
print("Sum of all the numbers is :",sum)

# 41 WAP to find status of the age

age=int(input("Enter your age:"))


if age>=18:
print("You are an adult.")
print("You are eligible for voting.")
elif age<18 and age>3:
print("You are in school.")
else:
print("You are a kid.")
print("Thank you.")

# 42 WAP to check the temperature

temp=int(input("Enter the temperature : "))


if temp<32:
print('ice')
elif temp<212:
print('water')
else:
print('steam')
# 43 WAP to check the weather forecast

weather=input("Enter the type of weather :")


if weather=='sunny':
print("wear sunglasses")
elif weather=='raining':
print("Take umbrella")
elif weather=='snow':
print("going sketing")
else:
print("It's invalid!!!")

#44 WAP find the type of the string

s = input("Enter any string :")


vowel = consonent = uppercase = lowercase= 0
for i in s:
if(i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u'or i == 'A' or i == 'E' or
i == 'I' or i == 'O' or i == 'U'):
vowel = vowel +1
else:
consonent = consonent + 1
if i.isupper() :
uppercase = uppercase + 1

if i.islower():
lowercase = lowercase + 1

print("Total number of vowel:",vowel)


print("Total number of consonent:",consonent)
print("Total number of uppercase letter:",uppercase)
print("Total number of lowercase letter:",lowercase)

#45 WAP to find total number of seconds

days=int(input("Enter the days :"))*3600*24


hours=int(input("Enter the hours :"))*3600
minutes=int(input("Enter minutes :"))*60
seconds=int(input("Enter seconds :"))
time= days+hours+minutes+seconds
print("Total number of seconds",time)

You might also like