What will be printed upon running following code:
alist = [3, 50, "Kity", [50, 52, "Rover"], [ ], 3.14, False, 'a'] print(len(alist[3]))alist = [3, 50, "Kity", [50, 52, "Rover"], [ ], 3.14, False, 'a'] print(len(alist[3]))
8
7
2
an error
3
Select the best reason why the code below returns True, False, False respectively?
a = 256 b = 256 print(id(a) == id(b)) c = 5.1 d = 5.1 print(id(c) == id(d)) x = 257 y = 257 print(id(x) == id(y))
All the numbers (both integers and floating point numbers) are immutable in Python and this has nothing to do with number of references
floating point numbers are mutable in Python and this has nothing to do with number of references
numbers grater than 256 are mutable in Python and this has nothing to do with id function
numbers between -5 and 256 inclusive are immutable in Python and this has nothing to do with id function
Python creates single objects (singletons) for values between -5 and 256 inclusive and this has nothing to do with mutability
As shown in below code the function, getrefcount() in sys module returns the count of all the references to a given object or a value. Please carefully analyze the following code and select all the correct conclusions that you can make:
import sys print(id(1)) alist = [1,1,1, 500, 500] print(id(1)) print(id(alist[0])) print(id(alist[4])) print(id(500)) print(sys.getrefcount(1)) print(sys.getrefcount(500))
for multiple objects referring to value 1 python creates multiple references to a single value 1
for objects referring to value 1 python creates multiple values 1 and multiple references to those multiple values
for multiple objects referring to value 500 python creates multiple references to a single value 500
for multiple objects referring to value 500 python creates multiple values of 500 and multiple references to those multiple values
Python seems to be using the value 1 a lot: lot more than value 500
Select all the lines of code that give you vowels = ['a', 'e', 'i', 'o', 'u']:
vowels = list("aeiou")
vowels = "a e i o u".split()
vowels = [ letters for letters in "aeiou"]
vowels = [ letters for letters in "abcdefghijklmnopqrstuvwzyz" if letters in "aeiou"]
vowels = "aeiou".split()
Select why the following code return a Typeerror:
t1 = (1,2, "test", 10) t1[2] = "pass"
Tuples are immutable
Tuples are mutable
Strings are immutable
Strings are mutable
String object does not support item assignment
1)What will be printed upon running the following code:
print(len(alist[3])) = 3 ([50, 52, "Rover"])
print(len(alist[3])) = 3 ( ([50, 52, "Rover"]))
2)Select all the lines of code that give you vowels = ['a', 'e', 'i', 'o', 'u']:
vowels = list("aeiou")
vowels = "a e i o u".split()
vowels = [ letters for letters in "aeiou"]
vowels = [ letters for letters in "abcdefghijklmnopqrstuvwzyz" if letters in "aeiou"]
vowels = "aeiou".split()
ANS)) here all lines of codes gives vowels but first 4 lines of codes gives vowels in the form of list ->( ['a', 'e', 'i', 'o', 'u'])
but last one gives vowels in the form of string in a list ->( ['aeiou'])
3)Select why the following code return a Typeerror:
t1 = (1,2, "test", 10)
t1[2] = "pass"
ANS)) tuples are immutable because the tuple itself isn't mutable it doesn't have any methods for changing its content.
What will be printed upon running following code: alist = [3, 50, "Kity", [50, 52, "Rover"],...
D Question 12 1.5 pts Check the true statements about NumPy arrays: O A single instantiated NumPy array can store multiple types (e.g., ints and strings) in its individual element positions. A NumPy array object can be instantiated using multiple types (e.g., ints and strings) in the list passed to its constructor O Memory freeing will require a double-nested loop. The number of bits used to store a particular NumPy array object is fixed. O The numpy.append(my.array, new_list) operation mutates...
For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print('\nStart of A2 Student class demo ') s1 = Student('David Miller', major = 'Hist',enrolled = 'y', credits = 0, qpoints = 0) s2 = Student('Sonia Fillmore', major = 'Math',enrolled = 'y', credits = 90, qpoints = 315) s3 = Student('A. Einstein', major = 'Phys',enrolled = 'y', credits = 0, qpoints = 0) s4 = Student('W. A. Mozart', major = 'Mus',enrolled = 'n', credits = 29, qpoints...
QUESTION 1 What will be displayed as a result of executing the following code? int x = 5, y = 20; x += 32; y /= 4; cout <<"x = " << x <<"y = " << y; A. x = 32, y = 4 B. x = 9, y = 52 C. x = 37, y = 5 D. x = 160, y = 80 8 points QUESTION 2 What will be the displayed when the following code...
Santa Monica College CS 20A: Data Structures with C++ Spring 2019 Name: True/False: Circle one Assignment 1 ID: 1. True / False 2. True / False 3. True / False 4. True / False 5. True / False 6. True / False 7. True / False 8. True / False 9. True / False 10. True / False Variable and functions identifiers can only begin with alphabet and digit. Compile time array sizes can be non-constant variables. Compile time array...
Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...
python 3 question Project Description Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gradebook software to keep track of your grades. Some instructors like to calculate grades based on what is sometimes called a “total points” system. This is the simplest way to calculate grades. A student’s grade is the sum of the points earned on all assignments divided by the sum of the points available...
These are my answere to the following questions: are they right? 1. B 2. T 3. T 4. T 5. F 6. T 7. A 8. D 9. E 10. B 11. B 12. A 13. A 14. D 15. C 16. D 17. T 18. C 19. T 20. T 21. T 22. A 23. T 24. D 25. B 26. A 27. A 28. A 29. T 30. C 31. D 32. A 33. T 34. F 35....
What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that share a set of tasks, even though the tasks are executed in different ways. Polymorphism allows a programmer to use a subclass object in place of a superclass object. Polymorphism allows a subclass to override a superclass method by providing a completely new implementation. Polymorphism allows a subclass to extend a superclass method by performing the superclass task plus some additional work. Assume that...
Please answer the following in Python: The cost of a travel pass includes a $5 administrative charge and the cost of one unit of trips (or 10 trips) at $1.50 per trip. A passenger who has a travel pass can perform these operations make trips as long as there is at least one unconsumed trip, top up in multiples of units of trips without incurring administrative charge get a refund at $1.20 per unconsumed trip C) C) C) When a...
The following are screen grabs of the provided files Thanks so much for your help, and have a nice day! My Java Programming Teacher Gave me this for practice before the exam, butI can't get it to work, and I need a working version to discuss with my teacher ASAP, and I would like to sleep at some point before the exam. Please Help TEST QUESTION 5: Tamagotchi For this question, you will write a number of classes that you...