Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need them in python Exercise 2 (5 points) Write a program that sums up a sequence of numbers within a range. Your program must define

need them in pythonimage text in transcribedimage text in transcribed

Exercise 2 (5 points) Write a program that sums up a sequence of numbers within a range. Your program must define a main function and a function named sum_between to carry out the sum. In main, you should prompt the user to input the low and high values. Function main will call the function sum_between with the two arugments, and return the sum of values within that range. For instance, if the user inputs 5 for low, and 10 for high, the function should compute the sum 5 + 6 + 7 + 8 + 9 + 10 and return the result to main. This is very similar to the program we developed in class on 10.11, except that here the sequence starts at a value that's specified by the user (in the program we developed in class, the sequence always started at 1). Exercise 3 (10 points) You are to write a program that draws multiple hexagons on the screen in random locations (in the range [- 100, 100]), side lengths (in the range [50, 100)) and using random colors (you get to specify the possible colors). Use pensize 5. The number of hexagons to draw is input by the user. The program must be organized using functions according to the structure described below. The main function should prompt the user for input, generate random colors, locations, and side lengths, and finally call draw_hexagon in a loop using the randomly generated values as arguments. The function draw_hexagon should draw a hexagon according to the argument values. Below is the program's structure and logic to help you develop it. import statements define function draw_hexagon. This should have as parameters the following: t (Turtle object), *_coord, Y_coord (the starting coordinates of the hexagon), color (the color of the hexagon outline), side (the length of the side). define function main create turtle object define list of possible colors prompt the user to input the number of hexagons to draw for loop randomly generate x and y coordinates of the starting point randomly generate side length randomly select color from color list call draw_hexagon using the appropriate arguments call function main 2 of 3 O

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions