Python Homework Help

Search for question

Questions & Answers

Question 1 (15 pts) For each of the following program fragments, give an analysis of the running time (using Big-Theta). Assume ‘sum’ and ‘n’ are initialized before running the fragment.


Part 1 - Write-up Consider these two scripts that determine whether a number is divisible by 5 or not: DivByFive_NoFunction.py and DivByFive Function.py Please write a brief paragraph (4-6 sentences) about the following: The differences between the two scripts The pros of each of the scripts The cons of each of the scripts Why functions are useful


Assignment: Lab 1-2D Arrays, Sets, Dictionaries, Backtracking and Sudoku


ENGR 102 - Fall 2022 Lab: Topic 8 (team) Deliverables: There are several deliverables for this team assignment. Please submit the following files to Canvas and zyBooks: • ascii_clock_planning.pdf • ascii_clock_XX.py where XX represents the initials of the team member • ascii_clock.py Activity #1: Top-Down Design of a Program - team Following the process described in the lecture, as a team perform a top-down design for the program described below. AFTER you plan your program, write the code. Write a program to take as input from the user a time and display that time using ASCII art. Format your output using the examples shown below. Draw each digit three (3) characters wide and five (5) characters tall, using only spaces and that digit. Draw one space between numbers. Draw the colon one (1) character wide. You do NOT need a leading zero or blank space for times earlier than noon.


Word searches are a type of puzzle in which a grid of letters is provided, along side a series of words. The task is then to find the given words inside the grid of letters. Depending on the word search itself, the words can be found in different orientations, left-to-right, top- to-bottom, or even at angles. While these are not terribly taxing puzzles compared to, for example, a crossword, or a sudoku, word searches remain a simple and entertaining type of puzzle for all ages. From a programmer's perspective, word searches create two interesting, and closely re- lated, challenges. First, given a 2d grid of characters and a specific string - determine whether or not the string is present, and if so report not only the location, but direction at which the word can be found. Second, given a target size, and a list of words, generate a pseudo-random 2d grid of characters such that all (or most) of the given words can be found in the generated grid. By the end of this project you should have a program capable of solving both of these problems.


Activity #1: Shoelace formula - team This activity will help you practice writing functions while solving for the area of a simple polygon. The shoelace formula (https://en.wikipedia.org/wiki/Shoelace formula) is an algorithm to calculate the area of a simple polygon given the vertices. Its name comes from repeatedly cross-multiplying the coordinates, like threading shoelaces. The math behind the method works by taking each edge of the polygon, forming a triangle with the origin, taking the cross-product (which gives the area of a parallelogram), then dividing by 2. The component areas will overlap, however the areas outside of the polygon will cancel out leaving only the area inside remaining. You can view a nice video explanation here: https://www.youtube.com/watch?v=0KjG8Pg6LGk Create a program named shoelace_formula.py that utilizes the shoelace formula via the following steps: 1. Create a function named getpoints that takes in as an argument a string and returns a list of points of arbitrary length. The string passed to the function contains pairs of numbers separated by commas, with each pair separated by a space, as shown in the format below. Have the function convert it to a list of points (the polygon's vertices). Each element in the list of points should itself be a list of one point. For the example shown below, your function should return: [[3, 4], [5, 6], [9, 51, [12, 8], [5, 11]] 2. Create a function named cross that takes in two arguments, both of which are a list of one point, and returns the cross-product. This is one step of the shoelace method. For example, if the points [1, 2] and [3, 4] are passed to the function, in that order, it will return -2. Cross product: (14) - (23) = -2 3. Create a function named shoelace that takes in as an argument a list of points and returns the area of the polygon calculated via the shoelace formula. The list of points passed to the function is the same list returned by your getpoints function. Your shoelace function should call your cross function. 4. Create a function named main that does not take in any arguments nor return any values. This function should take as input from the user a string of pairs of numbers separated by commas and spaces, as shown in the format below, and print the area of the polygon. Your main function should call your getpoints and shoelace functions. Format your output as shown below. 5. Finally, in your main code type the following: if__name__==main_ ==! main () You should NOT include any other executable lines in your main code.


Phase 1 1. Develop an algorithm/program to construct a connected graph on v vertices and e edges, where v and e are parameters and execute your algorithm/program and depict the results. Program's input and output are as follows: Inputs: o v: number of vertices o e: number of edges Outputs: o Constructed graph (Show the constructed graph as an adjacency list in an appropriate manner) o Running time for the algorithm


Assignment-2 (35pts) Implement the vector clock algorithm to enable causally-ordered events in the distributed system. Similar to the previous assignment, we use multiple processes to emulate multiple nodes. Assume that all nodes are initiated to the same vector clock. After completing a local operation, each process sends its updated vector clock to all other processes. Follow the steps on slide 34 in Lecture 6 to implement the vector clock algorithm.


Problem 7.4 Write a function day_name that converts an integer number 0 to 6 into the name of a day. Assume day 0 is "Sunday". Return None if the arguments to the function are not valid.


Problem 7.2 Write a function named collatz () that has one parameter named number. If number is even, then collatz() should return number // 2. If number is odd, then collatz () should return 3* number + 1. Call the function three times with arguments 300, 30 and 19 as follows: print (collatz (300)) print(collatz (30)) print(collatz(19))


No Question Found forPython

we will make sure available to you as soon as possible.