Betel_Negash_Lab_06-AnswerSheet
.pdf
keyboard_arrow_up
School
University of Maryland *
*We aren’t endorsed by this school
Course
171
Subject
Computer Science
Date
Dec 6, 2023
Type
Pages
18
Uploaded by CoachIronVulture32
CS 171 - Lab 6
Professor Mark W. Boady and Professor Adelaida Medlock
Content by Professor Lisa Olivieri of Chestnut Hill College
Detailed instructions to the lab assignment are found in the following pages.
•
Complete all the exercises and type your answers in the space provided. What to submit:
•
Lab sheet in PDF. Submission must be done via Gradescope
•
Please make sure you have marked the questions on the correct pages of the PDF and added any teammates to the submission •
We only accept submissions via Gradescope. Student Name: Betel Negash
User ID (abc123): bsn37
Possible Points: 88
Your score out of 88
:
Lab Grade on 100% scale:
Graded By (TA Signature):
CS 171
Lab 6
Week 6
Question 1: 1 point
FYI: PredeKined/built-in functions
: segments of code already included in Python.
print()
,
round()
,
abs()
,
pow()
,
int()
are examples.
Arguments
: The information that a function needs to work. Arguments are sent to the function between the
parentheses
()
.
To use a function, call the function.
input(
"
Enter your name
"
)
is a call to the
input
function sending
the string
"
Enter your name
"
as an argument.
Closely examine the Python program below.
(a)
(1 point) Circle / highlight calls to predefined functions in the program above. Question 2: 8 points
Enter and execute the following Python program.
(a) (1 point) What is printed by Line 2?
4.65
(b) (1point) What is printed by Line 3?
125
(c) (1 point) What is printed by Line 4?
7.0
(d) (1 point) What is printed by Line 5?
34
(e) (1 point) What is printed by Line 6?
7
(f) (1 point) What is printed by Line 9?
77
(g) (2 points) What is the difference between the
round
()
function and the
int
()
function?
round() is a function to round a float value passed as a parameter, int() is a function that will cast a float value to an integer value and get leaves the decimal part by removing it.
#Get Input name = input
("Enter your name: ") #Print Results print
("Name:", name)
1 #Sample functions 2
print
(
abs
(
−
4.67) ) 3
print
(
pow
(5, 3) ) 4
print
(
pow
(49, 0.5) ) 5
print
( int (34.8) ) 6 print
(
round
(6.9) ) 7 8
import random 9
print
(random.randint(1 ,100) )
2
CS 171
Lab 6
Week 6
Question 3: 5 points
What value is returned by each of the following function calls?
(a) (1 point)
abs
(4.5)
4.5
(b) (1 point)
int
("678")
678
(c) (1 point)
round
(
−
5.6)
-6
(d) (1 point)
random.randint(4, 10)
error because random is not deWined
(e) (1 point) Is
import
random
required to run
random.randint(4, 10)
?
Yes
Yes
No
Question 4: 1 point
Circle / highlight the
argument
in the call to the built-in function:
The argument is the number wrapped inside round(). Question 5: 1 point
answer = pow
(4, 3)
. What is/are the argument(s) in this code?
4 and 3
Question 6: 2 points
If a function contains more than one argument, do you think the order of the arguments makes a difference?
Explain your answer with an example.
Yes, the order definitely matters. Take pow(4,3) for instance – that's 4^3, which gives you 64. Now, if you mix it up and go with pow(3,4), you're looking at 3^4, and that gives you a totally different result of 81. So, switching things around can change the whole thing
Question 7: 6 points
Execute the following lines of code:
number = 45.78 answer = round
(number)
3
CS 171
Lab 6
Week 6
(a) (2 points) Explain the purpose of the
ceil()
function
The ceil() function rounds a number UP to the nearest integer, if necessary, and returns the result (b) (2 points) Explain the purpose of the
floor()
function.
The floor() function rounds a number DOWN to the nearest integer, if necessary, and returns the result. (c) (2 points) Why are the calls to the
floor()
and
ceil()
functions preceded by “
math
.”?
You gotta import floor() and ceil() from the math module before using them. So, math comes first.
Question 8: 6 points
Review the following Code.
import math x = 4.7 y = 5.3 z = −
4.8 a = −
3.2 print
(math.ceil(x)) print
(math.ceil(y)) print
(math.ceil(z)) print
(math.ceil(a)) print
(math.floor(x)) print
(math.floor(y)) print
(math.floor(z)) print
(math.floor(a))
FYI:
A
function
is a segment of code that performs a single task.
A
function deKinition
is the segment of code that tells the program what to do when the function is
executed. The Wirst line of a function deWinition is known as the
function header
4
CS 171
Lab 6
Week 6
(a) (1 point) What Python keyword is used to indicate that a code segment is a function deWinition?
Def
(b) (1 point) What are the two function headers in the Python code?
•
def printMessage (): def main(): (c) (1 point) The name of the function is in the function header. What are the names of the two functions?
printMessage and main (d) (1 point) Enter and execute the Python program. What is the output?
Hello Programmer! Welcome to Python. Learn the power of functions! (e) (2 points) What line of code would you add to the program to print the last two lines twice? Where
would you add the code?
I would add printMessage () inside the function main() twice #Description: This program uses a function to print a message #Function Definition def printMessage (): print
("Welcome to Python.") print
("Learn the power of functions!") #Function Definition def main() : print
("Hello Programmer!") #Function Call printMessage () #Function Call main() 5
CS 171
Lab 6
Week 6
Question 9: 14 points
Examine the following code.
(a) (2 points) Label the
function deKinitions
and the
function calls
in the above code.
Function definitions are: 1, area= math. pi * radius ** 2 print(“A circle of Radius %d has area %.2f”%(radius, area)) 2, radius = int(input(“Enter the radius: ”)) calculateArea(radius) main() is the function call. The computer will run what there are inside the main() function. (b) (2 points) The function call and the function deWinition for
calculateArea
each include a variable
within the parentheses. The variable in the function call is known as an
argument
. The variable in the
function deWinition is called a
parameter
. What is the parameter in the function deWinition? What is its
purpose?
A parameter is like a nametag for a variable that you toss into a function. It's how you bring in arguments to the party.
(c) (2 points) In this example the parameter in the
function de9inition
and the argument in the
function call
have the same name. Is this required?
#Description: This programuses functions to calculate # the area of a circle, given the radius import math def calculateArea (radius): area = math.pi ∗
radius ∗∗
2 print
("A circle of Radius %d has area %.2f" %(radius, area)) def main() : radius = int
(
input
("Enter the radius: ")) calculateArea(radius) #### Call to main #### main()
6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Written Use Case
Follow the sample format shown in the attached photo.Sample have its label, while the one you should make a written use case is the one who have blue ovalsNOTE: YOU SHOULD MAKE THE WRITTEN USE CASE AS YOU CAN SEE IN THE SAMPLE TABLE. SOMEONE IS ANSWERING MY QUESTION WRONG!
arrow_forward
Deliverable length: 5–8 PowerPoint Presentation slides with speaker notes (excluding the title and reference slide); including detailed speaker notes of 200–250 words speaker notes for each slide As the new HR manager of a jewelry company, you have put together some preliminary reports for the CEO. One of the reports you compiled focuses on employee turnover. The jewelry company is an organization with aggressive expansion goals. In the last 2 years, the company has continually hired new employees, yet it has not achieved the staffing levels it desired. The company knew that some employees had left the organization, but turnover rates have not been formally tracked. After your preliminary fact-finding, you were surprised to discover that the turnover rate for the past year was 38%. You know the CEO will not be pleased with this turnover rate, and you have made the decision to prepare yourself more before presenting the report to the CEO. Turnover…
arrow_forward
Execute the following: Split the text into two
columns, Change the table design
Your answer
The "tools" section contains the formatting
tools you will use to create equations
false
true
From which ribbon we can find? Header and
footer, Page background
Your answer
arrow_forward
With the frmTutorSearch form still open in Design View, use the Title button to add a title to the form. Replace the default title text with Tutor Information Form. (Hint: Do not include the period.) Save and close the frmTutorSearch
arrow_forward
Move the appropriate file types from the list on the left to the correct descriptions on the right.
File Types (Icons)
XE
F
E
4
Answer Area
A file where you create the user interface
allowing you to display information and react to
user input.
A file that contains all the setup information for
your app.
A file that contains coded app logic.
A file that contains a list of available resources
to be used in the project.
arrow_forward
Instructions:
• Assignment to be completed on an individual basis.
• Open a new word document
Save as 60#######-Assignment 1
•
Save as a word document any other format will not
be marked.
• Answers are to be in complete sentences.
Turnitin® will be applied to all uploads to the
"Dropbox" of D2L.
• Each short answer question should have a minimum
of 250 words.
• All citations must be in APA Formato If your paper
does not contain any citations, your assignment will
receive a grade of '0'
• Assignment is to include a Cover Page, Table of
Contents, Body and Reference Page.
• Minimum of one external (NOT class PowerPoints)
reference per answer. You can also use class
PowerPoints to support your answers but you must
reference them.
T
P
Part B - Word Processing
Br
F
Research and discuss two advanced word processing features NOT covered in class that can
be used to increase productivity. Explain how they would help someone be able to do more
work.
CHEE AN
Question 2
arrow_forward
Match each term with the correct definition.
Put responses in the correct input to answer the question. Select a response, navigate to the desired input and insert the response. Responses can be selected and inserted using the space bar, enter key, left mouse button or touchpad. Responses can also be moved by dragging with a mouse.
universal set
subset
empty set
set
element
arrow_forward
Written Assignment #1: To submit your assignment, click on the Written Assignment #1 link above. This will take you to
a Preview Upload Assignment window. You'll need to scroll down to Assignment Submission. From here you can write a text
submission or select Browse My Computer and find your file.
Directions: Answer each of the following questions. Show your work or explain how you arrived at your conclusion whenever
appropriate. Use your calculator.
In a random sample of 175 community college students, the mean number of hours spent studying per week is 13.7 hours and
the standard deviation is 4 hours.
a) Find the standard score (z-score) for students who study the following hours in a particular week. Round Z to the nearest
hundredth and interpret the meaning of each answer as it pertains to this problem.
i) 22 hours
ii) 6 hours
b)Assuming the distribution of the number of hours community college students study per week is normally distributed,
approximately how many of the students…
arrow_forward
42
Question 5
To make adjustments to your reference markers, you would navigate to the References
tab and open the
and
dialog box.
Bibliography/References
Footnote/Endnote
Table of Contents/References
O References / Citations
arrow_forward
A bold font is used:
Group of answer choices
In Level 1 Heading text
For the title of the paper on the title page
In table numbers on the actual table
For the title of the paper on the first page of the paper
Bold fonts are used in all these places
arrow_forward
print this image as output
arrow_forward
This section has a total of 6 questions.
Upload all scanned documents/files/ compressed folder in the linH
the end of Question 26.
Use the expression F = ((AC) +B') (C Đ A O B) to draw the Truth Table.
A -
I
Use the upload link after Question 26 to upload the answer. (image, word, pdf, or any
practical files)
استخدم رابط التحميل بعد السؤال 26 لتحميل الإجابة. )صورة، كلمة، pdf، او الملفات العملية(
H Dacimal pumbers with necessary steps.
arrow_forward
Please view attachment before answering. The attachment is the table and its contents. I am in need of assistance with part A. I am unsure on how i can go about attempting the question. I am using mysql terminal. Please explain solution in detail so i can fully understand . Attaching a visual will be of great help as well. (as in a screenshot or so) Thank you so much in advance!
Part A - Write a query that will give the employee names with the first letter capitalized and all other letters in lowercase. Label the column appropriately.
arrow_forward
Page Layout
insert
References
Mailings
Review
View
* Cut
Copy
Calibri (Body) - 11 - AA
Aa" | 三.ミ,,|章作|↓
AaBbCcDc AaBbCcDc AaBbC AaBbCc AaB AaBbCc. AqBbCcD AaBbCcDt AaBbCc
BIU abe x, x
A- V - A-
年二。1-
Format Painter
1 Normal
T No Spaci. Heading 1
Heading 2
Title
Subtitle
Subtle Em..
Emphasis
Intense E
Clipboard
Font
Paragraph
Styles
creat a program with function calculator function that take operand and operators from users
Page 1 of 1
Words 14 Enylish U.S
W
Type here to search
arrow_forward
Week 4 IPO
Assignment Content
There are 4question Create IPO chart
q1. When Trina began her trip from New York to Florida, she filled her car's tank with
gas and
reset its trip meter to zero. After traveling 324 miles, Trina stopped at a gas station to refuel; the
gas tank required 17 gallons.
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Related Questions
- Written Use Case Follow the sample format shown in the attached photo.Sample have its label, while the one you should make a written use case is the one who have blue ovalsNOTE: YOU SHOULD MAKE THE WRITTEN USE CASE AS YOU CAN SEE IN THE SAMPLE TABLE. SOMEONE IS ANSWERING MY QUESTION WRONG!arrow_forwardDeliverable length: 5–8 PowerPoint Presentation slides with speaker notes (excluding the title and reference slide); including detailed speaker notes of 200–250 words speaker notes for each slide As the new HR manager of a jewelry company, you have put together some preliminary reports for the CEO. One of the reports you compiled focuses on employee turnover. The jewelry company is an organization with aggressive expansion goals. In the last 2 years, the company has continually hired new employees, yet it has not achieved the staffing levels it desired. The company knew that some employees had left the organization, but turnover rates have not been formally tracked. After your preliminary fact-finding, you were surprised to discover that the turnover rate for the past year was 38%. You know the CEO will not be pleased with this turnover rate, and you have made the decision to prepare yourself more before presenting the report to the CEO. Turnover…arrow_forwardExecute the following: Split the text into two columns, Change the table design Your answer The "tools" section contains the formatting tools you will use to create equations false true From which ribbon we can find? Header and footer, Page background Your answerarrow_forward
- With the frmTutorSearch form still open in Design View, use the Title button to add a title to the form. Replace the default title text with Tutor Information Form. (Hint: Do not include the period.) Save and close the frmTutorSearcharrow_forwardMove the appropriate file types from the list on the left to the correct descriptions on the right. File Types (Icons) XE F E 4 Answer Area A file where you create the user interface allowing you to display information and react to user input. A file that contains all the setup information for your app. A file that contains coded app logic. A file that contains a list of available resources to be used in the project.arrow_forwardInstructions: • Assignment to be completed on an individual basis. • Open a new word document Save as 60#######-Assignment 1 • Save as a word document any other format will not be marked. • Answers are to be in complete sentences. Turnitin® will be applied to all uploads to the "Dropbox" of D2L. • Each short answer question should have a minimum of 250 words. • All citations must be in APA Formato If your paper does not contain any citations, your assignment will receive a grade of '0' • Assignment is to include a Cover Page, Table of Contents, Body and Reference Page. • Minimum of one external (NOT class PowerPoints) reference per answer. You can also use class PowerPoints to support your answers but you must reference them. T P Part B - Word Processing Br F Research and discuss two advanced word processing features NOT covered in class that can be used to increase productivity. Explain how they would help someone be able to do more work. CHEE AN Question 2arrow_forward
- Match each term with the correct definition. Put responses in the correct input to answer the question. Select a response, navigate to the desired input and insert the response. Responses can be selected and inserted using the space bar, enter key, left mouse button or touchpad. Responses can also be moved by dragging with a mouse. universal set subset empty set set elementarrow_forwardWritten Assignment #1: To submit your assignment, click on the Written Assignment #1 link above. This will take you to a Preview Upload Assignment window. You'll need to scroll down to Assignment Submission. From here you can write a text submission or select Browse My Computer and find your file. Directions: Answer each of the following questions. Show your work or explain how you arrived at your conclusion whenever appropriate. Use your calculator. In a random sample of 175 community college students, the mean number of hours spent studying per week is 13.7 hours and the standard deviation is 4 hours. a) Find the standard score (z-score) for students who study the following hours in a particular week. Round Z to the nearest hundredth and interpret the meaning of each answer as it pertains to this problem. i) 22 hours ii) 6 hours b)Assuming the distribution of the number of hours community college students study per week is normally distributed, approximately how many of the students…arrow_forward42 Question 5 To make adjustments to your reference markers, you would navigate to the References tab and open the and dialog box. Bibliography/References Footnote/Endnote Table of Contents/References O References / Citationsarrow_forward
- A bold font is used: Group of answer choices In Level 1 Heading text For the title of the paper on the title page In table numbers on the actual table For the title of the paper on the first page of the paper Bold fonts are used in all these placesarrow_forwardprint this image as outputarrow_forwardThis section has a total of 6 questions. Upload all scanned documents/files/ compressed folder in the linH the end of Question 26. Use the expression F = ((AC) +B') (C Đ A O B) to draw the Truth Table. A - I Use the upload link after Question 26 to upload the answer. (image, word, pdf, or any practical files) استخدم رابط التحميل بعد السؤال 26 لتحميل الإجابة. )صورة، كلمة، pdf، او الملفات العملية( H Dacimal pumbers with necessary steps.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- COMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE LNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage