Lab 2.02 - Casting

1) Without using the computer, predict what the following inputs will result in. Once you have filled in the "prediction" column, check your answers in interactive mode and write the actual result.

Input Prediction Result
float('1')
str(1 + '2')
str('2')
int('abc')
int(float('1.6'))
float(int(1.6))
str(float(1))

2) Create a program which will take in an input and print out that input divided by 2.

3) Alter one line of that program to return only whole numbers.

Bonus!

Make your program have two modes: an integer mode and a float mode. Add another input to ask which mode the user wants to use. If the user is in integer mode print out integers, otherwise print out float. Feel free to research Python docs (This is a concept covered in Snap)