For loop with range - Learn Python 3 - Snakify

Lesson 4.For loop with range

Problem «Series - 1» (Easy)


Given two integers A and B (A ≤ B). Print all numbers from A to B inclusively.

Problem «Series - 2» (Easy)


Given two integers A and B. Print all numbers from A to B inclusively, in increasing order, if A < B, or in decreasing order, if A ≥ B.

Problem «Sum of ten numbers» (Easy)


10 numbers are given in the input. Read them and print their sum. Use as few variables as you can.

Problem «Sum of N numbers» (Medium)


N numbers are given in the input. Read them and print their sum.

The first line of input contains the integer N, which is the number of integers to follow. Each of the next N lines contains one integer. Print the sum of these N integers.

Problem «Sum of cubes» (Easy)


For the given integer N calculate the following sum: $$ 1^3 + 2^3 + \ldots + N^3 $$

Problem «Factorial» (Easy)


In mathematics, the factorial of an integer \(n\), denoted by \(n!\) is the following product: $$n! = 1 \times 2 \times \ldots \times n$$

For the given integer \(n\) calculate the value \(n!\). Don't use math module in this exercise.

Problem «The number of zeros» (Medium)


Given N numbers: the first number in the input is N, after that N integers are given. Count the number of zeros among the given integers and print it.

You need to count the number of numbers that are equal to zero, not the number of zero digits.

Problem «Adding factorials» (Medium)


Given an integer \(n\), print the sum \(1!+2!+3!+...+n!\).

This problem has a solution with only one loop, so try to discover it. And don't use the math library :)

Problem «Lost card» (Hard)


There was a set of cards with numbers from 1 to N. One of the card is now lost. Determine the number on that lost card given the numbers for the remaining cards.

Given a number N, followed by N − 1 integers - representing the numbers on the remaining cards (distinct integers in the range from 1 to N). Find and print the number on the lost card.

Problem «Ladder» (Medium)


For given integer n ≤ 9 print a ladder of n steps. The k-th step consists of the integers from 1 to k without spaces between them.

To do that, you can use the sep and end arguments for the function print().