def class_demo():
    student1 = Student("Jim", "Business", 2.1, False)
    print(student1)
    print(f"{student1.name}  {student1.on_honor_roll()}")
    student2 = Student("Phyllis", "Business", 3.8, False)
    print(student2)
    print(f"{student2.name} {student2.on_honor_roll()}")

    chef = Chef("Skc")
    chef.make_special_dish()

    chef1 = ChineseChef("Skc")
    chef1.make_special_dish()
    chef1.make_salad()
    print("========line class Example========")
    coordinate1 = (3, 2)
    coordinate2 = (8, 10)
    line = Line(coordinate1, coordinate2)
    print(
        f"distance between {coordinate1}  and {coordinate2} : {line.distance()}"
    )
    print(f"slope between {coordinate1}  and {coordinate2} : {line.slope()}")

    print("========cylinder class Example========")
    cylinder = Cylinder(2, 3)
    print(f"volume of {cylinder} : {cylinder.volume():1.2f}")
    print(f"surface area of {cylinder} : {cylinder.surface_area():1.1f}")
Пример #2
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.makeSalad()
myChef.makeSpecialDish()

myChineseChef = ChineseChef()
myChineseChef.makeSpecialDish()
Пример #3
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_special_dish()

myChineseChef = ChineseChef()
myChineseChef.make_special_dish()
Пример #4
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChineseChef = ChineseChef()

myChef.MakeSpecialdish()
myChineseChef.MakeSpecialdish()
Пример #5
0
from RegularChef import Chef
from ChineseChef import ChineseChef
ourChef = Chef()
ourChineseChef = ChineseChef()
ourChef.make_special_dish()
ourChineseChef.make_special_dish()
ourChineseChef.make_chicken()
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_special_dish()

myChineseChef = ChineseChef()
myChineseChef.make_chicken()
Пример #7
0
from Chef import Chef
from ChineseChef import ChineseChef

c = Chef()
cc = ChineseChef()

c.make_special()
cc.make_special()
Пример #8
0
student1 = Student("Joey", "Acting", 0.5)
student2 = Student("Ross", "Paleontology", 3.8)


def on_honor_roll(self):
    if self.gpa >= 3.5:
        return True
    else:
        return False

print(student1.on_honor_roll())

from ChineseChef import ChineseChef

myChineseChef = ChineseChef()
myChineseChef.makes_special()

class Chef:

    def makes_steak(self):
        print("The chef makes steak!")
    def make_salad(self):
        print("The chef makes a salad!")
    def makes_special(self):
        print("The chef makes empanadas!")

from Chef import Chef
#inside ChineseChef they will be able to use all the function of Chef, over ride inheritance by writing another function
class ChineseChef(Chef): #paranthesis then mother class inherits functions, if you just want to inherit the functions put pass after so puthon ignores
    def makes_special(self):
Пример #9
0
from Chef import Chef
from ChineseChef import ChineseChef
myChef = Chef()
myChef.make_specia_dish()
myChineseChef = ChineseChef()
myChineseChef.make_fried_rice()
myChineseChef.make_specia_dish()
Пример #10
0
def run_test(questions):
    score = 0
    for question in questions:
        answer = input(question.prompt)
        if answer == question.answer:
            score += 1
    print("You got " + str(score))

