Follow

iklan banner
MASIGNCLEAN101

Python TYBBA (CA) Pratical Slip 4 Savitribai Phule Pune University

Python TYBBA (CA) Pratical Slip 4 Savitribai Phule Pune University
Mr PVK
March 30, 2025

 Slip 4


A) Write Python GUI program to create background with changing colors.


from tkinter import * 


gui = Tk(className='Python Window Color') 


# set window size

gui.geometry("420x220") 


#set window color 

gui.configure(bg='red') 

gui.mainloop()



OR



from tkinter import Button, Entry, Label, Tk


def changecolor():

    newvalue = value.get()

    gui.configure(background = newvalue)

    

gui=Tk()

gui.title("color change.")

gui.configure(background = "gray")

gui.geometry("400x300")


color = Label(gui, text = "color", bg = "gray")

value = Entry(gui)

apply = Button(gui, text = "Apply", fg = "Black", bg = "gray", command = changecolor)


color.grid(row=0,column=0)

value.grid(row=0,column=1)

apply.grid(row=0,column=2)


gui.mainloop()



Program Output :





B) Define a class Employee having members id, name, department, salary. Create a subclass called manager with member bonus. Define methods accept and display in both the classes. Create n objects of the manager class and display the details of the manager having the maximum total salary (salary+bonus).


class Employee:
    def __init__(self, id, name, department, salary):
        self.id=id
        self.name=name
        self.department=department
        self.salary=salary
        
class manager(Employee):
    def __init__(self, id, name, department, salary ,bonus):
        super(manager, self).__init__(id, name, department, salary)
        self.bonus=bonus
        
    def totalsalary(self):
        print(self.name,'got total salary :',self.salary+self.bonus)
        
n=manager('A023','Pratik','GENERAL MANAGEMENT',21000,8000)
m=manager('A025','Vaishnavi','MARKETIG',26000,6400)
n.totalsalary()
m.totalsalary()

Program Output :

Pratik got total salary : 29000
Vaishnavi got total salary : 32400



Share This :
Mr PVK
Write Your Response
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
-_-
(o)
[-(
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
(c)
cheer
(li)
(pl)