LearnFrenzy
Sign in Take a free test

Conditional Statements · Exercise 4 of 4

Conditional Statements Conditional Statements Coding Problems

  • 10 questions
  • Page 1 of 1
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Python programs that make decisions with if-elif-else and match-case. Write each one yourself first, then open the solution – every solution was run on Python 3, the output shown is the real output, and Run opens it in the online Python compiler.

Question 1 Easy

Read marks out of 100 for several students and print the grade (A+ 90+, A 75+, B 60+, C 40+, else F). Report marks outside 0–100 as invalid.

Question page & discussion
Question 2 Easy

Find the largest of three numbers with if-elif-else (without max()), and confirm it with max().

Question page & discussion
Question 3 Easy

For each character of the string "aZ7 #e", print whether it is a vowel, a consonant, a digit, a space or a special character.

Question page & discussion
Question 4 Medium

For each point (x, y), print its quadrant, or whether it lies on an axis or at the origin, using match-case with guards.

Question page & discussion
Question 5 Medium

Check each password: at least 8 characters, an uppercase letter, a lowercase letter, a digit and a special character. Print "strong" or the first rule it breaks.

Question page & discussion
Question 6 Medium

Process ATM commands such as deposit 500, withdraw 200, balance and exit with match-case, starting with a balance of ₹1000. Refuse withdrawals larger than the balance.

Question page & discussion
Question 7 Easy

For day numbers 1–7 (1 = Monday), print the day name and whether it is a weekday or the weekend; report other numbers as invalid.

Question page & discussion
Question 8 Easy

Print the numbers 1 to 15, but print Fizz for multiples of 3, Buzz for multiples of 5 and FizzBuzz for multiples of both.

Question page & discussion
Question 9 Medium

For three angles, check that they form a valid triangle (all positive, sum 180) and classify it as acute, right or obtuse.

Question page & discussion
Question 10 Hard

Compute shipping for orders: free for members or orders of ₹999 and above; otherwise ₹40 within the city and ₹80 outside, plus ₹30 for express delivery.

Question page & discussion
All exercises doneBack to Conditional StatementsRevise the concepts or pick another topic

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links