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

Python Day Session 2

The document outlines a Python hands-on session covering data types, user input, conditional statements, and loops, structured into a 90-minute schedule. It includes theoretical explanations, coding examples, and activities for practical application, culminating in a mini project focused on a simple banking system. The session concludes with a Q&A to address any doubts or unclear concepts.

Uploaded by

SADATH HUSSAIN
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)
15 views6 pages

Python Day Session 2

The document outlines a Python hands-on session covering data types, user input, conditional statements, and loops, structured into a 90-minute schedule. It includes theoretical explanations, coding examples, and activities for practical application, culminating in a mini project focused on a simple banking system. The session concludes with a Q&A to address any doubts or unclear concepts.

Uploaded by

SADATH HUSSAIN
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

‭Python Hands-on Session‬

‭Session Breakdown:‬

‭Time‬ ‭Activity‬

‭0 - 10 mins‬ ‭Introduction to Data Types & Basic Operations‬

‭10 - 20 mins‬ ‭User Input & Type Conversion‬

‭20 - 35 mins‬ ‭Conditional Statements (‬‭


if-elif-else‬
‭)‬

‭35 - 50 mins‬ ‭Loops (‬‭


for‬ while‬
‭,‬‭ ‭)‬

‭50 - 70 mins‬ ‭Hands-on Coding Activities & Challenges‬

‭70 - 90 mins‬ ‭Mini Project & Q&A‬

‭Data Types and Basic Operations (10 minutes)‬

‭Theory (5 mins)‬

int‬
‭●‬ ‭Data Types:‬‭ float‬
‭,‬‭ str‬
‭,‬‭ bool‬
‭,‬‭
+‭,‬‬‭
‭●‬ ‭Arithmetic Operations:‬‭ -‭,‬‬‭
*‬ /‭,‬‬‭
‭,‬‭ //‬ %‭,‬‬‭
‭,‬‭ **‬

‭Example 1: Basic Arithmetic Operations‬

‭a = 10‬
‭b = 3‬
‭print("Addition:", a + b)‬
‭print("Subtraction:", a - b)‬
‭print("Multiplication:", a * b)‬
‭print("Division:", a / b)‬
‭print("Floor Division:", a // b)‬
‭print("Modulus:", a % b)‬
‭print("Exponentiation:", a ** b)‬
‭Example 2: String Operations‬

‭name = "Python"‬
‭print("Hello " + name) # Concatenation‬
‭print(name * 3) # Repetition‬

‭Taking User Input (10 minutes)‬

‭Theory (5 mins)‬

‭●‬ ‭
input()‬‭function always returns a‬‭string‬‭.‬
‭●‬ ‭Use‬‭type conversion‬‭(‭
i
‬ nt()‬ float()‬
‭,‬‭ ‭) for numerical input.‬

‭Example 3: Taking User Input‬

‭ .‬ n
1 ‭ ame = input("Enter your name: ")‬
‭2.‬ ‭age = int(input("Enter your age: ")) # Converts input to an integer‬
‭3.‬ ‭print(f"Hello, {name}! You are {age} years old.")‬

‭Activity:‬

‭●‬ A
‭ sk students to modify the program to take their favorite color and print a‬
‭message.‬

‭Conditional Statements (‬‭


if-elif-else‬
‭) (15 minutes)‬

‭Theory (7 mins)‬

‭●‬ ‭
if‬‭checks a condition.‬
‭●‬ ‭
elif‬‭(else if) handles multiple conditions.‬
‭●‬ ‭
else‬‭executes if no conditions are met.‬

‭Example 4: Check Even or Odd‬

‭num = int(input("Enter a number: "))‬


‭if num % 2 == 0:‬
‭print("Even Number")‬
‭else:‬
‭print("Odd Number")‬

‭Example 5: Grade Classification‬

‭marks = int(input("Enter your marks: "))‬

‭if marks >= 90:‬


‭print("Grade: A")‬
‭elif marks >= 75:‬
‭print("Grade: B")‬
‭elif marks >= 50:‬
‭print("Grade: C")‬
‭else:‬
‭print("Grade: Fail")‬

‭Activity:‬

‭●‬ ‭Write a program to check whether a person is eligible to vote (age ≥ 18).‬

‭Loops (‬‭
for‬ while‬
‭,‬‭ ‭) (15 minutes)‬

‭Theory (7 mins)‬

‭●‬ ‭
for‬‭loop‬‭: Used when iterations are known.‬
‭●‬ ‭
while‬‭loop‬‭: Runs‬‭until‬‭a condition becomes False.‬

for‬‭Loop‬
‭Example 6: Print Numbers Using a‬‭

‭for i in range(1, 6):‬


‭print("Number:", i)‬

while‬‭Loop‬
‭Example 7: Print Numbers Using a‬‭

c‭ ount = 1‬
‭while count <= 5:‬
‭ rint("Count:", count)‬
p
‭count += 1‬

‭Example 8: Multiplication Table using a Loop‬

‭ um = int(input("Enter a number: "))‬


n
‭for i in range(1, 11):‬
‭print(f"{num} x {i} = {num * i}")‬

‭Activity:‬

for‬‭loop.‬
‭●‬ ‭Print‬‭all even numbers‬‭from 1 to 50 using a‬‭

‭Hands-on Coding Activities (20 minutes)‬

‭Students will apply concepts learned by solving small coding challenges.‬

‭Challenge 1: Reverse a User’s Name‬


‭ ame = input("Enter your name: ")‬
n
‭print("Reversed Name:", name[::-1])‬

‭Challenge 2: Find the Largest of Three Numbers‬


‭ = int(input("Enter first number: "))‬
a
‭b = int(input("Enter second number: "))‬
‭c = int(input("Enter third number: "))‬

‭if a > b and a > c:‬


‭print(f"Largest is {a}")‬
‭elif b > c:‬
‭print(f"Largest is {b}")‬
‭else:‬
‭print(f"Largest is {c}")‬

‭Activity:‬
‭●‬ W
‭ rite a program to calculate the sum of‬‭all numbers from 1 to N‬‭(where N is‬
‭user input).‬

‭Mini Project (20 minutes)‬

‭Simple Banking System‬

‭Concepts Used:‬

if-else‬
‭●‬ ‭Variables,‬‭ ‭, loops, user input.‬

‭balance = 1000 # Initial balance‬

‭while True:‬
‭print("\nWelcome to Simple Bank!")‬
‭print("1. Check Balance")‬
‭print("2. Deposit Money")‬
‭print("3. Withdraw Money")‬
‭print("4. Exit")‬

‭choice = int(input("Enter your choice: "))‬

‭if choice == 1:‬


‭print(f"Your balance is: ${balance}")‬
‭elif choice == 2:‬
‭amount = int(input("Enter deposit amount: "))‬
‭balance += amount‬
‭print(f"Successfully deposited ${amount}. New balance: ${balance}")‬
‭elif choice == 3:‬
‭amount = int(input("Enter withdrawal amount: "))‬
‭if amount > balance:‬
‭print("Insufficient balance!")‬
‭else:‬
‭balance -= amount‬
‭print(f"Successfully withdrew ${amount}. New balance: ${balance}")‬
‭elif choice == 4:‬
‭print("Exiting... Thank you!")‬
‭break‬
‭else:‬
‭print("Invalid choice! Try again.")‬
‭Activity:‬

‭●‬ ‭Modify the code to limit‬‭3 incorrect login attempts‬‭before exiting.‬

‭Q&A Session (Last 10-15 minutes)‬

‭●‬ ‭Discuss doubts and explain any unclear concepts.‬

You might also like