ASSESSMENT 1 Python 23-24 V2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Department of Computer & Information Sciences

ASSESSMENT BRIEF
Module Title: Programming
Module Code: KV4012
Academic Year / Semester: 2023-2024 / Semester 2
Andy Dow
Module Tutor / Email (all queries):
[email protected]
% Weighting (to overall module): 25%
Assessment Title: Assessment #1
Date of Handout to Students: Feb 23 2024

Mechanism for Handout: Module Blackboard


Deadline for Attempt Submission by
12 March 2024 16:00
Students:
Mechanism for Submission: Document upload to Module Blackboard Site
Please fill in the assessment online, upload source
Submission Format / Word Count
sketch.
Date by which Work, Feedback and
April 2024
Marks will be returned:
Mark and feedback will be automatically
Mechanism for return of Feedback
generated. For further queries please email
and Marks:
module tutor.

LEARNING OUTCOMES
The learning outcomes (LOs) for this module are:-
LO1 Knowledge & Understanding: Demonstrate an understanding of the basic
principles of programming using an appropriate programming language, including
the use of variables, conditions, loops, subprograms
LO2 Demonstrate an understanding of abstraction mechanisms and structured data
types
LO3 Intellectual / Professional skills & abilities: Create reliable and maintainable
software using appropriate code standards.
LO4 Personal Values Attributes (Global / Cultural awareness, Ethics, Curiosity) (PVA):
Solve problems using a structured approach.

This assessment addresses learning outcomes LO1, LO2, LO3 and LO4.
Nature of the submission required:

See the section below on how to submit your work.

Instructions to students:

This is an individual piece of work.

Referencing Style:

N/A

Expected size of the submission:

No expected size.

Academic Conduct:

You must adhere to the university regulations on academic conduct. Formal inquiry
proceedings will be instigated if there is any suspicion of misconduct or plagiarism in your
work. Refer to the University’s regulations on assessment if you are unclear as to the
meaning of these terms. The latest copy is available on the university website.
What to do
First, download Assessment1.zip from Blackboard. This contains the “harness” file that
you must update in order to complete the assessment. It automatically marks your work in
real time, so that you can get immediate feedback.

Create a new project In Pycham

Add main.py ( the file with the question stubs) and MarkingDoNotOpen.py to the project

Under no circumstances view/edit Marking Do Not Open.py

Run main.py put your answers there.

When finished upload your mark and code.

Do not use any AI like chat GPT in answering these questions.

Questions
1. In the function Question1, use print to print your name. This is a “starter question” to
get you used to using the automated marking system. It is not meant to be difficult, and
there are no tricks in this question.
[1]
2. In the function Question2, print the name of the weekday when the the Lecture for
KV4012 session is held (begins with a Capital Letter)
[1]
3. The function Question3 uses print to print the name of the course textbook in the
library. This has 4 words, begins with T. Case is not important. Single spaces between words.
[1]

4. The function Question4 uses print to print value of argument1. For example if
the value contained in argument1 is “house” print house. Do not print “argument1”.
[1]

5. Decode this and write the function. A chatbot wants to address the user by name. The
function Question5 accepts a String argument, Name, and prints the greeting “Nice
to meet ,you, ”. So if the variable Name contains “Brian” your code returns “Nice
,

to meet ,you, Brian”. Notice the comma and single space after the greeting – it’s
,

important that you include this. All spaces as single spaces.


[1]
6. In function Question6 RETURN the first argument added to the second. So if argument
arg1 is 5 and arg22is 4 the function returns -9.0
[1]

7. In function Question77 returns the first argument subtracted to the second. So if


argument arg1 contains 5.3 and arg2 contains-4 the function prints 1
[1]

8. In function Question8 returns the first argument multiplied by the second. So if


absolute

argument arg1 contains -5 and arg2 contains 4 the function prints 20


[1]

9. In function Question9 return the result of the formular . So if argument a

contains 10 and b contains 20, c 5 the function returns 2.550903979202493


[4]

10. Outside any function, at the top of your code, create an String variable called myFirstVar
( this name exactly). Set the value of this variable to “Question10” This is called a global
variable, as it’s accessible from anywhere in your code..
[1]

11. Outside any function, at the top of your code, create an String variable called myEmptyVar
( this name exactly). Set the value of this variable to None.
[1]

12. Outside any function, create global variable which is an integer called myNumberVar ( this
name exactly). Set the value of this variable to 20241
[1]

13. The function Question13 tests your ability to turn specification into code. Your gas bill is
computed by taking the number square meters of gas used that month multiplying it by -
1.343 then adding a £10.9standing change. So if the variable howMuchGass is 10 it would
return 23.433
[2]

14. The function Question14 takes the argument called fraction and returns the
number converted to an integer. So if the value 35.50 is passed it returns 35.50Use the cast
operator.
[1]

15. The function Question15_takes the argument which is an int called anything and
returns the Boolean constant True if the value is equal to-34. Otherwise it returns Not
False.
[1]

16. The function Question16 is a challenge for you to convert a specification into a code.
This function returns “PASS” if the mark is 40 or more or the string “FAIL” if the value is less
than 400.
[1]

17. The function Question17 takes the argument which is an int called anything and
returns the Boolean constant True if the value is less than to -1020 . Otherwise it returns
**2

False.
[1]

18. The function Question18 returns the Boolean True if the argument a1 is any number
except 90 . If the number is 90 it returns false. use != in the code (this will not be checked
automatically)
[1]

19. The function Question19 takes the argument which is an a boolean called anything
and returns the true if the value is false and false if the value is true. Do not use an if
statement, this will not be checked automatically.
[1]

20. The function Question20 returns true if the fi1st argument is more than eight and the
second argument is more then 90. For example a= 9 and b = 100 it returns true. If a=9 and
b = 30 it returns false. If either condition is not met the function returns false.

[1]

21. The function Question21 returns the Boolean True if the first argument is greater than
-14 and is equal to or less than 23. In all other cases it returns False.
[1]

22. The function Question22 returns the Boolean true if the first argument is greater than
or equal to the second or false if not.
[1]

23. The function Question23 returns false if the string is equal to the None value or
true if not.
[2]

24. The function Question24_ returns-24 if the string argument equals “Hello” exactly and
9**3 if not.
[2]

25. The function Question25 returns True if the string argument contains the word “main”
anywhere in the text passed (so the sentence ‘says mainly in the plane’ would return true).
Returns false otherwise.
[2]

26. The function Question26 returns True if the argument string contains the word "Yes"
or "yes" or "YES" but not "yES". False otherwise.
[3]

27. The function Question27 returns the index of the word “No” in the first argument. So
“MNo” returns 1. “No” returns 0. If not found return -1. This tests your documentation look
up methods/actions/functions ( try searching “Python String methods” )
[3]

28. The function Question28 returns True if the index of the word “Now” is after index 12
in the text of the first argument . False otherwise.
[3]

29. The function Question29 returns a list of exactly 8 items these can be strings or
numbers.
[3]

30. The function Question30 sets the variable Q30 to a list of two strings. This change must
happen in the function.
[3]

31. The function Question31 returns the length of the list passed. So if the argument is
[1,11] to it returns 2. if the argument is None then it is 0
[2]

32. In function Question32 has arguments m0useX and m0useY return Boolean True if the
mouse is with or on the boarder of the shape give in image and False if does not click in it

[4]

You might also like