Skip to content

Commit c996fa2

Browse files
Finished part 1
1 parent 3611f90 commit c996fa2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+592
-1
lines changed

Learnpython/Making decisions based on conditions/Conditional statements/What_i_learned_new.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ in practice31.py, i learned about a function name.endwith('a'), which returns bo
22
in practice33.py, i learned about a function name.startwith('x'), which returns boolean value.
33
in practice33.py, i learned about a function len(name), which returns length of the str.
44
in practice34.py, i learned about priority of AND OR NOT, order: NOT > AND > OR.
5+
in practice51.py, i learned about a function isnumeric(), which returns boolean value.
6+
in practice78.py, i learned about function invocation with parameter names, this will help to keep default values untouchable.
7+
in practice83.py, i learned about docstrings to know more visit: https://peps.python.org/pep-0257/
58

Learnpython/Quiz/question1.png

77.4 KB
Loading

Learnpython/Quiz/question1.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
count_posters = int(input('How many posters will be printed? '))
2+
3+
def calculate_cost(count_posters):
4+
if count_posters >= 125:
5+
cost = (count_posters // 125) * 50 + count_posters * 1.25
6+
else:
7+
cost = 50 + count_posters * 1.25
8+
print(f"This will cost {cost} USE.")
9+
10+
calculate_cost(count_posters)

Learnpython/Quiz/question2.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Ask the user for integer a, b, and c and print the smallest of them.
2+
3+
a = int(input('a=? '))
4+
b = int(input('b=? '))
5+
c = int(input('c=? '))
6+
7+
def smallest(a, b, c):
8+
if b > a < c:
9+
print(a)
10+
elif a > b < c:
11+
print(b)
12+
elif b > c < a:
13+
print(c)
14+
15+
smallest(a, b, c)

Learnpython/Quiz/question3.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Printing average value
2+
3+
count_numbers = int(input('How many numbers do you have? '))
4+
5+
sum = 0
6+
for i in range(0, count_numbers):
7+
number = int(input('Provide a number: '))
8+
sum += number
9+
print(f"The average is {sum/count_numbers}")

Learnpython/Quiz/question4.png

64.3 KB
Loading

Learnpython/Quiz/question4.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
def calculate_rental_cost(day=1, age=30):
3+
if age < 30:
4+
base_fare = 220
5+
else:
6+
base_fare = 100
7+
8+
free_of_charge = day // 7
9+
day = day - free_of_charge
10+
return day * base_fare
11+
12+
print(calculate_rental_cost(1, 17))

0 commit comments

Comments
 (0)