100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
ICS 31 Study Guide Questions and Answers £10.89
Add to cart

Exam (elaborations)

ICS 31 Study Guide Questions and Answers

 2 views  0 purchase
  • Module
  • PTS
  • Institution
  • PTS

ICS 31 Study Guide Questions and AnswersWhat is one similarity between print() and input()? * Both generate a string output * Both are built-in or standard library functions When ever the Python interpreter needs to evaluate a name (of a variable, function, ...), it searched for the name i...

[Show more]

Preview 2 out of 6  pages

  • January 3, 2025
  • 6
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • PTS
  • PTS
avatar-seller
ICS 31 Study Guide Questions and
Answers
What is one similarity between print() and input()? - answer * Both generate a string
output
* Both are built-in or standard library functions

When ever the Python interpreter needs to evaluate a name (of a variable, function, ...),
it searched for the name in order:
1)
2)
3)
4) - answer 1) local
2) Global
3)Module Import
4 ) Built in

Explain the difference between 'import math' and 'from math import sqrt' or 'from math
import*' - answer 'Import math' and 'From math import*' import all the
functions/objects of the module while 'from module import sqrt' imports the specific
function/object. "From math import*' and 'From math import sqrt' allow the object to be
referred to without including the module from which it was imported, which might lead to
pollution of the name space.

What is the difference between print() and return? - answer * print(): prints the
specified message to the screen
* return : is used to end the execution of the function call and "returns" the result (value
of the expression following the return keyword) to the caller
* print example
*return example

Which operator has the lowest precedence? Why?
count %= count - offset + 2 - answer answer: (%=)
explanation: Since the modulo operator is chained with the assignment operator(which
has the lowest precedence), the %= will execute last.

Do the keys in a dictionary best model a list or a set? - answer + 5 pts [List or Set]
Set
+ 5 pts [Uniqueness] Keys must be unique
+ 5 pts [Order] Keys and sets are unordered.
+ 5 pts [Mutability] Keys are immutable, and
elements of a set have to be immutable

, Give two examples of functionality/applications that you can do with a dictionary you
can't do with a list. - answer + 2.5 pts Relationships between keys and values
+ 2.5 pts Addressing values by key rather than index

Given a value for a dictionary, is there a built-in way to lookup the corresponding key?
Explain your answer. - answer + 4 pts There is NOT a built-in way.
+ 4 pts Keys are unique while values are not.
+ 4 pts Many keys might have the same associated value.

Why does python provide so many different ways to structure & store data? What would
happen if Python didn't provide data structure? - answer +4 pts Answered first
question: many ways to associate/store data
+4 pts Programs would have an unmanageable number of variables

Give two examples of functionality/applications that you can do with a dictionary you
can't do with a list. - answer + 2.5 pts Relationships between keys and values
+ 2.5 pts Addressing values by key rather than index
+ 2.5 pts Keys are unique
+ 2.5 pts Dictionaries are unordered

When can you change the field of a namedtuple and not change the original object's id?
Write a program to demonstrate. - answer + 4 pts Answer: when the field being
changed is a mutable object
+ 4 pts Example: nt = namedtuple('nt','immutable mutable')
e = nt('s',[0])
e.mutable.append(1)

Why is it good advise to use parentheses with Boolean expressions? - answer
*overrides operator precedence
* for readability
*you can use an example with the "and" and "or" operators to increase the precedence
of the or operator

What is the difference between a function that returns None and a value returning
method? - answer *a value returning method has a return statement, a function that
returns None doesn't exist
*result of a value returning method can be used in expressions(more commonly)

Arguement - answer the value that is sent to the function when its called

Parameter - answer a variable listed inside the parenthesis in a function's definition

Why is it good advice to use parentheses with Boolean expressions? Give an example
where it is necessary. - answer + 4 pts override operator precedence
+ 4 pts For readability of a very long and unreadable boolean expression

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 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 Pogba119. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

50990 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy revision notes and other study material for 15 years now

Start selling
£10.89
  • (0)
Add to cart
Added