print "Enter a number less than 10: "
num = 8
print num
#if statement
if num <= 10:
print("What an obedient servant you are !") #display result
dis = 0 #Initial Discount (%0)
#Input from the user
#qty,rate = raw_input("Enter quantity and rate: ").split()
print "Enter quantity and rate: "
qty = 1200 # Quantity of item
rate = 15.50 # Rate of item (Rs)
print qty , rate
#discount of 10% if quantity > 1000
if qty > 1000:
dis = 10
#Calculation
tot = (qty * rate) - (qty * rate * dis / 100 ) # total expenses (Rs)
#Result
print "Total expenses = Rs. ", tot
#cy,yoj = raw_input("Enter current year and year of joining: ").split()
print "Enter current year and year of joining: "
cy = 2013 # Current year
yoj = 1990 # Year of joining
print cy, yoj
#Calculation
yr_of_ser = cy - yoj # number of years of service
#Assign bonus if years of service > 3
if yr_of_ser > 3:
bonus = 2500 # Bonus of Rs. 2500
print "Bonus = Rs.", bonus #display result
print "Enter basic salary: "
bs = 2561.1 #Basic salary (Rs)
print bs
#Calculation
if bs < 1500: # if basic salary is less than Rs.1500
hra = bs * 10 / 100 # HRA (Rs)
da = bs * 90 / 100 #DA (Rs)
else: #if basic salary is greater than or equal to Rs.1500
hra = 500 # HRA (Rs)
da = bs * 98 / 100 # DA (Rs)
gs = bs + hra + da # gross salary (Rs)
#Result
print "gross salary = Rs. ", gs
print "Enter either 1 or 2: "
i = 1
print i
#nested if-else
if i == 1 :
print "You would go to heaven !"
else:
if i == 2 :
print "Hell was created with you in mind"
else:
print "How about mother earth !"
print "Enter marks in five subjects: "
m1 = 88 #Marks in 1st subject
m2 = 92 #Marks in 2nd subject
m3 = 87 #Marks in 3rd subject
m4 = 66 #Marks in 4th subject
m5 = 56 #Marks in 5th subject
print m1,m2,m3,m4,m5
#Calculation
per = ( m1 + m2 + m3 + m4 + m5 ) / 5 #Percentage
#check for different cases and display appropriate result
if per >= 60:
print "First division"
else:
if per >= 50:
print "Second division"
else:
if per >= 40:
print "Third division"
else:
print "Fail"
print "Enter marks in five subjects: "
m1 = 88 #Marks in 1st subject
m2 = 92 #Marks in 2nd subject
m3 = 87 #Marks in 3rd subject
m4 = 66 #Marks in 4th subject
m5 = 56 #Marks in 5th subject
print m1,m2,m3,m4,m5
#Calculation
per = ( m1 + m2 + m3 + m4 + m5 ) / 5 #Percentage
#check for different cases and display appropriate result
if per >= 60:
print "First division"
if (per >= 50) and (per <60):
print"Second division"
if (per >= 40) and (per <50):
print"Third division"
if per < 40 :
print"Fail"
print "Enter marks in five subjects: "
m1 = 88 #Marks in 1st subject
m2 = 92 #Marks in 2nd subject
m3 = 87 #Marks in 3rd subject
m4 = 66 #Marks in 4th subject
m5 = 56 #Marks in 5th subject
print m1,m2,m3,m4,m5
#Calculation
per = ( m1 + m2 + m3 + m4 + m5 ) / 5 #Percentage
#check for different cases and display appropriate result
if per >= 60:
print"First division"
elif per >= 50:
print"Second division"
elif per >= 40:
print"Third division"
else:
print"Fail"
print "Enter age, sex, marital status: "
age = 43 # Age of driver (years)
sex = 'M'
ms = 'M'
print age,sex,ms
#check for different cases and display appropriate result
if ms == 'M':
print("Driver is insured")
else:
if sex == 'M':
if age > 30:
print ("Driver is insured")
else:
print ("Driver is not insured")
else:
if age > 25:
print ("Driver is insured")
else:
print ("Driver is not insured")
print "Enter age, sex, marital status: "
age = 43 # Age of driver (years)
sex = 'M'
ms = 'M'
print age,sex,ms
#check for different cases and display appropriate result
if ((ms == 'M') or (ms == 'U' and sex == 'M' and age > 30) or (ms == 'U' and sex == 'F' and age >25) ) :
print"Driver is insured"
else:
print"Driver is not insured"
print "Enter Gender, Years of Service and Qualifications ( 0 = G, 1 = PG ):"
g = 'f'
yos = 8 # Years of service(years)
qual = 1 # Qualification ( 0=G, 1=PG)
print g,yos,qual
# Assign salary depending upon the conditions
if (g == 'm') and (yos >= 10) and (qual == 1):
sal = 15000 #salary
elif ((g == 'm' and yos >= 10 and qual == 0) or ( g == 'm' and yos < 10 and qual == 1 )):
sal = 10000 #salary
elif ( g == 'm' and yos < 10 and qual == 0 ):
sal = 7000 #salary
elif ( g == 'f' and yos >= 10 and qual == 1 ):
sal = 12000 #salary
elif ( g == 'f' and yos >= 10 and qual == 0 ):
sal = 9000 #salary
elif ( g == 'f' and yos < 10 and qual == 1 ):
sal = 10000 #salary
elif ( g == 'f' and yos < 10 and qual == 0 ):
sal = 6000 #salary
#Result
print "Salary of Employee = ", sal