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.