run_test(questions)
'''
print("")

#Object Functions
print("31. Object Functions")
from student import Student
student3 = Student("Yuri", 19, False, "Music")
student4 = Student("Yujin", 17, False, "Music")
print(student3.legal_age())

print("")

#Inheritance
print("32. Inheritance")
from Chef import Chef
from ChineseChef import ChineseChef

my_chef = Chef()
my_chef.make_specialdish()

my_chinesechef = ChineseChef()
my_chinesechef.make_specialdish()
Пример #11
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.makeChicken()
myChef.makeSpecialDish()

chineseChef = ChineseChef()
chineseChef.makeChicken()
chineseChef.makeSpecialDish()
chineseChef.makeFriedRice()
Пример #12
0
#from Class&Object_14
from Student import Student
from Chef import Chef
from ChineseChef import ChineseChef

student1 = Student("Jim", "Business", 3.1, False)
print(student1.gpa)

myChef = Chef()
myChef.make_salad()

myChineseChef = ChineseChef()
myChineseChef.make_salad()
Пример #13
0
from Chef import Chef
from ChineseChef import ChineseChef

China = ChineseChef()
myChef = Chef()

myChef.make_a_special_dish()
China.make_a_sushi()

from Chef import Chef
from ChineseChef import ChineseChef

chef1 = Chef()
chef1.makes_chicken()
chef1.makes_specialdish()

Chinesechef1 = ChineseChef()
Chinesechef1.makes_chicken()
Chinesechef1.makes_specialdish()
Пример #15
0
full_file = open("text_file.txt", "r")  #open a file in read mode
isReadable = full_file.readable()
if isReadable:
    print("The file is readable")
    print(full_file.read())
full_file.close()

print("\n--writing to files--")

full_file = open("text_file.txt", "a")
full_file.write("This is the added stuff")
full_file.close()

print("\n--classes and objects--")  #used to create a custom data type

student1 = Student(
    "Shobhit", "IT", 4,
    False)  #instantiate your Student Class.. create an object of the class
print("Student name is " + student1.name1)

is_on_honor_roll = student1.is_on_honor_roll()
if is_on_honor_roll:
    print(student1.name1 + " is on HonorRoll")

generic_chef = Chef()
chinese_chef = ChineseChef()

print("Generic Chef ki special dish: " + generic_chef.special_dish())
print("Chinese chef ki special dish" + chinese_chef.special_dish())
# Title:                            Inheritance in Python
# Author:                           Sachin Kotian
# Created date (DD-MM-YYYY):        08-12-2018
# Last modified date (DD-MM-YYYY):  08-12-2018
#
# ABOUT:
# This code imports the "Chef" and "ChineseChef" class
# ChineseChef inherits all the function from Chef
# Please refer to "Chef.py" and "ChineseChef.py" for the class code

# Importing the Chef and ChineseChef classes
from Chef import Chef
from ChineseChef import ChineseChef

# Defining the chefs 1 and 2
myChef1 = Chef()
myChef2 = ChineseChef()

# Calling the functions of the classes
myChef1.makes_chicken()
myChef1.makes_special_dish()
myChef2.makes_fried_rice()
myChef2.makes_salad()
Пример #17
0
from chefClass import chef
from ChineseChef import ChineseChef

myChef = chef()

myChef.make_chicken()
myChef.make_soup()

myChineseChef = ChineseChef()
myChineseChef.make_fried_rice()
myChineseChef.make_soup()
myChineseChef.make_chicken()
Пример #18
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()


# myChef.make_chicken()
# myChef.make_salad()
# myChef.make_steak()

myChineseChef = ChineseChef()

myChineseChef.make_steak()
myChef.make_steak()
Пример #19
0


print(student1.on_honor_roll())


"Inheritance"

from Chef import Chef
from ChineseChef import ChineseChef


myChef = Chef()
myChef.make_special_dish()

myChineseChef = ChineseChef()
myChineseChef.make_bbq()

"Python Interpreter is the environment we use to execute python commands  so we use command prompt"











Пример #20
0
from ChineseChef import ChineseChef
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef("홍길동")
myChef.make_chicken()

myChineseChef = ChineseChef("일지매")
print("중국세프 이름: " + myChineseChef.name)
myChineseChef.make_fried_rice()
myChineseChef.make_salad()
myChineseChef.make_special_dish()
# from Chef import Chef
# from ChineseChef import ChineseChef

# myChef = Chef()
# myChef.make_chicken()
# myChef.make_salad()
# myChef.make_special_dish()

# myChef = ChineseChef()
# myChef.make_special_dish()
# myChef.make_fried_rice()

#------------------------------------ Inheritance---------------------------------------------------------------
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_chicken()
myChef.make_salad()
myChef.make_special_dish()

myChef = ChineseChef()
myChef.make_special_dish()
myChef.make_fried_rice()

myChef.make_chicken(
)  # make chicken method removed from chinese chef but still can access it by inheritance

myChef.make_special_dish()
Пример #22
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_salad()

myChineseChef = ChineseChef()
myChineseChef.make_special_salad()
myChineseChef.make_fried_rice()
Пример #23
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_special_dish()

print()

myChineseChef = ChineseChef()
myChineseChef.make_chicken()
myChineseChef.make_salad()
myChineseChef.make_special_dish()
myChineseChef.make_fride_rice()
Пример #24
0
from CHEFS import Chef
from ChineseChef import ChineseChef

# myChef=Chef()
# myChef.make_chicken()
# myChef.make_Salad()
# myChef.make_special_dish()

MyChinese = ChineseChef()

MyChinese.make_Salad()
MyChinese.make_chicken()
MyChinese.make_fried_rice()
MyChinese.make_special_dish()
Пример #25
0
        return False 
print(student1.on_honor_roll()) #false
print(student2.on_honor_roll()) #true
-----------------------------------------------------
INHERTIANCE: where we can define attributes and functions inside of class
then create another class that inherits everything without writing the same
methods or attributes.

First file:
'''from Chef import Chef #importing the chef so we can use it'''
from ChineseChef import ChineseChef
myChef = Chef() #creating a new Chef 
myChef.make_chicken() #The chef makes a chick
myChef.make_special_dish() #makes bbq

