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

Python Phase 1 Basics

Phase 1 of the Python Learning Roadmap is aimed at absolute beginners, covering fundamental concepts such as variables, data types, operators, loops, functions, and basic input/output. Key lessons include understanding data types, using operators, implementing conditional statements, and handling exceptions. The roadmap provides examples and syntax for each topic to facilitate learning.

Uploaded by

pratheep.s537
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views3 pages

Python Phase 1 Basics

Phase 1 of the Python Learning Roadmap is aimed at absolute beginners, covering fundamental concepts such as variables, data types, operators, loops, functions, and basic input/output. Key lessons include understanding data types, using operators, implementing conditional statements, and handling exceptions. The roadmap provides examples and syntax for each topic to facilitate learning.

Uploaded by

pratheep.s537
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Python Learning Roadmap - Phase 1:

Python Basics
Introduction
Phase 1 is designed for absolute beginners who want to build a solid foundation in Python. It
covers basic concepts like variables, data types, operators, loops, functions, and more.

Lesson 1: Variables and Data Types


A variable is a name that refers to a value. It acts like a container for storing data values.

Python has several built-in data types including:

- int: Integer numbers (e.g., 10)


- float: Decimal numbers (e.g., 5.5)
- str: Strings or text (e.g., "Hello")
- bool: Boolean values (True or False)

Example:

name = "John"
age = 20
is_student = True

Lesson 2: Operators
Operators are used to perform operations on variables and values.

Types of operators:
- Arithmetic: +, -, *, /, %, **, //
- Comparison: ==, !=, >, <, >=, <=
- Logical: and, or, not
- Assignment: =, +=, -=, *=, etc.

Lesson 3: Conditional Statements


Conditional statements allow you to execute certain blocks of code based on conditions.

Syntax:
if condition:
# do something
elif condition:
# do something else
else:
# fallback

Lesson 4: Loops
Loops are used to repeat a block of code multiple times.

- for loop: Used to iterate over a sequence (like a list or range).


- while loop: Repeats as long as a condition is true.

Example:
for i in range(5):
print(i)

Lesson 5: Functions
A function is a block of reusable code that performs a specific task.

Syntax:
def function_name(parameters):
# code
return value

Example:
def greet(name):
return "Hello, " + name

Lesson 6: Lists, Tuples, Sets, Dictionaries


- List: Ordered and changeable. [1, 2, 3]
- Tuple: Ordered and unchangeable. (1, 2, 3)
- Set: Unordered, no duplicates. {1, 2, 3}
- Dictionary: Key-value pairs. {'name': 'John', 'age': 20}

Lesson 7: String Manipulation


Strings in Python can be manipulated using various methods like:
- len(), upper(), lower(), strip(), replace(), split(), join()

Example:
text = " Hello World "
print(text.strip().upper())
Lesson 8: Basic Input/Output
Use input() to get user input, and print() to display output.

Example:
name = input("Enter your name: ")
print("Hello", name)

Lesson 9: Exception Handling


Try-except blocks are used to handle errors gracefully.

Syntax:
try:
# risky code
except ExceptionType:
# handle error

Example:
try:
num = int(input("Enter a number: "))
except ValueError:
print("Invalid input")

You might also like