0% found this document useful (0 votes)
6 views14 pages

Python Basics Definitions Examples

The document provides an overview of Python basics, covering key concepts such as print statements, variables, data types, input and type casting, operators, conditionals, loops, functions, lists, dictionaries, modules, error handling, and file handling. Each concept is defined and illustrated with examples for clarity. This training material serves as a foundational guide for beginners learning Python programming.

Uploaded by

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

Python Basics Definitions Examples

The document provides an overview of Python basics, covering key concepts such as print statements, variables, data types, input and type casting, operators, conditionals, loops, functions, lists, dictionaries, modules, error handling, and file handling. Each concept is defined and illustrated with examples for clarity. This training material serves as a foundational guide for beginners learning Python programming.

Uploaded by

shivanip4595
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Python Basics Training

Definitions with Examples


Print Statement
• Definition: Used to display output on the
screen.
• Example: print("Hello, World!")
Variables
• Definition: A container for storing data values.
• Example: x = 10
name = "Rhea"
Data Types
• Definition: Defines the type of data: int, float,
str, bool, list, tuple, dict, set.
• Example: age = 25
pi = 3.14
is_active = True
fruits = ["apple", "banana"]
Input & Type Casting
• Definition: Takes user input and converts it
into required type.
• Example: age = int(input("Enter age: "))
print("Next year:", age+1)
Operators
• Definition: Symbols used to perform
operations on values.
• Example: x = 5 + 3 # 8
print(10 > 5) # True
Conditionals
• Definition: Used to make decisions in code.
• Example: age = 18
if age >= 18:
print("Adult")
else:
print("Minor")
Loops
• Definition: Used to repeat code multiple
times.
• Example: for i in range(5):
print(i)
Functions
• Definition: A block of reusable code.
• Example: def greet(name):
return "Hello " + name
print(greet("Shivani"))
Lists
• Definition: Ordered, changeable collection of
items.
• Example: fruits = ["apple", "banana"]
fruits.append("mango")
Dictionaries
• Definition: Collection of key-value pairs.
• Example: person = {"name": "Shivani", "age":
25}
print(person["name"])
Modules & Libraries
• Definition: Pre-written code you can import
and use.
• Example: import math
print(math.sqrt(16))
Error Handling
• Definition: Used to handle errors and prevent
crashes.
• Example: try:
num = int("abc")
except ValueError:
print("Invalid number!")
File Handling
• Definition: Used to read from and write to
files.
• Example: with open("data.txt", "w") as f:
f.write("Hello")

You might also like