# Lesson 1 - Intro to Python¶

This lesson will lead you through the basics of Python syntax and hotkeys for Jupyter.

## Declaring and Assigning values¶

Type print("Hello World") and press <Shift + Enter>

Values are a form of representation or description.

For example, a person's name is

The number of days I have to go school is

Commenting is a form of notation. Python ignores everything after the hashtag #

### Numbers¶

Numbers are categorised into 2 types

• Integers (Whole numbers)
• Floats (Decimal numbers)

Find out which type they are by using the function type()

### Strings¶

Strings refer to texts and are defined with quotation marks " ".

Is "6" a string or an integer? Find out with type() function!

### Recap¶

Find out whether the following are integers, floats or string

1. 3.1415
2. 9
3. "12309"
4. "Hi, what is your name?"
5. 3 + 19

## Variables¶

Variables are storage for your values. Imagine having a box and putting an apple inside.

Now try accessing the box to see what is inside by typing box and pressing <Shift + Enter>

What happens if you accessed a random_box?

Can you figure out why?

##### Rules for variable names¶
• Does not contain spaces (use _ to substitute)
• Must not be a function name e.g if, else, def, for

Try creating some variables that stores value!

• box_1
• box 1
• box1
• 1stbox
• Box_1

### Exercise 1¶

Store the following numbers in variables and obtain the total

• 51 --> first_num
• 48 --> second_num
• 23 --> third_num
• 93 --> fourth_num

total = ?

You realised you made a mistake in the third number. It was supposed to be 85 instead of 23. Find the new total.

After finding the new total, you wanted to compare what was the difference between the wrong answer.

#### Put on your thinking Cap¶

1. Why is there a need to use variables?

2. Why not type out the answers directly?

Type your answers in comments #

### Converters / Casting¶

Did the above give you the correct answer? What can you do to get the correct answer?

Hint Try using the functions int(), float(), str()

### Exercise 2¶

You are given the following variables. You want to see the difference between the + function in string and in int/floats.
Fix the variable names before finding the answer.

### Review¶

• Integers
• Floats
• Strings
• Type()
• Variables
• Values
• Converters/Casting