Python Lesson 1
Step 1. Print command. Type below at python shell
Create folder called Python under your document folder.
File>Save as >
At python shell, reopen the [Link] python file.
Step 2. Commenting in python
Type # infront of any python code. Python will not run and # will be treated as
comment. Save as comment.
Step 3. Type as below. First line will give you error. Then use “” quote to clear the
error in print command.
Step 4. \ is considered escape. When you type \ python will ignore the character
infront of it. Try this code. Save as escape_character.
Try this code again.
Step 5. Multiple Lines
We use \n to make multiple lines. Save as multiple lines.
Step 6. Variables
reader is the name of variable.
“Adam” is the string value store in variable called reader.
When you use print command to print out variable, use variable name (Capital and
small letter matters), do not use “”.
Exercise. Store your name in variable called my_name.
Print my_name variable.
Step 7. Data type
type is the command to check the data type of variable. In this case
type(my_number) returs as int. Int stand for integer.
Exercise.
1. Create variable called my_school and store your school name in my_school
variable.
2. Create variable called pi and store the 3.14 in that variable.
3. Create variable called age and store your age in that variable.
2. Print out all 3 variables and check their data type with type command. Save as
data_type.
Step 8. Type this and save as Formatted_strings.
{snack} must be curly bracket
Exercise:
1. Create variable called mood , store “proud” in that variable.
Try to print out with print(f”-------------“)
The output should be “I am proud to be python programmer”
2. create variable called score, subject, feeling.
Use print(f” ---------------“) to make following output.
Try to make output “I score 100 in Maths and I am feeling happy”
Step 9. Easier Multiple Line Strings
Activity 1. Introduce yourself.
Create variable and Use print(f”---“)
Sample output
“Hi! My name is Alice”