Python Task
Python Task
ARKA MUKHERJEE
IST AT2
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.
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.
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
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
# Variables (yellow)
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)
Question 2
Identify one variable, one loop and one assignment statement/declaration from the sample code below
Example
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
Comments:
Relational operators:
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
Print statements
9
Section 3
Algorithm Python
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
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
33 Enter
34 Open userlog.txt
35 On {date} {time},
{name} took {attempts}
attempts to guess
{random_number}
14