Activity 3

Workshop Resources

Let’s try to figure out the answers to the following using Python. Try printing out the result of the below (make sure you don’t miss any parentheses):

Challenge

Can you print out this statement? "527 time 199 is: __"

You will fill in the blank with the answer of what (527 * 199) is. If you want to print a string and a number together, you first have to convert the number into a string.

Here’s an example: print("Hello, World!" + str(5))

Using str(5) turns the number into the string "5". Converting one type of thing to another is called “casting”.

Fun Fact: Random Numbers

Here is how to print a random number between 1 (inclusive) and 10 (inclusive):

from random import randint

print(randint(1,10))

Want to know more? Ask for help or poke around on the internet! Every coder’s best friend is a search engine!

In particular, try understanding what the from and the import words mean. We will come back to these words later during the project.