100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
ENGR 102 Exam Tested Questions With Revised Correct Detailed Answers >Latest Update>> $12.99   Add to cart

Exam (elaborations)

ENGR 102 Exam Tested Questions With Revised Correct Detailed Answers >Latest Update>>

 1 view  0 purchase
  • Course
  • ENGR 102
  • Institution
  • ENGR 102

ENGR 102 Exam Tested Questions With Revised Correct Detailed Answers >Latest Update>> 1. Write the simplest expression that captures the desired comparison. x is a key in the dict my_dict. - ANSWER x in my_dict 2. Write the simplest expression that captures the desired co...

[Show more]

Preview 4 out of 32  pages

  • November 14, 2024
  • 32
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • ENGR 102
  • ENGR 102
avatar-seller
NURSINGDICTIONARY
ENGR 102 Exam
Tested Questions With Revised
Correct Detailed Answers
>Latest Update>>

1. Write the simplest expression that captures the desired comparison.
x is a key in the dict my_dict.

- ANSWER x in my_dict
2. Write the simplest expression that captures the desired comparison.
The character 'G' exists in the string my_str.

- ANSWER 'G' in my_str
3. How do you sort my_list from highest to lowest and then print the reversed
list? for i in reversed(sorted(my_list)):
- ANSWER print(i)
4. What does any(my_list) provide?

- ANSWER If the list contains non-zero elements, any() returns True, else
returns False
5. What does all(my_list) provide?

- ANSWER If the list contains a 0 element, all() returns False because not all
elements are non-zero, else returns True
Assume that my_list is [0, 5, 10, 15].


6. What is returned by any(my_list)? What is returned by all(my_list)?

- ANSWER True, False

,for (index, value) in enumerate(my_list):
print(index, value)


7. First prints the help because we ask for it in the code
then prints the rest of the function bc we call it


def myfunction(a, b=2, c):
return a * b * c

print(myfunction(1, 2, 3)) - ANSWER will print ERRRRROOOORR


to fix it:
def myfunction(a, b=2, c=2):
return a * b * c
print(myfunction(1, 2, 3))


#everything after the first thing you change has to change in the parameters
#maria's clear explanation: "a non default parameter can't follow a default
parameter
#be better Estelle


9. def add1(x):
if x + 1 < 10:
return x + 1
else:
return 'Too big!'

,print(add1(1), add1(24)) - ANSWER 2 Too big!


10. Don't forget: the coma automatically creates a space


x=4
y = timestwo(x)
def timestwo(x):
return x * 2

print(y) - ANSWER ERRRROOOOOR
the y that calls the function is before the function and python is stupid (unlike
java) so it doesn't get it
so u put it after :)


11. also: x in the function is not the same as the x = 4


mydict = {}
mylist = [1, 2, 3, 4, 5]
mydict['Length'] = len(mylist)
mydict['Max'] = max(mylist)
mydict['Min'] = min(mylist)
mydict['Crazy'] = mylist[1] * mylist[3] - mylist[-1]
for i in mydict:

print(i + ':', mydict[i]) - ANSWER Length: 5
Max: 5

, Min: 1
Crazy: 3


12. So the index i is the key in the dict and the [i] is the value associated to that
key


[:5]

is the 5 included? - ANSWER NOPE
goes from 0-4


mystr = "Howdy! Welcome to Texas A&M Engineering!"
mylist = mystr.split()
newstr = '' # empty string
for i in range(3, len(mylist)):
newstr += mylist[i] + ' '

print(mylist[0][:5] + ' ' + newstr[:-2] + ' students!') - ANSWER Howdy Texas
A&M Engineering students!


#the newstr = Texas A&M Engineering!_


listname.pop()


listname.remove(5) - ANSWER pops the last index if you don't specify an
index

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 NURSINGDICTIONARY. 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