write five python program
Answers
#1
message=input('Enter your welcome message : ')
print(message)
#2
a=int(input('Enter your 1st no. ='))
b=int(input('Enter your 2nd no. ='))
if (a > b) :
max = a
min = b
print("Largest no. is",max,"\nsmallest no. is" ,min)
elif (a < b) :
max = b
min = a
print("Largest no. is",max,"\nsmallest no. is" ,min)
else:
print("Both no.s are equal")
#3
a=int(input('Enter your 1st no. ='))
b=int(input('Enter your 2nd no. ='))
c=int(input('Enter your 3rd no. ='))
#for largest no.
if (a > b) and (a > c):
max = a
elif (b > a) and (b > c):
max = b
else:
max = c
#For smallest no.
if (a < b) and (a < c):
min = a
elif (b < a) and (b < c):
min = b
else:
min = c
print("Largest no. is",max,"\nsmallest no. is" ,min)
#4
n=int(input("How many terms?(enter 2+ value ) :")) #Fabonacci series
first=0
second=1
print("\nFabonacci series is :")
print(first,",",second,end=",")
for i in range(2,n):
next = first + second
print(next,end=",")
first=second
second=next
#5
n=int(input("Enter your number :"))
if n>1:
for i in range (2,n):
if n%i==0:
print(n,"is a composite number.")
break
else:
print(n,"is a prime number.")
else:
print(n,"is a composite number.")
Programs:
1. Hello World Program
- print("Hello, World!")
2. Maximum Number Finding Program
- num1 = int(input("Enter First Number: "))
- num2 = int(input("Enter Second Number: "))
- num3 = int(input("Enter Third Number: "))
- print(max(num1, num2, num3))
3. Decimal To Binary Converting Program
- num = int(input("Enter Decimal Number: "))
- print(f"Binary Number: {bin(num)}")
4. Say Hello Program
- name = input("Enter Your Name: ")
- print(f"Hello, {name}!")
https://assets.grammarly.com/emoji/v1/1f917.svg
5. Square Root Finding Program
- import math
- num = int(input("Enter Number: "))
- print(f"Square Root Of {num}: {math.sqrt(num)}")
HOPE IT HELPS YOU