Question

In: Computer Science

Python Question 5 (Multiple Choice) msg1 = "My favorite number is " + str(fav_num) + "."...

Python

Question 5 (Multiple Choice)

msg1 = "My favorite number is " + str(fav_num) + "." msg2 = "My favorite number is "+str(fav_num)+"." Why would msg1 be preferred over msg2
(a)The user output is easier to read

(b)The code is easier to read. (c)Both a and b

Question 6

Given this list: pets = ['teddy', 'jessie', 'skippy'] Be sure to refer to the list element by its index Write the python statement whose output is: Hello SKIPPY; you are a fine parrot!

Note: print("Hello SKIPPY; you are a fine parrot!") is incorrect

Question 7

Using the list in Question 6
Write the python statement to add 'spot' to the list between 'teddy' and 'jessie'.

Question 8

Using the list updated in Question 7
Write the python statement to remove 'jessie' from the list.

Solutions

Expert Solution

Question 5:

Answer :(b)The code is easier to read.

Explanation :

  • Both the statement msg1 and msg2 will produce the same output
  • But in case msg1 the code is easier to read

Below screen show the demonstration

*************************************************

Question 6 :

Answer :print("Hello "+pets[2].upper()+"; you are a fine parrot!")

Explanation :

  • list elements can be accessed from the list using listname[index]
  • hence pets[2] will get the skippy from the list and upper() will convert it into upper case

Demonstration :Below screen shows the demonstration

***************************************************

Question 7 :

Answer :pets.insert(1,'spot')

Explanation :Insert() method is used to insert an element into the list at given index

Demonstration :Below screen shows the output

********************************************

Question 8:

Answer :pets.remove('jessie')

Explanation :remove() method is used to remove an element from the list

Demonstration :Below screen shows the code and output


Related Solutions

this is multiple choice question, this is my mid term question, please do not give the...
this is multiple choice question, this is my mid term question, please do not give the answers by guessing because these marks really improtant to me, answer only if you are 100% sure, Thank you so much. 1) Which of the following is not a type of auditor's opinion? a) Qualified b)Adverse c) Unmodified d)Disclaimer of opinions e) Ordinary 2) Which of the following is least likely to be considered a covered member for the purpose of this year auditing...
I have 5 multiple choice question related to my accounting class. 1. In the "time interest...
I have 5 multiple choice question related to my accounting class. 1. In the "time interest earned" ratio, the numerator should be income before deducting (select the best answer): A. interest Expense B. Income tax expense C. Both A & B D. None of the above 2. A lender accepts real estate with a fair value of $15,000,000 in full settlement of a $20,000,000 loan. the real estate has a carrying value of $19,000,000 on the bond of the borrower....
Use Python, please type. A multiple-choice quiz with 5 questions. Each question has 4 possible answers...
Use Python, please type. A multiple-choice quiz with 5 questions. Each question has 4 possible answers labelled A, B, C and D.    After displaying the first question and the 4 possible answers, the user is asked to enter their choice. If their choice is correct, add 1 to the score, then display the next question and its 4 possible answers. At the end of the quiz, display their score out of 5, their score as a percentage, and if...
Write a shell script of the following: “A Multiple Choice Question that contains 5 questions and...
Write a shell script of the following: “A Multiple Choice Question that contains 5 questions and each question carries 2 options. Choice will be given by the students. A record file is created each time the script runs to store the answers along with the total marks obtained. The record filename that has date and timing information as well as the student name.
Multiple Choice question on Auditor's Report
The section of the annual report that is the report of the independent registered public accounting firm is often referred to as the  A. Auditor's Report B. Management's discussion and Analysis of Financial condition and results           of operations Report C.Business Overview Report D.Notes to Financial statements Report
1. A student takes a 12 question multiple choice test. There are 5 answer choices, and...
1. A student takes a 12 question multiple choice test. There are 5 answer choices, and the student guesses on all the questions. What is the probability the student will get exactly 7 questions correct in order to pass? Round to 5 decimal places. a. 0.00332 b. 0.00587 c. 0.08304 d. 0.00213 2. If the probability of a machine producing a defective part is 0.05, what is the probability of finding exactly 5 defective parts from a sample of 100?...
You take a quiz that consists of 5 multiple-choice questions. Each question has 5 possible answers,...
You take a quiz that consists of 5 multiple-choice questions. Each question has 5 possible answers, only one of which is correct. You will randomly guess the answer to each question. The random variable represents the number of correct answers. Construct the probability distribution for this random variable.
A student is given 20 multiple choice questions. Each multiple choice question has 4 options &...
A student is given 20 multiple choice questions. Each multiple choice question has 4 options & only one correct answer. The student answers all the questions in a random manner. a) What is the probability the student scores 80% or above? b) What is the probability the student scores 50% or above?
Your instructor administers a 5 question multiple choice test. Each question has 4 possible answers of...
Your instructor administers a 5 question multiple choice test. Each question has 4 possible answers of which 1 answer is correct. Find the probability of getting at least 1 question correct You and 5 friends are interested in forming a club. How many different ways can a President, Treasurer and Secretary be selected? A journalist has 10 books to review. Of the 10 books being reviewed, he can select 4 reviews for publication. How many ways can the 4 reviews...
my question is in python. My question is how to add post users to post gres...
my question is in python. My question is how to add post users to post gres in python
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT