Unit 1

Lesson 1: Arithmetics


Data Types:

Integers (int): whole numbers

Floating point (float): have decimals stuff

String (str): words or labels

Boolean: true or false

Declaring

  • Integers: a = 4

  • String: b = ‘Word’


Type casting input a dynamic variable

num1 = input(“Enter a number: “) ← string

num1 = int(input(“Enter a number: “) ← integer



Commands

type(variableName)

  • shows you what data type the variable is

print(‘What you want to print’)


Arithmetic Syntax

Division: 2 // gives you floor division, / is floating point

quot = num2 // num1 —> returns as integer

quot2 = num2 / num1


Find the remainder or modulus:

remainder = num1 % num2

  • when you divide 17 / 7 you get 2 with remainder 3

  • 2 × 7 = 14 + 3 ←- 3 is the modulus


Exponent:

num1 ** 2 —> squared