Python
1: Print Function
2: Escape Sequence
3: Comments
4: Escape Sequence as Normal Text
5: Print Emoji
6: Python as Calculator
7: Strings Concatenation
8: Input
9: int function
10: Variables
11: String Formatting
12: String Indexing
13: String Slicing
14: Step Argument
15: Some useful function and methods
16: Strip Method
17: Find and Replace method
18: Center method
19: If Statement
20: If else statement
21: Nested if-else Statement
22: if-elif-else statement
23: while loop
23.1: Example 1 while loop
23.2: Example 2 while loop
23.3: Example 3 while loop
24: Infinite loop
25: for loop
25.1: Example 1 for loop
26: break and continue statement
27: for loop with string
2: Escape Sequence
3: Comments
4: Escape Sequence as Normal Text
5: Print Emoji
6: Python as Calculator
7: Strings Concatenation
8: Input
9: int function
10: Variables
11: String Formatting
12: String Indexing
13: String Slicing
14: Step Argument
15: Some useful function and methods
16: Strip Method
17: Find and Replace method
18: Center method
19: If Statement
20: If else statement
21: Nested if-else Statement
22: if-elif-else statement
23: while loop
23.1: Example 1 while loop
23.2: Example 2 while loop
23.3: Example 3 while loop
24: Infinite loop
25: for loop
25.1: Example 1 for loop
26: break and continue statement
27: for loop with string
Chapter 22: if-elif-else statement
The elif statement is used when we need to check multiple conditions, one after another.
string = ("Ticket Price according to your age.")print(string.center(len(string)+8,"*"))age = int(input("Enter your age: "))if age == 0 or age < 0: print("Age can't be zero or negative.")elif 1 < age <= 3: print("Ticket Price: 0")elif 4<=age<=10: print("Ticket Price: 100")elif 11<=age<=60: print("Ticket Price: 200")else: print("Ticket Price: 150")Output 1:****Ticket Price according to your age.****Enter your age: 2Ticket Price: FreeOutput 2: ****Ticket Price according to your age.****Enter your age: 7Ticket Price: 100Output 3:****Ticket Price according to your age.****Enter your age: 15Ticket Price: 200Output 4:****Ticket Price according to your age.****Enter your age: 65Ticket Price: 150