0% found this document useful (0 votes)
9 views5 pages

Ap Cat Marking

marking scheme

Uploaded by

me.itzdavide
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)
9 views5 pages

Ap Cat Marking

marking scheme

Uploaded by

me.itzdavide
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/ 5

SCHOOL OF ENGINEERING AND TECHNOLOGY

BACHELOR OF TECHNOLOGY ELECTRONICS AND COMPUTER ENGINEERING


AND
BACHELOR OF TECHNOLOGY TELECOMMUNICATION ENGINEERING
CAT I
ECE 2423: APPLICATION PROGRAMMING

DATE: 16-10-2023 TIME: 1 Hour


a) Highlight three applications of application programming in the current world and also
in the future use. (3 Marks)
a. Smart Grids:
i. Smart grids use advanced electronics and software to optimize
electricity generation, distribution, and consumption, enhancing
efficiency and reliability.
b. Electric Vehicles (EVs):
i. EVs incorporate complex electrical systems and software to manage
power delivery, battery charging, and vehicle control, reducing carbon
emissions.
c. Home Automation Systems:
i. Smart home systems employ electronics and programming to automate
and control lighting, HVAC, security, and appliances for energy
efficiency and convenience.
d. Wearable Electronics:
i. Wearable devices, like fitness trackers and smartwatches, integrate
sensors and software to monitor health and collect data for user
insights.
e. Industrial Automation:
i. In manufacturing and industrial settings, automation systems leverage
electronics, sensors, and software to optimize production processes,
ensuring efficiency and quality.
Correct explanation earns full marks

b) Using a relevant Python code snippet, differentiate between the arithmetic operators
in Python: %, / and // (3 Marks)
i. % (Modulus Operator):

The modulus operator % calculates the remainder of a division operation. It returns


the remainder when one number is divided by another.

ii. / (Division Operator):

Programming is fun! Enjoy!


The division operator / performs regular division and returns a floating-point result
(a decimal number).

iii. // (Floor Division Operator):

The floor division operator // also performs division but rounds down the result to the
nearest whole number (integer division). It discards the decimal part.

Each correct explanation earns two marks with a correct code snippet earns two
marks.
c) Explain the difference between a local variable and a global variable (2 Marks)
• Global variables are defined at the top level of a Python script or module and can
be accessed from any part of the code.
• Local variables are defined within a function's scope and are only accessible within
that function. They are created when the function is called and destroyed when the
function exits.
Correct code with proper explanation earns full marks

d) What are Python data types? Provide examples of at least three different data types with
their respective initialization (3 Marks)
Integer (int):
• An integer data type represents whole numbers, both positive and negative, without
any decimal point.
Float (float):
• A float data type represents floating-point numbers, which can have decimal points
and fractions.
String (str):
• A string data type represents a sequence of characters enclosed in single (' '),
double (" "), or triple (''' ''' or """ """) quotes.

Correct code with proper explanation earns one mark for each

Programming is fun! Enjoy!


e) Write a Python program that asks the user to input a number. If the number is even,
the program should print "The number is even." If the number is odd, it should print
"The number is odd." Ensure that you store the user's input in a variable and use a
conditional control structure to determine whether it's even or odd. The program
should make use of a function named is_odd_even(x) that accepts an integer argument
and returns True or False. (4 Marks)

Correct definition of the function earns two marks


Correct user input earns one mark
Correct use of control structure i.e if statement earns one mark

f) Given the following Python Code snippet. Answer the following questions:

Figure 1 Code Snippet

i. What will be the data type of x for the following code? (1 Mark)
string
ii. Write a python code to print out the data type of x (1 Mark)
print(type(x))
iii. Write a python code to compare the variable type to the integer data type
(1 Mark)
(isinstance(x, int)
Each correct answer earns one mark
g) Write a Python program to read a value from the keyboard and output the phrase
NEGATIVE if the number is negative, POSITIVE if the number is positive or ZERO
otherwise. (4 Marks)

Programming is fun! Enjoy!


Correct code with proper explanation earns full marks
h) Using relevant programming languages examples, differentiate between compilers
and interpreters. (4 Marks)
Compilers and interpreters are both tools used in the field of programming to
translate and execute code, but they do so in different ways.
Translation Process:
• A compiler translates the entire source code of a program into machine code or
an intermediate code all at once, before execution.
• The resulting compiled code is often saved to a separate file, which can be
executed independently of the source code.
Translation Process:
• An interpreter translates and executes code line by line or statement by statement, as
it encounters each instruction.
Examples:
• One of the classic examples of a compiled language is C/C++. In C, you write your
code in a .c file and use a compiler like GCC to generate an executable file, which
you can run without needing the original .c file.
Examples:
• Python is a popular interpreted language. You write your Python code in a .py file,
and the Python interpreter reads and executes it line by line when you run the script.
Correct explanation earns full marks

i) How do you comment out code in Python, and why is commenting important? Using
relevant code snippet, show two ways you can comment out Python code (4 Marks)
Comments are placed using either # or “”” “””

Programming is fun! Enjoy!


Correct code with proper explanation earns full marks

Programming is fun! Enjoy!

You might also like