Python Intro
Mohammad Jawad barati
Software Engineer | Fullstack Engineer | Microservices | TS/JS | Python | IaC | AWS | TDD | BDD | Automation | CI/CD
Python 2 main focal point:
Compile programming language VS Interpreter programming language:
Our IDE - Integrated Development Environment
Basic types in Python
Comments in Python
领英推荐
'''
? ? This is a multiline comment due to it has no effect in Python
? ? Because Python ignore multiline strings that are not assigned to a variable
'''
# And I am a single line comment
functions
We can type our functions - It comes later on
def printList(numbers)
? ? print(numbers)
? ? for number in numbers:
? ? ? ? print(number)
? ? ? ? # print(type(numbers[index]))
def manyArguments(*args):
? ? print(args)
? ? for arg in args:
? ? ? ? print(arg)
? ? ? ? # print(type(numbers[index]))
list1 = [1,2,3,4,5,6]
str1 = 'string'
number1 = 123456
bool1 = True
manyArguments(list1, str1, number1, bool1)
printList(list1):
classes
class Enemy:
? ? # FIXME: wrong usage
? ? # __init__(self):
? ? #? ? ?anything = 'something'
? ? # FIXME: wrong usage
? ? # def __init__(self):
? ? #? ? ?self.attack_low = self.attack_low
? ? #? ? ?self.attack_high = self.attack_high
? ? def __init__(self, attack_low, attack_high):
? ? ? ? self.attack_low = attack_low
? ? ? ? self.attack_high = attack_high
? ? # README: static property
? ? hp = 200
? ? def get_hp(self):
? ? ? ? return self.hp
? ? def get_attack_info(self):
? ? ? ? print(self.attack_high, self.attack_low)
e1 = Enemy(80, 100)
e1.get_attack_info()
print(e1.get_hp())
Modules