Just to summarise everything
| Data Types | Example |
| Int | age = 10 date = 20 year = 2022 |
| Float | weight = 60.5 |
| String | name = "Vishal" output = "Vishal\'s age" movie = 'Brahmastra' |
| Boolean | is_it_day = True lights = False |
| List | all_subjects = ["English", "Hindi", "Maths", "Science"] print(all_subjects[1]) Output |
| Dictionaries | result={"English":57, "Hindi":80, "Maths":99, "Science":89} print(result["English"]) Output |
List Functions
| Function | Syntax | Example |
| Append | list.append() | all_subjects.append("Sanskrit") |
| Insert | list.insert(position, "value") | all_subjects.insert(2,"Social Science") |
| Delete | del(list[index]) | del(all_subjects[2]) |
For Loop with List in Python
Code
all_subjects = ["English", "Hindi", "Maths", "Science"]
for subject in all_subjects:
print(subject)
Output
English
Hindi
Maths
Science
If Else in Python
Code
light_is_on = True
if light_is_on :
print("Light is On")
else:
print("Light is Off")
Output:
Light is On
Comparison Operators
| Operator | Symbol |
| Equal to | "==" |
| Not Equal to | != |
| Less than | < |
| Greater than | > |
| Less than equal to | <= |
| Greater than equal to | >= |