Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
Write an if statement that prints 'Hello' if a variable x is greater than 10.
Think about the condition you're checking.
Create an if-else statement that checks if a number is even or odd.
Use the modulus operator %.
What does an if statement do?
Remember the conditional nature of if statements.
True or False: An if-else statement is used when you want to handle one condition only.
Consider what happens when the condition is false.
Write a program that takes an input of grades and provides feedback such as 'Excellent', 'Good', or 'Needs Improvement' based on the grade ranges.
Use elif to handle multiple outcomes based on the input grade.
Create a program that checks the weather condition from user input and responds differently based on conditions like 'rain', 'sunny', or 'cloudy'.
Use if-elif to give multiple responses based on specific inputs.
6 more questions in this section. Enroll free to practise them all.
Enroll free