INTERACTIVE ONLINE COURSE

Python 3

FOR BEGINNERS


"The first Python course that simply amazed me. Very well explained and easy to understand." (Alexandru Cosmin)

"The best Python course in Romania." (Iulian Geană)


ALL REVIEWS
LESSON 5
PAGE 4 / 4
Linear Structure
Home >>> Online Lessons, Python 3

Proposed Exercises

For a better understanding, solve the following tasks:

1. Carl Friedrich Gauss was a distinguished German mathematician known for his scientific achievements. Among them, he showed that the sum of the first n natural numbers can be calculated using the formula:



Task. Read a natural number n from the keyboard. Display the sum of the first n numbers.

2. Read two non-zero, different digits from the keyboard. Display the two numbers that can be formed with these digits.

3. Create a program that reads two non-zero natural numbers from the keyboard and displays their sum, difference, product, quotient, and remainder.

4. A German Shepherd ran n laps on a standard-sized tennis court: 23.77m x 8.23m. What distance did it cover?

Hint. Pay attention to the perimeter. Only the number of laps, denoted by n, is read from the keyboard.

5. Read a natural number consisting of exactly three digits. Display the number with all its digits decreased by 1.

Example. For the number 359, your code will display 248.

6. Read a natural number consisting of exactly two digits. Display the sum of the cubes of its digits.

Example. For the number 49, your code will display 43+93, which is 793.

7. Read two natural numbers into the variables x and y. Print the value of the expression: x2 + y2 - 23.

Good luck!
Editor - lesson5_exercises.py
       
Console / Output done
Congratulations!
You have completed the lesson.

 home   list  CONTENTS   perm_identity   arrow_upward