Conditional Statements Assignments
Questions Using If - else block
In a classic chase, Tom is running after Jerry as Jerry has eaten Tom's favourite food.
Jerry is running at a speed of metres per second while Tom is chasing him at a speed of metres per second. Determine whether Tom will be able to catch Jerry.
Note that initially Jerry is not at the same position as Tom. Take X of Jerry and Y of Tom from the user and make decision and print YES if tom can catch and NO if not. Sample Input
2 3
4 1
1 1
3 5Sample Output
YES
NO
NO
YESApple considers any iPhone with a battery health of % or above, to be in optimal condition.
Given that your iPhone has %battery health, find whether it is in optimal condition.
Take Battery Health from User and print YES if in optimal condition and NO if not. Sample Input
97
42
80
10Sample Output
YES
NO
YES
NOWhile purchasing certain items, a discount of 10 % is offered if the quantity purchased is more than 1000. If quantity and price per item are input through the keyboard, write a program to calculate the total expenses.
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.
A University allows students to sit in the exam despite of insufficient attendance if the student's attendance is short due to some medical cause. Take Input from User whether he had medical cause (Y/N) and print the message you are allowed if medical cause == Y otherwise print you are not allowed.
Write a program to check whether the last digit of the number is divisible by 3 or not. Take Number from user and your output must contain the number.
Write a program to display ‘Hello’ if the number entered by user is multiple of 5 otherwise prints ‘Bye’.
Write a program to check whether a person is eligible for voting or not.(voting age >=18)
Write a program to check whether a number entered by user is even or odd.
Write a program to check whether a given character is a vowel or a consonant.
Write a program to check whether a given string is a valid email address (i.e., it contains exactly one "@" symbol and at least one "." after the "@").
Questions using if-else ladder and nested if-else
Write a program to calculate the electricity bill (accept number of unit from user) according to the following criteria :
First 100 Units
No charge
Next 100 Units
5 Rs Per Unit
After 200 Units
10 Rs Per Unit
Write a program to accept percentage from the user and display the grade according to the following criteria:
>=90
A
>=80 and <90
B
>=60 and <80
C
<60
D
Enter the marks : 87
B
Write a python program that will check for the following conditions:
· If the light is green – Car is allowed to go
· If the light is yellow – Car has to wait
· If the light is red – Car has to stop
· Other signal – unrecognized signal. Example black, blue, etc…
Write a program to check whether the given number is positive, zero or negative.
Calculate income tax for the given income by adhering to the below rules
Taxable Income Rate (in %)
First Rs.10,0000 0
Next Rs. 10,0000 10
The remaining 20\
Write a program to take a digit and print it is In words(only 0 - 9) For Example : enter digit : 5 Five
Write a menu driven program for making a simple calculator.
An institution has decided to admit new candidates in different streams on the following criteria:
Total Marks Obtained Streams Offered
300 and above Science 200 and above but less than 300 Commerce Below 200 but not below 75 Arts Otherwise Admission is not granted, You have to appear in qualifying examination
Write a program to input total marks obtained in an examination and print the stream allotted on the basis of above criteria.
Design a Program to input two integers num1, num2 and a character(opr). The Variable opr reads only one of the four
characters(+,-,/,*). Your Program should perform the operation on the basis ofoperator on num1, num2. In case of subtraction, subtract smaller number from bigger number and in case of division divide the greater number by smaller numbers. Print Integers and result.A Scooter /motor cycle stand charges the following rates for the parking:
Hours Rate
First 4hours RS.5.00 Every next hour upto5 hours RS.3.00 per hour Any further hour above 9 hour RS.2.00 per hour
Write a program to input the number of hours for which a two wheeler is parked. Calculate and print the parking charges to be paid by the customer.
Monthly Electricity bill is calculated as –
Number of units Consumed Rate Per Unit
<=100 only meter rent Rs 200/- For next 200 units Rs. 1.00 per unit For next 200 units Rs 1.55 per unit For more than 500 units Rs 2.10 per unit
Write a program to take the consumer number, number of units consumed. Calculate bill amount. Print consumer number and total amount to be paid by the consumer. (Consumer number must be digits of length 5 and print appropriate message for incorrect input of consumer number).
Write a menu driven program for three options. (Take input of option from user).
i) Area of circle ii) Area of Rectangle iii) Area of Square
Print the area along with sides.
A Bank offers the following rate of interest for fixed deposit:
Time(Years) Rate(%)
<1 9.0 1 to 2 10.0 2 to 3 11.0 >3 12.0
The amount A after n years is calculated by using the formula: A = P(1 + r / 100)^n
Where P = principal amount deposited R = rate of interest N = number of years
Write a program to accept the deposited amount, number of years the amount is to be deposited for n and compute accrued amount for an investor.
Write a program to take number input between 1 to 7 and print the day associated to that number such as 1 for Sunday, 2 for Monday, etc.
Write a program to take number input between 1 and 12 and print the month associated with it.
Write a python program to accept the percentage from the user and display the category according to the following criteria: Percentage Category
<40 Failed >=40 and <55 Fair >= 55 and <65 Good >= 65 Excellent
Take three sides (number) from the user and tell whether the triangle is isosceles, scalene and equilateral triangle.
Alice, Bob and Charlie are bidding on an artifact at an auction.
Alice bids A rupees, Bob bids B rupees and Charlie bids C rupees (where A, B and C are distinct).
According to the rule of the auction, the one who bids the highest amount will win the auction. Determine who will win the auction.
Input:
Take input of alice, bob and Charlie’s amount.
Output:
Print the name of auctioner who wins the auction.
Last updated