Skip to content

IPP-DEV-03-004: Create a simple application #66

@labbenchstudios

Description

@labbenchstudios

Description

  • Using instructions from the in-class lecture, create a new module called MyFirstTestApp.py module. The framework for the app will be given below. You'll add a function to the app, along with some import logic, allowing you to invoke functions on other modules.

Review the README

  • Please see README.md for further information on, and use of, this content.
  • License for embedded documentation and source codes: IPP-DOC-LIC

Estimated effort may vary greatly

  • The estimated level of effort for this exercise shown in the 'Estimate' section below is a very rough approximation. The actual level of effort may vary greatly depending on your development and test environment, experience with the requisite technologies, and many other factors.

Actions

Step 1: Make Sure Your System is Setup for Python and This Course

Step 2: REMINDER: Make Sure PYTHONPATH is Set Correctly

Whether running Python tests within your IDE or from the command line, you must set the PYTHONPATH environment variable in every execution environment (e.g., every terminal you launch) when attempting to run any of your scripts and their tests or the IPP test app from the command line. The IPP source and test paths will be as follows:

  • {your IPP source code path}
  • {your IPP source code path}/tests

See IPP-DEV-01-001 for details.

Step 3: Create the MyFirstTestApp.py module in the labmodule03 directory.

  • Open the module, and implement the following test cases:

Test 1 (create the app)

  • Implement the following code:
import sys

def main():
	print('Hello, world!')
	
	return 0

if __name__ == '__main__':
	sys.exit(main())
  • Run the application from your IDE or the command line

Test 2 (add in a doWork() function)

  • After the import sys declaration, import the SimpleTempConversion module
import SimpleTempConversion
  • Before the def main() function, add a new function called doWork()
def doWork():
	f_val = 72.0
	
	c_val = SimpleTempConversion.convertTempFtoC(f_val)
	
	print(f"Converted temperature values: F = {f_val}; C = {c_val}")
  • Within your main() function, and AFTER the print('Hello, world!') line and BEFORE the return 0 line, add in the call to doWork()
  • Run the application from your IDE or the command line

Estimate

  • Medium

Tests

  • From within your IDE

    • Right click on your newly created module MyFirstTestApp.py and click your IDE's run icon
    • You should see output similar to that discussed in class
  • From the command line

    • Open a terminal and cd to your IPP_HOME path
    • Start your virtual environment (if not already running)
    • Be sure your PYTHONPATH is set correctly
    • Run the module
      • python ./labmodule03/MyFirstTestApp.py
    • You should see output similar to that discussed in class

Sample output (yours may differ slightly)


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Lab Module 03 - Functions & Flow

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions