03.PB Python Conditional Statements Advanced Exercise
03.PB Python Conditional Statements Advanced Exercise
Problems for exercise and homework for the "Programming Basics" course @ SoftUni Global
Submit your solutions to the SoftUni Judge system at: https://judge.softuni.org/Contests/4582
1. Cinema
In a cinema, the chairs are arranged in a rectangular shape in r rows and c columns. There are three types of
screenings with tickets at different prices:
Premiere – premiere screening, at a price of 12.00 USD.
Normal – standard screening, at a price of 7.50 USD.
Discount – screening for children, and students at a reduced price of 5.00 USD.
Write a program that reads the type of projection (string), a number of rows, and a number of columns in the hall
(integers) entered by the user and calculates the total ticket revenue for a full hall. Print the result in the format as
in the examples below, 2 characters after the decimal point.
3. Create a new variable, which will help us calculate the capacity of the hall:
4. Create a series of checks, for each of the screening types ("Premiere, Normal, Discount") and calculate
the corresponding price in the variable "income":
© SoftUni - https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Print on the console: "It's {degrees} degrees, get your {clothing} and {shoes}.""It's
{degrees} degrees, get your {outfit} and {shoes}."
16 It's 16 degrees, get your In the Morning when the temperature is 16,
Morning Sweatshirt and Sneakers. Steven takes a sweatshirt and sneakers.
© SoftUni - https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
3. New House
John and Sophie are buying a house not far from Sofia. Sophie loves flowers so much that she convinces you to write
a program that will calculate how much it will cost them, to plant a certain number of flowers and whether the
available budget will be enough. Different flowers have different prices.
Flowers Roses Dahlias Tulips Narcissus Gladiolus
Price in USD 5 3.80 2.80 3 2.50
These are the following discounts:
If Sophie buys more than 80 Roses - 10% discount from the final price
If Sophie buys more than 90 Dahlias - 15% discount from the final price
If Sophie buys more than 80 Tulips - 15% discount from the final price
If Sophie buys less than 120 Narcissus - the price increases by 15%
If Sophie Buys less than 80 Gladiolus - the price increases by 20%
3 rows are read from the console:
Type of flowers - a string with options - "Roses", "Dahlias", "Tulips", "Narcissus", "Gladiolus"
Number of flowers - an integer in the range [10…1000]
Budget – an integer in the range [50…2500]
© SoftUni - https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Roses Not enough money, you need 25.00 Sophie wants 55 roses. The price of one rose is 5 USD,
55 USD more. therefore for 55 pieces Sophie will have to pay: 55 * 5
250 = 275.
However, she has a budget of 250 USD.
Because 275> 250, it does not reach 25 USD.
Tulips Hey, you have a great garden with Narcissu Not enough money, you need
88 88 Tulips and 50.56 USD left. s 50.55 USD more.
260 119
360
4. Fishing Boat
Tony and his friends loved to go fishing. They were so passionate about fishing that they decided to go fishing by
boat. The price of renting a boat depends on the season and the number of fishermen.
The price depends on the season:
The price for renting a boat in the spring is 3000 USD
The price for renting a boat in summer and autumn is 4200 USD.
The price for renting a boat in winter is 2600 USD.
Depending on the number of people, the group receives a discount:
If the group is up to 6 people inclusive – a 10% discount.
If the group is from 7 to 11 people inclusive - a 15% discount
If the group is more than 12 people - a 25% discount
The fishermen receive an additional 5% discount if their group is an even number. If it is autumn - then they do not
have an additional discount.
Write a program that calculates whether fisherman will have enough money.
Input Data
3 rows are read from the console:
Group budget - an integer in the range [1…8000]
Season - string: "Spring", "Summer", "Autumn", "Winter"
© SoftUni - https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Output Data
Print on the console:
If the budget is enough:
"Yes! You have {money left} USD left."
If the budget is not enough:
"Not enough money! You need {needed money} USD."
Amounts must be formatted to two decimal places after the decimal point.
3000 Not enough money! In the Summer fishing tourism costs 4200 USD, 11 fishermen enjoy a 15%
Summe You need 570.00 discount -> 4200 - 15% = 3570 USD, an odd number are and do not use an
r USD. additional discount.
11 3000 <= 3570, therefore they do not reach 570.00 USD
3600 Not enough money! 2000 Yes! You have 50.00 USD left.
Autum You need 180.00 Winter
n USD. 13
6
5. Journey
Strangely, most people plan their vacation early. A young programmer has an exact budget and free time for each
season. Write a program that will accept the budget and the season, and print, where the programmer will rest and
how much he will spend.
The budget determines the destination, and the season determines how much of the budget he will spend. If it is
summer, he will rest at the campsite and in the winter at a hotel. If he is in Europe, he will stay in a hotel, regardless
of the season. Each campsite or hotel, according to the destination, has its price that corresponds to a certain
percentage of the budget:
At 100 USD or less – somewhere in Serbia
o Summer – 30% of the budget
o Winter – 70% of the budget
At 1000 USD or less – somewhere in Balkans
o Summer – 40% of the budget
o Winter – 80% of the budget
For more than 1000 USD. – somewhere in Europe
o When travelling in Europe, regardless of the season he will spend 90% of the budget.
Input Data
2 rows are read from the console:
The budget – a floating-point number in the range [10.00...5000.00].
© SoftUni - https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Output Data
On the console print.
Somewhere in {destination}
{Type of holiday} – {Money spent}
o The Holiday can be a "Camp", or "Hotel"
o The amount must be rounded to the second decimal place
75 Somewhere in Serbia
winter Hotel - 52.50
312 Somewhere in Balkans
summer Camp - 124.80
Input Data
3 rows are read from the console:
N1 – an integer in the range [0...40 000]
N2 – an integer in the range [0...40 000]
Operator – symbol of: "+", "-", "*", "/", "%"
Output Data
On the console print:
If the operation is addition, subtraction, or multiplication:
o "{N1} {operator} {N2} = {result} – {even/odd}"
If the operation is a division:
o "{N1} / {N2} = {result}" – the result is formatted to the second decimal place
© SoftUni - https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
7 7 * 3 = 21 - odd
3
*
7. Hotel Room
The hotel offers 2 types of rooms: studio and apartment. Write a program that calculates the price for the entire
stay for a studio and apartment. Prices depend on the month of stay:
May and October June and September July and August
Studio – 50 USD / night Studio – 75.20 USD / night Studio – 76 USD / night
Apartment – 65 USD / night Apartment – 68.70 USD / night Apartment – 77 USD / night
The following discounts are:
studio, for more than 7 nights in May and October: 5% discount.
studio, for more than 14 nights in May and October: 30% discount.
studio, for more than 14 nights in June and September: 20% discount.
apartment, for more than 14 nights, regardless of the month: 10% discount.
Input Data
2 rows are read from the console:
On the first row is the month – May, June, July, August, September, or October
On the second row is the number of nights – an integer in the range [0 ... 200]
Output Data
On the console print:
On the first line: "Apartment: {price for the whole stay} USD."
On the second line: "Studio: {price for the whole stay} USD."
The price for the entire stay must be formatted to two decimal places.
© SoftUni - https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
May Apartment: 877.50 USD. In May, for more than 14 nights, we reduce the price of the studio by 30%
15 Studio: 525.00 USD. (50 - 15 = 35) and the apartment - by 10% (65 - 6.5 = 58.5).
The whole stay in the apartment - 877.50 USD.
The whole stay in the studio - 525.00 USD.
Input Data
4 rows are read from the console:
The first line contains the exam time - an integer from 0 to 23.
The second line contains the minute of the exam – an integer from 0 to 59.
The third line contains the time of arrival – an integer from 0 to 23.
The fourth line contains the minute of arrival – an integer from 0 to 59.
Output Data
On the first line print:
"Late" - if the student arrives later than the exam time.
"On time" - if the student arrives exactly at the time of the exam or up to 30 minutes earlier.
"Early" - if the student arrives more than 30 minutes before the exam time.
If the student arrives at least one minute apart from the exam time, print on the next line:
"mm minutes before the start" for arriving earlier by less than an hour.
"hh:mm hours before the start" or 1 hour or earlier. Always print the minutes in 2 digits, for example 1:05.
"mm minutes after the start" for an hour delay.
"hh:mm hours after the start" for a delay of 1 hour or more. Always print the minutes with 2 digits, for
example 1:03.
© SoftUni - https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
9. Ski Trip
John decided to spend his vacation in a ski resort. Before he leaves, however, he must book a hotel and calculate
how much his stay will cost. The following types of accommodation are available, with the following
accommodation prices:
"room for one person" – 18.00 USD per night
"apartment" – 25.00 USD per night
"president apartment" – 35.00 USD per night
Depending on the number of days he will stay in the hotel (example: 11 days = 10 nights) and the type of room he
chooses, he can enjoy different discounts.
The discounts are as follows:
room type less than 10 days between 10 and 15 days more than 15 days
room for one person no discount no discount no discount
apartment 30% of the final price 35% of the final price 50% of the final price
president apartment 10% of the final price 15% of the final price 20% of the final price
After the stay, John’s rating for the hotel's services can be positive or negative. If his assessment is positive, John
adds 25% to the discount. If his assessment is negative, 10% is deducted from the discount.
Input Data
3 rows are read from the console:
First row - days of stay - integer in the range [0...365]
Second row – room type - "room for one person", "apartment" or "president apartment"
Third row - grade - "positive" or "negative"
Output Data
On the console print:
The price for his stay at the hotel is formatted to the second decimal place.
© SoftUni - https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
© SoftUni - https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.