Add-A-New-Column

Thu 08 January 2026

Add a New Column

import pandas as pd
data = {
    'city' : ['Toronto', 'Montreal', 'Waterloo'],
    'points' : [80, 70, 90]
}
data
{'city': ['Toronto', 'Montreal', 'Waterloo'], 'points': [80, 70, 90]}
type(data)
dict
df = pd.DataFrame(data)
df
city points
0 Toronto 80
1 Montreal 70
2 Waterloo 90
df = df.assign(code = [1, 2, 3])
df
city points code
0 Toronto 80 1
1 Montreal 70 2
2 Waterloo 90 3


Score: 10

Category: pandas-work


Age-Calculator

Thu 08 January 2026
from datetime import datetime
def get_age(d):
    d1 = datetime.now()
    months = (d1.year - d.year) * 12 + d1.month - d.month

    year = int(months / 12)
    return year
age = get_age(datetime(1991, 1, 1))
age
33


Score: 5

Category: basics

Read More

Basic Math

Thu 08 January 2026
a = 10
b = 11

temp = a
a = b

b = temp

print(a,b)
11 10


Score: 0

Category: maths

Read More

Bill

Thu 08 January 2026
print("Welcome to the Tip Calculator!")
bill = float(input("What was the total bill? $"))   
tip = int(input("What percentage tip would you like to give? 10, 12, or 15? "))
people = int(input("How many people to split the bill? "))  

tip_as_percent = tip / 100
total_tip_amount = bill * tip_as_percent
total_bill = bill + total_tip_amount
bill_per_person = total_bill …

Category: maths

Read More

Control Flow

Thu 08 January 2026
age = int(input(10))
if age >= 10:
    print("you are allowed")
else:
    print("go home ")
10 1


go home
print("hello")

Score: 0

Category: maths

Read More

Operator

Thu 08 January 2026
a = 10
b = 11

print(a+b)
#same goes for substraction
21


Score: 0

Category: maths

Read More

Temp

Thu 08 January 2026
a = 10
b = 11

temp = a
a = b
b = temp 
print(a,b)
11 10
print(a)
11


Score: 0

Category: maths

Read More
Page 1 of 1