How many feet are there in 12 meters?
Hint: there are 3.3 feet in a meter.
ⓘ
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
ⓘ
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
ⓘ
A company is building highways.
One worker can complete 0.5 kilometers per day.
Write a function that takes the total distance in kilometers, km,
and the number of days until the deadline, days,
and prints how many workers are needed to complete the highway on time.
ⓘ
How many miles are there in 10 kilometers?
Hint: there are 1.61 kilometers in a mile.
ⓘ
Suppose the cover price of a book is $24.95, but bookstores get a 40% discount. Shipping costs $3 for the first copy and 75 cents for each additional copy. What is the total whole sale cost for 60 copies?
ⓘ
An employer has many employees who work different numbers of hours per day and
receive different payments per hour.
Write a function that takes number of hours, hours, and payment per hour, payment,
and prints the total payment.
ⓘ
How many centimeters are there in 13 meters and 45 centimeters?
ⓘ
You're building a wall. Each brick is 20cm tall.
You want to build a wall of a certain height in meters.
Write a function that takes one argument, the height in meters,
and returns how many bricks you need.
Example:
>>> bricks_needed(1)
5.0
>>> time_to_print(3)
15.0
ⓘ
You buy 3 pencils for $0.50 each, 2 notebooks for $2.25 each, and a backpack for $35. If you pay with a $50 bill, how much change will you get?
ⓘ
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 three arguments, x, y and z, and prints True if x is negative, y is 0 and z is positive, or False otherwise.
ⓘ
Write a function that takes a list of strings and returns a dictionary mapping strings
to their length. Example:
>>> get_length(['yes', 'no' ,'a', 'b'])
{'yes': 3, 'no': 2 ,'a': 1, 'b': 1}
ⓘ
Write a function that takes one integer as argument and prints True if it is greater than 100 but not 500, and 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'}
ⓘ
def is_less_than_10(a): print(a < 10) a = 10 is_less_than_10(5)
What is printed after we execute the above program?
def calculate(attendance, grade): total = grade * 0.8 + attendance * 0.2 passes(total) def passes(total): print(total > 6.0)
What is printed if we execute calculate(10, 10)
What is printed if we execute calculate(10, 5)
What is printed if we execute passes(6.01)
def print_bool(a, b): res = a == b res = a < 10 < b print(res) res = 1 b = 20 print_bool(res, b)
What is printed after we execute the above program?
def not_equal(s1, s2): res = s1 != s2 res = 'ani' not_equal('ani', 'ani') res = res != 'pse'
What is value of res at the end of the program?
def compare(a, b, c): print(a == b or a < c) x, y, z = 1, 2, 3 d = x == 1 or y == 2 or y < z compare(x, y, -1 * z)
What is printed if we execute the above program?
What is value of d at the end of the execution of the above program?
a = 4 b = 2 c = a ** b print(c)
xx
>>> d = c + 4 * 2
>>>
What is printed and what is value of d at the end of the execution of the above program?
Printed value: | |
d: |
def accepted(level, evaluation): print((level == "senior" and evaluation > 8.0) or evaluation > 6.5) def evaluate(level, logic, syntax, communication): evaluation = (logic + syntax + communication) / 3 accepted(level, evaluation) print(evaluation) evaluate("senior", 7.0, 10.0, 1.0)
After the execution of the above program two values are printed. Write those values in the order that they are printed.
1: | |
2: |
def is_greater(s1, s2): print(s1 > s2) res = 10 is_greater(res, res) res = True
What is printed 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?