Final review and test
Answers are for parents and teachers.
1
Write a function that returns the sum of the squares of the even numbers from 1 to n (56 for n = 6: 4 + 16 + 36).
def juft_kv(n): ⏎ s = 0 ⏎ for i in range(2, n + 1, 2): ⏎ s += i ** 2 ⏎ return s ⏎ print(juft_kv(6))
2
n is typed. Write a program that counts how many numbers from 1 to n are multiples of 7 (7 for n = 50).
n = int(input()) ⏎ k = 0 ⏎ for i in range(1, n + 1): ⏎ if i % 7 == 0: ⏎ k += 1 ⏎ print(k)
3
Write the names of three standard modules studied in the course and one job of each.
random – a random number; math – mathematical functions; tkinter – windows and buttons.
4
What is done first when finding an error in a program?
The error message is read from the end and the line it shows is checked.