10 IST_2
ARKA MUKHERJEE
IST AT2
Software Development and Programming
Table of Contents
Part A 3
Section 1 4-6
2
PART A
3
Section 1
Question 1
IPO Chart:
A program requires that three numbers be added and their total printed. Complete the IPO chart below and create the pseudocode
for it.
Input Processing Output
Number A Read Numbers A, B, C Sum
Number B
Number C Add Numbers
Store the result in a variable called Sum
Print the Sum
Pseudocode:
Begin
Read Number’s A, B, C
Add all 3 numbers
Print the sum
End
Question 2
IPO Chart:
You need to design a program that calculates the average temperature of a given day. A user will input the minimum and maximum
temperatures of the day and accept these as integers. The program will then calculate the average temperature and display it on the
screen. Complete the IPO chart below and create a flowchart for it in the designated spaces below.
Input Processing Output
Minimum Daily Temp(Int) Read Minimum and Maximum Answer
Maximum Daily Temp(Int) Temperatures
Add Both numbers
Divide by 2
4
Print the answer
Algorithm(Flowchart)
Question 3
IPO Chart:
You work for a lawn care company. The manager decides to automate the quoting system. You need to create a program that will
prompt and accept the length and width of the block of land and the length and width of the house (for this example, land and house
are rectangles). The program must then compute and display the required time to cut the grass around the house at a rate of ten
square meters per minute. Complete the IPO chart below and create a pseudocode for it in the designated spaces below.
5
Input Processing Output
Length and Width of House Length x Width of garden = Area of Quotation
Length and Width of Garden garden
Length x Width of House = Area of house
(Area of garden - Area of House) / 10 =
Time taken(minutes)
Time x rate = Quotation
Print Quotation
Pseudocode:
Begin
Read Length and Width of House
Read Length and Width of Garden
Multiply Length and Width of house
Multiply Length and Width of garden
Subtract area of house from area of garden
Divide answers by 10 to find time taken in minutes(quotation)
Print Quotation
End
6
Section 2
Question 1
Identify 4 variables, 4 assignment statements/declarations and the string in the sample code below. In this section you can color code
each providing you provide a key to distinguish each of the components (e.g. yellow for variables, red for assignment
statements/declarations, green for the strings) as there are multiple subsections in this part you should remain consistent to avoid
confusion.
Example
word1 = “Good” word2
= “Morning” word3 =
“to you too!” print
word1, word2
sentence = word1 + “ ” + word2 + “ ” +word3 print
sentence
# Variables (yellow)
word1 = "Good"
word2 = "Morning"
word3 = "to you too!"
Sentence = word1 + “ ” + word2 + “ ” +word3
# Assignment statements/declarations (red)
word1 = "Good"
word2 = "Morning"
word3 = "to you too!"
Sentence = word1 + “ ” + word2 + “ ” +word3
# String (green)
sentence = word1 + " " + word2 + " " + word3 #This Line is the String
print(sentence)
Good Morning to you too!
Question 2
Identify one variable, one loop and one assignment statement/declaration from the sample code below
Example
Private Sub Command1_Click(Index As Integer)
Dim n As Integer
For n = 0 to 8
Command1(n).Caption = ””
Next
Randomize Timer
n = Int(Rnd * 9) If
Index = n Then
Command1(n).Caption = “Prize”
7
Else: Command1(n).Caption = “The Prize is here” End
If
End Sub
Variable: n is declared as an integer variable (Dim n As Integer). ‘Dim’ declares a new variable. ‘N’ is the name of the variable.
‘Integer’ is the type of variable.
Loop: For n = 0 to 8 This line starts the loop setting ‘n’ to 0 and specifying that the loop will run till ‘n’ reaches 8.
Assignment statement/declaration: Command1(n).Caption = "" assigns an empty string to the Caption property of Command1(n).
Identify the comments, relational operators, variables, functions and statements in the below code.
Example
import random def main(): raw_input('\nHow many turns
will it take to roll over 13?')
#lets roll a dice
diceRoll = 0 rolls = 0
rollsTotal = 0 while
rollsTotal < 13:
diceRoll = random.randrange(6)+1
rolls = rolls+1
rollsTotal = rollsTotal+diceRoll
print 'Roll number = ',rolls, 'was a ',diceRoll
print 'Roll Total = ',rollsTotal if rollsTotal >=
13:
# prints number of rolls taken to get to or over 13
print'\nIt took',rolls, 'rolls to get over 13.' main()
raw_input("\n\nPress the enter key to exit.")
Comments:
# lets roll a dice
# prints number of rolls taken to get to or over 13
(Anything that has ‘#’ at the front of the phrase.)
Relational operators:
1. rollsTotal < 13 (in the while loop)
8
2. rollsTotal >= 13 (in the if statement)
Variables:
diceRoll = random.randrange(6)+1
rolls = rolls+1
rollsTotal = rollsTotal+diceRoll
Function:
‘main()’ is a function defined to summarize the main logic of the program. This function prompts the user for input, simulates the roll
of a dice until reaching a total of 13 and then prints the number of rolls taken to surpass 13.
Statements:
Assignment statements
(diceRoll = random.randrange(6) + 1,
rolls = rolls + 1
rollsTotal = rollsTotal + diceRoll)
Print statements
print 'Roll number = ', rolls, 'was a ', diceRoll
print 'Roll Total = ', rollsTotal
print '\nIt took', rolls, 'rolls to get over 13.')
9
Section 3
Algorithm Python
1. get price of item
2. get sales tax rate
3. sales tax = price of item times sales tax rate
4 final price = price of item plus sales tax
5. display final price
1) Get price of item: The user is prompted to enter the
price of the item, which is then converted to a
floating-point number.
2) Get sales tax rate: The user is prompted to enter the
sales tax rate as a decimal (e.g., 0.07 for 7%), which is
then converted to a floating-point number.
3) Calculate sales tax: The sales tax is calculated by
multiplying the price of the item by the sales tax rate.
4) Calculate final price: The final price is calculated by
adding the sales tax to the price of the item.
5) Display final price: The final price is displayed,
formatted to two decimal places.
10
11
PART A
12
Line Number Process Conditions Input Output
1 Import Random
2 Import Datetime
5 Enter
6 Name
7 Enter
8 Enter
9 Enter
10
11
12 Random Number
13 Guess Number
14 Attempts = (Attempts+1)
15
16
17 Guess != random_number
18 Guess > random_number
19 Too big
20
21 Too Low
22 Guess Number
23 Attempts = (Attempts+1)
24
25
13
26 Attempts = str(Attempts)
27
28
29 guess==random_number Date/Time
30 Date
31 Time
32 You got the number in
{attempts} tries
33 Enter
34 Open userlog.txt
35 On {date} {time},
{name} took {attempts}
attempts to guess
{random_number}
14