You are on page 1of 20

ALX LESSON

0x00 Python -
Hello, World
python - Programming
TABLE OF CONTENTS

01 02
Overview Learning
topics Objectives

03 04
Quiz hands on lab
questions practice
01
OVERVIEW topics
Topics
Why Python programming is awesome

Who created Python

Who is Guido van Rossum

Where does the name ‘Python’ come from

What is the Zen of Python


python
How to use the Python interpreter
Programming
Topics How to print text and variables using print

How to use strings

What are indexing and slicing in Python

What is the official Python coding style and how to


check your code with pycodestyle
Slides On Telegram

https://t.me/alx_2023

python
Programming
Topics

Slides exist on telegram


@alx_2023ch
02
Learning Objectives
Why Python programming is awesome

Readability and Simplicity: Python's syntax emphasizes readability and is easy to


understand

Cross-Platform Compatibility: Python is available on multiple platforms,


including Windows, macOS, and Linux.

Ease of Learning: Python's simple and consistent syntax allows beginners to learn
programming concepts quickly.

Support for Object-Oriented and Functional Programming.

And more…
Who created Python

Python was created by Guido van Rossum. He began working on the language in
the late 1980s, and the first version of Python, version 0.9.0, was released in
February 1991. Guido van Rossum, a Dutch programmer, designed Python with a
focus on readability, simplicity, and ease of use. He aimed to create a
programming language that would be both powerful and enjoyable to work with.

Guido van Rossum


How to use the Python interpreter

Opening the Interpreter: typing python or python3 (depending on your system and
Python version) and then pressing Enter.

Exiting the Interpreter: you can use the exit() function or press Ctrl + D (on Unix-
like systems) or Ctrl + Z (on Windows) followed by Enter.

Running a Python Script: if you have a file named myscript.py, you can run it
from the terminal using python myscript.py or python3 myscript.py.
How to print text and variables using print

Printing Text:
print("Hello, Python!")

Printing Variables:
age = 25
print(age)

Printing Text and Variables Together:


name = "Alice"
age = 30
print("My name is", name, "and I am", age, "years old.")
How to print text and variables using print

Formatting with f-strings (Python 3.6+):


name = "Bob"
age = 22
print(f"My name is {name} and I am {age} years old.")

Using format() method:


name = "Charlie"
age = 28
print("My name is {} and I am {} years old".format(name, age))

Concatenating Strings and Variables:


name = "David"
age = 35
print("My name is " + name + " and I am " + str(age) + " years old.")
How to print text and variables using print

Additionally, note that the print() function automatically adds a newline


character at the end by default. If you want to print without a newline, you can
use the end parameter:

print("Hello", end=" ")


print("World")
How to use strings

Creating Strings:
Strings can be created using single quotes ('...') or double quotes ("...").
single_quoted = 'Hello, Python!'
double_quoted = "Welcome to Python!"

Multiline Strings:
Triple quotes ('''...''' or """...""") are used to create multiline strings.
multiline = '''This is a
multiline string.'''

String Concatenation:
Strings can be concatenated using the + operator.
greeting = "Hello, "
name = "Alice"
message = greeting + name
How to use strings

String Replication: Strings can be replicated using the * operator.


repeated = "-" * 10

String Methods: Strings have many built-in methods for manipulation, such as
upper(), lower(), capitalize(), replace(), find(), startswith(), endswith(), split(), join(),
and more.
text = "python programming"
upper_text = text.upper() # "PYTHON PROGRAMMING"
replaced_text = text.replace("python", "Python") # "Python programming"
words = text.split() # ['python', 'programming']
How to use strings

Escape Sequences: Special characters can be included using escape sequences, such
as \n for a newline and \" for a double quote.
quote = "He said, \"Hello!\""
newline = "Line 1\nLine 2“

String Length: You can find the length of a string using the len() function.
text = "Hello, Python!"
length = len(text) # 14
What are indexing and slicing in Python

Accessing Characters in a String: Individual characters in a string can be


accessed using indexing. Indexing starts from 0.
word = "Python"
first_char = word[0] # 'P'
second_char = word[1] # ‘y’

String Slicing: Slicing allows you to extract a portion of a string.


phrase = "Hello, World!"
slice = phrase[7:12] # "World"
04
Hands on lab Practice
Have a Question
Leave a Comment!
Subscribe
To stay updated with latest
videos

Share
To let the others know more
Thanks

You might also like