Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 1.4 KB

Week 1 - Day 1.md

File metadata and controls

57 lines (39 loc) · 1.4 KB

Numbers Arithmetic, and Printing to the Console

Basic Numbers

There is several different ways of representing numbers which is integers and floats.

Integer = 2

float = 3.14

The 'print' function

print is a builtin function that will output things to the console to see. We can use the print function multiple times if we want to, and values get printed out in the order of our print was called

Arithmetic Operators

If you want to add two numbers you use the addition symbol +. To subtract use the minus symbol -. To divide use the / symbol & to Multiply use thw * symbol. So when we write 3 + 2, Python evaluates that and we get an integer with the value 5

print(1 + 2)
print(3.4 + 11)
print(8 + 4.0)

We can also link together different operators: they don’t all have to be + or -, etc.

5 * 3 - 6 + 2 / 4

Day 1 Exercises

  1. Print your age, name, and year of birth to the console.
print(23)
print(Bria)
print(2000)
  1. Calculate and print the number of days, weeks, and months in 27 years. Don’t worry about leap years!
print(27 * 365)
print(27 * 52)
print(27 * 12)
# 9855 days, 1404 weeks, and 324 months.
  1. Calculate and print the area of a circle with a radius of 5 units. You can be as accurate as you like with the value of pi. ** can be used to square a number

    print(3.141 * 5 ** 2) # 78.525