- Run IDLE on your machine
- Write a comment
# Hello world!
Nothing prints because the Python interpreter ignores everything after #.
- Try to create a variable with an illegal name
1st_try = 55
You get an error message because the a variable name cannot start with a digit.
- Create the variable score and assign it an integer value
score = 85
- Run
type
on score
type(score)
- Assign score a decimal value
score = 85.0
- Run
type
on score
type(score)
- Assign score a string value
score = "85"
- Run
type
on score
type(score)
- Write a print statement that has more than one argument
print("My score on the test was", score, "but I hope to do better next time")
- Use the
import
function to read a string from the keyboard
name = input("Please enter your name: ")
- Print the value of the variable name
print(name)
- Get the data type of the value in the variable
type(name)
- Read in a value from the keyboard and convert it to integer
number = int(input("Please enter an integer: "))
- Get the data type of the variable
type(number)
- Read a value from the keyboard and convert it into a
float
number = float(input("Please enter a decimal number: "))
- Get the data type of the variable
type(number)
- Try to covert the value of name into an integer
number = int(name)
You get an error message because the text value of name can't be converted into an integer.