Question

In: Computer Science

1.For Python Which statement(s) are true regarding private class variables? private variables can be accessible inside...

1.For Python Which statement(s) are true regarding private class variables?

private variables can be accessible inside the class.

private variables can be accessible outside the class.

private variable values can be changed directly outside of the class

private variables can be changed outside the class through set methods.

2.

In the following code,

def A:
def __init__(self):
     __a = 1
     self.__b = 1
     self.c = 1
     __d__ = 1

# Other methods omitted

Which of the following is a private data field?

Group of answer choices

__a

__b

c

__d__

3.

Analyze the following code and choose the more accurate statement.

class A:
     def __init__(self, s):
         self.s = s

     def print(self):
         print(s)

a = A("Welcome")
a.print()

Group of answer choices

The program has an error because class A does not have a constructor.

The program has an error because class A should have a print method with signature print(self, s).

The program has an error because class A should have a print method with signature print(s).

The program would run if you change print(s) to print(self.s).

4.

Which of the following statement is most accurate?

Group of answer choices

A reference variable is an object.

An object is a reference type variable

An object may contain other objects.

An object may contain the references of other objects.

5.

Which special method returns a string representation of the object?

Group of answer choices

__init__ method

print method

__str__ method

constructor

6.

Class design should include ________

Group of answer choices

fields

constructor

accessor and mutator methods

other useful methods

All of the above

7.

What is max("Programming is fun")?

Group of answer choices

P

r

blank space character

u

8.

What is "Programming is fun"[1:3]?

Group of answer choices

Pr

Pro

ro

rog

Solutions

Expert Solution

1.For Python Which statement(s) are true regarding private class variables?

Answer: private variables can be accessible inside the class.

              private variables can be changed outside the class through set methods.
                  
                              

2. def __init__(self):
     __a = 1
     self.__b = 1
     self.c = 1
     __d__ = 1

# Other methods omitted

Which of the following is a private data field?

Answer: self.__b

self.__b is a private field


     


3. Analyze the following code and choose the more accurate statement.

class A:
     def __init__(self, s):
         self.s = s

     def print(self):
         print(s)

a = A("Welcome")
a.print()

Answer: The program would run if you change print(s) to print(self.s)

      


4. Which of the following statement is most accurate?

Group of answer choices

A reference variable is an object.

An object is a reference type variable

An object may contain other objects.

An object may contain the references of other objects.

Answer: An object may contain the references of other objects.

  

5. Which special method returns a string representation of the object?

Answer: __str__

      

6.Class design should include ________

Group of answer choices

fields

constructor

accessor and mutator methods

other useful methods

All of the above

answer: All of the above

     

7. What is max("Programming is fun")?

Group of answer choices

P

r

blank space character

u

answer: u

8. What is "Programming is fun"[1:3]?

Group of answer choices

Pr

Pro

ro

rog

Answer: ro


Related Solutions

Which statement is true regarding the molecular shapes A. Molecular shape can be predicted by the...
Which statement is true regarding the molecular shapes A. Molecular shape can be predicted by the number of electrons around an atom B. Molecular shape can be predicted by the number of bonds around an atom C. Molecular shape can be predicted by the number of electron pairs around an atom D. Molecular shapes cannot be predicted by the number of electrons around an atom E. Both (B) and (C)
Which statement regarding macroeconomics and microeconomics is TRUE?
 Which statement regarding macroeconomics and microeconomics is TRUE?  Neither macroeconomics nor microeconomics is concerned with prices.  Because it focuses on national economies, macroeconomics does not study international trade and finance. O Microeconomics examines consumer behavior, while macroeconomics studies business behavior.  Macroeconomics employs many of the same analytical tools as microeconomics. Prices typically contain more useful information for buyers than for sellers.  False  True A market is a physical location that enables buyers and sellers to interact and transact with one another.  True ...
1) Which of the following statement regarding macroeconomics is True? A) A country is said to...
1) Which of the following statement regarding macroeconomics is True? A) A country is said to be experiencing deflation when prices of most goods and services are rising over time. B) An economy that does not interact economically with the rest of the world is called an open economy. C) A country has a trade deficit when imports exceed exports. D) The unemployment rate is the number of employed divided by the number of unemployed. 2) Which of the following...
Select the answer for which all statement(s) is/are TRUE regarding ligands in coordination complexes: I. Complexes...
Select the answer for which all statement(s) is/are TRUE regarding ligands in coordination complexes: I. Complexes with CN = 4 are typically square planar for d^8 metal centers. II. Chelating ligands always bind the metal center in a polydentate fashion (CN ≥ 2). III. The charge of the ligands is the only component needed to determine the metal oxidation state in a complex. IV. Optical isomers exist when a molecule can be superimposed upon its mirror image. Answer choices: A)...
1. Implement the Vehicle class.  Add the following private instance variables to the Accoun class:...
1. Implement the Vehicle class.  Add the following private instance variables to the Accoun class: • An instance variable called wheelsCount of type int • An instance variable called vType of type String • An instance variable called isTruck of type boolean .  Add getters and setters for the three instance variables  Add the following methods to the Account class: • A void method called initialize that takes a parameter of type int, a String,and one double...
1- Based on our in-class discussions, which of the following statements regarding perception is not true?...
1- Based on our in-class discussions, which of the following statements regarding perception is not true? Select one: Through perception, people process information inputs into responses involving action Perceptions serve as a screen or filter through which information passes before it has an effect on people Although important, perceptions have only a minor impact on the way people respond to various situations It is through perception that people analyze information inputs into responses that translate action 2- During our review...
1. Which statement regarding workers is true? Cutting off trade with countries in which workers are...
1. Which statement regarding workers is true? Cutting off trade with countries in which workers are paid low wages improves the economic condition of these workers. Competition from low-wage nations does not cost U.S. workers their jobs. An important reason why workers in developing countries earn low wages is because of limited investment in human capital. Living conditions in poor countries are unrelated to the degree of economic freedom and a strong and fair legal system. 2. The solution to...
Which of the following is a TRUE statement regarding the treatment of scrap by a​ firm?...
Which of the following is a TRUE statement regarding the treatment of scrap by a​ firm? A. Revenue received from the sale of scrap on a job lowers the total costs for that job. B. Scrap is always allocated to a specific job. C. Scrap is separated between normal and abnormal scrap. D. There are costs assigned to scrap.
Which of the following is a true statement regarding the taxation of compensation received in the...
Which of the following is a true statement regarding the taxation of compensation received in the form of restricted property A) an employee is not taxed on compensation received in the form of restricted property B) an employee recognizes no income until the property is either (1) no longer subject to a substantial risk of forfeiture or (2) becomes transferable free of the risk,whichever occurs earlier c) an employee who receives restricted property may not elect to recognize income immediately...
Which of the following is not a true statement regarding macroevolution? a. Macroevolution and microevolution are...
Which of the following is not a true statement regarding macroevolution? a. Macroevolution and microevolution are different. b. An example of stasis is Nautilus belauensis because the species has exhibited little change over time. c. The patterns of macroevolution include lineage-splitting, stasis, reincarnation, and extinction. d. Every lineage has some chance of extinction and 99% of the species that have ever lived on earth have gone extinct. e. Over time a lineage-split can lead to a new species.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT