Absolute Values - Problem Description
Absolute Values - Problem Description
This document defines the exercises for the "Python Fundamentals" course at @SoftUni Global
Please submit your solutions (source code) to all the below-described problems in Judge.
1. Absolute Values
Write a program that receives a sequence of numbers, separated by a single space, and prints their absolute value
as a list. Use abs().
Example
Input Output
2. Grades
Write a function that receives a grade between 2.00 and 6.00 and print the corresponding grade in words.
2.00 – 2.99 - "Fail"
3.00 – 3.49 - "Poor"
3.50 – 4.49 - "Good"
4.50 – 5.49 - "Very Good"
5.50 – 6.00 - "Excellent"
Examples
Input Output
3.33 Poor
4.50 Very Good
2.99 Fail
Hints
Read the grade from the console:
© SoftUni – softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
3. Calculations
Create a function that receives three parameters, calculates a result depending on the given operator, and returns
it. Print the result of the function.
The input comes as three parameters – an operator as a string and two integer numbers. The operator can be one
of the following: "multiply", "divide", "add", and "subtract".
Example
Input Output
subtract 1
5
4
divide 2
8
4
Hints
Read the input data from the console:
Then, create the function and make an if statement for each case:
© SoftUni – softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
4. Repeat String
Write a function that receives a string and a counter n. The function should return a new string – the result of
repeating the old string n times. Print the result of the function. Try using lambda.
Examples
Input Output
abc abcabcabc
3
String StringStrin
2 g
Hints
1. Read the input data:
5. Orders
Write a function that calculates the total price of an order and returns it. The function should receive one of the
following products: "coffee", "coke", "water", or "snacks", and a quantity of the product. The prices for a
single piece of each product are:
coffee - 1.50
water - 1.00
coke - 1.40
snacks - 2.00
© SoftUni – softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Example
Input Output
water 5.00
5
coffe 3.00
e
2
Examples
Input Output
3 12
4
6 12
2
7. Rounding
Write a program that rounds all the given numbers, separated by a single space, and prints the result as a list. Use
round().
Example
Input Output
© SoftUni – softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.