Python_for_Data_Science_Guide
Python_for_Data_Science_Guide
Variables store data. Data types define the kind of data (string, number, boolean).
name = "Naveed"
age = 18
height = 5.9
is_student = True
print(marks[0])
Tuples are like lists but immutable. Sets are unordered and unique.
t = (1, 2, 3)
s = {1, 2, 2, 3}
print(s)
4. Dictionaries
print(student["marks"])
5. Conditional Statements
score = 80
print("Excellent")
else:
print("Try again")
6. Loops
for i in range(5):
print(i)
i = 0
while i < 3:
print(i)
i += 1
7. Functions
def greet(name):
print("Hello", name)
greet("Naveed")
8. Importing Libraries
import math
print(math.sqrt(16))
9. File Handling
print(file.read())
import pandas as pd
df = pd.read_csv("data.csv")
print(df.head())
import numpy as np
a = np.array([1, 2, 3])
print(a * 2)
import pandas as pd
data = {
df = pd.DataFrame(data)
df["Average"] = (df["Math"] + df["Science"]) / 2