Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 2

80 bytes added, 01:16, 25 May 2017
PART 1 - INPUT
= INVESTIGATION 1: USER INPUT =
== PART 1 - USER INPUT ==This first part will cover how to ask the user running the program for input or more informationdata. Though we will not be doing very much with the information we provide provided currently, in later labs sections this will become a key part of how you change the way a program works.
=== Storing User Input In Variables === :'''lab2aPerform the following steps:'''
:#First lets start out with a very basic script. This script will use variables to print out specific information to the screen. Make the script '''lab2a.py''' with the following content.<source>
#!/usr/bin/env python3
</source>
:#Before proceeding, make certain that you identify any and all errors in "lab2a.py". When the check script tells you everything is "ok", you may procede to the next step.
:#Now it's time to create a new script. Make a copy of '''lab2a.py''' and call it '''lab2b.py'''. Now modify '''lab2b.py''' so that it asks the user for both the value of name and the value of age. Use the input() function and store the values in the correct variables. Example output is shown below:
  ''' lab2b '''Now it's time to create a new script. Make a copy of '''lab2a.py''' and call it '''lab2b.py'''. Now modify '''lab2b.py''' so that it asks the user for both the value of name and the value of age. Use the input() function and store the values in the correct variables. Example output is shown below:::*The script should have a Shebang line::::*The script should use a variable called "name"::::*The script should use a variable called "age"::::*The script should prompt the user for "Name: "::::*The script should prompt the user for "Age: "::::*The script should store the values in the correct variables::::*The script should print the EXACT OUTPUT as shown
Sample run 1:
198
edits