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?
Write a function that takes two strings, s1 and s2, and prints all letters that appear in s1 but not in s2.
ⓘ
Write a function that takes one string and returns True if it is greater (comes after) than "Pse". It returns False otherwise.
ⓘ
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
ⓘ
Write a function which takes two strings as argument, s and method.
- If method is "lower", it returns lowercase version of the s.
- If method is "upper", it returns uppercase version of the s.
- If method is "capitalize", it returns capitalized version of the s.
- It returns s as it is otherwise.
ⓘ
Write a function which takes two strings, s1 and s2, and it concatenates the first 3
characters of s1 with the last 2 characters of s2 and returns it.
Example:
>>> concatenate_strings("power", "owl")
'powwl'
ⓘ
Write a function which takes two arguments, n and m.
- If both arguments are integers, and n is equal or less than m, it returns a random integer between n and m
- If both arguments are strings, it concatenates them and returns a random character out of the concatenated string
- It prints "not applicable" otherwise.
ⓘ
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}
ⓘ
def calculate(a, b): p = prod(a, b) d = diff(a, b) res = p + d return res def prod(x, y): res = x * y return res def diff(x, y): d = x - y return d c = calculate(5, 3)
In the above script what is value of c:
Write a function that takes a list of integers and returns sum of even numbers.
Example:
>>> add_evens([1, 2, 3, 4])
6
ⓘ