Module 1_ Hello World
Module 1_ Hello World
Foundation
Overview 3
Learning Objectives 3
Requirements 3
Sessions 4
Session 1: An introduction to programming and Python 4
Session 2: Number, Variables, and Data Types 4
Break Time 11
Summary 23
Next Steps 24
1
Module 1: Hello World
Overview
Welcome to the first Module where you will start writing Python code maybe for the
first time in your lives, Here we will learn about what programming languages are,
why we need them, and also why we are learning Python.
Duration:- 2 hrs.
Learning Objectives
After completing this module you will be able to:
Requirements
● You must complete module 0: introduction before working on the activities we
have put here.
2
Sessions
Session 1: An introduction to programming and Python
Duration: 50 mins.
● Activity 1: Reading
○ What is programming?
○ Why learn Python Programming?
● Activity 2: Your first program, “Hello World”
● Activity 3: Comments
Duration: 50 mins.
Session 1: An introduction to
programming and Python
Activity 1: Reading
During the next 5 days, you will be creating computer programs using Python, but
before you do you must understand what programming is and why we are learning
Python.
Duration: 15 mins.
Goal: To understand computer programming and the reason why one should learn
Python.
3
Instructions: Read Topic 1 and Topic 2 found below.
Computer programs are incredibly powerful tools that can be used in a variety of
ways. They can store and process large amounts of data quickly and accurately,
perform complex calculations, and create and modify documents. This makes them
invaluable tools in today's world.
Computer programs can also be programmed to do tasks that would ordinarily take a
human much longer to complete. For example, a computer program can be
programmed to automatically sort through hundreds of emails and organize them
into categories. This can save a great deal of time and effort, as well as reduce the
risk of human error.
In simple words, a computer program is like a recipe for a delicious meal. Just like a
recipe a computer program is a set of instructions that tell a computer what to do.
The instructions are written in a language that the computer can understand, like a
set of instructions written in English. The instructions tell the computer what to do
step-by-step, just like a recipe tells a cook what to do step-by-step. The instructions
can be as simple as telling the computer to print out a message, or as complex as
telling the computer to create a game. The instructions can also be used to create
websites, apps, and other software. Just like a recipe, the instructions need to be
written in the right order and with the right structure for the computer to understand
them. Once the instructions are written, the computer can follow them and do what it
is told.
Computer programming is the act of writing the step-by-step instructions that make
up a computer program and to write computer programs we use programming
languages, Although many languages share similarities, each has its syntax. Syntax
4
in a programming language can be compared to grammar in the English language.
Just as grammar is the set of rules that govern how words are used to form
sentences, Syntax is the set of rules that govern how programming language
instructions are written. Once a programmer learns the language's rules, syntax, and
structure, they write the source code in a text editor. Then, the programmer often
translates the code into machine language that can be understood by the computer
using a program called a compiler or an interpreter.
During the next 5 days, you will be learning a programming language called Python
which is easy to learn and can be used to write all sorts of computer programs. you
can use Python to build games, online tools, and websites. Python looks like a
mixture of recognizable words and characters, so it can be easily read and
understood by humans.
2. Python Is Versatile
Part of this acclaim is due to Python’s usefulness in the world of data science; as
fields like machine learning, data modeling, and AI grow, so too does the demand for
Python-related skills. You can use Python for both small and complex tasks, and it is
used across many different industries from data science and software engineering to
5
environments like mobile app development, artificial intelligence, and machine
learning.
Many major companies including DropBox, Netflix, and Facebook use Python.
According to Indeed, Python developers earn an average salary of $108,391,
Statista also named Python the third most in-demand language by recruiters in 2022.
Exercise
The journey of a thousand miles begins with the first step, well in our case creating a
computer program with thousands of lines of code starts with writing the first line so
get ready for some hands-on Python practice don’t worry if things get a little
confusing this is your first program after all.
Duration: 15 mins.
Goal: To create and run your first Python program using Jupyter notebook.
Instructions:
6
Reminder: Do not copy-paste code.
● Step 4: Once finished, run your code and check if you have errors.
○ In case of an error compare the code you have with the code that is
provided to you or Google the error code displayed by Jupyter and try
to find a solution.
● If you need more help check out the video titled ex1 found along with this
document in google classroom.
Note:
○ Point 1: The atom text editor used in the video corresponds to your
Jupyter notebook.
○ Point 2: Use Jupyter to run and test your code.
Notes:
The print() function in Python is used to display a specified message on the screen.
Study Drill:
The Study Drills contain things you must do before moving on to the next section. If
at any point you find yourself getting stuck revise your code and also try to use
google to your advantage.
7
For this exercise, try these things:
Activity 3: Comments
Duration: 20 mins.
Comments in Python are lines of text that are not run as part of the program. They
are used to explain what the code is doing and to make the code easier to read and
understand.
Comments are useful when you are writing code that is complex or that you may
need to refer back to later. They can help you remember what the code is doing and
make it easier to debug if something goes wrong.
8
Comments can also be used to disable a line of code temporarily. This is useful if
you want to test something without running the entire program. For example, if you
wanted to test a certain line of code without running the rest of the program, you
could add a comment like this:
Instructions:
Note:
○ Point 1: The atom text editor used in the video corresponds to your
Jupyter notebook.
○ Point 2: Use Jupyter to run and test your code.
Study Drills:
● Find out if you were right about what the # character does and make sure you
know what it's called (octothorpe or pound character).
● Take your ex2.py file and review each line going backward. Start at the last
line, and check each word in reverse against what you should have typed.
● Did you find more mistakes? Fix them.
● Please read what you typed above out loud, including saying each character
by its name. Did you find more mistakes? Fix them.
● Once you have finished the study drill submit the file you have worked on to
the respective assignment title in google classroom.
9
Common student questions:
The # in that code is inside a string used to store text information. Strings are
surrounded by either single quotation marks or double quotation marks. , so the #
will be put into the string until the ending " character is hit. Pound characters in a
string are just considered characters, not comments.
Some countries use the Alt key and combinations of other keys to print
characters foreign to their language. You'll have to look online in a search
engine to see how to type it.
It's a trick to make your brain not attach meaning to each part of the code, and
doing that makes you process each piece exactly. This catches errors and is a
handy error-checking technique.
Break Time
Take a 10-minute break and come back for session two.
10
Session 2: Numbers, Variables, and Data
Types
Activity 1: Numbers and Maths
Duration: 15 mins.
Goal: To create a program that uses the above math symbols for calculations
11
Math symbol Name Description Example
(Operator)
The symbols found in the above table are also known as operators, Python has
different kinds of operators that it uses to perform various tasks. you will learn about
them more as you progress through this course.
Instructions:
12
● Step 4: Run and evaluate your code.
Note:
○ Analyze your code line by line and say what it does in your head, This
will help you understand the code better.
■ For example, you could say: “Line 1 displays a text that reads I
13
● If you need more help check out the video titled ex3 found along with this
document in google classroom.
Note:
○ Point 1: The atom text editor used in the video corresponds to your
Jupyter notebook.
○ Point 2: Use Jupyter to run and test your code.
Study Drills:
1. write a comment using the # symbol above each line of code explaining what
it does.
Note:
Note: If you don’t know the age of your parents simply try to guess.
3. In your google search bar type “Arithmetic operators in Python“ and try to
learn what they are, afterwards check which Math Symbols/operators belong
to this category. (This task will not be submitted but you must take notes for
yourself).
4. Once you have finished the study drill submit the Jupyter file you have worked
on to the respective assignment title in google classroom.
14
Common Student Questions
Mostly that's just how the designers chose to use that symbol. In normal writing, you
are correct to read it as a "percent." In programming, this calculation is typically done
with simple division and the / operator. The % modulus is a different operation that
just happens to use the % symbol.
Another way to say it is, "X divided by Y with J remaining." For example, "100 divided
by 16 with 4 remaining." The result of % is the J part or the remaining part.
Duration: 10 mins.
Goal: To create and run a Python program that contains variables on Jupyter
notebook.
Variables are like little containers that hold information. Think of them like a box
where you can put things inside. For example, if you wanted to remember a person's
age, you could put that age inside a variable called "age", and then you can always
look inside the box to see what age is stored inside. Variables are very useful for
15
computer programs because they help keep track of lots of different pieces of
information.
Creating variables:
Python has no command for declaring a variable. A variable is created the moment
you first assign a value to it but Python still has specific rules as to how you can
name variables which are as follows:
16
A few things about the code above:
Instructions:
Study Drills:
1. Inside ex4 write a comment above each line that explains what it does. For
Example, your comment above line 1 should read.
2. Inside ex4 create a variable called age that stores your age.
3. Inside ex4 create a variable called age that stores your age.
4. Once you have finished the study drill submit the file you have worked on to
the respective assignment title in google classroom.
17
Common Student Questions
You can, but it's bad form. You should add space around operators like this so
that it's easier to read.
Very simple. Imagine you have a file with 16 lines of code in it. Start at line 16,
and compare it to my file at line 16. Then do it again for 15, and so on until
you've read the whole file backward.
18
Activity 3: Python Data Types
Duration: 20 mins.
Goal: To create a Python program that contains variables of number, text, and
Boolean Data Types
In a computer program, you will be working with different types of data such as
numbers, text, and so on. we call these Data types which are different kinds of
containers that can hold different types of information. For example, a string is like a
box that can hold words, and a number is like a box that holds numbers. When we
write a program, it helps to know what kind of information we will be using so that our
program can work correctly. When you tell someone your name, your age, or what
you had for breakfast, each of those pieces of information is a different data type.
Variables can store data of different types, and different types can do different things.
Python has the following data types built-in by default, in these categories:
Python also has more complex Data Types, but for now, knowing the ones
mentioned above is enough.
19
Note: In Python, the data type is set when you assign a value to a variable, Here is a
code containing the different data types:
Instructions:
20
Study Drills: These drills are to be performed on the ex5 file you just created.
1. Go to line 9 and use the print method to display the rest personal information.
Note:
2. For the following two tasks refer to line 11 to see the type of comment you
should add.
1. Add a comment on line 17 that explains what the code on line 18 does.
2. Add a comment on line 20 that explains what the code on line 21 does.
3. To the ex5 file add a variable called my_friend_name and assign it the name
of your friend, After that display the name of your friend as an output.
4. Create a variable named my_friend_age and assign it the age of your friend,
use the print statement to display the sum of my_age and my_friend_age
Note:
5. Google what “concatenating a string means” and try to explain it in your own
words using a flash card. ( you don’t need to submit this task).
6. Have you figured out what the type() method does? if not make sure you
check online what it does before moving on to the next activity.
7. Once you have finished the study drill submit the file you have worked on
under the respective assignment title in google classroom.
21
Common student questions
● What is concatenation?
String concatenation is a fun way to join two strings together. It's like putting
two pieces of a puzzle together! You can take two strings and put them
together to make one longer and bigger string. For example, if you have two
strings that say "hello" and "world", you can concatenate them together to
make a new string that says "hello world". Concatenation is performed using
either a comma ( , ) or a plus (+) symbol.
● Why do you put (single quotes) around some strings and double quotes
on others?
Mostly it's because of style, strings can be created using either single quotes
or double quotes.
Summary
Well Done! You have made it to the end of the module, here is what we have done
so far:
22
Next Steps
1. Fill in the TypeForm https://96q5m6wcmma.typeform.com/to/WJA2BHqG
2. Go to google classroom and download the Module titled Module 2:
23