Monday, March 9, 2020

[Python Tutorial] 02.How to make python class? What’s the most used python function?

02_basic_python_programming_operator_print_list_for_random_class
from IPython.display import Image
Image(url='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZtF-pSW_Qsr5vbkCey_g4ugJr7EBI4KAg4KRIAnH7vRHpEMRyJb4ytYVRa_C6b-iFNQpdDe__Qnot8fV475of1Wu8VxxuZtlpdRaSEUsL1iV5sQYwVrVofLAyoagpKH9sp5EZtON0hog/s1600/%255B%25ED%2581%25AC%25EA%25B8%25B0%25EB%25B3%2580%25ED%2599%2598%255D%255B%25ED%2581%25AC%25EA%25B8%25B0%25EB%25B3%2580%25ED%2599%2598%255D%25EC%259C%25A0%25ED%258A%259C%25EB%25B8%258C%25EC%258D%25B8%25EB%2584%25A4%25EC%259D%25BC.png')

Python Programing

Operator Calulation

  • We could add, substract, multiply and divide using python
  • Let's practice using blow example
1+1
2
1.0+1.0
2.0
1.0*2
2.0
10/3
3.3333333333333335
10%3
1
10//3
3
  • 'print' is the most used functions in programming
  • Let's practice using below example
print("%f %d" %(10.0,10.0))
10.000000 10

List and for function

  • 'List' and 'for' are the most used functioins in python programming
  • Let's practice like below examples.
List = ['machine','learning','versus','deep','learning']b
List
['machine', 'learning', 'versus', 'deep', 'learning']
for i in List:
    print(i)
machine
learning
versus
deep
learning

Random function

  • Random function are the most used function in machine learning
  • Let's practice like below examples
from random import randint
_rand = randint(0,4)
print("%d %s" %(_rand,List[_rand]))
1 learning

CLASS

  • class definition is the most used skills in my programming
  • Let's make class format like below example
class DeepLearningVersusMachineLearning():
    def __init__(self):
        self.name1 = "machinelearning"
        self.name2 = "versus"
        self.name3 = "deeplearning"
    def _mix(self):
        print(self.name1+self.name2+self.name3)

if __name__ == "__main__":
    MVD = DeepLearningVersusMachineLearning()
    MVD._mix()
machinelearningversusdeeplearning

No comments:

Post a Comment