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

  Write a Python program

Slip 2 A) Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters.

Sample String: 'The quick Brown Fox' Expected

Output: No. of Upper case characters: 3

No. of Lower case characters: 13

Answer :

def string_test(s):

 

d={"UPPER_CASE":0, "LOWER_CASE":0}

 

 

for c in s:

 

if c.isupper():

d["UPPER_CASE"]+=1

elif c.islower():

d["LOWER_CASE"]+=1

else:

pass

 

 

print ("Original String : ", s)

 

print ("No. of Upper case characters : ", d["UPPER_CASE"]) print ("No. of Lower case Characters : ", d["LOWER_CASE"])

string_test('The quick Brown Fox')


Output :

 

Slip 2 B) Write Python GUI program to create a digital clock with Tkinter to display the time.

Answer :

from tkinter import * from tkinter.ttk import * from time import strftime root = Tk() root.title('Clock')

def time():

string = strftime('%H:%M:%S %p') lbl.config(text = string) lbl.after(1000, time)

lbl = Label(root, font = ('calibri', 40, 'bold'),

background = 'purple', foreground = 'white')

lbl.pack(anchor = 'centre') time()

mainloop()

Output :


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

No comments:

Powered by Blogger.