# COMP 9021 Lab 1 solution

\$19.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

## Description

5/5 - (1 vote)

1 Running python code
Experiment with the diﬀerent ways of running python code as described in the pdf document Running python code.pdf, which is part of the material for the ﬁrst lecture.
2 Text-based programs
2.1 Arithmetic computations
Run and study the program fahrenheit_to_celsius.py. Then write a program celsius_to_fahrenheit.py that displays a conversion table from Celsius degrees to Fahrenheit degrees, with the former ranging from 0 to 100 in steps of 10.
2.2 Lists
Run and study the program max_in_list.py. Thenwriteaprogramlargest_difference.pythatgeneratesalistof10randomintegersbetween -50 and 50 (included), prints out the list, computes the maximum diﬀerence between 2 successive elements in the list, and prints it out. Here is a possible interaction:
\$ python largest_difference.py The list is: [29, -18, -21, -46, 32, -46, -10, -19, 31, 40] The maximum difference between successive numbers in this list is: 78 \$ python largest_difference.py The list is: [-17, -45, -28, -25, -48, 4, 29, -43, -1, 40] The maximum difference between successive numbers in this list is: 52 \$ python largest_difference.py The list is: [20, -16, 20, -44, 41, 31, 32, -2, -15, -40] The maximum difference between successive numbers in this list is: 85
2
3 Drawing pictures with turtle
For the following exercises, you can refer to the Turtle graphics documentation, but you can complete the exercises by just studying the sample programs.
3.1 An hexagram
Run and study the program dodecagrams.py. Then write a program hexagram.py that draws an hexagram that is centred horizontally in the window that displays it, with the colour of the tips alternating red and blue:
You are encouraged to draw the red part and then the blue part of the star.
3
3.2 An octagram
Run and study the program dodecagon.py. Then write a program octagram.py that draws an octagram, the inscribed octagon being coloured yellow, and the colour of the triangles alternating red and blue:
You can set the distance from the centre to an edge of the inscribed octagon to 100 pixels, and the distance from the centre to the tip of a triangle to 180 pixels.