myChineseChef = ChineseChef()
myChineseChef.make_fried_rice()

#lets create a class that modeled a Chinese Chef instead of normal chef.
#first crete a new file ChineseChef.py
1. class ChineseChef:#very specific and can do everything the other chef can do
2. #if we want to give him all of the functionality we can just copy info from previous file
class ChineseChef:
     def make_chicken(self): #the problem is we had to copy and paste the physical file
        print("The chef makes a chicken")
    def make_salad(self):
        print("The chef makes salad")
    def make_special_dish(self):
        print("The chef makes orange chicken")
    def make_fried_rice(self):
        print("the chef makes fried rice")
Пример #26
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()  #creating an object for chef
myChef.make_special_dish()

myChineseChef = ChineseChef()  #creating an object for ChineseChef
myChineseChef.make_special_dish()
Пример #27
0
from Chef import Chef
from ChineseChef import ChineseChef
from ChineseChefInheritance import ChineseChef

myChef = Chef()
myChef.make_special_dish()

myChineseChef = ChineseChef()
myChineseChef.make_special_dish()

myChineseChefInheritance = ChineseChef()
myChineseChefInheritance.make_special_dish()

Пример #28
0
from Chef import Chef
from ChineseChef import ChineseChef

my_chef = Chef()
my_chef.make_special_dish()

chinese_chef = ChineseChef()
chinese_chef.make_special_dish()
chinese_chef.make_fried_rice()

print(type(chinese_chef))
if type(chinese_chef) == ChineseChef:
    print("ok")
else:
    print("failed")

if type(chinese_chef) == Chef:
    print("ok")
else:
    print("failed")

if isinstance(chinese_chef, ChineseChef):
    print("ok")
else:
    print("failed")

if isinstance(chinese_chef, Chef):
    print("ok")
else:
    print("failed")
Пример #29
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_chicken()
myChef.make_special_dish()

myChineseChef = ChineseChef()
myChineseChef.make_chicken()
myChineseChef.make_fried_rice()
myChineseChef.make_special_dish()
Пример #30
0
from Student import Student
from Chef import Chef
from ChineseChef import ChineseChef

student1 = Student("Oscar", "CS", 3.2)
student2 = Student("Billy", "IF", 3.4)

myChef = Chef()
myChef.make_spesial_dish()

myChinese = ChineseChef()
myChef.make_spesial_dish()
myChinese.make_spesial_dish()