Skip to content

Commit e85f149

Browse files
improved lecture 8
1 parent 718475f commit e85f149

File tree

8 files changed

+684
-25
lines changed

8 files changed

+684
-25
lines changed

_quarto.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ website:
7575
href: part-07/lecture-scientific.qmd
7676
- text: "Tutorial"
7777
href: part-07/tutorial-scientific.qmd
78-
- section: "08 Tabular and AI"
78+
- section: "08 Pandas and AI"
7979
contents:
8080
- text: "Lecture"
8181
href: part-08/lecture-pandas.qmd
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import pandas as pd
2+
import numpy as np
3+
4+
# Create dates for 3 months
5+
dates = pd.date_range('2024-03-01', periods=92) # March through May
6+
7+
# Create seasonal temperature progression (slightly warming as we move into spring)
8+
hamburg_temps = np.concatenate([
9+
np.random.uniform(5, 12, 31), # March (cooler)
10+
np.random.uniform(8, 15, 30), # April (mild)
11+
np.random.uniform(12, 20, 31) # May (warmer)
12+
]).round(1)
13+
14+
la_temps = np.concatenate([
15+
np.random.uniform(15, 23, 31), # March
16+
np.random.uniform(17, 25, 30), # April
17+
np.random.uniform(19, 27, 31) # May
18+
]).round(1)
19+
20+
tokyo_temps = np.concatenate([
21+
np.random.uniform(10, 18, 31), # March
22+
np.random.uniform(14, 21, 30), # April
23+
np.random.uniform(18, 25, 31) # May
24+
]).round(1)
25+
26+
# Create DataFrame
27+
temperatures = pd.DataFrame({
28+
'Date': dates,
29+
'Hamburg': hamburg_temps,
30+
'Los_Angeles': la_temps,
31+
'Tokyo': tokyo_temps
32+
})
33+
34+
# Save to Excel file
35+
temperatures.to_excel('temperatures.xlsx', index=False)
36+
37+
print("First few rows of the dataset:")
38+
print(temperatures.head())
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import random
2+
3+
def number_guessing_game():
4+
# Generate a random number between 1 and 10
5+
secret_number = random.randint(1, 10)
6+
tries = 3
7+
8+
print("Welcome to the Number Guessing Game!")
9+
print("I'm thinking of a number between 1 and 10.")
10+
print(f"You have {tries} tries to guess it.\n")
11+
12+
while tries > 0:
13+
# Get player's guess
14+
try:
15+
guess = int(input(f"Enter your guess ({tries} tries left): "))
16+
17+
# Check if guess is in valid range
18+
if guess < 1 or guess > 10:
19+
print("Please enter a number between 1 and 10!")
20+
continue
21+
22+
# Check if guess is correct
23+
if guess == secret_number:
24+
print(f"\nCongratulations! You guessed it! The number was {secret_number}!")
25+
return
26+
elif guess < secret_number:
27+
print("Too low! Try again.")
28+
else:
29+
print("Too high! Try again.")
30+
31+
tries -= 1
32+
33+
except ValueError:
34+
print("Please enter a valid number!")
35+
continue
36+
37+
print(f"\nGame Over! The number was {secret_number}. Better luck next time!")
38+
39+
if __name__ == "__main__":
40+
number_guessing_game()

part-08/employees.xlsx

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)