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

CSE Assignmnet

The document provides instructions for an assignment on Python programming. It includes 8 questions covering topics like stacks, classes, inheritance, shapes, social media profiles, decks of cards. For each question, it provides sample inputs and outputs to test the code.

Uploaded by

123ad0006
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)
8 views

CSE Assignmnet

The document provides instructions for an assignment on Python programming. It includes 8 questions covering topics like stacks, classes, inheritance, shapes, social media profiles, decks of cards. For each question, it provides sample inputs and outputs to test the code.

Uploaded by

123ad0006
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

Indian Institute of Information Technology, Design & Manufacturing,

Kurnool (IIITDMK)
Department of Computer Science and Engineering
Python Programming Laboratory(S2-B.Tech CSE)

Assignment 7

Last date for submitting : 21/04/2024 17:00 Hrs

Naming Conventions for Submission


Submit a single ZIP (.zip) file (do not submit in any other archived formats like .rar or .tar.gz).
The name of this file must be ASSG<NUMBER>_<ROLLNO>_<FIRSTNAME>.zip. (eg:
ASSG1_118cs0006_LAXMAN.zip). DO NOT add any other files (like temporary files,
inputfiles, etc.) except your source code, into the zip archive. The source codes must be named
as ASSG<NUMBER>_<ROLLNO>_<FIRSTNAME>_<PROGRAM-NO>.<extension>. (For
example: ASSG1_118cs0006_LAXMAN_1.py). If there are multiple parts for a particular
question, then name the source files for each part separately as in
ASSG1_118cs0006_LAXMAN_1b.py.
If you do not conform to the above naming conventions, your submission might not be
recognized by some automated tools, and hence will lead to a score of 0 for the submission. So,
make sure that you follow the naming conventions.
1. STACK
a) Implement a stack using python class

Your program must support the following functions:


- push(stk, element) – puts the data specified by element on top of the stack specified by stk.
- pop(stk) – removes and returns the topmost element of the stack specified by stk. Return null
(or some special value), if the stack is empty.
- peek(stk) – returns the topmost element of the stack specified by stk, without actually removing
the element from the stack. Return null (or some special value), if the stack is empty.
- show(stk) – displays all the data present in the stack specified by stk.

Input - Output Format

The input consists of multiple lines, each one containing either one or two integers.
The first integer in the line can be 0, 1, 2, 3 or 4, and each one has its own meaning:
- The integer 0 means stop the program.
- The integer 1 means push the next integer from the input on the stack. In this case, the next
integer (>= 0) is given on the same line as the 1, separated by a space.
- The integer 2 means pop and output the topmost element of the stack. Output “EMPTY”, if the
stack was originally empty.
- The integer 3 means peek and output the topmost element of the stack. Output “EMPTY”, if the
stack was originally empty.
- The integer 4 means show all elements in the stack. In this case, output all elements of the stack
on a single line, separated by space, starting with the top most element. Output “EMPTY”, if the
stack was originally empty.

Sample Input Sample Output


1 45
1 65
1 74
1 25
1 98
3 98
3 98
2 98
3 25
1 17
4 17 25 74 65 45
2 17
2 25
2 74
2 65
2 45
2 EMPTY
3 EMPTY
4 EMPTY
0
2. Write a Python class named Circle constructed by a radius and two methods which will compute
the area and the perimeter of a circle.

Sample Input
8
Output
200.96
50.24

3. Write a python class simulates a bank account which allows users to check balance, make
withdrawal and deposit money.

Sample Input and output

Current Balance: 5000


Withdrawing 10000 ...
Error: Not enough funds
Lets try withdrawing 1000 ...
Successfully withdrawn 1000
Now Current Balance: 4000
Depositing 2000 ...
Now Current Balance: $6000

4. Write a python class that simulates a credit card which allows users to purchase any item when
the suuficient credit available.

Sample Input and output:

Customer = Raman

Bank = SBI

Account = 5391 0375 9387 5309


Limit = 2500
Topay = 2000
Balance = 500
credited = 1000
New Balance = 1500
5. Write a python class Progression using Inheritance

 Base Class: Progression


 Child Classes:
 ArithmeticProgression
 GeometricProgression
 FibonacciProgression
Sample Input1
seq = Progression()
seq.print_progression(10)
Output1:
0 1 2 3 4 5 6 7 8 9

Sample Input 2:
a = ArithmeticProgression()
a.print_progression(10)

Output2:
0 2 4 6 8 10 12 14 16 18

Sample Input 3:
b = GeometricProgression()
b.print_progression(10)

Output3:

1 2 4 8 16 32 64 128 256 512

6. Write a python class using inheritance, by considering base class as shape. The requirements of
shapes are:
 Set the appropriate color
 Set the bool value when the color filled
Create child classes for
1 Rectangle:
2 Circle:
Find the area and perimeter of the above shapes
Sample Input and Output
Area of rectangle r1: 26.25
Perimeter of rectangle r1: 26.0
Is rectangle r1 filled ? False
Color of rectangle r1: orange
Is rectangle r1 filled ? True

Area of circle c1: 452.39


Perimeter of circle c1: 75.40
Is circle c1 filled ? False
Color of circle c1: blue

Is circle c1 filled ? True

7. Write a python class using inheritance, by considering some attributes of a Facebook user. Let’s
add a first name, last name and a list of friends and add a method that prints the full name of a user,
also add a method that prints the list of friends. create a SpotifyUser class that will inherit the
methods and attributes from the FacebookUser class.

8. Create a deck of cards class. Internally, the deck of cards should use another class, a card class.
Your requirements are:

 The Deck class should have a deal method to deal a single card from the deck
 After a card is dealt, it is removed from the deck.
 There should be a shuffle method which makes sure the deck of cards has all 52 cards and
then rearranges them randomly.
 The Card class should have a suit (Hearts, Diamonds, Clubs, Spades) and a value
(A,2,3,4,5,6,7,8,9,10,J,Q,K)

You might also like