Pratik Ghelani

Pratik Ghelani

Breaking

Sunday, May 10, 2020

6:14 AM

Create a class "faculty" with attributes like id, name, designation, emailid, birthdate, city. a. getData() to take faculty information. b. setData() to display faculty information. Inherit class “Account” with attributes like acc_id, acc_type, amount and methods to generate account report of particular faculty in proper format.

Input:-

class faculty(object):
    faculty_id=0
    faculty_name=""
    designation =""
    Email_id=""
    DOB =""
    City =""

    def set(self,faculty_id,faculty_name,designation,Email_id,DOB,City):
        self.faculty_id=faculty_id
        self.faculty_name=faculty_name
        self.designation=designation
        self.Email_id=Email_id
        self.DOB=DOB
        self.City=City
    def get(self):
        print()
        print("Teacher details:-")
        print("Teacher id:-",self.faculty_id)
        print("Teacher Name:-",self.faculty_name)
        print("designation:-",self.designation)
        print("Email id:-",self.Email_id)
        print("DOB:-",self.DOB)
        print("City:-",self.City)

class Account(faculty):
    acc_id=0
    acc_type=""
    amount=0

    def set(self,acc_id,acc_type,amount):
        self.acc_id=acc_id
        self.acc_type=acc_type
        self.amount=amount
    def get(self):
        print()
        print("Account details:-")
        print("Account id:-",self.acc_id)
        print("Account type:-",self.acc_type)
        print("Amount:-",self.amount)

m = faculty()
m.set(1,"Parth Shah","Assistant Professor","parthshah01@gmail.com","27/06/1993","Surat")
m.get()

h = Account()
h.set(2,"Saving Account",25000)

h.get()

Output:-


6:12 AM

Write a python program to print given triangle.

Input:-

n = int(input("Enter the Number of Rows:"))
for row in range(n):
    for col in range(n):
        if col==0 or row==(n-1) or row==col:
            print("*",end="")
        else:
            print(end=" ")

    print()

Output:-

6:11 AM

Write a program to search palindrome number from given numbers and do addition of the digits of all palindrome numbers.

Input:-

digit = int(input("Enter the Digit:"))
print("palindrome Number:-")
def reverse(num):
    rev = 0;
    while (num > 0):
        rev = rev * 10 + num % 10;
        num = num // 10;  
    return rev;
def isPalindrome(num): 
    if (num == reverse(num)):
        return True;
    return False;
def printPalindromes(d):
    if (d <= 0):
        return;
    smallest = pow(10, d - 1);
    largest = pow(10, d) - 1;
for i in range(smallest, largest + 1):
        if (isPalindrome(i)):
            print(i, end = " "); 

printPalindromes(digit);


Output:-


6:10 AM

Create a class “Teacher” with attributes like Teacher_Id, Teacher_Name, Designation, Emailid, Birthdate, City. a.GetData() to take Teacher's information. b.SetData() to display Teacher's information. Inherit class “Account” with attributes like acc_id, acc_type, amount and methods to generate account report of particular teacher in proper format. Implement regular expression to validate emailid and birthdate.

Input:-

import re
class Teacher(object):
    teacher_id=0
    teacher_name=""
    designation =""
    Email_id=""
    DOB =""
    City =""
    emailmatch = "^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$"
    dateofbirthmatch = "^[0-3]?[0-9]/[0-3]?[0-9]/(?:[0-9]{2})?[0-9]{2}$"
    def set(self,teacher_id,teacher_name,designation,Email_id,DOB,City):
        self.teacher_id=teacher_id
        self.teacher_name=teacher_name
        self.designation=designation
        self.Email_id=Email_id
        self.DOB=DOB
        self.City=City
    def get(self):
        print()
        print("Teacher details:-")
        print("Teacher id:-",self.teacher_id)
        print("Teacher Name:-",self.teacher_name)
        print("designation:-",self.designation)
        if(re.search(self.emailmatch,self.Email_id)):
            print(self.Email_id,"is Valid")
        else:
            print(self.Email_id,"is not Valid")
        if(re.search(self.dateofbirthmatch,self.DOB)):
            print(self.DOB,"is Valid")
        else:
            print(self.DOB,"is not Valid")
        print("City:-",self.City)

class Account(Teacher):
    acc_id=0
    acc_type=""
    amount=0

    def set(self,acc_id,acc_type,amount):
        self.acc_id=acc_id
        self.acc_type=acc_type
        self.amount=amount
    def get(self):
        print()
        print("Account details:-")
        print("Account id:-",self.acc_id)
        print("Account type:-",self.acc_type)
        print("Amount:-",self.amount)

m = Teacher()
m.set(1,"Parth Shah","Assistant Professor","parthshah01@gmail.com","27/06/1993","Surat")
m.get()
m.set(1,"Parth Shah","Assistant Professor","parthshahgmail.com","27/1993","Surat")
m.get()

h = Account()
h.set(2,"Saving Account",10000000)

h.get()

Output:-

6:08 AM

Write a python program which asks user to enter value for number of line and then according to input following pattern should be displayed.


Code:-
num = int(input("Enter the number of D pattern:"))
string = ""
def D_Pattern(string, n):
    for i in range(0, n):    
        for j in range(0, n):
            if (j == 1 or ((i == 0 or i == n-1) and
               (j > 1 and j < n-2)) or (j == n-2 and i != 0 and i != n-1)):   
                string = string + "*"   
            else:      
                string = string + " "
        string = string + "\n"   
    return(string)
print(D_Pattern(string, num))


Output:-


6:07 AM

Write a python script to take input of string and find maximum occurrence words in inputted string.

Input:-

sentence = input("Enter the string:")
def word_count(str):
    counts = dict()
    words = str.split()

    for word in words:
        if word in counts:
            counts[word] += 1
        else:
            counts[word] = 1

    return counts


print( word_count(sentence))

Output:-



6:05 AM

Create a class "student" with attributes like id, name, semester, emailid, birthdate, city. a. getData() to take student information. b. setData() to display student information. Inherit class “Exam” with attributes like exam_id, exam_type, exam_subject, exam_marks and methods to generate report of particular student in proper format.

Input:-

class student(object):
    id =0
    Name = ""
    semester = 0
    Email = ""
    Birthday = ""
    City = ""
    def set(self,id,name,semester,Email,Birthday,City):
        self.id=id
        self.Name=name
        self.semester=semester
        self.Email=Email
        self.Birthday=Birthday
        self.City=City
    def get(self):
        print()
        print("Student details:-")
        print("Id:-",self.id)
        print("Name:-",self.Name)
        print("Samester:-",self.semester)
        print("email id:-",self.Email)
        print("Birthday:-",self.Birthday)
        print("City:-",self.City)
class Exam (student):
    exam_id=0
    exam_type=""
    exam_subject=""
    exam_marks=0

    def set(self,exam_id,exam_type,exam_subject,exam_marks):
        self.exam_id=exam_id
        self.exam_type=exam_type
        self.exam_subject=exam_subject
        self.exam_marks=exam_marks
    def get(self):
        print()
        print("Exam details:-")
        print("exam id:-",self.exam_id)
        print("exam type:-",self.exam_type)
        print("exam subject:-",self.exam_subject)
        print("exam_marks:-",self.exam_marks)
a = student()
a.set(91,"Parth Shah",6,"parthrohit24@gmail.com","21/02/2000","Naroli")
a.get()

b = Exam()
b.set("1023","Univercity","Python","80")

b.get()


Output:-