Lesson 3 - Numbers
Numbers in Python
+ addition operator, e.g. 2 + 2 = 4- subtraction operator, e.g. 10 - 6 = 4* multiplication operator, e.g. 5 * 6 = 30/ division operator, e.g. 8 / 4 = 2% modulo operator, returns the remainder after dividing one number by another, e.g. 10 % 7 = 3// floor division, first number or number at the left is divided by the second number or number at the right and returns the quotient, e.g. 47 // 10 = 4
Some functions
int() used to convert a given value into an integer.abs() returns the absolute value of a numbermin() used to find the smallest itemmax() used to find the largest item
The
input() function in Python is a built-in function used to obtain user input from the console.
Odd or Even
num = 11
Last Digit Finder
num = 128
First Digit of a 2-digit Number
num = 93
Sum of Digits (2-digit)
num = 54
Average of Three Numbers
a, b, c = 4, 8, 12
Double Then Add
x = 7
Guess the Remainder
num = 25
Reverse a Two-Digit Number
num = 47
Smallest and Largest of Three Numbers
a, b, c = 12, 7, 19
Guess the Number (Math Puzzle)
secret = 15