0% found this document useful (0 votes)
0 views23 pages

Pseudocode Flash Cards

The document outlines fundamental programming concepts including output, user input, variable declaration, data types, and control structures like loops and conditionals. It explains the roles of functions, procedures, and subroutines, along with array handling and statistical functions. Additionally, it emphasizes the importance of maintainable code through meaningful identifiers and the use of library routines.

Uploaded by

GopikaBineesh
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)
0 views23 pages

Pseudocode Flash Cards

The document outlines fundamental programming concepts including output, user input, variable declaration, data types, and control structures like loops and conditionals. It explains the roles of functions, procedures, and subroutines, along with array handling and statistical functions. Additionally, it emphasizes the importance of maintainable code through meaningful identifiers and the use of library routines.

Uploaded by

GopikaBineesh
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/ 23

Describe the process of output in Output refers to the process of displaying or

programming. saving the results of a program to the user.

You can display a welcome message in


How do you display a welcome message in
Python using the print function:
Python?
print("Welcome to Grade 10").

Define user input in the context of User input is data or information entered by
programming. the user during program execution.

Variable declaration is used to define a


What is the purpose of variable declaration
variable and its data type, allowing the
in programming?
program to store and manipulate data.

List the basic data types used in The basic data types include Integer, Real,
programming. Char, String, and Boolean.
An integer is used to represent whole
How is an integer represented in
numbers, either positive or negative, such as
programming?
10, -5, or 0.

Variables can change during program


Explain the difference between variables
execution, while constants remain the same
and constants.
throughout the program.

Arithmetic operators are used to perform


What is the purpose of arithmetic
mathematical operations such as addition,
operators in programming?
subtraction, multiplication, and division.

Order of precedence determines the


Describe the order of precedence in
sequence in which operations are performed
programming expressions.
in an expression, following rules like BIDMAS.

String types are sequences of characters,


How do string and integer types differ in while integer types represent whole
Python? numbers; they behave differently in
operations.
String concatenation is the process of
What is string concatenation? joining two or more strings together to form
a new string.

How can you find the length of a string in You can find the length of a string using the
Python? len() function, e.g., len(word).

A substring is a portion of a string


What is a substring in programming?
extracted from a larger string.

How do you convert a string to lowercase in You can convert a string to lowercase using
Python? the lower() method, e.g., word.lower().

Comments are used to explain code and


What is the purpose of comments in code? make it more readable; they are ignored by
the interpreter.
Sequence is the concept of executing
Define sequence in programming. instructions in a specific order, which is
fundamental in programming.

You can calculate the average by adding the


How do you calculate the average of two
marks and dividing by 2, e.g., average =
marks in Python?
(mark1 + mark2) / 2.

Selection is a programming concept that


Describe the concept of selection in
allows you to execute different sets of
programming.
instructions based on certain conditions.

The three main types of selection


List the three main types of selection statements are IF ELSE statements, CASE
statements. statements (or Elif statements), and Nested
If statements.

Comparison operators are used to compare


Define comparison operators in
two values and return a boolean result (true
programming.
or false).
IF ELSE statements are used to execute
Explain the purpose of IF ELSE statements. one set of statements if a condition is true
and a different set if the condition is false.

A CASE statement branches depending on


How does a CASE statement function in many different possible values for an
programming? identifier, executing different outputs based
on the value.

Nested If statements allow for an if


statement to be placed inside another if
What is the role of nested If statements?
statement, enabling more complex
condition checks.

AND returns TRUE if both conditions are


Describe the function of AND, OR, and NOT TRUE, OR returns TRUE if either condition is
operators. TRUE, and NOT inverts the truth value of an
expression.

A count-controlled loop is structured to


repeat a set of instructions a specific number
How is a count-controlled loop structured?
of times, using a counter variable that is
incremented or decremented.
A precondition loop continues executing
What distinguishes a precondition loop while a condition is true and does not have a
from a count-controlled loop? predetermined number of iterations, unlike a
count-controlled loop.

