Follow

iklan banner
MASIGNCLEAN101

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

Python TYBBA (CA) Pratical Slip 2 Savitribai Phule Pune University
Mr PVK
December 01, 2022

 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


str=input("Enter a string\n")

up=0

lw=0

for i in str:

 if i.isupper():

  up=up+1

 elif i.islower():

  lw=lw+1

 else:

  pass

print("No. of Upper case characters: ",up)

print("No. of Lower case characters: ",lw)



 Program Output :


Enter a string: 

The quick Brown Fox

No. of Upper case characters: 3

No. of Lower case characters: 13





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


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', 30, 'bold'),

            background='red',

            foreground='white')

 

lbl.pack(anchor='center')

time()

 

mainloop()



Program Output :




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)