0% found this document useful (0 votes)
24 views7 pages

Lecture 1

This document discusses using sequential structure in Scratch programming. It provides examples of writing simple Scratch scripts to print text, perform calculations, and have sprite conversations. It includes exercises for students to practice creating additional Scratch scripts to solve problems involving math operations, temperature conversion, distance and fuel calculation, area calculation, and more.

Uploaded by

Vikash Shivani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views7 pages

Lecture 1

This document discusses using sequential structure in Scratch programming. It provides examples of writing simple Scratch scripts to print text, perform calculations, and have sprite conversations. It includes exercises for students to practice creating additional Scratch scripts to solve problems involving math operations, temperature conversion, distance and fuel calculation, area calculation, and more.

Uploaded by

Vikash Shivani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CL-1002 LAB - 01

Programming Problem solving with sequential


Fundamentals structure using Scratch

NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES


Fall 2022

LAB#01: SEQUENTIAL STRUCTURE USING SCRATCH 1


Introduction
Visual Programming Language (VPL) is an application development environment designed on a graphical block-based
programming model.

Scratch Interface

Example#1: Writing our first script in a scratch to print “Hello” to the world.

#include <stdio.h>
int main()
{
printf(“Hello World”);
}

LAB#01: SEQUENTIAL STRUCTURE USING SCRATCH 2


Example#2: Prompting your Name and printing “Hello” to your Name.

Script: Output:

Example#3: Asking your Name and saying by speaking “Hello” to your Name.
Script:

Example#4: Calculate the hypotenuse of a right-angled triangle with given two sides using the formula.

Script:

LAB#01: SEQUENTIAL STRUCTURE USING SCRATCH 3


Example#5: Setting Grid Backdrop and moving spirit onto the xy-axis and draw square on the screen.

Script: Output:

Example#6: Write a script of input two numbers, add two numbers and print the sum of numbers.
Script: Output:

LAB#01: SEQUENTIAL STRUCTURE USING SCRATCH 4


Example#7: Write a script to find an area of circle
Script: Output:

Example#8: Conversation between two scripts when clicked on the spirit.

Spirit#1

Spirit#2

LAB#01: SEQUENTIAL STRUCTURE USING SCRATCH 5


EXERCISE#1

QUESTION#1
Make a simple calculator which performs basic arithmetic operations of mathematics such as addition, subtraction,
division, and multiplication using scratch.

QUESTION#2
Make a simple temperature converter that converts Fahrenheit into Celsius.
Celsius = ((Fahrenheit-32)*5)/9

QUESTION#3
A bus leaves the university to take students on a field trip. The bus travels 10 kilometers south, 10 kilometers west,
another 5 kilometers south and 15 kilometers north with the fuel consumption of 2 liters/km. Using scratch
calculate how many kilometers it has covered and how much fuel it has consumed on a field trip?

QUESTION#4
Calculate the area for a triangle in which user inputs height and length of a triangle using scratch.

QUESTION#5
Find out coordinates of midpoint using given formula, derived from Pythagorean Theorem and value of X by
Quadratic formula using scratch, as follows:

a. Midpoint= ((x2+x1/2), (y2+y1/2))

−𝑏±√𝑏2 −4𝑎𝑐
b. 𝑥 = Given (a≠0.)
2𝑎

QUESTION#6
For 4 weeks, Waseem volunteered as a helper for swimming classes. The first week, he volunteered for 8 hours. He
volunteered for 12 hours in the second week, and another 12 hours in the third week. The fourth week, he
volunteered for 9 hours. Using scratch calculate how many hours did he volunteer per week, on average?

QUESTION#7
A sweater is on sale for 25% off the original price. The original price is Rs. 5000. Using scratch calculate and print
the sale price.

QUESTION#8
One of the jobs that Joe Roberts has been given at work is to order special paper for a report for a board meeting.
The paper comes in reams of 500 sheets. He always makes five more copies than the number of people that will be
there. Joe wants to know how many reams of paper he needs for a meeting. He can order only whole, not partial,
reams. Assume the required number of pages will not equal an exact number of reams. Test your solution using
scratch with the following data:
The report is 140 pages long.
There will be 25 people at the meeting.
QUESTION#9
Ali and Bilal are the friends. Write some greeting conversation in between them when clicked on the spirit.

LAB#01: SEQUENTIAL STRUCTURE USING SCRATCH 6

You might also like