ICT112 Programming Fundamentals Assignment

Assignment Help Programming Languages
Reference no: EM133116578

ICT112 Programming Fundamentals - University of the Sunshine Coast

Theme: Training Turtles

Learning Objective 1: use variables to store values and update those values;

Learning Objective 2: draw simple shapes using Python 'Turtle Graphics' objects;

Learning Objective 3: use for loops to repeat a block of code a given number of times.

Training a Turtle

One of the fun things about the Python language is that one of its standard libraries is the 'Turtle Graphics' module. Turtles are a great visual way of learning about Python objects and methods, and practicing the problem-solving skills that are crucial to learning programming.

If you are using your own computer and haven't already you'll need to install VS Code and the Python libraries. If you are in the labs, please open VS Code and create a new python file.

Note: you do not need to type in the 'comments' (everything from the '#' character to the end of the line). Python ignores everything after a '#', so you can put comments in your code, but they just for human readers, to explain what is going on, and why the code is written that way.

You should see an output window pop up at this point. Drag it over to the right side of your screen so that it does not overlap your code window.

Then type in the next few lines and watch what alex (the 'turtle') does. and a turtle object that we call 'alex' (short for 'alexander' or 'alexandra'? It is difficult to know the sex of turtles!

Then we give 'alex' a few instructions on how to move, and as he/she moves along, a line is drawn in the imaginary sand.

You can find more explanation of this program and more details about turtles in Chapter 4 ('Python Turtle Graphics') of our online textbook:
Make sure you read that chapter sometime this week, if you are reading that one. Another useful source of reference documentation about turtles is the online Python documentation:

1.1 Some Simple Polygons

Here is a series of simple shapes to draw, to learn how to control the turtle and figure out how the angles work. After you complete each task, add an explanatory comment line above your code to explain what it does (for example: # draws a square). Then start drawing the next shape, by copying and pasting any bits of code that you need to reuse.

Extend the above program so that it draws the whole rectangle, 50 pixels wide and 30 pixels high.

1. Modify the rectangle code so that it draws a square, 100 by 100 pixels.

2. Add some extracode to draw an equilateral triangle, with three sides, each 100 pixels long.

3. Also draw a hexagon that has six sides, each 100 pixels long. Hmm, this hexagon code is getting to be a bit long and repetitive. Imagine how long our program would be if we wanted to draw a shape with 20 sides! Can you use a for loop to make your hexagon code shorter? Hint: for side inrange(6): ... (Make sure that all the code you want to repeat inside the loop is indented by four spaces.)

4. Define a variable: size = 90. Then change your hexagon code so that it uses your sizevariable for the length of each side. Rerun your hexagon code.

5. Change your sizevariable to be 180. Then rerun your hexagon code. Does it look larger?

1.2 Making it colourful
Let's make our shapes picture look a bit more colourful.We can call alex.pencolor("red") to set the colour of the pen to red - note the American spelling of 'color' in the method name.

Okay, now beautify your three shapes as follows:
• Change your square so that it is filled in with a nice light colour. Hint: ask alex to begin_fill() before you start drawing the square, and end_fill() after you finish drawing the square. The end_fill()method will paint the interior of the shape that you have just drawn. You can call alex.fillcolor("color name") to set the fill color any time before you call end_fill().
• Change your triangle so that it is also filled in, but choose a darkeror complementary colour that fits in nicely with the colour of your square.
• Change your hexagon so that it is drawn with dark, bold lines, 5 pixels wide. It should not be filled, just an outline shape. Choose a darkcolour for the lines, so that the hexagon creates a nice border for your picture.
Your final picture should look something like this (but with your colours):

2 Going a bit loopy
For this final part of the lab, we are going to use Python for loops to draw some slightly more interesting and complex pictures.

2.1 From Circles to Spirographs
Now, copy and paste the following example code into your program:

You will find that this draws a circle. But rather slowly, because it takes 360 tiny left turns to get around the whole circle! Try reducing the 360 iterations to just 36, and increase both 1's to 10, and it will draw more quickly, but still look quite close to a circle.
To make a more interesting picture, copy the code for your triangle and paste it inside this circle loop (just after the alex.left(10) line). Make sure that your triangle code is indented the same amount as the preceding lines, so that all the code inside the loop is at the same level. This is how Python knows which lines of code are inside the loop. Then run your program again and see what you see.

2.2 Spiralling Around
Experiment with varying the length of the forward(10) method call at the top of the loop. Also try changing it to forward(10+i).
Then can you change your program so it draws a spiral of triangles like the ones shown here?
Or get creative, and see if you can draw some more interesting spiral shapes!

2.3 The Drunk Pirate
A drunk pirate makes a random turn and then takes 100 steps forward, makes another random turn, takes another 100 steps, turns another random amount, etc. A social science student records the angle of each turn before the next 100 steps are taken. Her experimental data is:
angles = [160, -43, 270, -97, -43, 200, -940, 17, -86].
(Positive angles are counter-clockwise.)
Write a turtle graphics program, which uses your turtle to draw the path taken by our drunken friend. Make his path wide and red.
Hint: to loop through the angles, after you have added the above definition of the list of angles, you can use: for a in angles:
[Extension] A random drunk pirate?
Instead of following the same (historical) path of the same drunk pirate every time your program runs, can we model a drunk pirate who takes a different (and random) path each time? Yes, Python has a ‘random' module that makes it easy to do this.

Can you integrate this idea of 'random angles' into your program, to simulate a real drunk pirate?
Can you make him/her turn right as well as left randomly?

Computer workshop 2:

Theme: Chatbots

Some of the earliest "smart" software systems were chatbots like Eliza (Eliza: Wikipedia) which you can test out
In this workshop you'll build your own mini Eliza through a step-by-step tutorial from Hour of Code and then design and build your own ICT112 chatbot for frequently asked questions and/or importand information.

Learning Objective 1: use variables to store values and update those values;
Learning Objective 2: use conditional statements and Boolean logic to determine the next step/s;
Learning Objective 3: use for loops to repeat a block of code a given number of times.

1. Talk to Eliza
Visit at ElizaBot to try out an implementation of the original Eliza.
Now try a more modern chatbot at CleverBot

2. Build your own Eliza
Using the Hour of Code tutorial at Grok Learning build your own Eliza. Make sure you keep a copy of all the code you write in a separate word document

3. An ICT112 Chatbot

a. Design your own chatbot
Using what you learned in the Eliza tutorial design in pseudo code OR flow chart (you may use whichever one best suits you) an ICT112 chatbot that can conduct a quiz about the content from week's 1 & 2 - the big 5 imperative programming constructs, the setup of the course, or any other question you'd want answered as a new ICT112 student.
Your chatbot must have at least 5 questions or helpful hints. &needs to include at least one conditional and at least one for loop. (HINT: you'll likely need more conditions!)

b. Build your own ICT112 chatbot
Now implement your ICT112 chatbot according to your design, and test that it works.

Attachment:- Programming Fundamentals.rar

Reference no: EM133116578

Questions Cloud

Excessive increases in healthcare costs : For this week's discussion, let's do a little survey. Which of the following entities do you judge to be most responsible for excessive increases in healthcare
Pros and cons of federal privacy regulation : What are the pros and cons of a federal privacy regulation and which state policies should be considered as the blueprint for this and why?
Amount of funds city abc can expect : City ABC is going to issue a $100,000,000 10 year zero coupon bond, proceeds of which will be used for rail infrastructure purposes. If investors demand an annu
What is the price of the bond on issue date : Company 123 is about to issue a €100,000,000 bond rated BBB/Baa2 with a five year maturity. The investment bank underwriting the bond informs them that the mark
ICT112 Programming Fundamentals Assignment : ICT112 Programming Fundamentals Assignment Help and Solution, University of the Sunshine Coast - Assessment Writing Service
What would be the value of the firm : Assume the marginal corporate tax rate is 30%. The firm has no debt in its capital structure and is currently valued at $120 million.
How much of a monthly cpp benefit will stuart receive : Earlier this year, Stuart finally decided to retire on his 72nd. He is eligible for the maximum CPP retirement benefit. If the maximum monthly retirement benefi
Determine the november balance in the cash account : Nov. 2 Made cash sales of $3,400; the cost of the inventory sold was $2,040. Determine the November balance in the Cash account
Investment today for retirement : You are trying to decide how much to save for retirement. Assume you plan to save $6,000 per year with the first investment made one year from now. You think yo

Reviews

Write a Review

Programming Languages Questions & Answers

  Use switch statement to display roman numeral version

Use a switch statement to display the Roman numeral version of that number. Input Validation: Do not accept a number less than 1 or greater than 10.

  Main( ) function that instantiates one average object

Main( ) function that instantiates one Average object, and includes a for loop to take 10 inputs and calls to the calculation and output method.

  Define the stream extraction operator functions

CS3528 Assignment - Define the stream insertion and stream extraction operator functions. Write a main function that tests input of of user-defined class Point

  Identify differences between web design and oops

Identify two differences between web design and object-oriented programming, and explain the limitations of HTML and why XML was developed.

  TEB2164 Introduction to Data Science Assignment

TEB2164 Introduction to Data Science Assignment - Perform a test onto H0 using the test statistics given - count-based test as opposed to a linear regression

  Does python use strings under the cover for their numbers

Write few lines of code that outputs a natural phenomenon in python and Java, question: Does python use strings under the cover for their numbers

  Complete the attached code and do junit testing

Complete the attached code and do junit testing. Can you help with this? Testing class tests Check Date methods serves as a "test plan" for developer's testing.

  Write a program that use nested loop to collect data

ICT102 INTRODUCTION TO PROGRAMMING- Kings Own Institute-Australia-Write a program that use Nested Loop to collect data and calculate the average rainfall over.

  Explain some ways tables can be used on web page

Tables are one of the most useful page layout tools available to web designers. Explain some ways tables can be used on a web page. Elaborate on other ways to achieve the same look.

  Writing static program analyses using LLVM

Dataflow Analysis. Objective - This assignment will familiarize you with writing static program analyses using LLVM

  Write a program that is passed a virtual address

Write a program that is passed a virtual address (in decimal) via the attached txt file and have it output the page number and offset for the given address in the command line.

  Communicate with a pc using the rs232c serial protocol

In this assignment we will use the UART0 peripheral to communicate with a PC using the RS232C serial protocol.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd