Skip to content

Latest commit

 

History

History
32 lines (20 loc) · 897 Bytes

File metadata and controls

32 lines (20 loc) · 897 Bytes

Lab 2.01 - Casting

In your notebook

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))

In your console

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

  2. 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 asks for integer mode, then print out integers as the result of your division. Otherwise print out floating-point values (decimals).