Iteration is the process of repeating a set of


Explain the purpose of iteration in
instructions until a specific condition is met,
programming.
automating repetitive tasks.

Provide an example of a count-controlled FOR Count ← 10 TO 0 STEP -1 OUTPUT


loop in pseudocode. Count NEXT Count.

What is the output of the following


pseudocode: IF average >= 60 THEN The output will be 'Pass' if the average is 60
OUTPUT 'Pass' ELSE OUTPUT 'Fail' or higher; otherwise, it will be 'Fail'.
ENDIF?

A nested for loop operates by placing one


How does a nested for loop operate? for loop inside another, allowing for multiple
levels of iteration.
A post-condition loop executes a set of
Define a post-condition loop. instructions at least once and continues to
execute as long as a condition remains true.

The ELSE IF statement allows for testing


What is the significance of the ELSE IF
multiple conditions in sequence, executing
statement?
different statements for each condition.

A WHILE loop continues to execute as long


How does the WHILE loop function? as a specified condition is true, stopping
when the condition becomes false.

Describe the output of the following


The output will repeatedly prompt the user
pseudocode: WHILE Password <> 'charan'
for a password until they enter 'charan', at
OUTPUT 'Invalid password – try again'
which point it will stop.
INPUT Password ENDWHILE.

A counter variable is used to track the


What is the purpose of using a counter number of iterations in a loop, allowing the
variable in loops? loop to terminate when a specific value is
reached.
A definite loop has a known number of
Explain the difference between a definite
iterations, while an indefinite loop continues
loop and an indefinite loop.
until a certain condition is met.

A post-condition loop is a type of loop that


Describe a post-condition loop. executes at least once, checking the
condition at the end of the loop.

It is structured using a REPEAT...UNTIL


How is a post-condition loop structured in
format, where the loop continues until a
pseudocode?
specified condition is met.

Nested iteration refers to a loop that exists


Explain nested iteration. inside another loop, allowing for multiple
levels of iteration.

Provide an example of nested iteration in FOR i ← 1 TO 10, FOR j ← 1 TO 5, OUTPUT 'i


pseudocode. = ', i, ' j = ', j, END FOR j, END FOR i.
You can implement it using nested for
How can you implement nested iteration in
loops, such as: for i in range(1, 11): for j
Python?
in range(1, 6): print('i = ', i, ' j = ', j).

Define the concept of totalling in Totalling involves summing up values,


programming. typically using a loop to accumulate the total.

A total variable can be initialized to 0 and


How is a total variable initialized and
updated within a loop by adding input values
updated in a loop?
to it.

Counting is used to keep track of the


What is the purpose of counting in
number of occurrences of a specific event or
programming?
condition.

You can implement counting by initializing a


How can you implement counting in
count variable to 0 and incrementing it
Python?
within a loop based on a condition.
An array, or list in Python, is a data
Define an array in the context of Python. structure that holds multiple items of data
referenced by a single identifier.

All items in an array must be of the same


What is required for all items in an array?
data type.

How can you declare an array of strings in You can declare it as: DECLARE Usernames
pseudocode? : ARRAY[1:10] OF STRING.

How do you access the first and last elements The first element is accessed with
of an array in Python? Usernames

You can implement it by iterating through the


How can you implement a linear search in
array and checking if each element matches
Python?
the search key.
What is the purpose of initializing a count The count variable is initialized to 0 to start
variable in counting? tracking occurrences from a baseline.

You update it by adding the current input


How do you update a total variable in a
value to the total variable within each
loop?
iteration of the loop.

The output will be the total count of


What is the output of a counting loop when
occurrences that met the specified
the condition is met?
condition.

How do you declare an array of real You can declare it as: DECLARE Price:
numbers in pseudocode? ARRAY[1:5] OF REAL.

The LENGTH function returns the number of


