Create a function, random_digit, that returns a random integer between 0 and 9 (inclusive).
Write a function, shout_down, that takes a positive integer, n,
and inside a while True it prints all numbers between n and 1 (inclusive),
each in a new line.
Print "BOOM!" after the loop.
Example:
>>> shout_down(3)
3
2
1
BOOM!
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
Define a function named shtyp_tekstin, which prints Shndet prej mejet te m'i falesh.
Call shtyp_tekstin.
Define a function named perserit_tekstin, which calls shtyp_tekstin three times.
Call perserit_tekstin.
Define a function named print_smth, which prints Shnete e pranvere!.
Call print_smth.
Define a function named repeat_smth, which calls print_smth once.
Call repeat_smth.
Write a function, add that takes two numbers and returns their sum.
Write a function, square that takes a number and returns its square.
Example:
>>> square(3)
9
Write a function, sum_of_squares, that takes two numbers and returns sum of their squares.
Example:
>>> sum_of_squares(2, 3)
13
Restriction: You cannot use + or * signs inside this function's body
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?
def rect_area(l, w):
return l * w
def square_area(s):
return rect_area(s, s)
a = square_area(5)
print(a)
In the above example:
| What is the printed value: |
Complete execution flow of the following program
import math def cylinder_volume(r, h): return math.pi * r ** 2 * h def cylinder_volume_square(r, h): return math.pow(cylinder_volume(r, h), 2) print(cylinder_volume_square(5, 10))
Complete execution flow of the following program
def calculate(num): for item in '12ab': num = 2 + num return num def calculate2(num, string): for s in string: num = num ** 2 return num d = calculate2(3, 'an') - calculate(0)