CMPT120 – (Solution)

$ 29.99
Category:

Description

This is an individual assignment.

LEARNING OBJECTIVES:
• Brief review of materials seen so far in class and lab exercises
• Explore upcoming topics/calculations – for bonus points
• Practice “TRACE” printing to best follow a program execution • Review the submission process

SUBMISSION (Different than in the previous submission for people working with repl.it):
Everyone should submit:
• one .py file with the program and
• one .txt file with the reflection

NOTES ABOUT THE SUBMISSION PROCESS
• Make sure that you submit in Canvas by clicking on the button
• If you re-submit, you need to resubmit all (both) files
• You should not submit a copy of the shell dialog (i.e. the window with the Python prompt >>>). Instead, submit the .py file, that is, what you created in the editor window.
• If you created your Python file with repl.it o Include also at the top of your .py file , as part of the initial comments, the URL (address) of your repl.
o From repl-it, download the file in compressed format (zip).
o o From the compressed file extract the .py file in some folder in your computer. Upload this extracted .py file to Canvas.
o Instead of downloading as .zip from repl.it and extracting, you could also copy /paste your program to a local .py file using a text editor (IDLE, Notepad…) ( NOT WORD)
• NOTE: It is useful to view the files’ extensions (.py, .docx, .pdf, etc). Check your file explorer/finder, View option  file name extensions
PROBLEM DESCRIPTION

The T-shirt Greeter bot should:
a. Greet the user and ask the user for the first name and for last name (two inputs)
a.1. Bonus: (this influences some of next parts). Have the user input the first name and the last name with one single input, with one space in between
b. Ask the user his/her age (assume the user types correctly)
c. Respond to the user using the user’s initials.
d. If the user’s last name initial is any letter before (alphabetically) an “L” , then the bot should tell the user to join the “Queue before L”. If specifically, the last name’s initial is an “A” or a “B”, the queue should be “Queue A or B” instead. On the other hand, if the user’s last name initial is “L” or after in the alphabet, it will be “Queue L or after”.
d.1. Bonus: Further, any of the queues can have two variations. If the user’s is 18 years old or younger, it should be the “youth” queue, else it should be the “adult” queue. The words “youth” or “adult” are shown to the user in the same line
e. Calculate a random number (call it ran) between 1 and n, where n results from: Adding the length of the first name, the length of the last name, and the age. Calculate the square root of this number. n is integer part of this value.
(Hint: use functions in the modules random and math).
f. Inform the user the intermediate values: the sum, square root, n and ran.
NOTE: this is printed to allow you as programmer to trace that results are ok, not really for the “user”, hence we will print this with the word “TRACE”.
g. Also inform the user a text (this will be included in the user’s Tshirt). The text should have the first and second letter in the user’s name repeated ran times followed by the number ran and followed by two exclamation signs.

RUBRIC – total 7 points
1 – ask data to the user, save values in variables (parts a,b)
1 – respond with the initials (part c)
1 – queue is ok given the last name initial (part d)
1 – numbers n and ran are ok, and TRACE print is included (parts e,f)
1 – the text for the gift is ok (part g)
1 – your reflection
1 – comments and good variable names
2 – bonus (1 point for each bonus feature, parts a.1 and d.1)

SAMPLE RUNS

Your messages can be slightly different than in the sample runs, but the same information must be asked and shown. What the user types is underlined and highlighted in this description

>>>
Hi! I am the T-shirt Greeter Chatbot 2!

Your first name? –> Peter Your last name? –> Holmes

Welcome PH!!

Your age? –> 23

You should go to: Queue before L

TRACE – The sum is: 34 – sq root is: 5.830951894845301 – n is: 5 – ran is: 2

Your Tshirt will have the text: PePe2!!

BYE!

>>> ###################### [Version with bonus]

Hi! I am the T-shirt Greeter Chatbot 2!

Your first and last name (one space in between)? –> Liz Allen

Welcome LA!!

Your age? –> 18

You should go to: Queue A or B (youth)

TRACE – The sum is: 26 – sq root is: 5.0990195135927845 – n is: 5 – ran is: 3

Your Tshirt will have the text: LiLiLi3!!

BYE! >>>

Reviews

There are no reviews yet.

Be the first to review “CMPT120 – (Solution)”

Your email address will not be published. Required fields are marked *