himanshu1295 / python1

Demonstrating how explicit type casting is done in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lab Instructions: Type Casting Input

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.

Tips: Before you Begin

To view your code and instructions side-by-side, select the following in your VSCode toolbar:

  • 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.

To run your Python code

  • 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.

There are two exercises and objectives of this activity:

  • Exercise 1: Use explicit casting to apply the correct cast type

  • Exercise 2: Fix the script so it correctly outputs the bill total

Exercise 1:

In this exercise, you'll use explicit casting to apply the correct cast type.

Instructions

  1. Open the script exercise1.py present inside the project folder

  2. To run the script, open terminal and execute the following command:

    python3 exercise1.py
    
  3. Step 3: Fix the script so the variables have the correct type.

Exercise 2:

Your goal of this exercise is to fix the script so that each variable has the correct type.

Instructions

  1. Open the script exercise2.py present inside the project folder

  2. To run the script, open terminal and execute the following command. You will be prompted to enter some values.

    python3 exercise2.py 
    
  3. Fix the script so it outputs the correct bill total based on the data being entered.

About

Demonstrating how explicit type casting is done in Python


Languages

Language:Python 100.0%