Conditional Statements

Conditional logic is vital in programming as it makes sure that the program works regardless of what data you throw in and also allows branching. This exercise is about the implementation of various conditional logic in real-life problems.

📝 Task:

  • [ ] Write a program to create a prompt "How many km is left to go?" and based on the user and the following conditions, print the results in the console.
    • If there are more than 100 km left to go, print: "You still have a bit of driving left to go".
    • If there are more than 50 km, but less or equal to 100 km, print: "I'll be there in 5 minutes".
    • If there are less than or equal to 50 km, print: "I'm parking. I'll see you right now".
  • [ ] Write a program that checks whether a person is eligible to vote or not based on their age.

    • If the age of user is 18 or older then print You are eligible to vote
    • If the age of user is less than 18 then print You aren't eligible to vote.

      Note: age can be between 1 to 100.

💡 Hints:

  • Visit the conditional logic chapter to understand how to use conditional logic and conditional statements.

results matching ""

    No results matching ""