What is the significance of the LENGTH
elements in the array, which is useful for
function in arrays?
iteration.
The total price is calculated by iterating
Describe the process to calculate the total through each item, multiplying the price by
price from price and quantity arrays. the quantity for that item, and summing all
the subtotals to get the total price.

A subroutine is a set of instructions


designed to perform a frequently used
Define what a subroutine is in programming.
operation, allowing for code reuse and better
organization.

Parameters are values passed into a


subroutine, which can be passed by value
How do parameters function in
(copy) or by reference (original), affecting
subroutines?
how changes to the parameters are
handled.

Passing by value creates a copy of the


parameter for use in the subroutine, while
Explain the difference between passing
passing by reference uses the original
parameters by value and by reference.
parameter, allowing changes to affect the
original variable.

Subroutines help avoid code duplication,


What are the advantages of using improve readability and maintainability, and
subroutines in programming? can perform calculations or make decisions
based on input.
By iterating through each student's marks,
How can you display the total marks for
summing them up, and outputting the total
each student using a 2-dimensional array?
for each student.

A FOR loop allows for easy iteration through


What is the purpose of a FOR loop in relation
the elements of an array, enabling
to arrays?
operations on each item.

An array is a data structure that allows many


Define what an array is in programming. data items to be stored under one identifier,
with each item accessible by its index.

Indexes allow access to specific items in an


What is the significance of array indexes?
array, starting from zero.

A procedure is defined with the


Describe the structure of a procedure in PROCEDURE keyword, followed by its name
pseudocode. and parameters, containing a block of code
that performs a specific task.
A function in Python is defined using the
'def' keyword, followed by the function
How is a function defined in Python?
name and parameters, containing a block of
code that performs a specific task.

What is the output of the calculate_area The output will be 'The area is 15', as the
procedure when called with length 5 and area is calculated by multiplying length and
width 3? width.

The showMenu procedure outputs a menu of


Explain the role of the showMenu procedure. options for the user, providing a structured
way to present choices.

Fixed length means that the size of the


What is meant by fixed length in the context array is determined at the time of its creation
of arrays? and cannot be changed during the
program's execution.

The showmenu function displays a menu


Describe the purpose of the showmenu with options for playing a game, showing key
function in Python. controls, viewing high scores, returning to the
main menu, and exiting the game.
Procedures and functions are both
Define the difference between procedures subroutines; however, functions return a
and functions in programming. value after processing, while procedures do
not.

Functions in Python are defined using the


How are functions defined in Python?
'def' keyword.

To return a value from a function in Python,


Explain how to return a value from a
use the 'return' statement followed by the
function in Python.
value to be returned.

What is the output of the calculate_area


The output of the calculate_area function
function when called with arguments 5 and
with arguments 5 and 3 is 15.
3?

Local variables are defined inside a


Describe the role of local variables in a
function and their scope is limited to that
function.
function only.
Global variables are those which are not
defined inside any function and have global
What are global variables in Python?
scope, making them accessible anywhere in
the program.

Subroutines promote code reuse, enable


List three reasons for using subroutines in
decomposition of complex problems, and
programming.
result in more maintainable code.

How many parameters can functions and Functions and procedures can have zero,
procedures have? one, or many parameters.

Library routines are pre-written code that


What is a library routine? can be used in programs to perform specific
tasks, saving time and reducing errors.

The MOD function returns the remainder


Explain the MOD function in programming. when one number is divided by another,
represented as 'x MOD y' or 'x % y'.
The ROUND function rounds a number to a
What does the ROUND function do?
specified number of decimal places.

The RANDOM function generates a random


How is the RANDOM function used in number between specified values,
Python? represented as 'RANDOM(x,n)' or
'random.randint(x,n)'.

What is the output of the The output of the print(max([5,2,8]))


print(max([5,2,8])) statement? statement is 8.

Describe the purpose of the sum function in The sum function calculates the total of a
Python. list of numbers.

