As we know, Conditional Statements in Python are used to make decisions based on certain conditions.
So here are some 10 random questions related to Conditional Statements Problems in Python so before going to these problems let’s go through what is exactly a Conditional in Python so let’s begin.
Conditional statements in Python: Conditional statements in Python allows you to execute certain code blocks based on whether a condition is True or False.
The Basic syntax includes if, elif (short for “else if”), and else statements.
Now let’s go through problems and you will get to know how conditional statements works in Python?
1)Age Group Categorization.
Problem:-Classify a person’s age group [Child=(<13), Teenager=(13-19), Adult=(20-59), Senior Citizen=(60+)].
Program:-
2)Movie Ticket Pricing.
Problem:-Movie ticket are priced based on age:- 150rs for adults (18 & over), 100rs for children. Everyone gets a 20rs discount on Wednesday.
Program:-
3)Grade Calculator.
Problem:-Assign a letter grade based on a student’s marks: A(100-90), B(80-89), C(70-79), D(60-69), (Below 60).
Program:-
4)Fruit Ripeness Checker.
Problem:-Determine if a fruit is Ripe, Unripe, Overripe based on it color. (eg:- Banana:-Green=Unripe, Yellow=Ripe, Brown=Overripe).
Program:-
5)Weather Activity Suggestion.
Problem:-Suggest an activity based on the weather (example for Sunny:- Go for a walk, Rainy:- Stay at home and read a book, Snowy:- Build a Snowman).
Program:-
6)Transportation Mode Selection.
Problem:-Choose a mode of transportation based on a distance (eg:- <3=Walk, 3-15km=Bike, >15=Car).
Program:-
7)Coffee Customization.
Problem:-Customize a coffee order=”Small”, “Medium”, “Large” with an option for Extra shot of espresso.
Program:-
8)Password Strength Checker.
Problem:-Check if a password Strength is Weak, Medium or Strong. Based on criteria=<6 chars(weak), 6-10(medium), >10 chars (strong).
Program:-
9)Leap year checker.
Problem:-Determine if a year is a Leap Year (Leap year are divisible by 4, but not divisible by 100 unless also divisible by 400.)
Program:-
10)Pet food recommendation.
Problem:-Recommend a type of pet food based on the species of pet and age. (species=dog or cat) and age(Dog=<2 years:- Puppy food, Cat>5 years :-Senior cat(food)).
Program:-
So these were few problems related to Conditional Statements in Python.
This Content is been referred from the channel called Chai aur Code from YouTube:-
https://www.youtube.com/@chaiaurcode
and from the following video:-
https://youtu.be/v9bOWjwdTlg?si=yviqDKFKp67geFJC
And also follow me on my Instagram handle:-
https://www.instagram.com/yashpale_?igsh=MmVlMjlkMTBhMg==
Thank you for reading ;)…