Week 1 - Hello Python! (Introduction to Programming and Python)
Table of Contents:
A) Specialization Introduction (🎦 folder 1)
-
Working in IT is a career path.
-
The field of IT support is a launchpad for future career growth and better wages
-
Those who push themselves to learn how to code in Python typically saw stronger career growth.
-
They built skills that are critical to accessing higher level positions in the IT field.
-
They became:
- IT support specialists
- System administrators
- Technical Solutions Engineers
- Site Reliability Engineers
-
The common thread across all of these roles is knowing how to write code to solve problems and automate solutions.
-
This program offers 3 hands-on methods of teaching coding, Python and automation:
-
Code blocks
-
Jupyter notebooks
-
Qwiklabs
A.1) Specialization Content
- The program begins with,
-
A crash course in Python where you will learn to write simple programs and understand their role in automation.
-
Next, we will learn on how Python interacts with the operating system
-
After that, we'll cover how to use Git and GitHub to manage versions of your code
-
Next, we will focus on troubleshooting and debugging techniques to find and solve the root cause of problems in IT infrastructure.
-
The next course covers automating at scale where you will learn to deploy configuration management on a fleet of either physical or virtual machines running in the Cloud.
-
Last up, we will bring all this knowledge together and complete a final project designed to solve tasks you might encounter in real-world IT settings.
Bonus, you can post your projects to GitHub to show off your fancy new skills.
Finishing IT Support Professional Certificate 101 first is recommended
B) Course Introduction
-
Being able to write scripts and programs that tell your computer to perform a task equips you with an invaluable tool. Not only does it make your work easier and more efficient, it can help you grow faster and advance further in your IT career.
-
The role of a sysadmin can vary a lot from company to company and even within different teams in the same company.
"I, Christine Rafla, happen to work in the corporate identity and access management operations team. Which is a long way of saying that we make sure that everyone is represented correctly and if they need to access certain resources, they can"
-
Having coding skills can help you grow into more specialized roles like:
- Systems Administrator
- Cloud Solutions Engineer
- Dev Ops specialist
- Site Reliability Engineer
- Web developer
- Data Analyst
-
Getting good at something new requires a lot of practice
-
We will start slow with Python, master the foundations and then move to the more challenging stuff
B.1) Course Objectives
By the end of this course you will:
- understand the benefits of programming in IT roles
- be able to write simple programs in Python
- figure out how the building blocks of programming fit together
- combine all this knowledge to solve a complex programming problem
B.2) Python Information Resources
Finding out more information:
· The Official Python Tutorial: https://docs.python.org/3/tutorial/index.html
· The Think Python Book: https://greenteapress.com/wp/think-python/
· the Official language reference: https://docs.python.org/3/reference/index.html
_____________________________________________________________
C) Introduction to Programming (🎦 folder 2)
C.1) What is programming?
At a basic level, a "[[computer program]]"is a recipe of instructions that tells your computer what to do.
The recipe is written in a code called "[[programming language]]".
[[Programming languages]] are similar to human spoken languages since they have a syntax and semantics.
C.1.1) Syntax and Semantics (in Human Spoken Language)
In Human Spoken Languages:
-
Syntax: is the rules for how a sentence is constructed
-
Semantics: is the actual meaning of the statement.
To form a sentence that others can understand, you need to know both:
- the syntax that constructs the sentence
- and the semantics that gives it meaning.
For example:
The same applies to programming languages.
C.1.2) Syntax and Semantics (in Python)
In a Programming Language (like Python):
- Syntax: is the rules for how each instruction is written.
- Assignment statements is
Variable := Expression
- Expression is a Variable or a Number
- ✅ CORRECT is
price := 12,99
- ❌ INCORRECT is
price = A
- ✅ CORRECT is
- Semantics: is the effect the instructions have. What does the code mean?
price := 12,99
Means:
- Assign/Copy the value
12.99
to the variableprice
- Set the value of variable
price
to12.99
C.2) Variety in Programming Languages
Much like spoken languages, there are LOTS of programming languages to choose from.
Each has its own history, features and applications but they all share the same fundamental ideas.
So once you learn the basic concepts in one programming language, it becomes much easier to learn another.
Lastly, computers ALWAYS DO EXACTLY WHAT THEY ARE TOLD.
So, when you write a program, it is important to be SUPER CLEAR with the instructions.
Thus the importance of learning the syntax & semantics of the programming language you are using.
C.3) Note: Terminology to remember
Some TERMINOLOGY...
- What is the difference between a "[[script]]" and a "[[program]]"?
Ans: Sometimes they are used interchangeably, but in general...
[[Scripts]] are programs with a short development cycle that can be created and deployed rapidy.
In this course we will focus on a specific [[scripting language]] called [[Python]],
which we will use to learn the basics of programming.
Before we start learning how to code and writing our first python script, let's talk about why "[[automation]]" is useful.
D) What is automation?
[[Automation]] is the process of replacing a manual step with one that happens automatically.
For example: A traffic light that continuously regulates the flow of vehicles at an intersection.
It requires human intervention only when it needs repair or maintance.
The automatic regulation of traffic means that humans don't have to stand at the intersection manually signaling when cars should stop or go.
Instead, people can concentrate on more complex tasks.
What's more, traffic light DO NOT GET TIRED, BORED, or CAUSE AN ACCIDENT.
The benefit of automation is "consistency".
Humans are flawed, we make mistakes, we are not as consistent as a machine with repetitive tasks.
But automation is not a solution for every situation....
Some tasks just aren't suited for automation...
For example: Getting a haircut
It is a task that requires a degree of creativity and flexibility that automatic system CAN'T provide.
Also, the task is so complicated that creating the automation is more effort or cost than it's worth.
Automation is a powerful tool when used in the right place at the right moment.
[[Automation]] can:
- save time
- reduce errors
- increase consistency
- provide centralized solutions and mistakes (making them easier to fix).
Throughout this course, we'll talk about when it makes sense to apply automation and exactly how to do it.
D.1) Getting Computers to work for you (IT Examples)
Working in IT, a lot of what we do boils down to using computers to perform a certain task.
In your job you might:
- create user accounts,
- configure the networks, .
- install software,
- backup existing data,
- or execute a whole range of computer based tasks from day to day.
For example:
You could create a script that automatically types the authentication commands every day for you to work.
Tasks performed by computers that need to be done multiple times with little variation are really well suited for automation, because when you automate a task you avoid the possibility of human errors, and reduce the time it takes to do it.
For example:
You could also automate the task of sending emails. The computer will help you avoid sending the same email to the same person twice and personalize the email automatically.
Automating tasks allows you to focus on projects that are a better use of your time, letting computers do the boring stuff for you.
Learning how to program is the first step to being able to do this.
Example:
The following task are good candidates for automation:
- Periodically scanning the disk usage of a group of file servers.
- Installing software on laptops given to new employees when they are hired
More complex task can also be automated.
For example: You could make a [[script]] that changes a bunch of access permissions for a whole lot of internal services of a company.
The script can:
- reverse a large directory tree with tons of different files,
- check the contents,
- and then update the permissions to services based on the conditions laid out in the script.
E) 💬 Practice Quiz: Introduction to Programming
-
What's a [[computer program]]?
- A set of languages available in the computer
- A process for getting duplicate values removed from a list
- A list of instructions that the computer has to follow to reach a goal (Correct Answer)
- A file that gets copied to all machines in the network
-
What's the syntax of a language?
- The rules of how to express things in that language (Correct Answer)
- The subject of a sentence
- The difference between one language and another
- The meaning of the words
-
What's the difference between a [[program]] and a [[script]]?
- There's not much difference, but scripts are usually simpler and shorter. (Correct Answer)
- Scripts are only written in Python.
- Scripts can only be used for simple tasks.
- Programs are written by software engineers; scripts are written by system administrators.
-
Which of these scenarios are good candidates for automation? Select all that apply.
- Generating a sales report, split by region and product type (Correct Answer)
- Creating your own startup company
- Helping a user who's having network troubles
- Copying a file to all computers in a company (Correct Answer)
- Interviewing a candidate for a job
- Sending personalized emails to subscribers of your website (Correct Answer)
- Investigating the root cause of a machine failing to boot
-
What are semantics when applied to programming code and pseudocode?
- The rules for how a programming instruction is written
- The difference in number values in one instance of a script compared to another
- The effect the programming instructions have (Correct Answer)
- The end result of a programming instruction
____________________________________________________________
F) Introduction to Python (🎦 folder 3)
F.1) Why learn Python? (Documentation and Online Interpreters)
Welcome! In this course, we’ll use the Python programming language to introduce basic programming concepts and explore how to write scripts.
So, why [[Python]]? We chose [[Python]] for its simplicity and readability—its [[syntax]] is close to human language, making it easier to understand and write.
Lee la documentación oficial de Python.
For example, in Python, you can create a list of friend names and generate a greeting for each. Even if you’re new to programming, you might guess what this code does.
Don’t worry if it seems complex right now; we’ll cover each part in detail later.
Throughout the course, you’ll run Python code starting with simple exercises.
As you progress, you’ll work on more complex tasks using additional tools.
Practice is essential to mastering programming, and Python is no exception.
We recommend practicing each example we introduce and trying variations on your own.
F.1.1) Python Interpreter (Online Options)
If you don’t have Python installed on your computer, that’s okay; you can use an online [[Python interpreter]], a continuación encontrarás enlaces a algunos de los intérpretes y codepads en línea más populares. Pruébalos y encuentra tu favorito.
- https://www.python.org/shell/
- https://www.onlinegdb.com/online_python_interpreter
- https://repl.it/languages/python3
- https://www.tutorialspoint.com/execute_python3_online.php
- https://rextester.com/l/python3_online_compiler
- https://trinket.io/python3
Note: Puedes practicar usando uno de los muchos intérpretes de Python o codepads disponibles en línea. No hay mucha diferencia entre un intérprete y un codepad. Un intérprete es más interactivo que un codepad, pero ambos te permiten ejecutar código y ver los resultados.
Now, you might wonder, what exactly is a [[Python interpreter]]?
An interpreter is a program that reads and executes code, much like a chef following a recipe.
When your instructions (or source code) are written in Python, the interpreter reads them and translates them into actions for your computer (executed code).
Eventually, you’ll want to install Python locally for more extensive practice, but for now, you can use online interpreters to get started.
Una nota sobre sintaxis y bloques de código:
Cuando trabaje con código tenga en cuenta los errores de sintaxis, junto con el resultado general de su código. El hecho de que hayas corregido un error de sintaxis no significa que el código vaya a tener el efecto deseado cuando se ejecute, puede tener un problema semántico.
Recuerda que la sintaxis son las reglas de cómo se construye el código. La semántica es el significado de las declaraciones codificadas. ¿Qué quiere decir el código?
Recuerda: Es posible tener un código sintácticamente correcto que se ejecute correctamente, pero que no haga lo que queremos que haga.
F.2) Why is Pyhton Relevant in IT?
[[Python]] is known for its simplicity and ease of use, making it an ideal language for learning programming fundamentals like [[data structures]] and [[algorithms]].
Its readable syntax is one reason Python is popular in the IT industry.
Since its release by Guido van Rossum in 1991, Python has evolved significantly, with major updates like Python 2 in 2000 and Python 3 in 2008.
In this course, we’ll use Python 3.7, released in 2018, as our foundation.
While Python was initially used mostly for educational purposes and small scripts, its capabilities have expanded over recent years.
Now, it’s widely used for various tasks, from:
- statistics calculations
- and web services
- to automation,
making it a top choice in IT support, system administration, and web development.
It’s also essential in rapidly growing fields like [[machine learning]] and [[data analytics]].
Python’s versatility extends across operating systems, including Windows, Linux, and macOS, and its popularity in the workplace means you’ll likely encounter it throughout an IT career.
Programming often involves trial and error and learning from mistakes. Embrace these challenges as they’re essential for growth. Even seasoned programmers frequently rely on resources like Stack Overflow, online documentation, or help from colleagues.
Python’s developer community offers a wealth of support and knowledge-sharing, helping you learn quickly and effectively.
F.3) Other Relevant Programming Languages in IT
While we’re using Python for this course, it’s just one of many programming languages. Think of each language as a unique tool in your IT toolkit, each with specific strengths and weaknesses.
- Some languages, like [[PowerShell]] (for Windows) and [[Bash]] (for Linux), are platform-specific and commonly used for system administration.
- Others, like [[Python]], [[Perl]], and [[Ruby]], are [[general-purpose scripting languages]] favored for automation.
Video: https://youtu.be/1HreXLIvk_k
Video: https://youtu.be/74_7LrRe5DI
- [[JavaScript]], originally a [[client-side]] web language, is now widely used [[server-side]] as well.
- More traditional languages like [[C]], [[C++]], [[Java]], and [[Go]] offer additional versatility for a variety of applications.
Video: https://youtu.be/pRC09Tz9iVE
Video: https://youtu.be/446E-r0rXHI
As you advance in your IT career, you’ll likely encounter several programming languages and learn when each is most appropriate.
Fortunately, once you master programming fundamentals in one language, you can often apply those concepts to others. Common elements across languages—such as variables, control flow, input, and output—make it easier to transition from one language to another.
FOR EXAMPLE:
Consider the example of a program that prints “hello world” ten times, demonstrated here in Python, Bash, and PowerShell.
Each language uses different commands and structures but ultimately accomplishes the same goal.
- Python uses
print
withrange(10)
, - Bash uses
echo
with a sequence count, - and PowerShell applies
Write-Host
with a loop.
While the syntax varies, the core tasks—outputting text and counting iterations—remain the same.
Don’t feel overwhelmed by the diversity of programming languages; for now, you only need to focus on learning Python.
Once you’re comfortable with it, learning additional languages will become much easier.
G) 💬 Practice Quiz: Introduction to Python
- Question A: Python is an example of what type of programming language?
- Machine language
- Platform-specific scripting language
- General-purpose scripting language <--------
- Client-side scripting language
Correct
There you have it. Python is one of the most widely used general-purpose scripting languages for scripting and automation.
- Question B: Fill in the correct Python commands to print "This is fun!" on the screen 5 times.
for i in range(5):
print("This is fun!")
Correct
Well done! You've remembered how to use the "print" command to get the job done.
H) "Hello World!" - How to print strings (🎦 folder 4)
Now that you’ve seen an example of Python code, let’s explore one of its most basic programs:
- displaying "hello world" on the screen.
This example introduces the Python print
function, which instructs the computer to display specific text. When we run this code—whether locally on our machine or through an online interpreter—the phrase "hello world" appears, thanks to print
.
Although it may seem magical, it’s simply Python following instructions.
H.1) Functions and Keywords in Python
The print
[[function]] is a built-in feature of Python, part of its basic language structure. By using these built-in [[functions]] and [[keywords]], we communicate with the computer via the programming language's syntax.
*But what are [[functions]] and [[keywords]]?
- Functions are blocks of code designed to perform a particular task.
As we progress, you’ll learn how to create your own functions to expand what your programs can do.
Read more: https://www.geeksforgeeks.org/python-functions/
- Keywords are reserved words used to build core instructions, like
if
,while
, andfor
. These cannot be used freely as variable names or function names, as they’re reserved for specific language functions.
In [[Python]], as in other languages, syntax—the combination of functions, keywords, and rules—allows us to construct instructions for the computer.
Keywords Examples: we can't name our variables like this...
H.2) Introduction to "Strings" in Python
Now, notice that "hello world" is enclosed in double quotation marks. This indicates that "hello world" is a string in Python,
which means it’s treated as text.
Note: Any text not in quotation marks is interpreted as code rather than data.
LET'S REVIEW SOME EXAMPLES:
In Python, if you want to include double quotation marks ("
) within a string, there are several ways to do it:
1. Use Single Quotation Marks Around the String
If your string is enclosed in single quotes ('...'
), you can include double quotes inside without any issues:
print('He said, "Hello, world!"')
2. Escape Double Quotes with a Backslash
If your string is enclosed in double quotes but needs to include double quotes inside, you can escape the internal double quotes with a backslash (\
):
print("He said, \"Hello, world!\"")
3. Use Triple Quotes for the Entire String
Triple quotes ("""..."""
or '''...'''
) allow you to use both single and double quotes inside the string without escaping:
print("""He said, "Hello, world!" and 'Welcome!'""")
These methods allow you to easily include double quotes as part of your string in Python.
Read more here: https://www.w3schools.com/python/python_strings.asp
Why is “hello world” the go-to phrase in Programming Tutorials?
It’s a programming tradition dating back to the 1970s when it was featured in the book
The C Programming Language.
In that example, displaying "hello world" took three lines of code,
while in Python, it’s just one.
This simplicity gives you a first glimpse of Python's accessible syntax and how functions work.
Now that you've created your first Python program, let’s move on to something a bit more challenging!
I) Introduction to User Input in Python
For a program to be useful, it often needs input from the user.
With this data, the program can perform specific, relevant actions, rather than general ones like simply printing "hello world."
Data can be entered into a program in many ways.
- On a website, you might input data by typing into text fields or clicking links.
- In a mobile app, data entry could be through buttons or drop-down menus.
- In a command-line program, you might pass data as parameters or interactively enter it as the program runs.
Each platform—whether web, mobile, or command-line—handles data entry differently.
For instance, some programs read data from files, while others gather it in the background from external sources.
In our earlier example of automating duplicate email removal, the data was a list of emails, typically provided in a file, with each email on a separate line.
In this course, our initial examples will keep data simple by placing it directly in the code. While this approach is basic, it allows us to focus on core concepts. Later on, we’ll introduce more dynamic methods for inputting data.
As a simple example,
separating a user’s name from the call to the print
function allows us to personalize a greeting.
This approach keeps the print
function generic while making it easy to change the name without altering the core code.
Next, we’ll explore a few more tasks that Python can handle easily.
J) Arithmetic Operators in Python
Python can do a lot, and you'll explore many of its capabilities throughout this course. But before diving into complex topics, let’s try a simple and fun task: using Python as a calculator.
Let’s start with some basic calculations:
- For example,
, , and . - When dealing with repeating numbers, like
, Python will display many decimal places to represent the repeating sequence, as it can't show infinite repeats.
Now, let’s try something a bit more challenging:
- Suppose we want to calculate
. - To get the correct result, we need to use parentheses, just like in standard math notation.
Python can also handle exponents. For instance, to find **
operator (2 ** 10
), which gives us the answer.
You might wonder, "Why use Python instead of a regular calculator?" Practicing these calculations helps you get comfortable with Python’s math capabilities, which are useful in IT tasks. For example, you may need to:
- Count occurrences of a word in a text.
- Calculate the average time for an operation.
- Determine the compression needed to fit an image into a specific size.
Writing scripts for calculations can make tasks faster and more accurate. Python also offers advanced numeric capabilities for fields like data analysis, statistics, and machine learning. While we won’t cover these in this course, there are plenty of resources available online if you want to explore them further.
Python puede operar con números usando los operadores matemáticos habituales, y también algunos operadores especiales. Estos son todos ellos...
Operadores aritméticos:
- a + b = Suma a y b
- a - b = Resta b de a
- a * b = Multiplica a y b
- a / b = Divide a entre b
- a ** b = Eleva a a la potencia de b. Para valores no enteros de b, esto se convierte en una raíz (es decir, a**(1/2) es la raíz cuadrada de a)
- a // b = La parte entera de la división entera de a por b
- a % b = La parte restante de la división entera de a por b
K) 💬 Practice Quiz: First Steps with Python
-
¿Qué son las funciones en Python?
- Las funciones nos permiten utilizar Python como una calculadora.
- Las funciones son piezas de código que realizan una unidad de trabajo.
- Las funciones sólo se utilizan para imprimir mensajes en la pantalla.
- Las funciones son la forma de saber si nuestro programa funciona o no.
Correcto
Así es. Las funciones de Python encapsulan una acción determinada, como la salida de un mensaje a la pantalla en el caso deprint()
. -
¿Qué son las palabras clave en Python?
- Las palabras clave son palabras reservadas que se utilizan para construir instrucciones.
- Las palabras clave se utilizan para calcular operaciones matemáticas.
- Las palabras clave se utilizan para imprimir mensajes como "¡Hola Mundo!" en la pantalla.
- Las palabras clave son las palabras que necesitamos memorizar para programar en Python.
Correcto
¡Ya lo tiene! Utilizando las palabras reservadas que nos proporciona el lenguaje podemos construir instrucciones complejas que formarán nuestros guiones. -
Sustituya el marcador de posición ___ y calcule la proporción áurea:
Consejo: para calcular la raíz cuadrada de un número ( x ), puede utilizarx**(1/2)
.ratio = 0.5 * (1 + 5**(0.5)) print(ratio)
Correcto
¡Increíble trabajo! Vea cómo podemos utilizar Python para calcular complejos valores por nosotros.
________________________________________________________________
L) 🔸 Week 1 - Summary 📄
Congratulations on completing the first module! You’ve taken the initial steps in learning a new programming language and expanding your IT skills—a great achievement that shows real determination and a willingness to learn.
In this module, you covered a range of foundational topics:
- Understanding what scripting is and the basics of programming language syntax and semantics.
- Learning how these concepts relate to automation.
- Writing small blocks of Python code and seeing why Python is so valuable in IT.
- Exploring other programming languages.
- Practicing how to input data, create simple scripts, and use Python for basic math calculations.
That’s a solid start to your Python journey! This is just the beginning, and we hope you’re excited to dive deeper into coding.
Previous Part | Next Part 🔜
Z) 🗃️ Glossary
File | Definition |
---|