关键词 > Python代写

HOMEWORK 3

发布时间:2023-12-10

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

SOFTWARE

HOMEWORK 3

(handout for students)

42 marks in total

This homework aims to test your problem-solving skills and challenge you to apply coding concepts from the last few weeks. The questions in this homework may be similar to what you’d face in a coding interview and in certain sections of the Final Assessment.

For some solutions you will be asked to judge the eŨciency, a concept which will be

taught in the first session of next week. You can either do external research beforehand, or wait until the topic is taught to complete.

QUESTION 1: Jumping The Queue

15 marks

A ] Write a program that takes in an input file and prints out a list with the final order of who’s in the queue.

You are expected to use the provided input file hw3_q1.txt to develop and test your solution.

The first word on each line will either be “JUMP” or “JOIN” and the second word the name of the person, the word “JUMP”  means the person in question has gone to the front of the queue, if the word is “JOIN”  it means they have joined the back of the queue.

You are expected to identify and use a container from the collections module for your solution.

B ]  What is the time and space complexity of your solution? If you are making any assumptions, list them.

Add your answer to this as a comment above or below your solution to Part A.

QUESTION 2: Number In Sequence

12 marks

A ] Write a function that returns the Nth number in the following sequence

8, 15, 22, 29, 36, …

For example:

   num_in_seq(1) = 8

   num_in_seq(5) = 36

   num_in_seq(10) = 71

Non-recursive solution: 6 marks

Recursive solution: 12 marks

QUESTION 3: Hyperlink History

15 marks

A ] Simulate clicking around the CFG Website. Keep track of the URL changes and print the current URL after each move.

●   You will need to display the options for each link, and include an option for ‘ Back’ if not on the Base URL.

●   You do not need to worry about error handling

●   You are recommended to keep the simulation going within a while True loop so the logic keeps looping until an exit is forced.

You only need to consider the following URLs for your solution:

1.   Base URL: https://codefirstgirls.com/

2.  Category URLs: /courses ,/opportunities/

3.  Sub-category URLs: /courses/cfgdegree/ , /opportunities/ambassadors/

Example run of the program:

You are currently on the URL https://codefirstgirls.com/

Where are you clicking?

Options: Courses, Opportunities

Courses

You are currently on the URL https://codefirstgirls.com/courses

Where are you clicking?

Options: CFGDegree, Back

CFGDegree

You are currently on the URL https://codefirstgirls.com/courses/cfgdegree Where are you clicking?

Options: Back

Back

You are currently on the URL https://codefirstgirls.com/courses

Where are you clicking?

Options: CFGDegree, Back

Back

You are currently on the URL https://codefirstgirls.com/

Where are you clicking?

Options: Courses, Opportunities

Opportunities

You are currently on the URL https://codefirstgirls.com/opportunities

B ]  What is the time and space complexity of your solution? If you are making any assumptions, list them.

Add your answer to this as a comment above or below your solution to Part A

SUBMISSION CRITERIA:

   This homework is to be submitted solely via GitHub.

   Your pull request needs to contain all the python solutions (either in one file or 3 separate ones)

   The answers for complexity should be comments given above or below your solution - these need to be clear and annotated well.