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...
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
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...
Please use the python and explain. Also please show python. Suppose that a cashier owes a...
Please use the python and explain. Also please show python. Suppose that a cashier owes a customer some change and that the cashier only has quarters, dimes, nickels, and pennies. Write a program the computes the minimum number of coins that the cashier can return. To solve this problem use the greedy algorithm explained below. PROBLEM STATEMENT: Your program should first ask the user for the amount of money he/she is owed (in dollars). You may assume that the user...
Python #For question 1 and 2 you may not use ''' ''' Question 1 Print the...
Python #For question 1 and 2 you may not use ''' ''' Question 1 Print the messages below without using variables. Output must be 2 lines identical to below: What is the snake's favorite language? "I love Python", said the snake. Question 2 Write a python statements to match the 5 lines of output below. Use a single print statement to produce the list of 4 languages The 3 most popular programming languages of 2020 are: 1.         Python 2.         Javascript 3.         Java 4.         C#...
Suppose you were interested in crop yields and you had collected data on the amount of...
Suppose you were interested in crop yields and you had collected data on the amount of rainfall, the amount of fertilizer, the average temperature, and the number of sunny days. How could you formalize this a as regression problem?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT