The repository contains a boilerplate code for programs that do some sort of a unit conversion or mathematical calculations.
For each program there are tests being executed on the push and pull request to the repository. The tests for a correct program must pass.
-
Use only
float64variables in all programs. -
Use the following functions:
The workflow to complete and submit the assignment is the following:
- In the top-right corner of the page, click Fork
-
The repository will be "copied" to your GitHub account.
-
Complete the assignment by commiting your changes to your GitHub repository. Make sure that the tests in Actions tab of the repository pass successfully.
-
Once done, create a Pull request to the original prog-1/unit-conversions repository.
- Select Pull requests tab in your repository.
- Click New pull request.
- Click Create pull request.
Directory rectangle.
The program must print the perimeter and the square of a rectangle given the rectangle (non-opposite) sides.
Example:
The program prints the perimeter and the square of a rectangle given the rectangle sides.
Enter the length and the breadth of the rectangle:
4 5.5
Perimeter: 19
Square: 22
Directory circle.
The programm must print the perimeter and the square of a circle given the circle radius.
Example:
The program prints the perimeter and the square of a circle given the radius.
Enter the radius:
8
Perimeter: 50.26548245743669
Square: 201.06192982974676
You will need to use math.Pi constant to represent π value.
Directory speed.
The program must convert the speed in km/h to the speed in m/s.
Example:
The program converts km/h to m/s.
Enter the speed in km/h:
100
The speed in m/s: 27.77777777777778
Directory temperature.
The program must convert Celsius degrees to Fahrenheit degrees. Finding a conversion formula is part of the exercise.
Example:
The program converts temperature from Celsius to Fahrenheit.
Enter the temperature in Celsius:
100
The temperature in Fahrenheit: 212
Directory quadratic.
Given coefficients A, B, and C of a quadratic equation Ax^2 + Bx + C = 0, write a program that prints the equation solutions x1 and x2.
You will need to use math.Sqrt function to calculate a square root.
Example:
The program finds solutions of a quadratic equation.
Enter the coefficients A, B and C:
1 3 -10
x1 = 2
x2 = -5
Directory maxmin.
Write 4 programs (each in a separate subdirectory):
-
(
maxmin/max2) a program that calculates the maximum of two numbers. You can use the following formula:max(a, b) = (a + b + |a - b|)/2. You will need to use math.Abs function to calculate an absolute value. Example:The program finds the maximum of two numbers max(a, b). Enter two numbers: 5 7 max: 7 -
(
maxmin/min2) a program that calculates the minimum of two numbersmin(a, b), -
(
maxmin/max3) a program that calculates the maximum of three numbersmax(a, b, c), -
(
maxmin/min3) a program that calculates the minimum of three numbersmin(a, b, c),
Directory resistance.
Write a program that calculates the resistance R of two resistors with the
resistance R1 and R2 assuming that
- the resistors
R1andR2are connected in series, i.e.R = R1 + R2; - the resistors are connected in parallel, i.e.
1 / R = 1 / R1 + 1 / R2.
Example:
The program calculates the resistance R of two resistors.
Enter the resistance of two resistors:
4 8
Resistance when connected in series is 12; resistance when connected in parallel is 2.6666666666666665.
