In this lab you will be presented with three exercises to demonstrate how explicit type casting can be.
used to solve data being inputted from an end user. Each exercise will ask you to solve a particular problem relating to types.
- View -> Editor Layout -> Two Columns
- To view this file in Preview mode, right click on this README.md file and
Open Preview
- Select your code file in the code tree, which will open it up in a new VSCode tab.
- Drag your assessment code files over to the second column.
- Great work! You can now see instructions and code at the same time.
- Questions about using VSCode? Please see our support resources here.
- Select your Python file in the Visual Studio Code file tree
- You can right click the file and select "Run Python File in Terminal" or run the file using the smaller
play button in the upper right-hand corner of VSCode.
(Select "Run Python File in Terminal" in the provided button dropdown)- Alternatively, you can follow lab instructions which use python3 commands to run your code in terminal.
-
Exercise 1: Use explicit casting to apply the correct cast type
-
Exercise 2: Fix the script so it correctly outputs the bill total
In this exercise, you'll use explicit casting to apply the correct cast type.
-
Open the script exercise1.py present inside the project folder
-
To run the script, open terminal and execute the following command:
python3 exercise1.py
-
Step 3: Fix the script so the variables have the correct type.
Your goal of this exercise is to fix the script so that each variable has the correct type.
-
Open the script exercise2.py present inside the project folder
-
To run the script, open terminal and execute the following command. You will be prompted to enter some values.
python3 exercise2.py
-
Fix the script so it outputs the correct bill total based on the data being entered.
Nice work! To complete this assessment:
- Save your file through File -> Save
- Select "Submit Assignment" in your Lab toolbar.
Your code will be autograded and return feedback shortly on the "Grades" tab.
You can also see your score in your Programming Assignment "My Submission" tab.