Category: Python

Python Dictionary Exercises

Exercise 1: Create a Dictionary Question Create a dictionary of a student and print it. Solution student = { “name”: “Amit”, “age”: 20, “city”: “Delhi” } print(student) Exercise 2: Access Dictionary Item Question Print...

1 Python If Statement

1. What is an If Statement? An if statement is used to make decisions in Python. In simple words: 👉 Python checks a condition👉 If the condition is True, Python runs the code👉 If...

2 Python Elif Statement

1. What is an Elif Statement?

  In simple words: 👉 Python checks one condition after another👉 When a condition becomes True, Python runs that code👉 Then Python stops checking the rest 2....

3 Python Else Statement

1. What is an Else Statement? The else statement is used with if. In simple words: 👉 Python checks the if condition👉 If the condition is True, Python runs if code👉 If the condition...

4 Python Shorthand If

1. What is Shorthand If? Shorthand if is a short and one-line way to write an if statement. In simple words: 👉 If you have only one condition👉 And only one line of code...

5 Python Logical Operators

1. What are Logical Operators? Logical operators are used to combine conditions. In simple words: 👉 They help Python make decisions using more than one condition. Python has three logical operators: and or not...

6 Python Nested If

1. What is a Nested If? A nested if means an if statement inside another if statement. In simple words: 👉 Python checks one condition👉 If it is True, Python checks another condition inside...

7 Python Pass Statement

1. What is the Pass Statement? The pass statement is used when Python expects some code,but you don’t want to write anything yet. In simple words: 👉 pass means “do nothing for now” 2....

1 Python Match

1. What is the match Statement? The match statement is used to compare one value with many options. In simple words: 👉 Python checks a value👉 It compares the value with different cases👉 When...

2 Python While Loops

1. What is a While Loop? A while loop is used to repeat code again and againas long as a condition is true. In simple words: 👉 Python checks a condition👉 If it is...