Day 5 Python 2 & Python 3 (User Input)
Day 5 Python 2 & Python 3 (User Input)
Ex:
regno = input("Enter reg no:")
name = raw_input("Enter name:")
math = input("Enter math marks")
print "regno:",regno
print "name:",name
print "math mark:",math
Python3:
--------
Ex:
regno = int(input("Enter reg no:"))
name = input("Enter name:")
math = float(input("Enter math marks"))
print ("regno:",regno)
print ("name:",name)
print ("math mark:",math)
Lab1
1. Write a program to add two number
Ans
no1 = int (input ("Enter 1st number"))
no2 = int (input ("Enter 2nd number"))
res = no1 + no2
print ("sum of two number =", res )
Lab 2 :
1. Write a pogram to find simple interest where principal amount , rate of
interest and time are given by user
Ans
principalamount = float (input ("Enter principal amount "))
rate = float (input ("enter rate of interest "))
time = float (input ("enter time period"))
i = (principalamount * time * rate)/ 100
totalamount = i + principalamount
print (" interest=", i)
print ("total amount =", totalamount)
2. Write a program to find area of triangle where three sides are given by user .
Ans
from math import sqrt
s1= float (input ("Enter side 1 value "))
s2= float (input ("Enter side 2 value "))
s3= float (input ("Enter side 3 value "))
s=(s1+s2+s3)/ 2;
area = sqrt (s * (s- s1) * (s-s2) * (s-s3))
print ("area of circle =", area)
3. Write a program to find max value from two number where two number are given by
user .
Ans
no1 = int (input ("Enter 1st number"))
no2 = int (input ("Enter 2nd number"))
if no1 > no2 :
max = no1
else :
max = no2
print ("max value =", max )