0% found this document useful (0 votes)
32 views10 pages

Python Programs for User Input Tasks

The document outlines five Python programming tasks, each requiring user input and calculations related to passwords, dice rolls, electric car costs, pizza pricing, and digital image file sizes. Each task specifies the necessary inputs, outputs, and conditions for correctness, along with a marking scheme that evaluates design and logic. The tasks emphasize the use of meaningful variable names and proper Python syntax.

Uploaded by

iqanahmedup01
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)
32 views10 pages

Python Programs for User Input Tasks

The document outlines five Python programming tasks, each requiring user input and calculations related to passwords, dice rolls, electric car costs, pizza pricing, and digital image file sizes. Each task specifies the necessary inputs, outputs, and conditions for correctness, along with a marking scheme that evaluates design and logic. The tasks emphasize the use of meaningful variable names and proper Python syntax.

Uploaded by

iqanahmedup01
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

01 Write a Python program to check if a password change has been done correctly.

Your program must:

 get the user to input a password


 get the user to input the same password a second time
 output the message password has been changed if both passwords are the
same
 output the message passwords do not match if both passwords entered are
not the same and return to the start to allow both passwords to be re-entered

You should use meaningful variable name(s) and Python syntax in your answer.

The answer grid below contains vertical lines to help you indent your code.

[7 marks]
02 Write a Python program to randomly generate dice values for an adventure game.

Your program must:

 get the user to input the number of sides of a dice - between 1 and 20
 get the user to input the total number of dice to roll - between 1 and 3
 output each individual dice value
 output the total combined dice value

You should use meaningful variable name(s) and Python syntax in your answer.

The answer grid below contains vertical lines to help you indent your code.

[5 marks]

03 Write a Python program that calculates the cost per mile for an electric car.
Your program must:

 get the user to input the maximum distance the electric car will cover on a full
charge
 get the user to input the cost for fully charging an electric car
o the number of units of electricity used
o the cost per unit of electricity
o the standing charge - a fixed amount of £5
 output the cost per mile

You should use meaningful variable name(s) and Python syntax in your answer.

The answer grid below contains vertical lines to help you indent your code.

[7 marks]

04 Write a Python program that calculates the cost per slice of a pizza.
Your program must:

 get the user to input the size of a pizza - either medium or large
 get the user to input the number of toppings
 output the cost per slice of the pizza:
o if the size is medium with a total of 8 slices, then the pizza cost will be £5
plus number of toppings multiplied by £0.50 p
o if the size is large with a total of 12 slices, then the pizza cost will be £7.50
plus number of toppings multiplied by £0.50 p

You should use meaningful variable name(s) and Python syntax in your answer.

The answer grid below contains vertical lines to help you indent your code.

[7 marks]

05 Write a Python program that calculates the file size of a digital image in bits and bytes.
Your program must:

 get the user to input the pixel dimensions of the image - breadth and height
 get the user to input the colour depth of the image in bits - between 2 and 8
 output the image file size in bits
 output the image file size in bytes

You should use meaningful variable name(s) and Python syntax in your answer.

The answer grid below contains vertical lines to help you indent your code.

[5 marks]

MS MARKING SCHEME
01

Note that DESIGN marks are for selecting appropriate techniques, and should be credited whether
the syntax of the programming statements is correct or not and regardless of whether the solution
works

DESIGN

Mark A for using meaningful variable names throughout and for using two different variables to
store the two password inputs

Mark B for the use of a selection construct

Mark C for the use of an iteration construct

LOGIC

Mark D for using user input and storing the passwords in two variables correctly for the first and
second password input

Mark E for a correct expression that checks if the second password is equal (or not equal) to the first
password

Mark F for outputting password has been changed or passwords do not match
messages in logically separate places such as the IF and ELSE part of selection

Mark G for returning to re-input the passwords if passwords do not match

Maximum 6 marks if any errors in code

MS 02
Note that DESIGN marks are for selecting appropriate techniques, and should be credited whether
the syntax of the programming statements is correct or not and regardless of whether the solution
works

DESIGN

Mark A for using meaningful variable names throughout and for using three different variables to
store the dice sides, total number of dice and sum total of values

Mark B for the use of addition

LOGIC

Mark C for using user input and storing the dice sides and number of dice in two variables correctly

Mark D for use of random library to generate values and calculating and storing the result of the
calculation in a variable correctly

Mark E for correct output of ALL values - individual dice totals and the sum total

Maximum 4 marks if any errors in code

MS 03
Note that DESIGN marks are for selecting appropriate techniques, and should be credited whether
the syntax of the programming statements is correct or not and regardless of whether the solution
works

DESIGN

Mark A for using meaningful variable names throughout and for using four different variables to
store the distance, number of units, cost per unit and standing charge inputs

Mark B for the correct application of a suitable formula to calculate the total cost of electricity

( cost of electricity = (units * cost per unit) + standing charge )

Mark C for the correct application of a suitable formula for the cost per mile calculation

( cost per mile = cost / distance e.g. if cost to charge is £10 ( = 1000 p) and distance is 80 miles,

cost per mile = 1000 p/80 = 12.5 p / mile)

LOGIC

Mark D for using user input and storing the distance, number of units, cost per unit and standing
charge in four variables correctly

Mark E for a correct expression that calculates the cost of electricity

Mark F for a correct expression to calculate the cost per mile

Mark G for outputting the cost per mile

Maximum 6 marks if any errors in code

MS 04
Note that DESIGN marks are for selecting appropriate techniques, and should be credited whether
the syntax of the programming statements is correct or not and regardless of whether the solution
works

DESIGN

Mark A for using meaningful variable names throughout and for using four different variables to
store the size of pizza, number of toppings, cost of a full pizza and number of slices/cost per slice

Mark B for a selection construct

Mark C for the correct application of a suitable formula to calculate the total cost of a pizza

Mark D for the correct application of a suitable formula for the cost per slice of pizza

LOGIC

Mark E for using user input and storing the size of pizza, number of toppings, total cost of pizza and
cost per slice in four variables correctly

Mark F for correctly calculating the cost of pizza/cost per slice of pizza in logically separate places
such as the IF and ELSE part of selection

Mark G for outputting the cost per slice of pizza

Maximum 6 marks if any errors in code

MS 05
Note that DESIGN marks are for selecting appropriate techniques, and should be credited whether
the syntax of the programming statements is correct or not and regardless of whether the solution
works

DESIGN

Mark A for using meaningful variable names throughout and for using three different variables to
store the breadth, height and colour depth

Mark B for the use of multiplication for total bits and calculation for bytes

LOGIC

Mark C for using user input and storing the breadth, height and colour depth in three variables
correctly

Mark D for calculating image file size in bits and bytes and storing the result(s) of the calculation in
(a) variable(s) correctly

Mark E for correct output of ALL values - image file size in bits and image file size in bytes

Maximum 4 marks if any errors in code

You might also like