Betel_Negash_Lab_02-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
10
Uploaded by CoachIronVulture32
CS 171
Lab 2
Week 2
CS 171 - Lab 2
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.
•
For questions 12 and 21 of this lab you must submit screen shots of your source code (.py file)
What to submit:
•
Lab sheet in PDF format to Gradescope
Submission must be done via Gradescope
Students’ Names:
Betel Negash
User IDs (abc123): bsn37
Possible Points:
88
Your score out of 88
:
Lab Grade on 100% scale:
Graded By
(TA Signature):
CS 171
Lab 2
Week 2
Question 1:
7 points
Execute each of the below Python statements.
Write the output for each on the space provided.
(a)
(1 point)
print
(16 + 3)
19
(b)
(1 point)
print
(16
−
3)
13
(c)
(1 point)
print
(16 * 3)
48
(d)
(1 point)
print
(16 ** 3)
4096
(e)
(1 point)
print
(16 / 3)
5.33333333
(f)
(1 point)
print
(16 // 3)
5
(g)
(1 point)
print
(16 % 3)
1
Question 2:
7 points
State the arithmetic operation each symbol represents.
(a)
(1 point)
+
Addition
(b)
(1 point)
−
subtraction
(c)
(1 point)
*
multiplication
(d)
(1 point)
**
exponent
(e)
(1 point)
/
division
(f)
(1 point)
//
floor division
(g)
(1 point)
%
remainder
CS 171
Lab 2
Week 2
FYI:
An
assignment statement
is a line of code that uses a “
=
” sign. The statement stores the result of an
operation performed on the right-hand side of the sign into the variable memory location on the left-hand
side.
Question 3:
2 points
Enter and execute the following two lines of Python code:
1
2
(a)
(1 point) What does the assignment statement:
age = 15
do?
Assign the value 15 to the variable age
(b)
(1 point) What happens if you replace the comma (
,
) in the
print
statement with a plus sign
(
+
) and execute the code again?
The code crashes because of a type error you can’t concatenate a string with an integer
Question 4:
2 points
Execute the following code.
1
answer = 6 ** 2 + 3 * 4 // 2
2
final = answer % 4
(a)
(1 point) What is the value of
answer
after running the code?
42
(b)
(1 point) What is the value of
final
after running the code?
2
Question 5:
2 points
Execute the following code.
1
2
3
4
(a)
(1 point) The third line of code contains an assignment statement.
What is stored in the variable
fullName
when the line is executed?
It contains the concatenated
string “drexeluniversity” with no spaces
(b)
(1 point) How can you fix the output so that the words are separated?
Add “” between school name and type of school so it would be fullName = schoolName + " " +
typeOfSchool
FYI:
The “
+
” concatenates the two strings stored in the variables into one string. “
+
” can only be used
when both operators are strings
.
age = 15
print
(" Your age is
"
, age
)
schoolName = "Drexel"
typeOfSchool = "University"
fullName = schoolName + typeOfSchool
print
(fullName)
CS 171
Lab 2
Week 2
Question 6:
2 points
Execute the following code.
1
2
3
4
(a)
(1 point) What happens when you execute the code?
There isa type error because we are trying to concatenate an integer with a string directly
(b)
(1 point) How could you fix the code to work correctly?
By converting the integer into a string using str() function so it would be
streetAddress =
str(addressNumber) + “ “ + streetName
Question 7:
2 points
Before entering the following code into the Python interpreter, try to figure out what you think the
statement should print, then execute it.
1 myWord =
"
Hello!
"
* 10
2
print
(myWord)
(a)
(1 point) What you think it does?
I think it would print out the string yellow 10 Times
(b)
(1 point) What does it actually do?
It printed out hello 10 times
Question 8:
6 points
Let’s take a look at a program that prompts the user for two numbers and subtracts them.
1
2
3
4
(a)
(2 points) What happens when you execute the code?
There is a syntax error because it tries to subtract to input strings with out converting them to integers
(b)
(2 points) Fix the program so it works as intended. What did you do?
firstNumber = int(
input
("Enter a number: “))
secondNumber = int(
input
(“Enter a number: “))
difference = firstNumber – secondNumber
print
("Difference = ", difference)
Added int before the input to convert user inputs to integers
(c)
(2 points) What does the
int
command do?
It converts value to an integer
addressNumber = 9701
streetName = "Germantown
Ave"
streetAddress = addressNumber + streetName
print
(streetAddress)
firstNumber =
input
("Enter a number: ")
secondNumber =
input
(“Enter a number: ")
difference = firstNumber – secondNumber
print
("Difference = ", difference)
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
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
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
PHP
According to table the in the image
(Build a file to link to your database and give it the file name config.php)
(Build a file to display matrixnum, name from students table, subject_code and sub_name from subjects table and total_marks, grade from assessment table.)
Build code using javascript, to calculate total_marks and determine grade. Where total_marks are calculated by adding quiz, assignment and project and divided by 3. Where the value range of each quiz, assignment and project is 0 to 100. Next the grade will be determined based on the grading system (refer to the grading table)
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
5- The data editor has tabs for switching between (0.5 mark)
a- Data View and Variable View.
bvalues and cell contents.
c-Rows and called cases
d- the column and header,
e- each respondent in a study
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
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
Article Link:
https://www.mdpi.com/2304-6740/11/2/65Write a summary about the article
- Summarize the main idea/point(s)
- Please include excerpts from the article to emphasize a point, but it must be cited as an in-text citation. E.g. "Quote." (Author's lat name page) For example, (John 6)
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
File
Home
Insert
Draw
Page Layout
Formulas
Data
Review
View
Help
A Share
P Comments
14
fe
A
E
G
H
J
K
L
M
Q
R
1 Semeste Course NumbelCoure NameCredit Hours Letter Grad Grade Points
Directions
Create a spreadsheet that correctly
calculates your GPA - must use formulas for
GPA =
full credit. You need to inlcude grades for
two semesters. If you do not already have
two semesters worth of grades assume this
semesters grades and one future semester
worth of grades.
2
3
4
To calculate GPA dividing the total amount
5
of grade points earned by the total amount
of credit hours attempted. Your grade point
6
7
8
average may range from 0.0 to a 4.0.
9
Grade Points - multiply credit hours of
course by the number associated with the
3
letter grade you earned.
• A = 4
B = 3
C = 2
5
-7
D = 1
F = 0
1
Wine Sales
Cinderella's
Grades
Your GPA
+
+ 95%
arrow_forward
CPE162_exer3_5 [Read-Only] [Compatibility Mode] - Word
Table Tools
Ace Jan C. Lape
File
Home
Insert
Design
Layout
References
Mailings
Review
View
Help
Design
Layout
O Tell me what you want to do
& Share
X Cut
P Find -
- 11
- A A Aa -
Arial
AABBCCL AABBC AaBbCc[ AaBbCcl AaBbCcD AaBbC
akc Replace
A Select -
EE Copy
Paste
U - aly , A-
- abe x, x A
Emphasis
Heading 1
I Normal
Strong
Subtitle
Title
Format Painter
Paragraph
CPE162
Clipboard
Font
Styles
Editing
Course Number
Course Title
Computer Programming 2
Topics Covered:
ARRAY
To know what arrays are
• Implement a program to apply array manipulation and apply how to
declare arrays
Declare, define, and initialize arrays
• Write programs that access data in the array list
Objectives:
Description
Create an array of 15 integers. Add all elements located at ODD index positions and sum also
all numbers located at EVEN (Assume zero index is even) index positions in the linear array.
The user will be the one to input each item in the array of 15…
arrow_forward
print this image as output
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
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
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
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_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_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
- PHP According to table the in the image (Build a file to link to your database and give it the file name config.php) (Build a file to display matrixnum, name from students table, subject_code and sub_name from subjects table and total_marks, grade from assessment table.) Build code using javascript, to calculate total_marks and determine grade. Where total_marks are calculated by adding quiz, assignment and project and divided by 3. Where the value range of each quiz, assignment and project is 0 to 100. Next the grade will be determined based on the grading system (refer to the grading table)arrow_forwardMatch 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_forward5- The data editor has tabs for switching between (0.5 mark) a- Data View and Variable View. bvalues and cell contents. c-Rows and called cases d- the column and header, e- each respondent in a studyarrow_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_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_forwardArticle Link: https://www.mdpi.com/2304-6740/11/2/65Write a summary about the article - Summarize the main idea/point(s) - Please include excerpts from the article to emphasize a point, but it must be cited as an in-text citation. E.g. "Quote." (Author's lat name page) For example, (John 6)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_forwardFile Home Insert Draw Page Layout Formulas Data Review View Help A Share P Comments 14 fe A E G H J K L M Q R 1 Semeste Course NumbelCoure NameCredit Hours Letter Grad Grade Points Directions Create a spreadsheet that correctly calculates your GPA - must use formulas for GPA = full credit. You need to inlcude grades for two semesters. If you do not already have two semesters worth of grades assume this semesters grades and one future semester worth of grades. 2 3 4 To calculate GPA dividing the total amount 5 of grade points earned by the total amount of credit hours attempted. Your grade point 6 7 8 average may range from 0.0 to a 4.0. 9 Grade Points - multiply credit hours of course by the number associated with the 3 letter grade you earned. • A = 4 B = 3 C = 2 5 -7 D = 1 F = 0 1 Wine Sales Cinderella's Grades Your GPA + + 95%arrow_forwardCPE162_exer3_5 [Read-Only] [Compatibility Mode] - Word Table Tools Ace Jan C. Lape File Home Insert Design Layout References Mailings Review View Help Design Layout O Tell me what you want to do & Share X Cut P Find - - 11 - A A Aa - Arial AABBCCL AABBC AaBbCc[ AaBbCcl AaBbCcD AaBbC akc Replace A Select - EE Copy Paste U - aly , A- - abe x, x A Emphasis Heading 1 I Normal Strong Subtitle Title Format Painter Paragraph CPE162 Clipboard Font Styles Editing Course Number Course Title Computer Programming 2 Topics Covered: ARRAY To know what arrays are • Implement a program to apply array manipulation and apply how to declare arrays Declare, define, and initialize arrays • Write programs that access data in the array list Objectives: Description Create an array of 15 integers. Add all elements located at ODD index positions and sum also all numbers located at EVEN (Assume zero index is even) index positions in the linear array. The user will be the one to input each item in the array of 15…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:CengageNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning
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
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning