0% found this document useful (0 votes)
0 views6 pages

? Python Review Session_ Basics to Nested Loops

This document outlines a Python review session covering topics from basic syntax to nested loops. It includes key points, examples, and homework assignments for each topic such as variables, data types, input/output, arithmetic operators, conditional statements, and loops. The session aims to reinforce Python fundamentals through practical exercises.

Uploaded by

Abdur Rahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views6 pages

? Python Review Session_ Basics to Nested Loops

This document outlines a Python review session covering topics from basic syntax to nested loops. It includes key points, examples, and homework assignments for each topic such as variables, data types, input/output, arithmetic operators, conditional statements, and loops. The session aims to reinforce Python fundamentals through practical exercises.

Uploaded by

Abdur Rahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

🧠 Python Review Session: Basics to

Nested Loops

🔹 1. Introduction to Python
✅ Key Points:
●​ Python is interpreted, beginner-friendly, and uses indentation instead of braces.​

●​ It can be run using IDLE, VS Code, or online editors like Replit.​

🧪 Example:
# Hello world in Python
print("Hello, world!")

📝 HW:
●​ Print your name and your favorite programming language.​

🔹 2. Variables and Data Types


✅ Key Points:
●​ Variables store data.​

●​ Common data types: int, float, str, bool

🧪 Example:
name = "Rahim"
age = 20
height = 5.6
is_student = True
print(name, age, height, is_student)
📝 HW:
●​ Create 3 variables: one int, one float, and one str, and print them all in a single line.​

🔹 3. Input and Output


✅ Key Points:
●​ Use input() to get user input.​

●​ Use print() to display output.​

🧪 Example:
name = input("Enter your name: ")
print("Welcome,", name)

📝 HW:
●​ Ask the user for their city and favorite color. Print a greeting using both.​

🔹 4. Type Conversion
✅ Key Points:
●​ Convert string inputs to numbers using int() or float()​

🧪 Example:
num1 = int(input("Enter a number: "))
num2 = float(input("Enter another number: "))
print("Sum:", num1 + num2)
📝 HW:
●​ Take two inputs from the user as numbers and show their difference, product, and
division.​

🔹 5. Arithmetic Operators
✅ Operators:
●​ +, -, *, /, //, %, **​

🧪 Example:
a=9
b=2
print(a + b, a - b, a * b, a / b, a // b, a % b, a ** b)

📝 HW:
●​ Write a program that asks for 2 numbers and prints all arithmetic operations between
them.

🔹 6. Conditional Statements
✅ Key Points:
●​ Use if, elif, else for decision making.​

🧪 Example:
age = int(input("Enter your age: "))
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
📝 HW:
●​ Ask the user for a number. If it’s even, print "Even", otherwise print "Odd".​

🔹 7. Comparison & Logical Operators


✅ Comparison:
==, !=, >, <, >=, <=

✅ Logical:
and, or, not

🧪 Example:
a = 10
b=5
print(a > b and b < 3) # False

📝 HW:
●​ Ask for a user’s age and nationality. If age ≥ 18 and nationality is "Bangladeshi", print
"Eligible".​

🔹 8. While Loop
✅ Key Points:
●​ Repeats code while condition is True​

🧪 Example:
i=1
while i <= 5:
print("Count:", i)
i += 1

📝 HW:
●​ Write a program to print numbers from 1 to 10 using while.​

🔹 9. For Loop
✅ Key Points:
●​ Use range() for sequences​

🧪 Example:
for i in range(5):
print("Hello", i)

📝 HW:
●​ Print all even numbers between 1 and 20 using a for loop.​

🔹 10. Nested Loops


✅ Key Points:
●​ Loop inside a loop; used for patterns, grids​

🧪 Example:
for i in range(1, 4):
for j in range(1, 4):
print(f"({i},{j})", end=" ")
print()

📝 HW:
●​ Create a nested loop to print the following pattern:​

***
***
***

✅ Final Challenge (Bonus HW)


●​ Write a program that asks for a number n and prints a right-angled triangle of stars:​

If n = 4

*
**
***
****

You might also like