For example, there is a task to calculate the length of the hypotenuse of a right triangle from its legs. Launch a text editor and write the following text:
a = 179
b = 197
c = (a**2 + b**2)**0.5
print(c)
Here we use variables - objects in which you can store various (numeric, string, and other) values. In the first line, the variable a is assigned the value 179, then the variable bis assigned the value 971, then the variable cis assigned the value of the arithmetic expression equal to the length of the hypotenuse.
After this, the value of the variable c is displayed on the screen.
Save this text in a file named hypot.py.
Launch a terminal, go to the directory where this file is located and run this program:
$python3 hypot.py
The Python language interpreter, launched with a file name, does not start in interactive mode, but executes the sequence of commands that is stored in the file. In this case, the values of the calculated expressions are not displayed on the screen (unlike the interactive mode), so in order to display the result of the program, that is, the value of the variable, c we need a special function print.
Be up-to-date with our recent updates, new problems and answers!
Our goal at this course is to enhance our students’ mathematical intuition by focusing on a deep understanding of mathematical concepts and to enable them to link different concepts and apply their knowledge to solve mathematical problems to help them to improve their performance at Maths exams.
This course guides you through the fundamentals of Python programming using an interactive Python library known as Turtle.
This course encompasses a range of Geometry topics such as coordinate and spatial geometry, introductory trigonometry, angles, parallel lines, congruent and similar triangles, polygons, circles, the Pythagorean Theorem, and more. Emphasis will be placed on reinforcing Algebra skills and enhancing critical thinking through problem-solving in both mathematical and real-world contexts.