Changes

Jump to: navigation, search

OPS435 Python Lab 2

199 bytes added, 14:16, 21 January 2019
LAB REVIEW
:*'''Process the inputted data''' using '''Conditional Statements'''.
:::This means that the program will completely change how it works 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 program to repeatedly run the same code block of codes over and over. An example of this, could be found when you provide the incorrect password to a login page and it responds with, 3 attempts to login remaining.
<br><br>
== PART 1 - User Input ==
:In this section, you will learn how to prompt (ask) the user running the program python script for input or data. Although you will not be immediately be using the data that the user provided, you will use that data later in this lab to change how a Python script works in different situations.
'''Storing User Input data to Python objects'''
= LAB REVIEW =
:# Write a short Python function script to input ask the user for to provide their shoe sizeat the keyboard, and store the result in a variable an integer object called '''shoeSize'''.:# Write a Add codes to the previous Python function script to display the shoe size entered from using the value stored in the variable mentioned in the previous questionsame integer object created. (For example: '''Your size size is: 16''').:# What is the purpose of importing special variables module from your system?:# Write a function 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>
:# What is the purpose of using an '''if''' statement?
:# What is the purpose of using an '''if-else''' statement?
:# Write a short Python code to terminate script which terminates the execution of the running Python script if there are not exactly 3 arguments contained after given at the Python script upon executioncommand line.
:# What is the purpose of an '''if-elif-else''' statement?
:# Write a Python script to prompt the user for a course mark (no error checking is required... you can assume that the input will be a valid mark from 0 to 100). Use an if-elif-else statement to convert the mark to a letter grade. For simplicity, you don't have to worry about D+, C+, B+, or A+
:# Write a Python script to print the text '''I love Python''' twenty times (on a separate line).
:# Identify and list the Python 3 keywords used in this lab.
:# Identify and list the Python 3 built-in functions used in this lab. (hint: the functions provided by the __builtins__ module)
:# '''INTERESTING CHALLENGE:''' Perform a Netsearch to see how you can write Python code to perform error-checking (using a loop) to force a user to enter a number for the shoe size script (created in question #2). There are two things to consider:<ol type="a"><li>A number as opposed to a string</li><li>It has to be an acceptable range from 1 to 20</li></ol>
[[Category:OPS435-Python]]
1,760
edits

Navigation menu