All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Hire a Tutor
AI Study Help
New
Search
Search
Sign In
Register
study help
computer science
starting out with python
Questions and Answers of
Starting Out With Python
Assume the variable dct references a dictionary. Write an if statement that determines whether the key 'James' exists in the dictionary. If so, display the value that is associated with that key. If
Write a program that opens a specified text file then displays a list of all the unique words found in the file.Store each word as an element of a set.
Suppose a dictionary named employee has been created. What does the following statement do?employee['id'] = 54321
You can use _________ to create an empty dictionary.a. {}b. ()c. [ ]d. empty()
True or FalseA list can be a dictionary key.
What will occur when the following code is executed?months = {'Jan':1, 'Feb':2, 'Mar':3}months[2]
Assume the variable dct references a dictionary. Write an if statement that determines whether the key 'Jon' exists in the dictionary. If so, assign the value of 'Jon' to a key of 'John', and then
Write a program that generates 100 random numbers between 1 and 10. The program should store the frequency of each number generated in a dictionary with the number as the key and the amount of times
What will the following code display?stuff = {1 : 'aaa', 2 : 'bbb', 3 : 'ccc'}print(stuff[3])
The _________ method returns a randomly selected key-value pair from a dictionary.a. Pop()b. Random()c. Popitem()d. Rand_pop()
After the following statement executes, what elements will be stored in the myset set?myset = set(['a', 'bb', 'ccc', 'dddd'])
Are the elements of a set ordered or unordered?
This operator can be used to find the union of two sets.a. |b. &c. −d. ˆ
What will the following code display? myset = set('1 2 3')print(len(myset))
Does a set allow you to store duplicate elements?
This operator can be used to find the difference of two sets.a. |b. &c. −d. ˆ
After the following code executes, what elements will be members of set3?set1 = set([10, 20, 30, 40])set2 = set([40, 50, 60])set3 = set1.union(set2)
How do you create an empty set?
This operator can be used to find the intersection of two sets.a. |b. &c. −d. ˆ
After the following code executes, what elements will be members of set3?set1 = set(['o', 'p', 's', 'v'])set2 = set(['a', 'p', 'r', 's'])set3 = set1.intersection(set2)
After the following statement executes, what elements will be stored in the myset set?myset = set('Jupiter')
This operator can be used to find the symmetric difference of two sets.a. |b. &c. −d. ˆ
After the following code executes, what elements will be members of set3?set1 = set(['d', 'e', 'f'])set2 = set(['a', 'b', 'c', 'd', 'e'])set3 = set1.difference(set2)
After the following statement executes, what elements will be stored in the myset set?myset = set(25)
After the following code executes, what elements will be members of set3?set1 = set(['d', 'e', 'f'])set2 = set(['a', 'b', 'c', 'd', 'e'])set3 = set2.difference(set1)
After the following statement executes, what elements will be stored in the myset set?myset = set('www xxx yyy zzz')
After the following code executes, what elements will be members of set3?set1 = set([1, 2, 3])set2 = set([2, 3, 4])set3 = set1.symmetric_difference(set2)
After the following statement executes, what elements will be stored in the myset set?myset = set([1, 2, 2, 3, 4, 4, 4])
Look at the following code:set1 = set('abc')set2 = set('def')What would be the result of calculating the intersection of set1 and set2? Which other set operation would produce the same result as the
After the following statement executes, what elements will be stored in the myset set?myset = set(['www', 'xxx', 'yyy', 'zzz'])
How do you determine the number of elements in a set?
After the following statement executes, what elements will be stored in the myset set?myset = set([10, 9, 8])myset.update([1, 2, 3])
After the following statement executes, what elements will be stored in the myset set?myset = set([10, 9, 8])myset.update('abc')
What is the difference between the remove and discard methods?
How can you determine whether a specific element exists in a set?
After the following code executes, what elements will be members of set3?set1 = set([10, 20, 30])set2 = set([100, 200, 300])set3 = set1.union(set2)
After the following code executes, what elements will be members of set3?set1 = set([1, 2, 3, 4])set2 = set([3, 4, 5, 6])set3 = set1.intersection(set2)
After the following code executes, what elements will be members of set3?set1 = set([1, 2, 3, 4])set2 = set([3, 4, 5, 6])set3 = set1.difference(set2)
After the following code executes, what elements will be members of set3?set1 = set([1, 2, 3, 4])set2 = set([3, 4, 5, 6])set3 = set2.difference(set1)
After the following code executes, what elements will be members of set3?set1 = set(['a', 'b', 'c'])set2 = set(['b', 'c', 'd'])set3 = set1.symmetric_difference(set2)
Look at the following code:set1 = set([1, 2, 3, 4])set2 = set([2, 3])Which of the sets is a subset of the other?Which of the sets is a superset of the other?
What is object serialization?
When you open a file for the purpose of saving a pickled object to it, what file access mode do you use?
When you open a file for the purpose of retrieving a pickled object from it, what file access mode do you use?
What module do you import if you want to pickle objects?
What function do you call to pickle an object?
What function do you call to retrieve and unpickle an object?
What is an object?
The ______________ programming practice is centered on creating functions that are separate from the data that they work on.a. Modularb. Proceduralc. Functionald. Object-oriented
True or FalseThe practice of procedural programming is centered on the creation of objects.
Write a definition for a class Book. The Book class has data attributes for a title, an author name and the number of pages. The class also has the following methods:a. An _ _init_ _ method for the
Write a class named Pet, which should have the following data attributes:• _ _name (for the name of a pet)• _ _animal_type (for the type of animal that a pet is. Example values are ‘Dog’,
The ______________ programming practice is centered on creating objects.a. Object-centricb. Objectivec. Procedurald. Object-oriented
A(n) ______________ is a component of a class that references data.a. Methodb. Instancec. Data attributed. Module
True or FalseIt is a common practice in object-oriented programming to make all of a class’s data attributes accessible to statements outside the class.
What are public methods? What are private methods?
An object is a(n) ______________.a. Blueprintb. Cookie cutterc. Variabled. Instance
The part of a problem that can be solved without recursion is the _______________ case.a. Baseb. Solvablec. Knownd. Iterative
Is recursion ever required to solve a problem? What other approach can you use to solve a problem that is repetitive in nature?
The following function uses a loop. Rewrite it as a recursive function that performs the same operation.def queue(length):while length > 0:print('Please wait.')length = length – 1print('It is your
Write a recursive function that accepts an integer argument, n. The function should display n lines of asterisks on the screen, with the first line showing 1 asterisk, the second line showing 2
The part of a problem that is solved with recursion is the _______________ case.a. Baseb. Iterativec. Unknownd. Recursion
Design a function that accepts a list as an argument and returns the largest value in the list. The function should use recursion to find the largest item.
When a function explicitly calls itself, it is called _______________ recursion.a. Explicitb. Modalc. Directd. Indirect
Why is an object’s internal data usually hidden from outside code?
Write a class named Car that has the following data attributes:• _ _year_model (for the car’s year model)• _ _make (for the make of the car)• _ _speed (for the car’s current speed)The Car
Write a class definition named Book. The Book class should have data attributes for a book’s title, the author’s name, and the publisher’s name. The class should also have the following:a. An _
How are an object’s data attributes made inaccessible to code outside the class definition?
True or FalseObject reusability has been a factor in the increased use of object-oriented programming.
Design a function that accepts a list of numbers as an argument. The function should recursivelycalculate the sum of all the numbers in the list and return that value.
When possible, you should avoid using __________ variables in a program.a. Localb. Globalc. Referenced. Parameter
True or FalseYou do not need to have an import statement in a program to use the functions in the random module.
What are the pieces of data that are passed into a function called?
This is a prewritten function that is built into a programming language.a. Standard functionb. Library functionc. Custom functiond. Cafeteria function
True or FalseComplex mathematical expressions can sometimes be simplified by breaking out part of the expression and putting it in a function.
Suppose you want to select a random number from the following sequence:0, 5, 10, 15, 20, 25, 30What library function would you use?
The following statement calls a function named half, which returns a value that is half that of the argument. (Assume the number variable references a float value.) Write code for the function.result
There are three seating categories at a stadium. Class A seats cost $20, Class B seats cost $15, and Class C seats cost $10. Write a program that asks how many tickets for each class of seats were
What does the phrase “calling a function” mean?
A(n) __________ is the part of a program in which a variable may be accessed.a. Declaration spaceb. Area of visibilityc. Scoped. Mode
True or FalseIn Python, you cannot write functions that accept multiple arguments.
What statement do you have to have in a value-returning function?
A program contains the following function definition:def cube(num):return num * num * numWrite a statement that passes the value 4 to this function and assigns its return value to the variable result.
A painting company has determined that for every 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Write a
When a function is executing, what happens when the end of the function’s block is reached?
Why must you indent the statements in a block?
A(n) __________ is a piece of data that is sent into a function.a. Argumentb. Parameterc. Headerd. Packet
True or FalseIn Python, you can specify which parameter an argument should be passed into a function call.
Draw an IPO chart that documents the input, processing, and output of the built-in input function.
Write a function named times_ten that accepts a number as an argument. When the function is called, it should return the value of its argument multiplied times 10.
A retail company must file a monthly sales tax report listing the total sales for the month, and the amount of state and county sales tax collected. The state sales tax rate is 5 percent and the
What is a local variable? How is access to a local variable restricted?
A(n) __________ is a special variable that receives a piece of data when a function is called.a. Argumentb. Parameterc. Headerd. Packet
True or FalseYou cannot have both keyword arguments and non-keyword arguments in a function call.
What is a Boolean function?
Write a function named is_valid_length that accepts a string and an integer as arguments. When the function is called, it should return False if the length of the string is greater than the integer,
One foot equals 12 inches. Write a function named feet_to_inches that accepts a number of feet as an argument and returns the number of inches in that many feet. Use the function in a program that
What is a variable’s scope?
A variable that is visible to every function in a program file is a __________.a. Local variableb. Universal variablec. Program-wide variabled. Global variable
True or FalseSome library functions are built into the Python interpreter.
Showing 100 - 200
of 839
1
2
3
4
5
6
7
8
9