PYTHON CHAPTER 5 (2022-2023)
Study Guide
Chapter 5
Part 1: Evaluate:
1. round(5) = 5
2. round(5.55) = 6
3. round(7.32) = 7
4. int(7.77) = 7
5. int(8.99) = 8
6. float(55) = 55.00
7. float(1000) = 1000.00
Part 2: Questions:
What is an integer division?
- returns the number of times a value is divided into evenly
What is a mod division?
- returns the remainder
Evaluate:
- 17//5 = 3
- 15%5 = 0
- 24//9 = 2
- 33%31 = 2
- 55%15 = 10
What is a random number and what is the syntax needed to import it.
- Random numbers allow us to generate values within a particular range.
- from random import randrange
True/False: Loops can be used with random numbers.
- True
What is the difference between round, int function, and float?
- Round allows numbers to be rounded to a certain number. Below .4 then rounds down. .5 or higher it rounds up.
- Int - Allows to cut off the decimal portion (#.##).
- Float is a command that changes an integer to a decimal value.
What is the syntax for round?
- round()
What is the syntax for int function?
- int()
What is the syntax for float?
float()
How do we round numbers in decimal places and what is the syntax?
Process rounds the value in x to y decimal places
r=round(x,y)
What is the import for the math class?
From math import*
There are many different types of methods for the math class. What is a brief example of the syntax for each one and what do each do. (Understand their meanings)
Here are some methods
y= sqrt(x)
returns square root
y=pow(a,b)
raises a to the b power
y=isnan(x)
returns true if x is not a number and false if it is
y=radians(x)
converts degrees to radians
y=degrees(x) converts radians to degrees
Trig functions
y=sin(x)
returns the sine if x is in radians
y=cos(x)
returns the cosine if x is in radians
y=tan(x)
returns the tangent if x is in radians
y=asin(x)
returns the inverse sine if x is in radians
y=acos(x)
returns the inverse cosine if x is in radians
y=atan(x)
returns the inverse tangent if x is in radians
y=pi
returns y with the value 3.141592653589793
Questions 13-15 No Answers Needed.
- Understand output from Chapter 5
- Understand Syntax
STUDY THE KAHOOT AS WELL IT WILL HELP!