100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
ENGR 102 Exam 1 Questions and Answers 100% Solved $12.99   Add to cart

Exam (elaborations)

ENGR 102 Exam 1 Questions and Answers 100% Solved

 4 views  0 purchase
  • Course
  • ENGR 102
  • Institution
  • ENGR 102

ENGR 102 Exam 1 Questions and Answers 100% Solved

Preview 3 out of 17  pages

  • October 21, 2024
  • 17
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • ENGR 102
  • ENGR 102
avatar-seller
TheeGrades
ENGR 102 Exam 1 Questions and
Answers 100% Solved
Which of the following represents a conditional construct? - ✔✔Does not have a loop, BUT has a branch. Question
2, Quiz 6 (the middle one)




How is repetition handled in programs? - ✔✔The loop will repeat a computation several times.



The "continue" statement is a keyword that you can put in the middle of your loop.

What does it do? - ✔✔It does not executed the below code but repeats the loop in a new iteration.




Which of the following would represent a loop? - ✔✔The one on the right with the arrow back to the top Question
4, Quiz 6 (answer C)

What will be printed when the following Python code is executed?



magic = [[4, 9, 2], [3, 5, 7], [8, 1, 6]]



diag_sum = 0 vert_sum = 0 horz_sum = 0



for i in range(3):

diag_sum += magic[i][i] vert_sum += magic[2][i] horz_sum += magic[i][1]




print(diag_sum, vert_sum, horz_sum) - ✔✔A 3x3 magic square is a 3x3 square grid filled with distinct positive
integers such that each cell contains a different integer and the sum of the
integers in each row, column and diagonal is equal. For a 3x3 grid, the following is the only unique solution.



492

357

816

Notice that the sum of any row, column or diagonal adds up to 15.

,What is printed to the console when the following Python program is executed?



a = [12.3, 25.6, 48.6] b = [78.6, 14.6, 3.5] c = b + a

print(c[1]) - ✔✔[78.6, 14.6, 3.5, 12.3, 25.6, 48.6], when lists are added, they are placed side by side, so ORDER
MATTERS.



What is the output of the following program?




language = ['P', 'y', 't', 'h', 'o', 'n'] print(language[:-4]) - ✔✔['P', 'y']


x = [] for i in range(2):

x.append(i) x += x




print(x) - ✔✔Before Loop: x = [] After Iteration 1: i = 0, x = [0, 0]
After Iteration 2: i = 1, x = [0, 0, 1, 0, 0, 1]



What will be printed when the following Python program is executed?



a = [10.0, 20.0, 30.0] b = [0, 1, 0, 2] c = 0 for i in b:

print(a[b[i]]) - ✔✔Iteration 1: i = 0, b[i] = 0, a[b[i]] = 10.0

Iteration 2: i = 1, b[i] = 1, a[b[i]] = 20.0

Iteration 3: i = 0, b[i] = 0, a[b[i]] = 10.0

Iteration 4: i = 2, b[i] = 0, a[b[i]] = 10.0


What characters are allowed when using print statements in Python? (Pick all that applies) -
✔✔letters, numbers, and underscores



The basic types of variables in Python are , floating-point, and string. -
✔✔integers

, Which of the following are valid variable names (pick one)

-Winner!

-2nd_name

-My_Name

-Gig'Em

-Gig-Em - ✔✔My_Name (does not start with a number or _ and does not have a !,',-, or space




How do you print a floating-point variable, x_value, in Python? - ✔✔print(float(x_value))




Consider the lines of code written in Python. What is the output on the screen?



=1

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller TheeGrades. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $12.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75759 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$12.99
  • (0)
  Add to cart