8000 Update section names and add new exercise solutions · monkeyfx/python-basics-exercises@8c7b151 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8c7b151

Browse files
committed
Update section names and add new exercise solutions
1 parent 07e5971 commit 8c7b151

5 files changed

+40
-17
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 5.3 - Integers and Floating-Point Numbers
2+
# Solutions to Review Exercises
3+
4+
5+
# Exercise 1
6+
num1 = 25000000
7+
num2 = 25_000_000
8+
print(num1)
9+
print(num2)
10+
11+
# Exercise 2
12+
num = 1.75e5
13+
print(num)
14+
15+
# Exercise 3
16+
# NOTE: Your solution may vary!
17+
print(2e308)

ch05-numbers-in-python/2-challenge.py renamed to ch05-numbers-in-python/3-challenge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 5.2 - Challenge: Perform Calculations on User Input
1+
# 5.3 - Challenge: Perform Calculations on User Input
22
# Solution to challenge
33

44

ch05-numbers-in-python/4-work-with-numbers.py

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 5.5 - Built-in Math Functions
2+
# Solutions to Review Exercises
3+
4+
5+
# Exercise 1
6+
user_input = input("Enter a number: ")
7+
num = float(user_input)
8+
print(f"{num} rounded to 2 decimal places is {round(num, 2)}")
9+
10+
# Exercise 2
11+
user_input = input("Enter a number: ")
12+
num = float(user_input)
13+
print(f"The absolute value of {num} is {abs(num)}")
14+
15+
# Exercise 3
16+
num1 = float(input("Enter a number: "))
17+
num2 = float(input("Enter another number: "))
18+
print(
19+
f"The difference between {num1} and {num2} is an integer?"
20+
f"{(num1 - num2).is_integer()}!"
21+
)

ch05-numbers-in-python/5-print-numbers-in-style.py renamed to ch05-numbers-in-python/6-print-numbers-in-style.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 5.5 - Print Numbers in Style
1+
# 5.6 - Print Numbers in Style
22
# Solutions to Review Exercises
33

44
# Exercise 1

0 commit comments

Comments
 (0)
0