Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: Programming Practice-Problem Questions and Detailed Solutions - Volume 2 (Mathematical Equations and Formulae Exercises)
Description: The document consists of Python programming problems and exercises as well as the detailed solution and explanation for each practice question.

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


PROGRAMMING PRACTICE-PROBLEM QUESTIONS AND
DETAILED SOLUTIONS – VOLUME 2
MATHEMATICAL EQUATIONS AND FORMULAE EXERCISES

1

Contents
1

Problem to Determine the Area and Circumference of a Circle
...
1

Program
...
2

Output
...
3

2
...
3

2
...
4

3

Problem to Compute the Sum of Interior Angles of a Regular Polygon
...
1

Program
...
2

Output
...
4

4
...
4

4
...
5

5

Problem to Compute the Quadratic Equation
...
1

Program
...
2

Output
...
Your
program should then use the radius to calculate the area and circumference of the circle
...
1 Program
import math
#The math class needs to be imported as done above so as to use the function pi later
radius = float(input("Please provide the radius of the circle:\n"))
#float is a keyword for specifying that a data type of decimal can be allowed
area = math
...
pi*radius
print("The area of the circle is " + str(area) + " square units")
print("The circumference of the circle is " + str(circumference) + " units")

1
...
5
The area of the circle is 38
...
991148575128552 units

2

Problem to Calculate the Volume of a Cone
Make a computer program through which one can provide the radius and the height of the
cone and the program will determine the volume of the cone
...
1 Program
import math
radius = float(input("What is the cone's radius?\n"))
height = float(input("What is its height?\n"))
volume = (1/3)*(math
...
2 Output
What is the cone's radius?
3
...
06312046977213 cubic units

3

Problem to Compute the Sum of Interior Angles of a Regular Polygon
Create a computer program with an interactive capability to ask the user of the number of
sides in a regular polygon, and thereafter the program will calculate the sum of the interior
angles
...
1 Program
sides_number = int(input("What is the number of sides of the polygon?\n"))
#int is a keyword specifying that only a data type of integer (whole number) is allowed
sum_of_angles = (sides_number-2)*180
print("The sum of interior angles is " + str(sum_of_angles) + " degrees")\n"))

3
...
The problem is for you to develop a dynamic program that can calculate the
any of the trio when you are given the other two sides
...
1 Program
#1
...
sqrt(opp**2 + adj**2)

4

print("The hypotenuse side has a length of " + str(hyp) + " units")

#2
...
sqrt(hyp**2 - adj**2)
print("The opposite side has a length of " + str(opp) + " units")

#3
...
sqrt(hyp**2 + opp**2)
print("The adjacent side has a length of " + str(adj) + " units")

4
...
22
What is the length of the adjacent side?
5
...
295752536432797 units
What is the length of the hypotenuse side?
7
...
33
The opposite side has a length of 6
...
33
What is the length of the adjacent side?
2
...
663330768243817 units

5

5

Problem to Compute the Quadratic Equation
The quadratic equation is a mathematical expression that results to more than one solution
...
You are to create a computer program that
will solve for the two quadratic roots
...
1 Program
import math
a = float(input("What is the value of a?\n"))
b = float(input("What is the value of b?\n"))
c = float(input("What is the value of c?\n"))
first_root = (-b + math
...
sqrt(b**2 - 4*a*c))/2*a
print("The roots are " + str(first_root) + " and " + str(second_root))

5
...
0

of a?
of b?
of c?
and -4
Title: Programming Practice-Problem Questions and Detailed Solutions - Volume 2 (Mathematical Equations and Formulae Exercises)
Description: The document consists of Python programming problems and exercises as well as the detailed solution and explanation for each practice question.