This subject introduces students to the programming process. It begins with the development of problem solving skills relevant to the solution of programming problems. This subject is one of the foundation subjects for other studies in information technology because it develops skills, techniques and approaches that underpin many other areas of the discipline of computing.
Upon successful completion of this subject, students should:
• be able to analyse the steps involved in a disciplined approach to problem-solving, algorithm development and coding;
• be able to demonstrate and explain elements of good programming style;
• be able to identify, isolate and correct errors; and evaluate the corrections in all phases of the programming process; • be able to interpret and implement algorithms and program code;
• be able to apply and justify the concept of object orientation as an approach to data abstraction;
• be able to apply sound program analysis, design, coding, debugging, testing and documentation techniques to simple programming problems;
• be able to write code in an appropriate coding language;
• be able to compare and contrast aspects of the procedural and object oriented programming approaches.
Write a program to print out Collatz sequence (https://en.wikipedia.org/wiki/ Collatz_conjecture) for a user-supplied number. Prompt the user for a positive integer which will become the first number in the sequence. Next number in the sequence is derived as follows:
• If previous number is odd, the next number is 3 times the previous, plus 1.
• If previous number is even, the next number is half of the previous.
According to Collatz proposition, the sequence ultimately reaches 1 no matter what the starting number is.
Your program should print out all numbers in the sequence down to 1. At the end, display number of iterations it took to arrive at 1, and average of all values in sequence. For prettier output, insert a line break after printing every five numbers, align the numbers in columns and format the average value to two decimal places.
After printing a Collatz sequence, your program should ask the user if they want to print out another sequence. The loop will continue until user decides to quit. Review the sample run below to clearly understand all requirements.
Draw a flowchart that presents the steps of the algorithm required to perform the task specified. You can draw the flowcharts with a pen/pencil on a piece of paper and scan it for submission, as long as the handwriting is clear and legible. However, it is strongly recommended to draw flowcharts using a drawing software. Here are links to some free drawing tools
• Draw.io (https://www.draw.io/)
• Lucidchart (https://www.lucidchart.com/pages/usecase/education) with an education account (register using email@example.com)
• yEd Graph Editor (https://www.yworks.com/products/yed)
• Pencil Project (https://pencil.evolus.vn/)
Implement your algorithm in Python. Comment on your code as necessary to explain it clearly. Your submission will consist of:
1. Your algorithm through flowchart/s
2. Source code for your Python implementation
This assessment task will work towards assessing the following learning outcome/s:
• be able to analyse the steps involved in a disciplined approach to problem-solving, algorithm development and coding.
• be able to demonstrate and explain elements of good programming style.
• be able to identify, isolate and correct errors; and evaluate the corrections in all phases of the programming process.
• be able to interpret and implement algorithms and program code.
• be able to apply sound program analysis, design, coding, debugging, testing and documentation techniques to simple programming problems.
• be able to write code in an appropriate coding language.
You have to prepare and present all source code, and flowchart/s separately and include them all in a single MS Word file identified by your name. See the 'Requirements' section below. The Python source code you write should be saved with a name such as ITC558assignment1YourName.py and then include a copy of it as text in the MS Word file named ITC558assignment1YourName.docx.
You have to save all the parts of the assignment (as described under 'Presentation' above) into a single MS Word document identified by your name as outlined in the section on presentation.
Failure to adhere to these requirements may disqualify the submission for marking.
Submit your complete assignment in MS Word format to Turnitin and insert your program source code as an object to your MS Word document (The subject lecturer will explain to you how to insert the object to your MS Word document).
Value: 15% Due Date: 03-May-2020 Return Date: 25-May-2020 Submission method options: Alternative submission method
In this assignment you will use turtle graphics to create an interactive forest drawing application.
Start by creating a module ‘utilities.py’ which should contain four drawing functions as listed below.
• draw_triangle(centre_x, centre_y, width, height, pen_color, fill_color)
• draw_rectangle(centre_x, centre_y, width, height, pen_color, fill_color)
• draw_circle(centre_x, centre_y, radius, pen_color, fill_color) • stamp_turtle(centre_x, centre_y, color)
The parameter names are self explanatory. For example, the draw_triangle() function should draw an upwards pointing triangle with (centre_x, centre_y) located as shown in figure
• distance(x1, y1, x2, y2) – to find the Cartesian distance between two points (x1, y1) and (x2, y2)
• save_state() and restore_state() – the former should save turtle’s important parameters (position, pen color, fill color) in global (module-level) variables. The latter function will reload the turtle’s state from those same variables. The four drawing functions listed above should call these save and restore functions before and after a drawing respectively so that turtle’s state is restored to same values as it was before a drawing.
In your main file ‘forest.py’ you should import the utilities module and call its functions to do all drawings. No direct drawing should be needed from main file.
At the program start, you should disable all turtle animations and change the turtle’s icon to a bird shape (see sample code). Then turtle should be hidden from view. Next your program should implement the following requirements.
• Create a large rectangle to represent drawing boundary.
• On top of the rectangle, draw two small circles and write text to let the user choose between a bird and tree drawing. When the program starts, tree must be chosen by default.
• Handle mouse clicks in the turtle window. Clicks within the drawing rectangle will draw a tree or bird depending on user’s selection. Mouse clicks outside the drawing rectangle are ignored, except for those within the selection circles which switch the drawing mode from bird to tree.
• Drawing a tree consists of drawing one vertical rectangle (stem) and three overlapped triangles (branches and leaves).
• The bird on the other hand should be drawn using turtle stamping at the click point.
• Tree size should change randomly. First you will choose a reference size for tree components (stem rectangle and leave triangles). Then at the drawing time, generate a random value between 0.7 and 1.3 which will act as a scale factor so that individual trees can be shorter, equal to or bigger than the reference size.
• When the bird mode is selected, the (bird shaped) turtle becomes visible in the top left corner. When tree mode is selected, turtle hides itself again.
• While the bird mode is selected, your program should respond to left (?) and right (?) keyboard buttons. User will press these buttons in order to change the turtle’s tilt
Holding a PhD degree in Finance, Dr. John Adams is experienced in assisting students who are in dire need...
55 - Completed Orders
Canada, Toronto I have acquired my degree from Campion College at the University of Regina Occuption/Desi...
52 - Completed Orders
Even since I was a student in Italy I had a passion for languages, in fact I love teaching Italian, and I...
102 - Completed Orders
To work with an organization where I can optimally utilize my knowledge and skills for meeting challenges...
109 - Completed Orders