Students will learn how to perform simple calculations using fixed numbers, numbers in variables, and numbers from the user
This task contains three code examples.
Examine and study each example carefully. Predict about what each example will do when it runs. Your prediction should be included as comments to the code (#). In your prediction, you should use the key terms variable, operations, converting data types, and user input in your prediction.. If you need a reminder on these key terms, click on the links below.
Be able to read, understand, trace, adapt and create Python code using selection that:
If one / is used for division, the result will be a decimal, known as a float. If two // are used for division, the esult will be a whole number, known as an integer (or int for short).
Input from the user in Python code is usually a string(text), but calculations required an integer(whole number) or a float(decimal number). Casting is the act of changing the data type of a variable to match a need.
To save the user’s inputted number as a whole number in a variable, use **int(input(“Ask user to enter something -> “))
To save the variable as a decimal number, use **float(input(“Ask user to enter something -> “))
The link to the slide deck for this topic can be found here:
https://docs.google.com/presentation/d/1choFBbf7jyjNm-h37Z4Qyo1xOVVTj0W6mj6PCLRjbYw/edit?usp=sharing
When you run into an error with your code, ensure you have checked the following:
+ addition
- subtraction
* multiplication
/ float division
// integer division