CSE Assignmnet
CSE Assignmnet
Kurnool (IIITDMK)
Department of Computer Science and Engineering
Python Programming Laboratory(S2-B.Tech CSE)
Assignment 7
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
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.
4. Write a python class that simulates a credit card which allows users to purchase any item when
the suuficient credit available.
Customer = Raman
Bank = SBI
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:
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
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)