Assignment 2
Assignment 2
Include a Python
function to remove duplicates from a list while preserving the order.
Original List:
[25, 45, 36, 47, 69, 48, 68, 78, 14, 36, 45, 16, 25, 78, 68, 69, 47]
2.) Write out a short definition of all the data structures, including how to create them.
Include type conversion.
Hint. Include their characteristics and when they are best used.
a.) Create an empty list on line 3 and assign its type on line 4
gift_list=
answer_1=
print(answer_1)
Create an empty dictionary on one line, and assign it’s type on the next line.
grocery_items=
answer_2=
print(answer_2)
Create an empty tuple on one line, and assign it’s type on the next line.
bucket_list=
answer_2=
print(answer_2)
3.) Split the verse into a list of words. Hint: You can use a string method you learned in the
previous lesson. Hint: Use
Convert the list into a data structure that would keep only the unique elements
from the list.
5.) Select the correct way to access the value of a history subject
sampleDict = {
"class":{
"student":{
"name":"Mike",
"marks":{
"physics":70,
"History":80
x=0
a=5
b=5
if a > 0:
if b < 0:
x=x+5
elif a > 5:
x=x+4
else:
x=x+3
else:
x=x+2
print(x)
print(a)
print(b)
7.) You decide you want to play a game where you are hiding a number from someone. Store
this number in a variable called 'answer'. Another user provides a number called 'guess'.
By comparing 'guess' to 'answer', you inform the user if their guess is too high or too low.
Fill in the conditionals below to inform the user about how their guess compares to the
answer.
Hint - Fill in the conditionals below to inform the user about how their guess compares to
the answer.
if #provide conditional
result = "Oops! Your guess was too low."
elif #provide conditional
result = "Oops! Your guess was too high."
else:
result = "Nice! Your guess matched the answer!"
8.) Depending on where an individual is from we need to tax them appropriately. The states
of CA, MN, and NY have taxes of 7.5%, 9.5%, and 8.9% respectively. Use this
information to take the amount of a purchase and the corresponding state to assure that
the right amount taxes them. Explain the process (write it out).
9.)