Each student needs a notebook and a pen.
Write a function that takes number of students, students, price of notebook, notebook_price,
and price of pen, pen_price, and returns total cost for the entire class. Example:
>>> total_cost(10, 1, 0.5)
15.0
>>> total_cost(20, 1, 2)
60
ⓘ
How many miles are there in 10 kilometers?
Hint: there are 1.61 kilometers in a mile.
ⓘ
At the art store, you buy 3 sketchbooks at $7.40 each. If there's a "Buy 2, get 1 half off" deal, how much do you pay in total?
ⓘ
A concert hall sells three types of tickets:
- Premium: $50
- Standard: $30
- Economy: $20
They sold 120 premium tickets, 200 standard tickets, and 350 economy tickets.
What is the total revenue? Find and print it.
ⓘ
At Traukni School, students can join the school's sports team if they meet the criteria.
To join, a student must have a GPA greater than 3.5 and be part of the track team,
or they must be in the top 10% of their class academically.
Write a function that takes student's gpa: float, track_team: bool and top_10_percent: bool and prints True
if they qualify, and False otherwise.. Examples:
>>> check_sports_team(gpa=3.6, track_team=True, top_10_percent=False) True >>> check_sports_team(gpa=3.5, track_team=True, top_10_percent=True) True >>> check_sports_team(gpa=3.5, track_team=False, top_10_percent=False) False >>> check_sports_team(gpa=2.6, track_team=True, top_10_percent=False) False
ⓘ
Dudije is organizing gift bags for a party. Each gift bag contains:
- 2 pencils (each costs $0.50)
- 1 notebook (costs $2.00)
- 3 candies (each costs $0.25)
She is preparing 60 gift bags.
Calculate the total cost and print it.
ⓘ
In Babrruja, there's a rule for who gets invited to the annual birthday party.
The guest must either be a teenager, between 13 and 19 years old (inclusive),
and enjoy video games, or be someone who loves outdoor activities but is 25 years old or younger.
Write a function that checks if a person gets an invite by taking their age and interest.
Print True if they qualify for an invitation, and False otherwise. Examples:
>>> check_invite(14, "video games") True >>> check_invite(21, "outdoor activities") True >>> check_invite(5, "outdoor activities") True >>> check_invite(15, "hiking") False >>> check_invite(21, "video games") False
ⓘ
How many seconds are in 42 minutes and 42 seconds?
ⓘ
At The Shebang Shop, there's a special discount. You can get it if you're a farmer and have spent at
least 25$, or if you've spent over $100.
Write a function that takes occupation and total_spent and prints True if the person qualifies for the discount,
and False otherwise. Examples:
>>> check_discount("farmer", 25) True >>> check_discount("prime minister", 100) False >>> check_discount("developer", 30) False >>> check_discount("developer", 101) True >>> check_discount("farmer", 10) False
ⓘ
You have to read books, and you want to know for how many days you finish a book.
Write a function that takes two arguments, total_pages and pages_per_day, and returns
number of days you need to finish the book. Example:
>>> calculate(100, 20)
5.0
>>> calculate(150, 20)
7.5
ⓘ
Write a function that takes two arguments, x and y, and prints True if at least one of them is negative. It prints False otherwise.
ⓘ
Write a function that takes two strings of the same length, s1 and s2,
and returns a dictionary which maps s1[i] with s2[i].
Example:
>>> map_strings('ani', 'pse')
{'a': 'p', 'n': 's', 'i': 'e'}
ⓘ
Write a function that takes a dictionary, d, whose values are numbers, and a number, n,
and adds n to each value of dictionary.
Example:
>>> d = {'a': 1, 'b': 3}
>>> add_number(d, 3)
>>> d
{'a': 4, 'b': 6}
ⓘ
Write a function that takes one float as argument and prints True if it is greater than 100 and less than 500 (excluding 100, including 500), and False otherwise.
Call it giving 100 as argument
Call it giving 500 as argument.
ⓘ
Write a function that takes one integer as argument and prints True if it is greater than 100 but not 500, and False otherwise.
ⓘ
def is_less_than_10(a, b): print(a <= 10) a = 10 is_less_than_10(5, a)
What is printed after we execute the above program?
def calculate(x, y): res = x * y res = x + res revert(res, x, y) def revert(a, b, c): res = a - b res = res / c print(res) calculate(2, 3)
Write the printed value after we execute the above program.
def is_greater(s1, s2): res = s1 > s2 res = 10 is_greater(res, res) print(res)
What is printed when we execute the above program?
def do_smth_twice(a, b): do_smth(a, a) do_smth(a, b) def do_smth(a, b): print(a + b) do_smth('ani', 'pse')
What is printed if we execute the above program?
n = 10 m = 11 o = m * 2 + n print(m)
xx
>>> o = o + m + n
>>>
What is printed and what is value of o at the end of the execution of the above program?
Printed value: | |
o: |
def print_result(a, b): print(not a > b) a = 10 b = 10 res = a + b print_result(res, a)
What is printed if we execute the above program?
What is value of res at the end of the execution of the above program?
def pow(a, b): res = a ** b return res def sum(x, y): res = x + y return res def mp(n, m, p): po = pow(n, m) s = sum(po, p) return s res = mp(1, 2, 3)
In the above script what is value of res:
def compare(a, b): print(1 + 2) def not_equal(a, b): s = not a == b d = a == b not_equal(True, False) compare(11, 2)
What is printed if we execute the above program?
def print_bool(a, b): print(res == False) res = 1 res = res == res < 0 b = 20 print_bool(res, b) print(b)
What is value of res at the end of the program?