Practice - if-else Statement
Enroll to start learning
You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Practice Questions
Test your understanding with targeted questions
Write an if-else statement to check if a variable x is greater than 5.
💡 Hint: Remember to correctly format your conditions.
Create an if statement to print 'Good morning' if the hour is less than 12.
💡 Hint: Only check the hour condition.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What will the following code print if age is 16?
💡 Hint: Think about what the comparison operator does!
True or False: The elif statement can be used to chain multiple conditions.
💡 Hint: Recall how we can check multiple scenarios sequentially.
1 more question available
Challenge Problems
Push your limits with advanced challenges
Write a program that checks a user's username. If it is 'admin', print 'Access granted'; if it is 'guest', print 'Access limited'; otherwise, print 'Access denied'.
💡 Hint: Remember to check the username step-by-step.
Create a grading system based on scores. If the score is 90 or above, print 'Grade: A'; if between 80 and 89, print 'Grade: B'; if between 70 and 79, print 'Grade: C'; otherwise, print 'Grade: F'.
💡 Hint: Use sequential checking for grading conditions.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.