Saturday, 13 May 2017

Greatest number among 3 numbers which are user entered

#Greatest number among 3 numbers which are user entered

#Accepting 3 numbers from user
a=int(input('enter number:'))
b=int(input('enter number:'))
c=int(input('enter number:'))

# find which is greatest number
if a>b:
    if a>c:
        print(a,'is greatest number')
    else:
        print(c,'is greatest number')
else:
    if b>c:
        print(b,'is greatest number')
    else:
        print(c,'is greatest number')

OUTPUT:

Fibonacci series using for loop

#Fibonacci series using for loop

#Asking user that how much terms he want in the fibonacci series
n=int(input("How much terms you want:"))

#displaying fibonacci terms
a,b=0,1
print("fib series=\n",1)
for i in range(1,n):
    s=a+b
    print(s)
    a,b=b,s

OUTPUT:

Dictionary of Days and their Temperature

#Dictionary of Days and their Temperature

#defining an empty dictionary to add days and their temperature
d={}

#defining a list of name of days
days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']

#take entry of temperature from user
for i in days:      
    temp=int(input("enter temperature of "+i+" :"))
    d[i]=temp

#to display the day and its temperature in the form of dictionary
print('DAY & TEMPERATURE')
print(d)

#find maximum temperature
tmax=max(d.values())
print('maximum temperature' , tmax)

OUTPUT: