Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 1.18 KB

session-0.md

File metadata and controls

51 lines (40 loc) · 1.18 KB

Session 0

A little theory

Which of the following are operators, and which are values?

*
'hello'
-88.8
-
/
+
5

Why does this expression cause an error? How can you fix it?

'I have eaten ' + 99 + ' burritos.'

Computers love arithmetic

Write a script that prompts the user for two numbers, multiplies the numbers together and prints the result to the console.

# To prompt the user to enter a value
my_string = input("Message to the user")

Division

What is 17 divided by 3? How many times does 3 divide into 17?

Rounding numbers

Write a script that prompts the user for a floating point number and the number of decimal places to round the number, print the rounded number to the console. Python has a tool for doing this: round().

Sample input/output:

>>> Enter a floating point number: 2.0453687
>>> How many decimal places would you like: 3
>>> The rounded number is: 2.045

Greetings

Write a script that prompts the user for their full name, then print a message to the console. A sample is shown below (Google "python string split" if you get stuck). Sample input/output:

>>> What is your full name: Alex Smith
>>> Hello Smith, Alex