Question

In: Computer Science

In Python, suppose you had: >>> a_name = 'Byb' Then is this legal? >>> a_name[1] =...

In Python, suppose you had:

>>> a_name = 'Byb'

Then is this legal?

>>> a_name[1] = 'o'

  1. _________________

If not why not?

  1. _________________

Solutions

Expert Solution

Answer: The statement a_name[1] = 'o' is not a legal statement.

Explanation: a_name = 'Byb' indicates string object.But a_name[1] = 'o' indicates list item.In python lists are declared as fruits = ['apple','banana'] ,the second statement is legal when such type of list is declared in the code.

code:


Related Solutions

This should be in Python Statement : A lot of people drink and drive. The legal...
This should be in Python Statement : A lot of people drink and drive. The legal blood alcohol level is .08%. Blood alcohol level largely depends on an individual’s BMI and the percentage and amount of whatever it is they consumed. This program could potentially help users estimate how long to wait before driving, if they must drive. Program Description This program will: Give the most recent statistics of drinking and driving in California. It will allow user to create...
What experience have you had with the legal system? Do not wish to infringe on anyone’s...
What experience have you had with the legal system? Do not wish to infringe on anyone’s privacy. Did you hire a lawyer? What would your recommendations to others be, based on your experience?
Intro to python question: #Recall in the lesson on sorts that we had you complete the...
Intro to python question: #Recall in the lesson on sorts that we had you complete the #Bubble and Selection sort, and we showed you Merge sort. #We didn't show any of insertion sort, and I bet you can #guess why. # #Implement insertion sort below. # #Name your function 'insertion'. insertion should take as #input a list, and return as output a sorted list. Note that #even though technically a sorting method does not have to #return the sorted list,...
Suppose a car insurance company sells you an insurance policy that “gets you legal” and costs...
Suppose a car insurance company sells you an insurance policy that “gets you legal” and costs $7.50 per month. What is the problem with this insurance policy? What does it mean to have only 25/50/25 liability coverage for the following situations (what could the insurance company pay)? a. If you hit someone (you are at fault)? b. If someone hits you (they are at fault) and is insured? c. If someone hits you (they are at fault) and is not...
Suppose at time 0 you had $2500 in the bank and 21 years later you had...
Suppose at time 0 you had $2500 in the bank and 21 years later you had $15650. Calculate the effective annual rate of return if the bank pays interest: Continuously
Python Problem Problem 1: In this problem you are asked to write a Python program to...
Python Problem Problem 1: In this problem you are asked to write a Python program to find the greatest and smallest elements in the list. The user gives the size of the list and its elements (positive and negative integers) as the input. Sample Output: Enter size of the list: 7 Enter element: 2 Enter element: 3 Enter element: 4 Enter element: 6 Enter element: 8 Enter element: 10 Enter element: 12 Greatest element in the list is: 12 Smallest...
Use Python to solve: show all code: 2) For the last assignment you had to write...
Use Python to solve: show all code: 2) For the last assignment you had to write a program that calculated and displayed the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. The program output looked like this: Balance after year 1 is $ 1060.0 Balance after year 2 is $ 1123.6 Balance after year 3 is $ 1191.02 Balance after year 4 is $ 1262.48 Balance after...
Suppose you won the lottery and had two options: (1) receiving $0.1 million or (2) taking...
Suppose you won the lottery and had two options: (1) receiving $0.1 million or (2) taking a gamble in which, at the flip of a coin, you receive $0.2 million if a head comes up but receive zero if a tail comes up. What is the expected value of the gamble? Round your answer to two decimal places. Enter your answer in millions. For example, an answer of $550,000 should be entered as 0.55. million Would you take the sure...
Python 1.Suppose you were going to design an event-driven application like the famous wack-a-mole game. Do...
Python 1.Suppose you were going to design an event-driven application like the famous wack-a-mole game. Do the following: a) draw a mockup of the layout of the screen--this is usually easiest by hand. Submit a legible picture of your drawing. b) List the events your game would have to respond to (such as when certain keys are pressed). 2.Explain why you should avoid using loops to repeat actions in a GUI application. What should you do instead?
1.Suppose a dictionary Groceries maps items to quantities.     Write a python to print the names...
1.Suppose a dictionary Groceries maps items to quantities.     Write a python to print the names of the grocery items whose quantity exceeds 400.     For example, if groceries = {‘cake mixes’: 430, ‘cheese’:312, ‘Orange’:525, ‘candy bars’: 217}         The output will be                                 Cake mixes                                 Orange 2. which Python string method would be the best choice to print the number of time “the” occurs in a sentence entered by the user? Provide a one word answer. Just...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT