Skip to main content

Chapter 1a - Printing

Printing Messages​

print ("Hello World!")  # Print a message using double quotes
print ('Hello World!') # Print a message using single quotes
πŸ§ͺ Try the code out!
Time to work on our Japanese Emoticons!

Click here to go to our Japanese Emoticons project You only need to complete this for this class. But if you would like to, feel free to peek into the topics below!

Printing numbers​

# This program displays some stuff 
print ("Welcome to Python Programming")
print ("Try coding, it's fun. Do you know what is 4*3?")
print (4*3) # This should print 12
πŸ§ͺ Try the code out!

Special Characters when Printing​

πŸ‘€

print('Hello\n World') # Move to the next line after Hello
print('') # Leave an empty line on console
print('Hello\nWorld') # Move to the next line after Hello, white space before World has been removed here

print('\nDemonstration of backslash')
# print('\') # uncommenting this line will cause an error
print('\\') # to print a backslash, you need to escape with another backslash
πŸ§ͺ Try the code out!

πŸ‘€

Example​

Printing a Human Character

Let's say we want to create the following figure:

πŸ”¬ Solution
Try out this solution
Problem 1

Let's say you want to create the following figure:

πŸ“ Solve this problem in Trinket or here
πŸ’‘ Hints
  • What are the different characters that have been used to create this shape?
  • How will you get the spacing right? What lines are the characters on? Hint: Use a table and add the different characters in the cells as they appear in the image. Or simply align the characters on your code editor first.
  • Write down the instructions needed to create this graphic in the Instructions window of your Trinket.

πŸ‘€

πŸ‘€Assessment Quiz