Open main menu

CDOT Wiki β

Changes

OPS435 Python3 Lab 2

757 bytes added, 14:27, 24 January 2020
m
LAB REVIEW
[[Category:rchan]][[Category:OPS435-Python]= Under construction - DO NOT USE - not ready yet! =]
= LAB OBJECTIVES =
:'''<u>Objectives</u>'''
:Learn the following python topics:
:*'''builtin functions:''' input(), print(), len(), str(), int()
:*'''builtin module:''' sys - special list object sys.argv
:*'''flow control statements and block:''' if, if/else, if/elif/else, while
:*'''code indentation''' - 4 spaces (avoid using tabs)
:Write Python code in order to:
 
:*'''Accept data from users ''' at the command line, such as name and age.
 
:*'''Prompt the user to provide specific data''' from the stdin (standard input channel), such as a username or password.
 
:*'''Process the inputted data''' using '''Conditional Statements'''.
:::This means that the program will change how it behaves based on the input given, an example would be, providing the correct password or providing the wrong password.
 
:*'''Process the inputted data''' using '''Looping Statements'''.
:::Looping (iteration) is the ability for your script to repeatedly run the same block of codes over and over until a given condition is met. For example, an authentication process would allow your 3 attempts to provide the correct password, and it will deny you access after 3 attempts have been tried and failed.
python3 ./CheckLab2.py -f -v lab2f
</source>
:::4. Before proceeding, make certain that you identify any and all errors in '''lab2dlab2f.py'''. When the check script tells you everything is '''OK''', you may proceed to the next step.
== PART 3 - Combining WHILE loops with IF statements==
:::*The script should have a '''Shebang line'''
:::*The script should have a comment line which contains the word "Author:" and your '''full name'''
:::*The script should have another comment line which contains the word "Author ID:" and your '''seneca_id'''
:::*The script should have another comment line which contains the word "Date Created:" and the actual date in "yyyy/mm/dd" format
:::*The script should '''import sys'''
:::*The script should assign the value of '''3''' to an object named '''timer''' when there is '''no arguments''' provided.
:'''Be able to answer any questions about the lab to show that you understood it!'''
 
:<span style=color:green;font-size:1.5em;">&#x2713;</span> Submit the CheckLab2.py script output and all your Python scrips for this lab via Blackboard by the due date for Lab 2.
= LAB REVIEW =
:# Write a short Python script to ask the user to provide their shoe size at the keyboard, and store the result in an integer object called '''shoeSize'''.
:# Add codes to the previous Python script to display the shoe size entered using the same integer object created. (For example: '''Your size shoe size is: 16''').
:# What is the purpose of importing special module from your system?
:# Write a short Python script to display two arguments from running your Python script.<br>For example if your Python script was called '''myscript.py''' and you issued the command:<br>'''python myscript.py happy afternoon''', you would get the following output:<br><br>The first argument is: happy<br>The second argument is afternoon<br><br>
14
edits