03.PB Python Conditional Statements Advanced
03.PB Python Conditional Statements Advanced
Problems for lab exercise for the "Programming Basics" course @ SoftUni Global
Submit your solutions in the SoftUni Judge system at: https://judge.softuni.org/Contests/4581
1. Day of Week
Write a program that reads an integer entered by the user and prints a day of the week within [1 ... 7] or prints
"Error" if the number entered is invalid.
Input Output
Sunday Weekend
Input Output
April Error
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
4. Personal Titles
Write a console program that reads the age (a floating-point number) and gender ("m" or "f") entered by the user
and prints an address from the following:
"Mr." - a man (gender "m") of 16 years or more
"Master" - a boy (gender "m") under 16 years old
"Ms." – a woman (gender "f") of 16 years or more
"Miss" – a girl (gender "f") under 16 years old
12 17 25 13.5
Miss Mr. Ms. Master
f m f m
2. Checks the gender and then the age. In the body of the if-condition for age print the appropriate output:
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
5. Small Shop
1. An enterprising person opens neighbourhood shops in several cities and sells at different prices:
city / product coffee water beer sweets peanuts
London 0.50 0.80 1.20 1.45 1.60
Rome 0.40 0.70 1.15 1.30 1.50
Paris 0.45 0.70 1.10 1.35 1.55
2. Write a program that reads product (string), city (string), and quantity (a floating-point number) entered by
the user and calculates and prints how much the corresponding quantity of the selected product costs in the
specified city.
3. Make a series of conditions, where in each town you check the product. In each product check, change the
value of the price variable and then print it. Take a look at the example below:
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
6. Number in Range
Write a program that checks if the number entered by the user is in the range [-100, 100] and is different from 0 and
print "Yes" if it meets the conditions, or "No" if it is outside the range.
7. Working Hours
Write a program that reads an hour of the day (integer) and a day of the week (string) - entered by the user and
checks whether the company's office is open, the office hours are from 10:00(10 am) to 18:00(6 pm), from Monday
to Saturday including.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
8. Cinema Ticket
Write a program that reads the day of the week (string) - entered by the user and prints on the console the price of
a movie ticket according to the day of the week:
9. Fruit or Vegetable
Write a program that reads a product name entered by the user and checks if it is a fruit or vegetable.
The fruits are banana, apple, kiwi, cherry, lemon, and grapes
The vegetables "vegetable" are tomato, cucumber, pepper, and carrot
Everything else is "unknown"
Print "fruit", "vegetable" or "unknown" depending on the introduced product.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Londo InvalidName
Rome Paris
n 120.00 27.50 387.45 error
499.99 3874.50 -50
1500
© 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.