Skip to content

Commit 491638e

Browse files
Update 02_print.py
1 parent c70916f commit 491638e

File tree

1 file changed

+47
-27
lines changed

1 file changed

+47
-27
lines changed

scripts/02_print.py

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,81 @@
11
#===================================================================
22
# PRINT()
33
# ---------------------------------------
4-
# ......
5-
# ......
4+
# The `print()` built-in Python function is used to display text
5+
# on the screen. It’s your main way to *communicate* with users
6+
# and check what your code is doing.
7+
# You’ll use it in almost every Python program!
68
#===================================================================
79

8-
print("Hi Python")
9-
print('Hello Python')
10-
# print("Hi')
10+
print("Hi Python") # Double quotes
11+
print('Hello Python') # Single quotes
12+
# print("Hi')
1113

14+
# Print a Header with Separators
1215
print("--------------------")
1316
print(" LEARN PYTHON ")
1417
print("--------------------")
1518

19+
# For Fun!
1620
print(" __")
1721
print(" / _)")
1822
print(" .-^^^-/ / ")
1923
print("__/ / ")
2024
print("<__.|_|-|_| ")
2125

22-
# Escape Sequences
23-
# \"
24-
# \'
25-
# print("Hi "Python"")
26-
print("Hi \"Python\"")
27-
print('Hi 'Python'')
28-
print('Hi "Python"')
29-
print('Hi 'Python'')
30-
print('Hi \'Python\'')
31-
32-
# \\
33-
print("Path: C:\Users\Baraa")
34-
print("Path: C:\\Users\\Baraa")
35-
36-
# \n New Line
26+
# ---------------------------------------
27+
# ESCAPE SEQUENCES
28+
# ---------------------------------------
29+
30+
# \" and \' - Print quotes inside strings
31+
32+
# print("Hi "Python"") #Invalid: Double quotes inside Double quotes
33+
print("Hi \"Python\"") # Fix1: Use escape character (backslash)
34+
print('Hi "Python"') # Fix2: Mix single and double quotes
35+
# print('Hi 'Python'') #Invalid: Single quote inside Single quotes
36+
print('Hi \'Python\'') # Fix1: Use escape character (backslash)
37+
print("Hi 'Python'") # Fix2: Mix single and double quotes
38+
39+
# \\ - Backslash
40+
print("Path: C:\Users\Baraa") #Invalid
41+
print("Path: C:\\Users\\Baraa")
42+
43+
# \n - New Line
3744
print("Message1")
38-
print()
45+
print() # Blank Line
3946
print("Message2")
4047

41-
print("Message1\n")
48+
print("Message1\n") # Adds one new line
4249
print("Message2")
4350

44-
print("Message1\n\n\nMessage2")
51+
print("Message1\n\n\nMessage2") # Adds three new lines
52+
print("Message1\nMessage2") # One new line between
4553

46-
print("Message1\nMessage2")
47-
48-
# \t New Line
54+
# \t - Tab
4955
print("Message1\tMessage2")
5056

57+
# -----------------------------------------------
58+
# CHALLENGE TIME
59+
# Recreate the following using ONLY ONE print() function:
60+
# Your learning Path:
61+
# -Python Basics
62+
# -Data Engineering
63+
# -AI
64+
# -----------------------------------------------
65+
66+
# Multi-line string with tabs
5167
print("Your learning Path:\n\t-Python Basics\n\t-Data Engineering\n\t-AI")
5268

69+
# Alternative multi-line string using triple quotes
5370
print("""Your learning Path:
5471
\t- Python Basics
5572
\t- Data Engineering
5673
\t- AI""")
5774

58-
# Why we need really PRINT()
75+
# ---------------------------------------
76+
# PRINT() | Real Use Case for PRINT()
77+
# ---------------------------------------
78+
5979
price_shirt = 25.00
6080
price_jeans = 45.50
6181

0 commit comments

Comments
 (0)