Python Basics 2

Simple Code

Raspberry Pi (Same as past two weeks)

This week we’re looking at some simple coding in Python. We’ll get some input from the user, then get another number. We’re going to make a calculator that bites back! First, open Menu>Programming>Thonny Python IDE and write this into the main section (not shell):

firstnumber = input("What number would you like to multiply: ")
secondnumber = input("And what would you like to multiply it by: ")
print("Why do I have to do your calculation for you?!?")

Press run and save it as calculator in the Python folder you made last week.

Enter your numbers then… It’ll bite back!

What features could you spot? Scroll down when you think you know!

There was:

something = something_else this made the computer set on value to be the same as something else

input() this asked the user to do something

That’s it for this week. See you next week!

, , , ,

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.