Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Python Practical Slip 11 Answers

   Write a Python program

Slip 11 A) Write a Python program to compute element-wise sum of given tuples. Original lists: (1, 2, 3, 4) (3, 5, 2, 1) (2, 2, 3, 1) Element-wise sum of the said tuples: (6, 9, 8, 6)

Answer :


x = (1,2,3,4)

 

y = (3,5,2,1)

 

z = (2,2,3,1)

 

print("Original lists:") print(x)

print(y) print(z)

print("\nElement-wise sum of the said tuples:") result = tuple(map(sum, zip(x, y, z))) print(result)

from numpy import array lst1=[1,5,7]

lst2=[3,2,1]

a = array(lst1) b = array(lst2) print(a + b)

Output :

 

Slip 11 B) Write Python GUI program to add menu bar with name of colors as options to change the background color as per selection from menu option.

Answer :


from tkinter import * app = Tk()

app.title("Hi !Welcome to TYBBACA Students") app.geometry("800x500")

menubar = Menu(app, background='blue', fg='white')

file = Menu(menubar, tearoff=False, background='yellow')

edit = Menu(menubar, tearoff=False, background='pink') file.add_command(label="New") file.add_command(label="Exit", command=app.quit) edit.add_command(label="Cut") edit.add_command(label="Copy") edit.add_command(label="Paste") menubar.add_cascade(label="File", menu=file) menubar.add_cascade(label="Edit", menu=edit) app.config(menu=menubar)

app.mainloop()


Output :

Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Python Practical Slip 11 Answers Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Python Practical Slip 11 Answers Reviewed by technical_saurabh on December 31, 2021 Rating: 5

No comments:

Powered by Blogger.