Skip to content

Commit 022dd5f

Browse files
Add files via upload
1 parent 69473db commit 022dd5f

32 files changed

+1257
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Write a program that reads an integer entered by the user and prints the day of the week,
3+
in the range [1...7], or prints "Error" in case the entered number is invalid.
4+
"""
5+
6+
number_of_day = int(input())
7+
8+
if number_of_day == 1:
9+
print("Monday")
10+
elif number_of_day == 2:
11+
print("Tuesday")
12+
elif number_of_day == 3:
13+
print("Wednesday")
14+
elif number_of_day == 4:
15+
print("Thursday")
16+
elif number_of_day == 5:
17+
print("Friday")
18+
elif number_of_day == 6:
19+
print("Saturday")
20+
elif number_of_day == 7:
21+
print("Sunday")
22+
else:
23+
print("Error")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""
2+
Write a program that reads the day of the week (text), in English - entered by the user.
3+
If the day is working, it prints on the console - "Working day", if it is a holiday - "Weekend".
4+
If a text other than a day of the week is entered, "Error" will be printed.
5+
"""
6+
7+
day_of_week = input()
8+
9+
if day_of_week in "Monday" "Tuesday" "Wednesday" "Thursday" "Friday":
10+
print("Working day")
11+
elif day_of_week in "Saturday" "Sunday":
12+
print("Weekend")
13+
else:
14+
print("Error")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Write a program that prints the class of the animal according to its name entered by the user.
3+
1. dog -> mammal
4+
2. crocodile, tortoise, snake -> reptile
5+
3. others -> unknown
6+
"""
7+
8+
animal = input()
9+
10+
if animal == "dog":
11+
print("mammal")
12+
elif animal in "crocodile" "tortoise" "snake":
13+
print("reptile")
14+
else:
15+
print("unknown")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Write a console program that reads the age (real number) and gender
3+
('m' or 'f') entered by the user and prints an address from among the following:
4+
• "Mr." – male (gender 'm') aged 16 or over
5+
• "Master" – boy (gender 'm') under 16 years old
6+
• "Ms." – female (gender 'f') aged 16 or over
7+
• "Miss" – girl (gender 'f') under 16 years old
8+
"""
9+
10+
age = float(input())
11+
gender = input()
12+
13+
if gender == "m":
14+
if age >= 16:
15+
print("Mr.")
16+
else:
17+
print("Master")
18+
19+
if gender == "f":
20+
if age >= 16:
21+
print("Ms.")
22+
else:
23+
print("Miss")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""
2+
An enterprising Bulgarian opens neighborhood shops in several cities and sells at different prices
3+
depending on the city:
4+
5+
city / product coffee water beer sweets peanuts
6+
Sofia 0.50 0.80 1.20 1.45 1.60
7+
Plovdiv 0.40 0.70 1.15 1.30 1.50
8+
Varna 0.45 0.70 1.10 1.35 1.55
9+
10+
Write a program that reads a product (text), a city (text), and a quantity (decimal number)
11+
entered by the user, and calculates and prints how much the corresponding quantity of the
12+
selected product costs in the specified city.
13+
"""
14+
15+
product = input()
16+
city = input()
17+
quantity = float(input())
18+
19+
price = 0
20+
21+
if city == "Sofia":
22+
if product == "coffee":
23+
price = 0.50
24+
elif product == "water":
25+
price = 0.80
26+
elif product == "beer":
27+
price = 1.20
28+
elif product == "sweets":
29+
price = 1.45
30+
elif product == "peanuts":
31+
price = 1.60
32+
33+
if city == "Plovdiv":
34+
if product == "coffee":
35+
price = 0.40
36+
elif product == "water":
37+
price = 0.70
38+
elif product == "beer":
39+
price = 1.15
40+
elif product == "sweets":
41+
price = 1.30
42+
elif product == "peanuts":
43+
price = 1.50
44+
45+
if city == "Varna":
46+
if product == "coffee":
47+
price = 0.45
48+
elif product == "water":
49+
price = 0.70
50+
elif product == "beer":
51+
price = 1.10
52+
elif product == "sweets":
53+
price = 1.35
54+
elif product == "peanuts":
55+
price = 1.55
56+
57+
final_price = price * quantity
58+
59+
print(final_price)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
Write a program that checks if the number entered by the user is in the interval
3+
[-100, 100] and is different from 0 and outputs "Yes" if it meets the conditions
4+
or "No" if it does not.
5+
"""
6+
7+
number_in_range = int(input())
8+
9+
if -100 <= number_in_range <= 100 and number_in_range != 0:
10+
print("Yes")
11+
else:
12+
print("No")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
Write a program that reads the hour of the day (integer) and the day of the week (text)
3+
- entered by the user and checks whether the office of a company is open, with the working hours
4+
of the office being from 10 a.m. to 6 p.m., from Monday to Saturday inclusive
5+
"""
6+
7+
hours = int(input())
8+
day = input()
9+
10+
if 10 > hours or hours > 18 or day == "Sunday":
11+
print("closed")
12+
else:
13+
print("open")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Write a program that reads the day of the week (text) - entered by the user
3+
and prints on the console the price of a movie ticket according to the day of the week:
4+
5+
Monday Tuesday Wednesday Thursday Friday Saturday Sunday
6+
12 12 14 14 12 16 16
7+
"""
8+
9+
day_of_week = input()
10+
price = 0
11+
12+
if day_of_week in "Monday" "Tuesday" "Friday":
13+
price = 12
14+
elif day_of_week in "Wednesday" "Thursday":
15+
price = 14
16+
elif day_of_week in "Saturday" "Sunday":
17+
price = 16
18+
19+
print(price)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
Write a program that reads a product name entered by the user and checks whether it is a fruit or a vegetable.
3+
4+
• "fruit" has the following possible values: banana, apple, kiwi, cherry, lemon and grapes;
5+
• Vegetables have the following possible values: tomato, cucumber, pepper and carrot;
6+
• All others are "unknown".
7+
8+
Display "fruit", "vegetable" or "unknown" according to the product entered.
9+
"""
10+
11+
fruit_or_vegetable = input()
12+
13+
if fruit_or_vegetable in "banana" "apple" "kiwi" "cherry" "lemon" "grapes":
14+
print("fruit")
15+
elif fruit_or_vegetable in "tomato" "cucumber" "pepper" "carrot":
16+
print("vegetable")
17+
else:
18+
print("unknown")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
A given number is valid if it is in the range [100…200] or is 0.
3+
4+
Write a program that reads an integer entered by the user and prints
5+
"invalid" if the entered number is not valid.
6+
"""
7+
8+
number = int(input())
9+
10+
if 100 <= number <= 200 or number == 0:
11+
pass
12+
else:
13+
print("invalid")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"""
2+
The fruit shop operates at the following prices on working days:
3+
4+
fruit banana apple orange grapefruit kiwi pineapple grapes
5+
price 2.50 1.20 0.85 1.45 2.70 5.50 3.85
6+
7+
On Saturdays and Sundays, the store operates at higher prices:
8+
9+
fruit banana apple orange grapefruit kiwi pineapple grapes
10+
price 2.70 1.25 0.90 1.60 3.00 5.60 4.20
11+
12+
Write a program that reads from the console the following three variables entered by
13+
the user and calculates the price according to the prices in the tables above:
14+
15+
• fruit - banana / apple / orange / grapefruit / kiwi / pineapple / grapes;
16+
• day of the week - Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday;
17+
• quantity (real number).
18+
19+
Print the result rounded to 2 decimal places. For an invalid day of the week or an invalid fruit name, print "error".
20+
"""
21+
22+
fruit = input()
23+
day = input()
24+
quantity = float(input())
25+
26+
price = 0
27+
28+
if day in "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" \
29+
and fruit in "banana" "apple" "orange" "grapefruit" "kiwi" "pineapple" "grapes":
30+
if fruit == "banana":
31+
price = 2.50
32+
elif fruit == "apple":
33+
price = 1.20
34+
elif fruit == "orange":
35+
price = 0.85
36+
elif fruit == "grapefruit":
37+
price = 1.45
38+
elif fruit == "kiwi":
39+
price = 2.70
40+
elif fruit == "pineapple":
41+
price = 5.50
42+
elif fruit == "grapes":
43+
price = 3.85
44+
45+
final_price = price * quantity
46+
print(f"{final_price:.2f}")
47+
48+
elif day in "Saturday" "Sunday" \
49+
and fruit in "banana" "apple" "orange" "grapefruit" "kiwi" "pineapple" "grapes":
50+
if fruit == "banana":
51+
price = 2.70
52+
elif fruit == "apple":
53+
price = 1.25
54+
elif fruit == "orange":
55+
price = 0.90
56+
elif fruit == "grapefruit":
57+
price = 1.60
58+
elif fruit == "kiwi":
59+
price = 3.00
60+
elif fruit == "pineapple":
61+
price = 5.60
62+
elif fruit == "grapes":
63+
price = 4.20
64+
65+
final_price = price * quantity
66+
print(f"{final_price:.2f}")
67+
68+
else:
69+
print("error")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
A company gives the following commissions to its salespeople according to the city
3+
in which they work and the volume of sales:
4+
5+
City 0 ≤ s ≤ 500 500 < s ≤ 1,000 1,000 < s ≤ 10,000 s > 10,000
6+
Sofia 5% 7% 8% 12%
7+
Varna 4.5% 7.5% 10% 13%
8+
Plovdiv 5.5% 8% 12% 14.5%
9+
10+
Write a console program that reads city name (text) and sales volume (real number)
11+
entered by the user and calculates and outputs the trade commission amount according
12+
to the above table. Output the result formatted to 2 decimal places. Invalid city or
13+
sales volume (negative number) to print "error".
14+
"""
15+
16+
city = input()
17+
sales = float(input())
18+
19+
commission = 0
20+
21+
if city == "Sofia":
22+
if 0 <= sales <= 500:
23+
commission = sales * 0.05
24+
elif 500 < sales <= 1000:
25+
commission = sales * 0.07
26+
elif 1000 < sales <= 10000:
27+
commission = sales * 0.08
28+
elif sales > 10000:
29+
commission = sales * 0.12
30+
31+
elif city == "Varna":
32+
if 0 <= sales <= 500:
33+
commission = sales * 0.045
34+
elif 500 < sales <= 1000:
35+
commission = sales * 0.075
36+
elif 1000 < sales <= 10000:
37+
commission = sales * 0.10
38+
elif sales > 10000:
39+
commission = sales * 0.13
40+
41+
elif city == "Plovdiv":
42+
if 0 <= sales <= 500:
43+
commission = sales * 0.055
44+
elif 500 < sales <= 1000:
45+
commission = sales * 0.08
46+
elif 1000 < sales <= 10000:
47+
commission = sales * 0.12
48+
elif sales > 10000:
49+
commission = sales * 0.145
50+
51+
if city in "Sofia Varna Plovdiv" and sales > 0:
52+
print(f"{commission:.2f}")
53+
54+
else:
55+
print("error")
56+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
In a movie theater, the chairs are arranged in a rectangular shape in r rows and c columns.
3+
4+
There are three types of screenings with tickets at different prices:
5+
6+
• Premiere - premiere screening, at a price of BGN 12.00;
7+
• Normal - standard projection, at a price of BGN 7.50;
8+
• Discount - screening for children, schoolchildren and students at a reduced price of BGN 5.00.
9+
10+
Write a program that reads the projection type (text), number of rows and number of columns in the hall
11+
(integers) entered by the user and calculates the total ticket revenue for a full house.
12+
13+
Print the result in 2 decimal places format.
14+
"""
15+
16+
type = input()
17+
rows = int(input())
18+
columns = int(input())
19+
20+
income = 0
21+
cinema_capacity = rows * columns
22+
23+
if type == "Premiere":
24+
income = cinema_capacity * 12.00
25+
elif type == "Normal":
26+
income = cinema_capacity * 7.50
27+
elif type == "Discount":
28+
income = cinema_capacity * 5.00
29+
30+
print(f"{income:.2f} leva")

0 commit comments

Comments
 (0)