Answer to Question #286125 in Python for hoet

Question #286125

Write a code in python’s data structures (only in linked list) of:




Cargo system



START




Take information from user (Name, passport number)



Ask user to select country from (Australia, USA)



If Australia



Ask user “what kind of package do you want to send: a) luggage b) car c) Mail”




If a)



Ask weight of luggage



Calculate and show price= 75 $ /kg




If b)




Ask user “Select type of vehicle 1) light weight 2) heavy weight 3) motorcycles”



If 1)



“Price is =2500$”



If 2)



“Price is 3500$”




If 3)



“Price is 1000$”




If c)



Ask for address “enter address”



Show “Price is 100”




If USA



“same as above as Australia”




END



PS: you are only supposed to use linked list




1
Expert's answer
2022-01-09T13:06:30-0500
# importing module

import collections

 
# initialising a deque() of arbitrary length

linked_lst = collections.deque()

 
# filling deque() with elements

linked_lst.append('first')


linked_lst.append('second')


linked_lst.append('third')

 

print("elements in the linked_list:")


print(linked_lst)

 
# adding element at an arbitrary position

linked_lst.insert(1, 'fourth')

 

print("elements in the linked_list:")


print(linked_lst)

 
# deleting the last element
linked_lst.pop()
 

print("elements in the linked_list:")


print(linked_lst)

 
# removing a specific element

linked_lst.remove('fourth')

 

print("elements in the linked_list:")


print(linked_lst)

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS