RECORD LIST-All Program
RECORD LIST-All Program
RECORD LIST-All Program
else:
print("Result: FAIL")
4.
#temperature coding
num=float(input("Enter the temperature: "))
print("Type 1 to convert from Celsius to Farenheit")
print("Type 2 to convert from Farenheit to Celsius")
choice=int(input("Enter your choice: "))
print("\t\tTemperature Conversion")
print("\t\t**********************")
if choice==1:
far=num*(9/5)+32
print(num,"degree Celsius in Farenheit is equal to ",far)
elif choice==2:
cel = (num-32)*(5/9)
print(num,"degree Farenheit in Celsius is equal to ",cel)
else:
print("Enter only numbers 1 or 2")
6. #Quadratic equation
a=int(input("Enter the co-efficient of x^2: "))
b=int(input("Enter the co-efficient of x: "))
c=int(input("Enter the value of constant: "))
d=(b**2)-(4*a*c)
root1=(-b)+(d**0.5)/(2*a)
root2=(-b)-(d**0.5)/(2*a)
print("\t\t\tRoots Calculation")
print("\t\t\t*****************")
print("\t\t\tCo-efficient of x^2: ",a)
print("\t\t\tCo-efficient of x: ",b)
print("\t\t\tValue of constant: ",c)
if d==0:
print("\t\t\tRoots are:",root1,"and",root2)
print("\t\t\tReal and Equal Roots")
elif d>0:
print("\t\t\tRoots are:",root1,"and",root2)
print("\t\t\tReal and Distinct Roots")
else:
print("\t\t\tImaginary Roots")
7. #code7
print("Menu Driven Program 1")
print("*********************")
while True:
print("1.Area of circle")
print("2.Perimeter of circle")
print("3.Exit")
choice=int(input("Enter your choice: "))
if choice==1:
radius=float(input("Enter the radius: "))
area=3.14*(radius**2)
print("Area of the circle: ",area)
elif choice==2:
radius=float(input("Enter the radius: "))
peri=2*3.14*radius
print("Perimeter of the circle: ",peri)
elif choice==3:
break
else:
print("Enter a valid option")
print("Its sad to see you go :(")
8. #code8
print("Menu Driven Code-II")
print("*****************")
choose="Y"
while choose.upper()=='Y':
print("1. Sum of n natural numbers")
print("2. Multiplication table of given number ‘n’ for ‘m’ multiples")
print("3. Exit")
choice=int(input("Enter the choice: "))
if choice==1:
num1=int(input("Enter the number to calculate the sum: "))
ans=0
for i in range(num1+1):
ans=ans+i
print("Sum of 'n' natural numbers is: ",ans)
elif choice==2:
num1=int(input("Enter the number for the multiplication table: "))
num2=int(input("Enter the number for the multiples: "))
for i in range(1, num2+1):
print(num1,"*",i,"= ",num1*i)
elif choice==3:
print("Thank you")
break
else:
print("Please enter a valid choice")
choose=input("Do you wish to continue? Y/N: ")
else:
print("Have a good day")
9. #Fibonacci
print("Fibonacci Series")
print("*************")
choose="Y"
while choose.upper()=='Y':
print("Main Menu")
print("************")
print("1. Fibonacci Series")
print("2. Exit")
choice=int(input("Enter the choice: "))
if choice==1:
num=int(input("Enter the number of terms: "))
first=0
second=1
for i in range(num):
print(first, end=' ')
third = first+second
first=second
second=third
elif choice==2:
print("Thank you")
break
else:
print("Please enter a valid choice")
choose=input("\nDo you wish to continue? Y/N: ")
else:
print("Have a good day")
10.#prime:
print("Prime numbers in Range")
print("******************************")
while True:
print("Main Menu")
print("************")
print("1.Prime number Calculation")
print("2.Exit")
choice=int(input("Enter your choice: "))
if choice==1:
n1 = int(input("Enter the Starting number: "))
n2 = int(input("Enter the To number: "))
if n1 and n2 >1:
print("Prime numbers between", n1, "and", n2, " :")
for num in range(n1, n2+1): #
for i in range(2, num):
if (num % i) == 0:
break
else:
print(num, end=" ")
choice=input("\nDo you wish to continue: y/n: ")
if choice.upper()=="N":
print("Have a good day")
break
elif n1==1 or n2==1:
print("1 is neither prime nor composite")
else:
print("Only Positive numbers please")
elif choice==2:
print("Have a good day")
break
else:
print("Enter a valid choice of 1 or 2")
11.#conversion
print("NUMBER CONVERSIONS")
print("******************")
while True:
print("Main Menu")
print("************")
print("1.Decimal to Binary")
print("2.Binary to Decimal")
print("3.Octal to Decimal")
print("4.Exit")
choice=int(input("Enter your choice: "))
if choice==1:
n1=int(input("Enter the decimal number: "))
binary=bin(n1)
print("The binary value is:",binary[2:])
elif choice==2:
n1=input("Enter the Binary number: ")
binary=int(n1,2)
print("The Decimal value is:",binary)
elif choice==3:
n1=input("Enter the Octal number: ")
binary=int(n1,8)
print("The Decimal value is:",binary)
elif choice==4:
print("Have a good day")
break
else:
print("Enter a valid choice of 1 or 2")
13. #capitalize
print("CAPITALIZE EACH WORD")
print("*********************")
while True:
print("Main Menu")
print("**********")
print("1.String Capitalize")
print("2.Exit")
choice=int(input("Enter your choice: "))
if choice==1:
msg=input("Enter the string to capitalize: ")
newst=msg.title()
print("Capitalized String is: ",newst)
elif choice==2:
print("Have a good day")
break
else:
print("Enter a valid choice of 1 or 2")
wish=input("\nDo you wish to continue: y/n: ")
if wish.upper()!="Y":
print("Have a good day")
break
prime()
16.
print("Sorting")
print("********")
while True:
print("Main Menu")
print("**********")
print("1.Bubble Sort")
print("2.Insertion Sort")
print("3.Exit")
choice=int(input("Enter your choice: "))
if choice==1:
L=eval(input("Enter the list: "))
n=len(L)
for i in range(n-1):
for j in range(n-i-1):
if L[j]>L[j+1]:
L[j],L[j+1]=L[j+1],L[j]
print("Bubble Sorted List",L)
elif choice==2:
L=eval(input("Enter the list: "))
n=len(L)
for i in range(1,n):
for j in range(i,0,-1):
if L[j]<L[j-1]:
L[j],L[j-1]=L[j-1],L[j]
print("Sorted List",L)
elif choice==3:
print("Have a good day")
break
else:
print("Enter a valid choice of 1 or 2")
wish=input("Do you wish to continue: y/n: ")
if wish.upper()!="Y":
print("Have a good day")
break
18. #dictionary
print("TELEPHONE DIRECTORY")
print("*******************")
while True:
print("1.Search for phone number")
print("2.Display Ph.No in sorted order")
print("3.Exit")
d1={9865:'A',12345:'B',86045:'C'}
choice=int(input("Enter your choice:"))
if choice==1:
num=int(input("Enter the Ph.No: "))
name=d1.get(num,"Ph.No doesn't exist")
print("The Ph.No belongs to: ",name)
elif choice==2:
newdict=sorted(d1)
print("Sorted Order of Ph.No: ",newdict)
elif choice==3:
print("Have a good day")
break
else:
print("Enter a valid choice of 1,2,3")
wish=input("Do you wish to continue: y/n: ")
if wish.upper()!="Y":
print("Have a good day")
break