Cat Crossing the Street! (Activities involving 2 persons)

01 Initial Setup

Let’s create a scenario for a cat crossing the street!

  • Cat: “Hey, I’m gonna cross the street
  • Dog: “Wait”
  • Cat: “What?”
  • Dog: “Look both ways before you cross”
  • the cat looks left
  • the cat looks right
  • Cat: “Crossing now”
  • The cat crosses the street



Guided instruction to implement this scenario in Scratch

  1. Open Scratch and create a new project.
  2. Select the “urban” backdrop by clicking on the “Choose a backdrop from library” button below the stage and choosing the “urban” backdrop.
  3. Add the “dog2” sprite by clicking on the “Choose a sprite from library” button below the stage, selecting the “Animals” category, and choosing the “dog2” sprite.
  4. Resize both sprites to a size of 50 by clicking on the sprite and using the “Size” block in the sprite’s code.
  5. Position the dog sprite on one side of the street and the cat sprite on the other side as shown in the image provided. You can drag the sprites to the desired positions.
  6. Horizontally flip all costumes for the dog sprite so that it faces to the left. To do this, click on the dog sprite, go to the “Costumes” tab, select each costume, and use the “Flip horizontally” button.
  7. Copy the first costume of the cat sprite and place it in the third position. To do this, click on the cat sprite, go to the “Costumes” tab, select the first costume, and click on the “Duplicate” button. Then drag the duplicated costume to the third position.
  8. Horizontally flip the third costume of the cat sprite. To do this, click on the cat sprite, go to the “Costumes” tab, select the third costume, and use the “Flip horizontally” button.

Now you have set up the sprites and costumes for the cat crossing the street scenario in Scratch. You can continue by adding scripts to animate the sprites and make the cat look left and right before crossing the street.

Video Tutorial

Follow along with the video below:

https://youtu.be/q4TzNKMy63s

Suggested solution

Scratch project: https://scratch.mit.edu/projects/848541187

For our Sprite 1 (Cat)

02 Sprite1 Code (Cat)

For Our Dog2

03 Dog2 Code

© 2023  Vedesh Kungebeharry. All rights reserved. 

SD Card Reader

SD Cards (Secure Digital Cards) are a popular form of portable flash memory storage because of it’s small size , speed and durability. It’s used widely in digital video/photography to store media, and as expansion storage for other smart devices including phones , tablets etc.

It was created by a group of companies and has now become a standard for portable data storage.

SD Cards

SD Card readers are devices that allow for SD Cards to be read by the computer system and can be internal (built into) or externally connected via USB ports.

Below: An external SD Card Reader with an inserted Micro SD Card

SD card reader

Below: An internal SD Card Reader built into the computer’s system unit.

Toshiba Satellite S40t laptop - SD card reader - 10086954974

Why are SD Card Readers needed?

Because of it’s widespread use, it has become desirable to include SD card readers in newer computer systems to facilitate easier data transfer from device to device.

A common task that a user would face would be copying their media from their digital camera to their pc. In the past, this meant that the user would have to install the camera’s software and drivers on the pc, then connect a cable from the camera to the pc to access the media.

This process changes when a sd card reader is built in or connected to a computer, the user simply removes the sd card from the digital camera and inserts it into the sd card reader, where the media is immediately accessible as using any other portable secondary storage device.

Attributions to media used in this post

Original: 毛抜きDerivative work: Tkgd2007, CC BY-SA 3.0, via Wikimedia Commons

Dineshkumar Nallaveerappan, CC BY-SA 4.0, via Wikimedia Commons

liewcf, CC BY-SA 2.0, via Wikimedia Commons

© 2023  Vedesh Kungebeharry. All rights reserved. 

Screen size and resolution

Size

Screen sizes are measured along the diagonal of the screen and is usually quoted in inches. For example, a typical computer monitor or laptop screen may be 15” in size.

Display size measurements

Resolution

Screen resolution refers to the quality and level of detail that can be displayed on the screen. The screen is made up of a matrix of individual dots that can be coloured  differently.  Each dot is know as a picture element or pixel for short.

Pixel-example
Example of pixels. Shows a zoomed section of an image to demonstrate how it is made up of pixels.

Maximizing the number of dots in a unit area of the screen will result in a sharper image with more detail , or as we say, a  higher resolution image.

A monitor’s screen resolution is denoted as horizontal pixels x vertical pixels. e.g 1920 * 1080

How does Size and Resolution relate to each other?

