0% found this document useful (0 votes)
26 views4 pages

Computer Answers Chap 3

The document contains a series of questions and answers related to programming concepts, specifically in Python and Scratch. It covers topics such as variable assignment, arithmetic operators, interfaces, algorithms, error handling, and the differences between programming environments. Additionally, it discusses the advantages of using programming languages over machine code and the translation of source code into machine code.

Uploaded by

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

Computer Answers Chap 3

The document contains a series of questions and answers related to programming concepts, specifically in Python and Scratch. It covers topics such as variable assignment, arithmetic operators, interfaces, algorithms, error handling, and the differences between programming environments. Additionally, it discusses the advantages of using programming languages over machine code and the translation of source code into machine code.

Uploaded by

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

COMPUTER

Q: Write the Python command to


ANSWERS CHAP 3 make a variable called city with
the value "Paris".
Q: What are the four arithmetic
A: city = "Paris"
operators?
A: The four arithmetic operators
are:
Q: Write the Python command to
 Addition (+) output the variable age.
 Subtraction (-) A: print(age)
 Multiplication (*)
 Division (/)
Q: Write the Python command to
ask the user "How old are you?",
Q: What is an interface? get user input, and store the user
A: An interface is a way for input as the variable age.
different parts of a program, or A: age = input("How old are
different programs, to you?")
communicate with each other. It
defines the rules or methods they
must follow.
Q: Explain how error messages
help you to be a good
programmer.
Q: An algorithm sets out the A: Error messages show where
inputs and outputs of a program. the problem is in your code and
What else does it set out? what went wrong, so you can fix it
A: An algorithm also sets out the and improve your programming
steps or instructions needed to skills.
solve a problem.

Q: What is the advantage of


Q: When you make a Scratch making a program file instead of
program, what is the purpose of typing commands in the Python
the 'Event' block? Shell?
A: The 'Event' block starts a part A: A program file allows you to
of the program when something save and reuse your code, while
happens, like clicking a sprite or the Shell only runs commands
pressing a key. temporarily.
Q: Name two different colours Q: What is the data type of the
used in the Python program file price variable?
window. Name the type of A: The data type is float.
program content that has each
colour.
A: Q: The variable points stores data
that the user has input. What is
 Blue: Keywords like def or
the data type of this variable?
print.
A: The data type is string by
 Green: Comments written
default.
by the programmer.

Q: Write a command to convert


Q: Explain two different ways you
the points variable to any
can find errors in your Python
numerical data type (integer or
programs.
float).
A:
A: points = int(points) or points =
1. Read error messages to float(points)
identify and fix mistakes.
2. Use debugging tools to step
through your code and see
what happens at each step.

Q: Describe one difference


between the IDE for Scratch and
the IDE for Python.
A: Scratch uses blocks for coding,
1. Name one programming
while Python uses text-based
language you have learned and
code.
one programming language you
have not learned.
Learned: Python
Q: Write the Python command to Not Learned: Java
assign the value 9.99 to a variable
called price. 2. Name one good feature that
A: price = 9.99 Scratch shares with Python.
Both Scratch and Python allow the that a computer can run directly
use of variables to store and to perform specific tasks.
manipulate data.
3. Why does source code need to
3. Name one good feature of be translated before the
Scratch that Python does not computer can execute it?
have. Explain how this feature Source code is written in a
helps young learners to make human-readable language, but
programs in Scratch. computers can only understand
Scratch has visual blocks for machine code. Translation
coding. This feature helps young converts the source code into
learners because it removes the machine code.
need to memorize syntax, making
programming easier and more 4. How is Scratch code translated
fun. into commands that the computer
can understand?
4. You can buy apps made using Scratch code is interpreted by the
Python. But you cannot buy many Scratch software, which converts
apps made using Scratch. In your the visual blocks into instructions
own words, explain why. the computer can execute.
Python can create complex and
professional apps that work on
different devices, while Scratch is
mainly for learning and making
simple programs that are not
suited for commercial use.

1. Programmers don't usually


1. What does 'download' mean?
write programs using machine
code. Why not? Download means transferring a
Writing in machine code is very file or program from the internet
difficult and time-consuming or another computer onto your
because it uses only 0s and 1s, own device.
which are hard to understand and
debug.

2. What is an executable file? 2. What does 'run' mean?


An executable file is a program file
Run means to execute a program 6. Will you use Python or Scratch
or app so it starts working on your to make the app for wheelchair
computer or device. users in your city?

I would use Python because:


3. Why did the source code have  It allows for more complex
to be translated into machine features, such as database
code? management and GPS
integration, which are
The source code had to be
useful for creating
translated into machine code
accessible and practical
because computers can only
apps.
understand and execute
 Python supports
instructions written in machine
professional app
code (binary).
development, making the
app usable on different
devices.
4. Why didn’t Louis write the app Using Scratch would not be
in machine code? ideal as it is better suited
for simple, visual programs
Louis didn’t write the app in and not for building
machine code because it is complex, functional apps.
extremely difficult to use, very
time-consuming, and hard to
debug. Programming languages
like Python make writing code
easier and more efficient.

5. Identify one way of translating


source code into machine code.

One way to translate source code


into machine code is by using a
compiler, which converts the
entire source code into machine
code before execution.

You might also like