






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







What Is Python?
Web development (Django, Flask) Data analysis (Pandas, NumPy) Machine learning (TensorFlow, Scikit-learn) Automation (Scripting, bots) Game development (Pygame)
🎯 Step-by-Step Guide
Sticky Note ✅ checked Download Python from python.org and install with “Add to PATH”.
🎯 Recommended IDEs IDE Description VS Code Lightweight, customizable, extensions PyCharm Full-featured, great for large projects Jupyter Ideal for data science and notebooks Thonny Beginner-friendly, simple interface
Let’s write the classic “Hello, World!” program. python print("Hello, world!")
Sticky Note 🧾 Use print("Hello, world!") to display output in Python.
🎯 Explanation print() is a built-in function that displays output. The text inside quotes is a string. Python uses indentation and clean syntax—no semicolons needed.
🎯 Comments Used to explain code or disable lines. python
''' This is a multi-line comment spanning multiple lines.
✅ Use Python for math: +, - , *, /, **, %, //
Type Example Description int 10 Whole numbers float 3.14^ Decimal numbers str "Hello"^ Text or characters bool True, False Boolean values list [1, 2, 3]^ Ordered, mutable collection tuple (1, 2, 3)^ Ordered, immutable collection dict {"a": 1}^ Key-value pairs set {1, 2, 3}^ Unordered, unique elements
🎯 Taking Input
python name = input("Enter your name: ") print("Hello, " + name)
🎯 Type Conversion
python age = input("Enter your age: ") age = int(age) print("Next year, you will be", age + 1)
Sticky Note 🧾 Use input() to take user input. Convert types with int(), str(), float(). name = input("Enter your name: ") age = int(input("Enter your age: ")) print("Next year, you’ll be", age + 1)
Python has reserved words that cannot be used as variable names. Keyword Purpose if (^) Conditional statement else (^) Alternative condition for (^) Looping while (^) Looping def (^) Define a function return (^) Return from a function import (^) Import a module class (^) Define a class try (^) Start error handling block except (^) Handle exceptions
String formatting
Mistake Fix Forgetting quotes Use "text" for strings Wrong indentation Use consistent spaces (usually 4) Mixing types Convert types before operations Using reserved keywords Avoid using if, for, etc. as names Forgetting parentheses Use print() not print
Sticky Note ⚠️ Watch out for indentation errors, type mismatches, and missing quotes.
Mistake Fix print "Hello" Use print("Hello") if x = 5: Use if x == 5: Mixing int and str Convert types before using
Python is beginner-friendly and powerful. Use print() to display output. Use input() to take user input. Python uses indentation instead of braces. Learn basic data types: int, float, str, bool, list, dict. Practice writing small programs to build confidence.
Writeaprogramthatasksforyournameand age,thenprintsagreeting. Createacalculatorthataddstwonumbers enteredbytheuser. Writeaprogramthatprintsyourname 5 times using Build a bot that asks for a password and loops aloop. until it’s correct.