Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Assignment Objectives Obtain and user input at runtime. Work with expressions, variables and assignments. Be able to construct arithmetic and Boolean Python expressions and

Lab Assignment Objectives

  1. Obtain and user input at runtime.
  2. Work with expressions, variables and assignments. Be able to construct arithmetic and Boolean Python expressions and assignment statements that correspond to informal specifications in English.
  3. Construct Python expressions and statements involving strings and Python string operators (including format specifiers) that correspond to lab specifications.
  4. Construct, starting from a specified expression set, Python expressions and statements involving lists/tuples and Python list/tuples operators and methods.
  5. Use Python Basic Data Types understanding what is meant by an object's type and value. Understand how the type determines the operators and methods that can be applied to the object. Be aware of how implicit and explicit type conversion between the basic Python data types are done.
  6. Import and use a module from the Python Standard Library.

Understand the Application

Obtain the family (last name) and student ID of the user at run time.

Based on the user input, you program will create two int variables, my_id and n_let, into which you will store:

  • my_id = The sum of the numbers in your College Generated student ID. (This is the sum of an 8-digit number; not to confuse it with your social security # or a password, which it is not).
  • n_let = The number of letters in your family (last) name.

In order to receive any credit for this assignment, these two values must match what I have for you on my class roster.

Your program will compute some values based on these two numbers, so that each student will have a unique output.

The Program Specification

The first thing your program needs to do is obtain valid user input for your family (last) name and your student ID. Next your program will generate the variables my_id and n_let. The expression set will be computed and the results displayed. Before exiting your program will display the current date and time.

The following expressions assume that you have stored the calculation of the sum of the numbers of your student ID into the variable my_id, and the calculation of the number of letters in your last (family) name into the variable n_let.

Your program should compute and display the results for the following expressions:

expression1: my_id / 2

expression 2: my_id % 2

expression 3: 2 + 3 + + n_let

expression 4: my_id + n_let

expression 5: abs(n_let my_id)

expression 6: (my_id) / (n_let + 1100)

expression 7: (n_let % n_let) and (my_id * my_id)

expression 8: 1 or (my_id / 0)

expression 9: round(3.15, 1)

Write a Python program that constructs an ordered collection data type whose elements consist of the Python expressions to realize the above expression set. Your program will compute and display the results of these nine expressions. Import and use the datetime (Links to an external site.) module to generate the date of your test run. Print this date in your run output.

Input Error Checking: Validate all user input before computation. A valid student id contains only digits and is of length 8. A valid last name contains only characters and is of a minimum length 2, maximum length 15.

Your program display should look something like this partial run (although the values will differ for each student):

Enter your family name: Student Enter your student ID: 12345678 my_id is: 36 n_let is: 7 expression 1: 18.00 ... Today's date is 2020-01-07

Here are some tips and REQUIREMENTS:

  1. The "..." is called an "ellipsis (Links to an external site.)" and means "and so forth". So, when n_let is 7, the expression 2 + 3 _+... + nLet really means to add the numbers from 2 all the way up to and including the number 7. Note: If the value of your num_let is 2 this expression is 2 + 2.
  2. Your personal information is to be entered as user input at run time.
  3. Validate user input whereby a last name need be of a minimum length of 2 chars and a maximum length of 15 characters [2..15] and the student ID need consist of eight digits (0..9) only; the result value for the calculation of my_id need be > 0.
  4. Assign the expression results to an ordered collection data structure (i.e. list or tuple).
  5. Use a space around operators.
  6. Keep source statement width
  7. Perform the necessary data conversions to perform arithmetic operations.
  8. Format floating point numbers to 2 decimal places. Hint: Only expressions 1, 6 and 9 are expected to generate floating point results.
  9. Import the datetime (Links to an external site.)module to display the current date of your test run submission.
  10. As you can see in the sample run, the first thing your program needs to do is issue a prompt string to obtain your family (last) name and your student ID.
  11. Use a space around operators.
  12. Ensure that your solution is well organized. Providing a program header and comments to document and organize your source code.
  13. Provide a commented out copy of your program run. Enclose the run inside of comment delimiters so that your program will run in the grader test bed. Place the run after your program source code (i.e. view the format of the file annFoothillLab1.py shown below).

What to Turn In

1. Hand in a .py file.

2. Use this title format for your .py file : yournameLabn.py (Example yournameLab1.py). (Note: Use YOUR name).

3. Include a Program Header followed by the Python source followed by the run (comment out the run).

Example Lab File Format Submission:

  • Student Name: Ann Foothill
  • Submission file name annFoothillLab1.pyimage text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

Use a three-step process to develop effective business messages.

Answered: 1 week ago