Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Provide your own examples of the following using Python lists. Create your own examples. Do not
copy them from another source.
Nested lists
The “*” operator
List slices
The “+=” operator
A list Õlter
A list operation that is legal but does the "wrong" thing, not what the programmer expects
Provide the Python code and output for your program and all your examples.
Write a Python program that does the following.
Create a string that is a long series of words separated by spaces. The string is your own creative
choice. It can be names, favorite foods, animals, anything. Just make it up yourself. Do not copy
the string from another source.
Turn the string into a list of words using split.
Delete three words from the list, but delete each one using a diàerent kind of Python operation.
Sort the list.
Add new words to the list (three or more) using three diàerent kinds of Python operation.
Turn the list of words back into a single string using join.
Print the string.
Describe the diàerence between objects and values using the terms “equivalent” and “identical”.
Illustrate the diàerence using your own examples with Python lists and the “is” operator.
Describe the relationship between objects, references, and aliasing. Again, create your own
examples with Python lists.
Finally, create your own example of a function that modiÕes a list passed in as an argument.
Describe what your function does in terms of arguments, parameters, objects, and references.
Write a program that accepts a number as input, and prints just the decimal portion. Your program must account for negative numbers.
The Scenario
You have decided to start a website and are creating a chatbot prototype to show investors so you can raise money and launch your website.

Your chatbot should ask the user the following (minimum requirements for the autograder) and then give answers depending on the answers the user inputs:

at least 5 questions, and
at least 2 if-elif-else statements.
Based on this criteria, some responses will be based on what the user types, and some will be based on random numbers.

For example, if the chatbot asks how the user is doing, your chatbot might respond I’m sorry to hear that. in response to a user input of sad, or That's great! in response to a user input of happy.

Additionally, you could also have a random number generated between, say, 1 and 3 and have a corresponding response depending on the number to randomly answer with That is great to hear. or So interesting., and so on.
Write a program that asks the user to enter a name, and then prints Nice to meet you NAME. Your program should repeat these steps until the user inputs Nope.
Develop a Python script to have a list of tourist destinations given as input each of which is worthy for a visit. We would like to select one or more randomly from the list. If the chosen one is not liked by the user, it can be rejected to select another set randomly. This will be continued until the user responds with ‘y’. Each time before the random selection, the list should be shown with rearranged values to rule out any biasness. The selection can be done repeatedly until the user signals ‘no more selection required’.
1. Consider the loop from Section 8.3 of your textbook.

prefixes = 'JKLMNOPQ'

suffix = 'ack'

for letter in prefixes:

print(letter + suffix)

Put this code into a Python script and run it. Notice that it prints the names "Oack" and "Qack".

Modify the program so that it prints "Ouack" and "Quack" but leaves the other names the same.

Include the modiÕed Python code and the output in your submission.

2. Give at least three examples that show diàerent features of string slices. Describe the feature

illustrated by each example. Invent your own examples. Do not copy them for the textbook or any

other source
Write a function named test_sqrt that prints a table like the following using a while loop, where

"dià" is the absolute value of the diàerence between my_sqrt(a) and math.sqrt(a).

a = 1 | my_sqrt(a) = 1 | math.sqrt(a) = 1.0 | diff = 0.0

a = 2 | my_sqrt(a) = 1.41421356237 | math.sqrt(a) = 1.41421356237 | diff =

2.22044604925e-16

a = 3 | my_sqrt(a) = 1.73205080757 | math.sqrt(a) = 1.73205080757 | diff =

0.0

a = 4 | my_sqrt(a) = 2.0 | math.sqrt(a) = 2.0 | diff = 0.0

a = 5 | my_sqrt(a) = 2.2360679775 | math.sqrt(a) = 2.2360679775 | diff = 0.0

a = 6 | my_sqrt(a) = 2.44948974278 | math.sqrt(a) = 2.44948974278 | diff =

0.0

a = 7 | my_sqrt(a) = 2.64575131106 | math.sqrt(a) = 2.64575131106 | diff =

0.0

a = 8 | my_sqrt(a) = 2.82842712475 | math.sqrt(a) = 2.82842712475 | diff =

4.4408920985e-16

a = 9 | my_sqrt(a) = 3.0 | math.sqrt(a) = 3.0 | diff = 0.0

Modify your program so that it outputs lines for a values from 1 to 25 instead of just 1 to 9
Encapsulate the following Python code in a function named my_sqrt that takes a as a parameter, chooses a starting value for x, and returns an estimate of the square root of a.
while True:
y = (x + a/x) / 2.0
if y == x
break
x = y
LATEST TUTORIALS
APPROVED BY CLIENTS