It’s possible for a monitor with large screen to have a small resolution, to the average person, the screen may display images which are blocky, where the pixels are discernable and the image is not smooth.

It’s also possible to have a very small screen have a high resolution, as in the case of a high end smartphone.

Size and resolution consideration depends on where the screen needed, for example, having a large screen with a low resolution at a train station or airport is feasible since a lot of people can easily view the screen at once , however , we do not require the need to display detailed images, just formatted text or cursive fonts.

Haneda-Airport-T2-STA Monorail-Gate-LED

On the other side of the spectrum, a graphic artist travelling on a long train ride may opt to get his/her/them/they/us work done on a portable tablet computer which has a small but very high resolution stylus touch screen to allow for fine and detailed designs to be viewed while being created.

T-FLEX CAD - Коллективная работа

Attributions to media used in this post:

florisla, CC BY-SA 2.0, via Wikimedia Commons

ed g2s • talk, CC BY-SA 3.0, via Wikimedia Commons

MaedaAkihiko, CC BY-SA 4.0, via Wikimedia Commons

TopSystemsLTD, CC BY-SA 4.0, via Wikimedia Commons

© 2023  Vedesh Kungebeharry. All rights reserved. 

.

Debugging in Context with Flowgorithm

When developing a solution to a problem in program code, we usually aim to write a bit of code that implements part of the solution and run it to see if works.

Bugs can start here, they manifest as errors that prevent your code from being compiled or executed out right, or produce incorrect results.

It’s important to note in our context that programs written in source code must be translated to machine code , which is directly executable by your computer’s CPU.

The translation can take place

  • with the entire file, that is, the entire source code compiled into executable code or
  • line by line, i.e a single line of source code is interpreted as machine code, then executed and so on.

Syntax , Logical and Runtime Errors

The errors or bugs experienced while we develop our code can be classified into three types:

  • Syntax – this is were the rules for structuring the code are broken, or not followed which prevents the translation process – this applies to both the compiler and interpreter which performs these tasks. The result of a syntax error is that the entire program cannot be executed. The programmer must fix the errors and try running the program again.
  • Logical – this is where the translation process completes successfully, but when the program is run it produces incorrect results or undesired behavior. After producing the logical error, the program continues to run indefinitely or until it stops by reaching the end of code produced by the programmer.

    For example, let’s say we were developing a solution that would prompt the user to enter 2 numbers, and output the sum, the following are some logical errors:
    • if the user entered 5.1 and 5, and the program outputs 10, this is an incorrect result
    • if the user entered 5.1 and 5, and the program doesn’t output anything – this is incorrect behavior
    • if the user entered 5.1 and 5, and the program continues to prompt the user to enter another and another indefinitely.
  • Runtime – this is where the program halts abruptly during execution and stops running (sometimes called a crash). It definitely passed the translation process, and can be run successfully in most cases (with or without logical errors), however some cases of user input or abnormal conditions of the computer system , the program crashes. Some reasons include:
    • the program attempts to divide by 0,
    • the program tries to access a memory location that it is not allowed to by the operating system
    • the operating system runs out of resources to provide to the program.

Video

Teacher Demonstration In class: bugs in Flowgorithm

© 2023  Vedesh Kungebeharry. All rights reserved. 

Computational Thinking  – A simple task! (Optional Class Activity)

In class Exercise

Students are arranged into groups of two.

Student 1 – writes instructions for student 2 to perform a simple task. Student 2 is not allowed to see the instructions as they are written.

Student 2 – Performs the task according to the given instructions.

Tasks include

Drawing

  • Draw a triangle
  • Draw a square

Dancing

Do the floss[1]

Discussion

Were the instructions precise?

Written Instruction In book

Instruction: Students are instructed to rewrite the instructions in a concise and precise manner with the expectation that the recipient of the instruction is motivated to achieve the goals of the instruction; i.e. the recipient understands the intent of the instructions and is not subject trivial misinterpretation which can lead to faults.

Moving From documenting an activity to solving problems

When solving a problem the following the steps to be followed:

  1. Information gathering;
  2. Brainstorming;
  3. Identification of resources;
  4. Evaluation of pros and cons of multiple solutions;
  5. Determining most feasible solution.

See the plan for next class discussion here: https://islandclass.org/2021/05/19/problem-solving-discussion/

Homework

Visit scratch.mit.edu and create an account for class next week.


[1] https://metro.co.uk/2018/04/18/floss-dance-created-everyone-7476359/

© 2022  Vedesh Kungebeharry. All rights reserved.