- 13th Jul 2024
- 19:54 pm
In this assignment we will teach you how to develop algorithms and Python code to solve programming problems involving selection and iteration control structures and lists. Organization/Structure of Report:
- Section 1: Problem Analysis: In this section, student should define the problem and break it down to show what the input, outputs and processes are.
- Section 2: Solution Design: In this section student should provide Algorithms/Pseudo-code or a flowchart to explain their algorithm and the logic that will drive the Python code.
- Section 3: Implementation: In this section, student should list the complete Python Code. The student must not forget to include comments which explain what the code is doing.
- Section 4: Evaluation: In this section, student should include screenshots of their program’s output, based on various inputs provided.
- Section 5: Self-reflection: In this section, student should reflect on what the student has learned in this project and outline the challenges that were faced while working on this project, and how the student overcame them.
Developing Algorithms with Control Structures and Lists - Get Assignment Solution
Please note that this is a sample assignment solved by our Python Experts. These solutions are intended to be used for research and reference purposes only. If you can learn any concepts by going through the reports and code, then our Python Tutors would be very happy.
- To download the complete solution along with Code, Report and screenshots - Please visit our Python Assignment Sample Solution page
- Reach out to our Python Tutors to get online tutoring related to this assignment and get your doubts cleared
- You can check the partial solution for this assignment in this blog below
Free Assignment Solution - Developing Algorithms with Control Structures and Lists
#!/usr/bin/env python
# coding: utf-8
# In[37]:
total_transport_fare=0.0
total_bus_fair=0.0
total_taxi_fair=0.0
total_metro_fair=0.0
while(1):
passenger = input ("Input Passenger type : [1: standard 2:student 3:people of determination 4:senior citizen 5: to break program]")
if (passenger=='5'):
print("Program terminated") #terminate condition
break
elif (passenger=='1' or passenger=='2' or passenger=='3' or passenger=='4'):
transport = input ("Input Transportation type :[1. Bus 2. Taxi 3. Metro]") #input transport
if transport=='1':
if (passenger=='2' or passenger=='3' or passenger=='4'):
print("Current ride is free") #free for this users
else:
bus_ride=input ("Input Busride type :[1:city 2:suburb 3:capital]")
num_bus=input ("NUmber of busride ")
if bus_ride=='1':
cur_bus=float(num_bus)*2 +(float(num_bus)*2*.05) #vat is included
print("current bus fair is "+str(cur_bus))
total_bus_fair=total_bus_fair+cur_bus #total bus fair is updated
total_transport_fare=total_transport_fare+cur_bus #total transport fair is updated
elif bus_ride=='2':
cur_bus=float(num_bus)*4 +(float(num_bus)*4*.05) #for suburub fare rate is different
print("current bus fair is "+str(cur_bus))
total_bus_fair=total_bus_fair+cur_bus
total_transport_fare=total_transport_fare+cur_bus
elif bus_ride=='3':
cur_bus=float(num_bus)*10 +(float(num_bus)*10*.05)
print("current bus fair is "+str(cur_bus))
total_bus_fair=total_bus_fair+cur_bus
total_transport_fare=total_transport_fare+cur_bus #total transport fair is updated
elif transport=='2':
taxi_type=input("Input Taxy type :[1:Day 2:Night]")
num_taxy=input ("NUmber of taxy_ride ")
if taxi_type=='1':
cur_tax=float(num_taxy)*0.5+(float(num_taxy)*0.5*.05)
print("current taxy fair is "+str(cur_tax))
total_taxi_fair=total_taxi_fair+cur_tax #total taxi fair is updated
total_transport_fare=total_transport_fare+cur_tax
elif taxi_type=='2':
cur_tax=float(num_taxy)*1+(float(num_taxy)*1*.05)
print("current taxy fair is "+str(cur_tax))
total_taxi_fair=total_taxi_fair+cur_tax
total_transport_fare=total_transport_fare+cur_tax #total transport fair is updated
elif transport=='3':
if (passenger=='2' or passenger=='3' or passenger=='4'):
print("Current ride is free")
else:
num_metro=input ("NUmber of metro stations ")
cur_metro=float(num_metro)*5+(float(num_metro)*5*.05)
print("current metro fair is "+str(cur_metro))
total_metro_fair=total_metro_fair+cur_metro
total_transport_fare=total_transport_fare+cur_metro
else:
print("Invalid transport!") #error for invalid transport input
continue
print()
print("total bus fair is "+str(total_bus_fair))
print("total taxy fair is "+str(total_taxi_fair)) #display the results
print("total metro fair is "+str(total_metro_fair))
print("total transportation fair is "+str(total_transport_fare))
else:
print(passenger)
print("Invalid passenger type") #error for invalid passenger type
continue
# In[ ]:
# In[ ]:
# In[ ]:
Get the best Control Structures and Lists assignment help and tutoring services from our experts now!
About The Author - Dr. Alex Morgan
Dr. Alex Morgan is a seasoned computer science educator with a passion for teaching algorithm development and Python programming. With extensive experience in designing comprehensive curriculum, Dr. Morgan guides students through complex concepts, fostering a deep understanding of programming fundamentals and problem-solving techniques.