Answered step by step
Verified Expert Solution
Question
1 Approved Answer
QUESTION 13 OF 40 Given this class definition, what is the correct way to call the method? class Fruit(): def _init_(self, color): self.color=color def describe(self):
QUESTION 13 OF 40 Given this class definition, what is the correct way to call the method? class Fruit(): def _init_(self, color): self.color=color def describe(self): print(self.color) Apple=Fruit('red') Fruit.describe(Apple) Apple.describe('red') Fruit.describe() Apple.describe() QUESTION 12 OF 40 What is the typical relationship you will see in object-oriented code? Objects define methods, and methods define classes. Properties create objects, and objects create methods. Methods create properties and are used to define objects. Classes define properties and are used to create objects. QUESTION 5 OF 40 Which valid Java function is equivalent to this Python function? def greet(): print("hi!") greet() \{ System. out. println("hi!") \} void greet( System.out.println("hi!") ) String greet(): System.out.println("hi!"); void greet() \{ System.out.println("hi!"); 3 QUESTION 15 OF 40 When will this function return true? def check(x): if (x%2)==0: return(True) else: return(False) when the provided argument is odd when the provided argument is not zero when the provided argument is even when the provided argument is larger than 10 QUESTION 20 OF 40 What would you add as the function body for this small program to print the square of 4 ? def sqr(x): sqr(4) print("the square of {x} is {xx} ) print(f"the square of {x} is {xx}) print("the square of x is xx ") print(f"the square of x is x2) Which statement is true regarding modules and code libraries? They are imported automatically into all applications. They are usually not provided for free. They can include your code or code from others. They can only be used in a single application. QUESTION 24 OF 40 What should go into the empty placeholder for this code to print the sum of all the numbers in the list? nums=[1,2,3,4,5]sum=0print(sum) for num in nums: sum += nums [num] for num of nums: num += sum for num in nums: sum += num while num in nums: sum = sum + num QUESTION 26 OF 40 What will this code output? items1 =[1,2,3,4] items2 ={a:1, 'b':2, 'c':3, 'd':4 print(items1[2] + items2['c']) 7 5 4 6 QUESTION 33 OF 40 Which Python code won't work? coll={1:1,2:2,3:three}coll[1]=2 coll=(1,2,three)coll[1]=2 coll=[1,,,three]coll[1]=2 coll=[1,2,three]coll[1]=2 QUESTION 36 OF 40 How can you write this Python code differently? if xy : print (x) else: print(y) if x>=y print(x) else print (y) if x>y : print(y) else: print(x) if x==y : print(y) else: print (x) QUESTION 37 OF 40 Python dictionaries can also include lists, which can be accessed using an index. What can you substitute lines 6,7 , and 8 with to simplify this program? 1: person = \{ 2: "name" : "Sunita", 3: "phone" : "212-515-5555", 4: "address" : ["123 Main St", "Sydney"] 5: \} 6: address = person ["address"] 7: city = address[1] 8: print(city) print (person ["address"] ["city"]) print(person [1]) print (person ["address"] [1]) print("address"]["city"]) Which string will the regex pattern match on? "12-34-56" "98s765y4" "abc8def1" "a21b67
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started