What is the output of the The output of the print(round(2.34565,3))


print(round(2.34565,3)) statement? statement is 2.346.
Global variables are accessible anywhere in
Explain the difference between local and the program, while local variables are only
global variables. accessible within the subroutine in which
they were created.

What is the output of the sum function The output of the sum function when called
when called with arguments 10 and 20? with arguments 10 and 20 is 30.

Functions can be called from other parts of


How can functions be called from other
the program using their name, and their
parts of a program?
return value can be stored in a variable.

The calculate_area function computes the


What is the purpose of the calculate_area
area of a rectangle given its length and
function?
width.

Describe the purpose of the mean function The mean function calculates the average
in statistics. of a set of numbers.
The median is the middle value in a sorted
Explain the role of the median in a data set. list of numbers, which separates the higher
half from the lower half.

What does the mode function do in The mode function identifies the most
statistics? frequently occurring value in a data set.

You can sort an array in Python using the


How do you sort an array in Python? sort() method, which arranges the elements
in ascending order.

You can check if an item exists in an array


Demonstrate how to check if an item exists in
using the 'in' keyword, which returns True if
an array.
the item is found.

Maintainable programs are easier to


Define the importance of maintainable understand, modify, and collaborate on,
programs. leading to improved quality and reduced
costs.
Meaningful identifiers make code easier to
How can meaningful identifiers improve
understand and maintain by clearly indicating
code maintainability?
the purpose of variables and functions.

Comments are used to explain the code,


What is the purpose of comments in
document assumptions, and clarify complex
programming?
parts for better understanding.

Procedures and functions modularize code,


Explain the benefits of using procedures and
making it easier to understand, debug, and
functions in programming.
maintain.

Commenting syntax helps explain the


What is the significance of commenting
purpose of individual lines or blocks of code,
syntax in code?
aiding in understanding complex algorithms.

File handling involves techniques for


working with information stored in text files,
Describe file handling in programming.
including opening, reading, writing, and
closing files.
To write a line of text to a file, open the file
How do you write a line of text to a file in
for writing, input the text, and use a write
programming?
command to save it.

To read a line of text from a file, open the file


What steps are involved in reading a line of
for reading, use a read command to retrieve
text from a file?
the text, and then close the file.

Opening a file for writing allows you to add


Define the process of opening a file for
content to the file, typically using a specific
writing in programming.
command or method.

You close a file using a close command or


How do you close a file after reading or
method, which ensures that all operations are
writing?
completed and resources are released.

Descriptive names for procedures and


Explain the significance of using descriptive
functions help clarify their purpose, making
names for procedures and functions.
the code easier to read and maintain.
To write to a file in Python, you first open the
file in write mode using 'open(filename,
Describe the process of writing to a file in
"w")'. Then, you can use the 'write()'
Python.
method to add text to the file. Finally, you
close the file using 'close()'.

To read from a file in Python, you first need


to open the file in read mode using
How do you read from a file in Python after 'open(filename, "r")'. Then, you can use the
writing to it? 'read()' method to retrieve the contents of
the file. After reading, you should close the
file using 'close()'.

The 'close()' method is used to close a file


Define the purpose of the 'close()' method in that has been opened. This is important to
file handling. free up system resources and ensure that all
data is properly written and saved.

The 'input()' function is used to take user


What is the significance of using 'input()' in
input, which allows the user to enter a line of
the file writing process?
text that will be written to the file.

The sequence involves opening a file in write


mode, taking user input to write to the file,
Explain the sequence of operations for file
closing the file, then reopening it in read
handling in the provided code.
mode, reading its contents, and finally closing
it again.
The 'print()' function is used to display
How does the 'print()' function contribute to messages to the user, such as prompting for
the file handling process? input and showing the contents of the file
after reading.

If you try to read a file that has not been


What happens if you try to read a file that written to, it will return an empty string or
has not been written to? may raise an error, depending on the
implementation.

You might also like