0% found this document useful (0 votes)
4 views2 pages

Python Crash Course

Uploaded by

nahdi.hassene34
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)
4 views2 pages

Python Crash Course

Uploaded by

nahdi.hassene34
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/ 2

■ Python Crash Course: Core Syntax & Data

Structures

1. Python Basics: Syntax & Variables


1 Python uses indentation instead of braces.
2 Variables are dynamically typed (no need to declare type).
3 Comments use # for single-line, triple quotes for multi-line.
■ Mini Project: Mini Project: Create a simple calculator that adds, subtracts, multiplies, and divides
two numbers.

2. Data Types
1 Common types: int, float, str, bool, None.
2 Use type() to check type of a variable.
3 Type conversion with int(), float(), str().
■ Mini Project: Mini Project: Build a temperature converter (Celsius <-> Fahrenheit).

3. Strings
1 Strings are sequences of characters inside quotes.
2 Supports slicing, indexing, and methods like .upper(), .lower(), .replace().
3 f-strings for formatting: f"Hello {name}".
■ Mini Project: Mini Project: Write a program that asks for your name and prints it in reverse.

4. Lists
1 Lists are mutable ordered collections.
2 Access with indexes, slice with [:], modify with append(), remove(), sort().
3 Supports iteration with for loops.
■ Mini Project: Mini Project: Build a to-do list manager where users can add and remove tasks.

5. Tuples & Sets


1 Tuples are immutable ordered collections.
2 Sets are unordered collections of unique elements.
3 Useful for removing duplicates and fast membership tests.
■ Mini Project: Mini Project: Write a program that removes duplicate words from a sentence.

6. Dictionaries
1 Dictionaries store key-value pairs.
2 Access with dict[key], iterate with .items().
3 Keys must be immutable types (e.g., str, int, tuple).
■ Mini Project: Mini Project: Create a phonebook program that stores names and phone numbers.
7. Control Flow (if, for, while)
1 if, elif, else for conditions.
2 for loops iterate over sequences.
3 while loops repeat until condition is False.
4 break and continue modify loop execution.
■ Mini Project: Mini Project: Guess the number game (random number between 1–100).

8. Functions
1 Defined with def keyword.
2 Parameters can have default values.
3 Return values with return keyword.
4 Supports *args and **kwargs for flexible arguments.
■ Mini Project: Mini Project: Write a function-based program that calculates factorial of a number.

9. File Handling
1 Use open(filename, mode) to read/write files.
2 Modes: 'r' = read, 'w' = write, 'a' = append.
3 Always close files or use with open() as f: for automatic closing.
■ Mini Project: Mini Project: Create a notes app that saves user input to a text file.

10. Final Project


1 Combine all concepts into a simple project.
■ Mini Project: Final Project: Build a Student Management System with add, delete, search, and
list students using dictionaries and file handling.

You might also like