Going through today's exercises in Python
The code in the below file is using VS Code's Python Interactive Mode (i.e. Jupyter cells) - please read this documentation if you don't know about them: https://code.visualstudio.com/docs/python/jupyter-support-py
Codebase: https://github.com/jacksorjacksor/bennyScript-exercises-in-python
Questions:
1. Write some code to print out all the numbers from 1 to 10
2. Write some code that prints out only the even numbers between 1 and 10
3. Write some code that prints out only the even numbers between 1 and 1000
4. The opposite of a number is the number itself with its sign reversed. For example, the opposite of 1 is -1. The opposite of -6 is 6. Write some code to accept a numerical input from a user and print out the opposite of that input.
5. Write some code that prints out the numbers between 1 and 1000, but if the number is divisible by 3 it prints ‘fizz’, if the number is divisible by 5 it prints ‘buzz’ and if the number is divisible by 3 and 5 it prints ‘fizzbuzz’
6. A square number is the product of a number multiplied by itself. Write some code that takes a numerical input from the user and prints out all the square numbers below that value.
7. The Fibonacci sequence starts with the values 1, 2. The next number in the sequence is generated by summing the previous 2 values, so the first 5 numbers in the sequence are:
1, 2, 3, 5, 8, …
a. Write some code to generate the first 100 values in the Fibonacci sequence
b. Write some code to add up only the even values in the first 1000 values of the Fibonacci sequence
8. The sum of digits of a number is found by adding all the digits of a number together. For example, the sum of digits of 234 is 2 + 3 + 4 = 9. Write some code to take a numerical input from a user and print out the sum of digits of that number.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Going through today's exercises in Python», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.