Slip 14 A)
Write a Python GUI program to accept dimensions of a cylinder and display the
surface area and volume of cylinder.
Answer :
pi=22/7
height =
float(input('Height of cylinder: ')) radian = float(input('Radius of cylinder: ')) volume = pi
* radian * radian * height
sur_area = ((2*pi*radian)
* height) + ((pi*radian**2)*2) print("Volume is: ", volume)
print("Surface Area is: ", sur_area)
Output :
Slip 14 B)
Write a Python program to display plain text and cipher text using a Caesar
encryption.
Answer :
def encrypt(text,s):
result = ""
for i in range(len(text)):
char = text[i]
if (char.isupper()):
result += chr((ord(char) + s-65)
% 26 + 65) else:
result += chr((ord(char) + s -
97) % 26 + 97) return result
text = "CEASER CIPHER DEMO"
s = 4
print "Plain Text : " + text print "Shift pattern : "
+ str(s)
print "Cipher: " + encrypt(text,s)
Output :
No comments:
Post a Comment