0% found this document useful (0 votes)
10 views3 pages

Python 7 Day Tutorial

This document outlines a 7-day Python tutorial aimed at teaching the basics of Python programming. Each day focuses on different concepts such as setup, data types, control structures, functions, file handling, libraries, and debugging, with examples and practice exercises provided. A bonus day is included for using AI tools to generate and modify Python code.

Uploaded by

aloknyati199701
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)
10 views3 pages

Python 7 Day Tutorial

This document outlines a 7-day Python tutorial aimed at teaching the basics of Python programming. Each day focuses on different concepts such as setup, data types, control structures, functions, file handling, libraries, and debugging, with examples and practice exercises provided. A bonus day is included for using AI tools to generate and modify Python code.

Uploaded by

aloknyati199701
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

■ 7-Day Python Tutorial & Notes

Goal: Learn Python basics to understand, edit, and debug AI-generated code confidently.

Day 1 – Setup & First Code


Install Python and VS Code or use Jupyter Notebook. Run your first code to understand how
Python works.

■ Example Code:
print('Hello, World!') # Try variables and comments name = 'Alok' print('Hi', name)

■ Try Yourself:
• Change the print message to greet yourself.
• Add two variables and print their sum.

Day 2 – Data Types & Variables


Learn strings, integers, floats, booleans, lists, and dictionaries.

■ Example Code:
name = 'Alok' age = 25 height = 5.9 is_active = True hobbies = ['music', 'travel', 'coding'] person =
{'name': name, 'age': age} print(person['name']) print(type(hobbies))

■ Try Yourself:
• Create a list of your favorite foods and print it.
• Create a dictionary for a book with title, author, and pages.

Day 3 – Conditions & Loops


Use if/else statements and loops to control your program.

■ Example Code:
age = 20 if age >= 18: print('Adult') else: print('Minor') for i in range(3): print('Count:', i) x = 0 while x
< 3: print('x =', x) x += 1

■ Try Yourself:
• Write a loop to print numbers 1 to 5.
• Use if/else to check if a number is even or odd.

Day 4 – Functions
Functions help you reuse code. Define them using def and use return values.
■ Example Code:
def greet(name): return f'Hello, {name}!' print(greet('Alok'))

■ Try Yourself:
• Create a function that adds two numbers.
• Create a function that returns the square of a number.

Day 5 – Files
Read and write files using Python to save and retrieve data.

■ Example Code:
with open('[Link]', 'w') as f: [Link]('Hello from Python') with open('[Link]', 'r') as f: content =
[Link]() print(content)

■ Try Yourself:
• Write a list of your favorite movies to a file.
• Read the file and print each line.

Day 6 – Libraries
Use Python’s built-in modules for extra functionality.

■ Example Code:
import math print([Link](16)) import random print([Link](1, 5))

■ Try Yourself:
• Use random to pick a random item from a list.
• Use math to calculate power or absolute value.

Day 7 – Debug & Practice


Run AI-generated code and debug errors like SyntaxError, TypeError, IndentationError.

■ Example Code:
def add_numbers(a, b): return a + b result = add_numbers(5, '3') # Causes TypeError print(result) #
Fix: result = add_numbers(5, int('3')) print(result)

■ Try Yourself:
• Intentionally cause and fix a TypeError.
• Use print() inside loops to check variable values.
Bonus – Day 8: Using AI with Python
Use ChatGPT or GitHub Copilot to generate Python code, then analyze and modify it.

■ Example Code:
# Example: Ask AI to create a sorting function, then tweak it. def sort_list(lst): return sorted(lst)
print(sort_list([5, 2, 9]))

■ Try Yourself:
• Ask ChatGPT to write a script and modify it.
• Debug AI-generated code to understand its logic.

■ After 7 Days: You’ll confidently read, edit, and debug most AI-generated Python scripts.

You might also like