Python Programming
Assignment
Assignment Questions
Question 1
●Write a Python program that takes an
integer input and checks whether it is
positive, negative, or zero.
●If the number is positive, print all even
numbers from 1 to that number using a
loop.
Question 2
●Write a Python program that takes a string
input from the user.
●Store the frequency of each character in a
dictionary and store all unique characters
in a set.
Question 3
●Define a function calculate_factorial(n) that
returns the factorial of a number.
●Call the function from the main program
and handle negative input.
Question 4
●Create a class Student with attributes
name and marks.
●Use encapsulation to make marks private.
●Create a child class GraduateStudent to
demonstrate inheritance and
polymorphism.
Question 5
●Write a Python program that writes user
input text into a file and then reads the
content back.
●Handle exceptions such as
FileNotFoundError and invalid input.