PYTHON DEVELOPER HOMEWORK

module №1 "Python Starter"

Lesson №1 "Introduction to Python"


Homework task №1 and №2

Install Python and PyCharm (or whatever Python-enabled IDE you are comfortable with). Explore customize your development environment: pick a color scheme and settings the editor font you like, enable or disable the display of line numbers, the current line, displaying separators between code sections, etc.

Homework task №3

Create a new project in the PyCharm IDE. Create a file source code and write a program that prints out your name. Start it up. Create the second file with the code and write a program that asks the user for his name, and greets him. Start it up. Switch to the first script and run it. switch back to the second script.

Homework additional task

Write a program where the user can select a calculator, necessary necessary numbers and get the result. Operations to be implemented: addition, subtraction, multiplication, division, exponentiation of a number


Lesson №2 "Variables and data types"

Homework task №1

Write a program that asks the user for two words and outputs them separated by commas.

Homework task №2

Write a program that asks for three integers a, b, and x and prints True if x is between a and b, or False otherwise.

Homework task №3

Write a program that solves the quadratic equation 𝑎𝑥2 + 𝑏𝑥 + 𝑐 = 0 using the formulas 𝑥1,2 = −𝑏 ± √𝑏2−4𝑎𝑐2𝑎. The values a, b and c are entered from the keyboard. To extract the root, use the exponentiation operator rather than the math.sqrt function to get complex numbers when the radical expression is negative.

Homework additional task

Write a program that asks the user for the radius of a circle and displays its area. The formula for the area of a circle is S = 𝜋𝑟2.


Lesson №3 "Conditional statements"

Homework task №1

Write a program that asks the user for his name, and if it matches yours, it displays a specific message.

Homework task №2

Write a program that calculates the value of a function.

Homework task №3

Write a program that solves the quadratic equation 𝑎𝑥2 + 𝑏𝑥 + 𝑐 = 0 in real numbers. Unlike a similar exercise from the previous lesson, the program should display a message about the absence of real roots, if the value of the discriminant 𝐷 = 𝑏2−4𝑎𝑐 is negative, the only solution is 𝑥 = −𝑏2𝑎, if it is zero, or two roots 𝑥1,2 = −𝑏 ± √𝐷2𝑎 if it is positive.

Homework additional task

Write a program that checks if a number is even or odd, and positive or negative.


Lesson №4 "Loop statements"

Homework task №1

Given numbers a and b (a <b). Print the sum of all natural numbers from a to b (inclusive).

Homework task №2

The factorial of the number n is the number 𝑛! = 1 ∙ 2 ∙ 3 ∙… ∙ 𝑛. Create a program that calculates the factorial of a user-entered number.

Homework task №3

Using nested loops and the functions print (‘*’, end = ’’), print (‘’, end = ’’) and print () print the right triangle.

Homework additional task

Create a program that draws a rectangle of stars with a user-specified width and height on the screen.


Lesson №5 "Functions 1"

Homework task №1

Create a function that displays a greeting for the user with the given name. If no name is specified, it should display a greeting for the user with your name.

Homework task №2

Create two functions that calculate the values of certain algebraic expressions. Display a table of the values of these functions from -5 to 5 in increments of 0.5.

Homework task №3

Create a calculator program that supports four operations: addition, subtraction, multiplication, division. All data must be entered in a loop until the user indicates that he wants to terminate the execution of the program. Each operation must be implemented as a separate function. The division function should check the data for correctness and issue an error message if it tries to divide by zero.

Homework additional task

Create a program that consists of a function that takes three numbers and returns their arithmetic mean, and a main loop that asks the user for a number and calculates their average using the function you just created.


Lesson №6 "Functions 2"

Homework task №2

Create a program that checks if the entered phrase is a palindrome.

Homework task №3

Suppose you can stand on each rung of the ladder with the previous one or by stepping over one. Determine how many ways you can climb a given step.

Homework additional task

Write a recursive function that calculates the sum of natural numbers that fall within a given range.


Lesson №7 "Lists"

Homework task №1

Create a list and enter its values. Find the largest and smallest element in the list, as well as the sum and the arithmetic mean of its values.

Homework task №2

Assignment 2 Rewrite the solution to the last problem from the sixth lesson so that it does not use recursion and does not calculate all intermediate numbers of paths many times (which is extremely inefficient), but stores them in a list.

Homework task №3

A prime is a number that is divisible only by one and itself. The number 1 is not considered simple. Write a program that finds all prime numbers in a given range, displays them on the screen, and then displays their sum or product at the user's request.

Homework additional task

Create a list, enter the number of its elements and the values themselves, print these values to the screen in reverse order.


Lesson №8 "PEP8"

Homework

Edit the code according to PEP8.