Professional Documents
Culture Documents
Solution:
import smtplib
from email.message import EmailMessage
class MyCollege:
def __init__(self, IUKL_code = 0, college_name = "", total_student = 0,
area_of_college = 0, density_of_college = 0):
self.IUKLCode = IUKL_code
self.CollegeName = college_name
self.TotalStudent = total_student
self.AreaOfCollege = area_of_college
self.DensityOfCollege = density_of_college
def CalculateDensity(self):
density = self.TotalStudent / self.AreaOfCollege
return density
def InputInformationOfCollege(self):
self.IUKLCode = int(input("Enter IUKL Code: "))
self.CollegeName = input("Enter College Name: ")
self.TotalStudent = int(input("Enter Total Number Of Student: "))
self.AreaOfCollege = int(input("Enter Area Of College: "))
self.DensityOfCollege = self.CalculateDensity()
def DensityInformation(self):
print("==============")
print("Information")
print("==============")
print("IUKL ID = " + str(self.IUKLCode))
print("College Name = " + (self.CollegeName))
print("Total Student = " + str((self.TotalStudent)))
print("Area of College = " + str((self.AreaOfCollege)))
print("Density of College = " + str((self.DensityOfCollege)))
if self.TotalStudent > 1500 < 5000:
print("High Presence of Student")
self.mailsend("balwar@gmail.com", "Highly Presence of Student")
elif self.TotalStudent >= 500 <= 1500:
print("Average Presence in the College")
self.mailsend("admin2@iukl.com.np", "average presence in the Colle
ge")
elif self.TotalStudent < 500:
print("too less student in the college")
self.mailsend("info@iukl.com.np", "too less student in the college
")
def mailsend(self, email, subject):
password = "Bi@L.21"
message = EmailMessage()
contain = "Total Student = " + str(self.TotalStudent) + " CollegeName
= " + str(
self.CollegeName) + " IUKLCode = " + str(self.IUKLCode) + " Area o
f college = " + str(
self.AreaOfCollege) + " Density of college = " + str(self.DensityO
fCollege)
message.set_content(contain)
message['Subject'] = subject
message['From'] = "suk@gmail.com"
message['To'] = email
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login("suk@gmail.com", password)
server.send_message(message)
server.quit()
print("Email Sent")
college = MyCollege()
college.InputInformationOfCollege()
college.DensityInformation()
Question number 2:
Solution:
ef vowel():
f = open('question2.txt', 'r')
lines = f.readlines()
vowel_count = ''
for i in lines:
if i[0] == 'a' or i[0] == 'e' or i[0] == 'i' or i[0] == 'o' or i[0] =
= 'u' or i[0] == 'A' \
or i[0] == 'E' or i[0] == 'I' or i[0] == 'O' or i[0] == 'U':
vowel_count += ("'" + i + "'" + "It is start with vowels'\n")
print(vowel_count)
vowel()
#Output:
'''an apple is tasty
'It is start with vowels'
'elephants are always fat.'It is start with vowels'
PS C:\Users\BISHAL\Desktop\4th_semester\final_exams\AP>'''
Question number 3:
Solution: