0% found this document useful (0 votes)
6 views

Python Exam

This document is a practical question paper for a Core Python Programming assessment worth 50 marks, divided into two sections. Section A includes tasks such as determining if an integer is even or odd, calculating the perimeter of a rectangle, and checking for palindromes, while Section B involves creating a class for squares, reversing lists, and implementing a menu-driven program. Students are instructed to write code without using external libraries and to ensure their code is well-commented.

Uploaded by

fakivkhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python Exam

This document is a practical question paper for a Core Python Programming assessment worth 50 marks, divided into two sections. Section A includes tasks such as determining if an integer is even or odd, calculating the perimeter of a rectangle, and checking for palindromes, while Section B involves creating a class for squares, reversing lists, and implementing a menu-driven program. Students are instructed to write code without using external libraries and to ensure their code is well-commented.

Uploaded by

fakivkhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical Question Paper : Core Python Programming (No Libraries) - 50 Marks

Total Marks: 50

Instructions:
●​ This question paper consists of two sections, A and B.
●​ Answer all questions in each section.
●​ Use Python to write code to solve the problems without importing any external libraries.
●​ Provide your Python code as the answer to each question.
●​ Ensure your code is well-commented and produces the expected output.

Section A: (25 Marks)


1.​ (4 Marks) Write a Python program to determine if a given integer is even or odd. The
program should take an integer input from the user and print "Even" or "Odd".
2.​ (5 Marks) Create a Python function called calculate_perimeter that calculates the perimeter
of a rectangle. The function should take the length and width as arguments and return the
perimeter. Write a program to use this function to calculate the perimeter of a rectangle with
length 12 and width 7, and print the result.
3.​ (5 Marks) Write a Python program to calculate the product of all numbers in a list. The list
of numbers should be defined within the program (e.g., numbers = [2, 3, 4, 5]). Print the
product.
4.​ (5 Marks) Create a Python program that takes a string as input and checks if it is a
palindrome. The program should print "Palindrome" if it is, and "Not a palindrome"
otherwise.
5.​ (6 Marks) Write a Python program to read a text file named "my_text.txt" (assume this file
exists in the same directory). The program should read the content of the file line by line
and print each line to the console.

Section B: (25 Marks)


6.​ (5 Marks) Create a Python class called Square with an initializer that takes the side length
as an argument. The class should have a method get_area that calculates and returns the
area of the square, and a method get_perimeter that calculates and returns the perimeter.
7.​ (6 Marks) Write a Python function called reverse_list that takes a list as input and returns a
new list with the elements in reverse order. For example, if the input is [10, 20, 30, 40], the
output should be [40, 30, 20, 10].
8.​ (7 Marks) Write a Python program that simulates a basic menu-driven program. The
program should display a menu with options like "1. Add", "2. Subtract", "3. Multiply". It
should then ask the user to choose an option and enter two numbers. Based on the chosen
option, perform the corresponding arithmetic operation and print the result. The program
should loop until the user chooses to exit (e.g., by entering '4. Exit').
9.​ (7 Marks) Write a Python program to read data from a CSV file named "info.csv" (assume
this file exists in the same directory and contains comma-separated values). The program
should read each line from the CSV file and print each value in each line, separated by
tabs.

--- End of Question Paper —

You might also like