A company decided to give bonus of 5% to employee if his/her year of service is more than 5 years. Ask user for their salary and year of service and print the net bonus amount.
print"Enter salary"salary=input()print"Enter year of service"yos=input()ifyos>5:print"Bonus is",.05*salaryelse:print"No bonus"
2.
Take values of length and breadth of a rectangle from user and check if it is square or not.
print"Enter length"length=input()print"Enter breadth"breadth=input()iflength==breadth:print"Yes, it is square"else:print"No, it is only Rectangle"
3.
Take two int values from user and print greatest among them.
print"Enter first number"first=input()print"Enter second number"second=input()iffirst>second:print"Greatest is",firstelifsecond>first:print"Greatest is",secondelse:print"Both are equal"
4.
A shop will give discount of 10% if the cost of purchased quantity is more than 1000. Ask user for quantity Suppose, one unit will cost 100. Judge and print total cost for user.
A school has following rules for grading system: a. Below 25 - F b. 25 to 45 - E c. 45 to 50 - D d. 50 to 60 - C e. 60 to 80 - B f. Above 80 - A Ask user to enter marks and print the corresponding grade.
Take input of age of 3 people by user and determine oldest and youngest among them.
print"Enter first age"first=input()print"Enter second age"second=input()print"third age"third=input()iffirst>=secondandfirst>=third:print"Oldest is",firstelifsecond>=firstandsecond>=third:print"Oldest is",secondelifthird>=firstandthird>=second:print"Oldest is",thirdelse:print"All are equal"
7.
Write a program to print absolute vlaue of a number entered by user. E.g.- INPUT: 1 OUTPUT: 1 INPUT: -1 OUTPUT: 1
print"Enter a number"number=input()ifnumber<0:printnumber*-1else:printnumber
8.
A student will not be allowed to sit in exam if his/her attendence is less than 75%. Take following input from user Number of classes held Number of classes attended. And print percentage of class attended Is student is allowed to sit in exam or not.
print"Number of classes held"noh=input()print"Number of classes attended"noa=input()atten=(noa/float(noh))*100print"Attendence is",attenifatten>=75:print"You are allowed to sit in exam"else:print"Sorry, you are not allowed. Attend more classes from next time."
9.
Modify the above question to allow student to sit if he/she has medical cause. Ask user if he/she has medical cause or not ( 'Y' or 'N' ) and print accordingly.
#Hint only#Do it yourselfifmedical_cause=='Y':print"You are allowed"else:ifatten>=75:print"Allowed"else:print"Not allowed"
Level 2
1.
Write a program to check if a year is leap year or not. If a year is divisible by 4 then it is leap year but if the year is century year like 2000, 1900, 2100 then it must be divisible by 400.
Use % ( modulus ) operator.
2.
Ask user to enter age, sex ( M or F ), marital status ( Y or N ) and then using following rules print their place of service. if employee is female, then she will work only in urban areas.
if employee is a male and age is in between 20 to 40 then he may work in anywhere
if employee is male and age is in between 40 t0 60 then he will work in urban areas only.
And any other input of age should print "ERROR".
print"Enter age"age=input()print"SEX? (M or F)"sex=raw_input()print"MARRIED? (Y or N)"marry=raw_input()ifsex=="F"andage>=20andage<=60:print"Urban areas only"elifsex=="M"andage>=20andage<=40:print"You can work anywhere"elifsex=="M"andage>40andage<=60:print"Urban areas only"else:print"ERROR"
3.
A 4 digit number is entered through keyboard. Write a program to print a new number with digits reversed as of orignal one. E.g.- INPUT : 1234 OUTPUT : 4321 INPUT : 5982 OUTPUT : 2895
print "Enter number"
number = input()
#seperating digits of the number
#1234/1000 = 1
#1234%1000 = 234
first_number = number/1000
rem = number%1000
#234/100 = 2
#234%100 = 34
second_number = rem/100
rem = rem%100
#34/10 = 3
#34%10 = 4
third_number = rem/10
fourth_number = rem%10
#creating new number with digits reversed
#1234 = (1*1000)+(2*100)+(3*10)+4 i.e., 1000+200+30+4
new_number = (fourth_number*1000)+(third_number*100)+(second_number*10)+(first_number)
print new_number