



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A comprehensive introduction to python programming, covering fundamental concepts such as variables, data types, operators, and expressions. It also delves into control structures like conditional statements and loops, as well as functions, which are essential for writing efficient and organized code. The document further explores data structures like lists, dictionaries, sets, and tuples, and introduces powerful libraries like numpy and pandas for data manipulation and analysis. Finally, it touches upon intermediate topics such as error handling, file input/output, and classes and objects, laying a solid foundation for further exploration in python programming.
Typology: Quizzes
1 / 7
This page cannot be seen from the preview
Don't miss anything!




age = 25 name = "Alice"
Data Types
print(type(age)) _# Output: _ print(type(name)) _# Output: _ Operators
# Arithmetic operators sum = 10 + 5 # Addition product = 10 * 5 _# Multiplication
is_equal = (age == 25 ) _# Checks if age is equal to 25
is_valid = (age > 18 ) and (name == "Alice") # Returns True if both conditions are met Expressions
total_price = price * quantity # Here, total_price is an expression
Functions
def greet(name): return f"Hello, {name}!" message = greet("Alice") print(message) # Output: Hello, Alice!
Working with Data and Libraries
Lists
fruits = ["apple", "banana", "cherry"] fruits.append("orange") # Adding an item print(fruits) # Output: ['apple', 'banana', 'cherry', 'orange']
Dictionaries
person = { "name": "Alice", "age": 30 , "city": "New York" } print(person["name"]) # Output: Alice
Sets
numbers = { 1 , 2 , 2 , 3 , 4 } print(numbers) # Output: {1, 2, 3, 4}
Tuples
coordinates = (10.0, 20.0) print(coordinates[ 0 ]) # Output: 10. Libraries for Data Manipulation
import numpy as np array = np.array([ 1 , 2 , 3 , 4 , 5 ]) print(array.mean()) # Output: 3.
import pandas as pd data = {'Name': ['Alice', 'Bob'], 'Age': [ 30 , 25 ]} df = pd.DataFrame(data) print(df)
Intermediate Python Topics and Summary