0% found this document useful (0 votes)
66 views13 pages

Class 12 Python Revision Tour (All Programs)

Uploaded by

goverdhansmart
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views13 pages

Class 12 Python Revision Tour (All Programs)

Uploaded by

goverdhansmart
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

#program 1.

3
n1=int(input("enter a digit within the range 0-
999:"))
if n1<0:
print("please enter a number greater than 0")
elif n1<10:
print("the given digit is a 1 digit number")
elif n1<100:
print("the given digit is a 2 digit number")
elif n1<=999:
print("the given digit is a 3 digit number")
else:
print("please enter digit within range 0-999")

#problem 1.4
n1=int(input("enter a integer within the range 0-
999:"))
if n1>0:
if n1<10:
print("the given integer is a 1 digit number")
elif n1<100:
print("the given integer is a 2 digit number")
elif n1<=999:
print("the given integer is a 3 digit number")
else:
print("please enter integer within range 0-999")
else:
if n1>(-10):
print("the given integer is a 1 digit number")
elif n1>(-100):
print("the given integer is a 2 digit number")
elif n1>=(-999):
print("the given integer is a 3 digit number")
else:
print("please enter integer within range 0-999")
#problem 1.5
import math
n1=int(input("enter a number between range 15-
20:"))
if n1>=15 and n1<=20:
n2=math.pow(n1,3)
print(n2)
else:
print("invalid entry ; please enter a digit within
range 15-20")

#problem 1.6
import math
for i in range(1,10,2):
n1=math.pow(i,2)
print(n1,end=" ")
#problem 1.7
n1=int(input("enter the first integer:"))
n2=int(input("enter the second integer:"))
o1=0
for i in range(n2):
o1 +=n1
print("the product of",n1,"and",n2,"is:",o1)

#ch-1 solved problems(q.no-21)


s1=int(input("enter the no of seconds:"))
m1=(s1//60)
s2=(s1%60)
print("the no of mintes in",s1,"is:",m1)
print("the no of remaining seconds is:",s2)

#ch-1 solved problems(q.no-22)


o1=0
while True:
ns1=input("enter a number or enter done:")
if ns1!="done":
n1=int(ns1)
o1 +=n1
else:
print("thank you")
break
print("the sum of the numbers you entered is:",o1)

#ch-1 solved problems(q.no-23)


for row in range(1,10):
for col in range(1,10):
pro=row*col
print(pro," ",end="")
print()
#ch-1 programming practice(q.no-1)
n1=int(input("enter the digit to check if its a
positive/negative digit or zero:"))
if n1==0:
print("the digit",n1,"is zero")
elif n1>0:
print("the digit",n1,"is a positive digit")
else:
print("the digit",n1,"is a negative digit")

#ch-1 programming practice(q.no-2)


n1=int(input("enter a number:"))
if n1%2==0:
print("true")
else :
print("false")

#ch-1 programming practice(q.no-3)


a1=input("if the year is leap year then type yes
otherwise type no :")
if a1=="yes":
s1=(365)*(24)*(60)*(60)
print(s1)
else:
s2=(366)*(24)*(60)*(60)
print(s2)

#ch-1 programming practice(q.no-4)


n1=int(input("enter the first integer:"))
n2=int(input("enter the second integer:"))
if (n1%n2)==0:
print("the first integer is divisible by the second
integer")
else:
print("the first integer is not divisible by the sond
integer")
#ch-1 programming practice(q.no-5)
dn1 = ["MONDAY", "TUESDAY", "WEDNESDAY",
"THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"]

dn2 = int(input("Enter day number: "))


dn3 = input("First day of year: ")
if dn2 < 2 or dn2 > 365:
print("Invalid Input")
else:
startDay= dn1.index(str.upper(dn3))
currDay = dn2 % 7 + startDay - 1

if currDay >= 7:
currDay = currDay - 7

print("Day on day number", dn2, ":",


dn1[currDay])
#ch-1 programming practice(q.no-6)
def feetToInches(lenFeet):
lenInch = lenFeet * 12
return lenInch

def getInput():
len = int(input("Enter length in feet: "))
return len

def displayLength(l):
print("Length in inches =", l)

ipLen = getInput()
inchLen = feetToInches(ipLen)
displayLength(inchLen)
#ch-1 programming practice(q.no-7)
n = int(input("Enter N: "))
sum = 0
if n < 0:
for i in range(2 * n, n + 1):
sum += i
else:
for i in range(n, 2 * n + 1):
sum += i

print("Sum =", sum)

#ch-1 programming practice(q.no-8)


months = ["January", "February", "March", "April",
"May", "June",
"July", "August", "September", "October",
"November", "December"]
dateStr = input("Enter date in MMDDYYYY format: ")
monthIndex = int(dateStr[:2]) - 1
month = months[monthIndex]
day = dateStr[2:4]
year = dateStr[4:]

newDateStr = month + ' ' + day + ', ' + year


print(newDateStr)

#ch-1 programming practice(q.no-9)


print('Pounds | Kilograms')
print(1, "\t", 0.4535)
for i in range(10, 101, 10):
print(i, "\t", i * 0.4535)

#ch-1 programming practice(q.no-10)


print('Miles | Kilometres')
print(1, "\t", 1.60934)
for i in range(10, 101, 10):
print(i, "\t", i * 1.60934)

#ch-1 programming practice(q.no-11)


ft = input("Please enter the first time : ")
st = input("Please enter the second time : ")

# Converts both times to minutes


fMins = int(ft[:2]) * 60 + int(ft[2:])
sMins = int(st[:2]) * 60 + int(st[2:])

# Subtract the minutes, this will give


# the time duration between the two times
diff = sMins - fMins;
# Convert the difference to hours & mins
hrs = diff // 60
mins = diff % 60

print(hrs, "hours", mins, "minutes")

You might also like