Students will learn more about the types of data within Python code.
Create new code to perform the following tasks:
Be able to read, comprehend, trace, adapt and create Python code using selection that:
A data type is a setting for a variable that tells it what sort of data to accept. The three data types we will use in these exercises are:
Casting is the act of converting variables to different data types. This can be done with separate functions:
Casting is also used during input. Normally, all inputs from the user are strings, but it can be casted into a different data type and stored into a variable: Example
num_1 = int(input(“Enter a number -> “))
Certain operators are used to compare data types, they are:
Note that string data types cannot be used with mathematical operations
The type function returns the data type of a variable or piece of data. Examples include:
The data type can be printed as well.
print(type(6))
The slideshow that are part of this section can be found here:
https://docs.google.com/presentation/d/1KN5LkKUI5LiVpOnr27HTCMtdODOqScXQ8LnROVvtOwI/edit?usp=sharing
When you encounter errors you can code, make sure to check if: