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

Python Basics Beginner Guide

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)
22 views2 pages

Python Basics Beginner Guide

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 Basics - Beginner Friendly Guide

Expanded Python Basics Guide

1. Python Overview
Python is a high-level, interpreted language known for readability and simplicity. Dynamically typed and
beginner-friendly.

2. Syntax and Variables


- Indentation defines code blocks.
- No curly braces or semicolons.

Example:
if 5 > 2:
print("Five is greater than two")

Variables created by assignment:


x = 10
name = "Alice"
price = 99.9
is_valid = True

Variables can be reassigned:


x = 10
x = "Ten"

3. Data Types
int: 10
float: 3.14
str: "Hello"
bool: True, False

Check type:
print(type(10)) # int

4. Type Conversion
float(5) becomes 5.0
int(3.14) becomes 3
str(100) becomes "100"
int("25") becomes 25

Invalid conversion:
int("abc") # Error

5. Input and Output


print("Hello", name)
age = input("Enter age: ")
age = int(age)

6. Operators
Python Basics - Beginner Friendly Guide

Arithmetic: + - * / // % **
Comparison: == != > < >= <=
Logical: and or not

7. Control Flow (If-Else)


age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

8. Loops
While Loop:
count = 0
while count < 3:
print(count)
count += 1

For Loop:
for i in range(5):
print(i)

9. Functions
def greet(name):
print("Hello", name)

greet("Alice")

10. Lists, Tuples, Dictionaries


List (mutable):
fruits = ["apple", "banana"]
fruits.append("mango")

Tuple (immutable):
coords = (10, 20)

Dictionary (key-value):
person = {"name": "Alice", "age": 25}
print(person["name"])

You might also like