Priscilla Joly - 3iS school
python3 --version
#Python 3.10.8
Docstring : Apprendre Python de A à Z (YouTube - 7h)
python3 fileName.py
Create a Hangman's game !
- Print and prompt
- Generate a random number
- Select a random word in array
- Create and use functions
- Create and use variables
- Work with : string and array
- Array loop (while, for)
- Condition (if, else if, else)
- Import libraries
- Equals: a == b
- Not Equals: a != b
- Less than: a < b
- Less than or equal to: a <= b
- Greater than: a > b
- Greater than or equal to: a >= b
Print text with print()
:
print("Hello World !") # Hello World !
Prompt in terminal with input()
:
response = input("What's your name ?") # Priscilla
print(response) # Priscilla
name = "Priscilla"
print(f"Bonjour {name}") # Bonjour Priscilla
Get length of an array with len()
:
array = [1]
item = 1
size = len(array)
print(size) # 1
Add item in an array with .append()
:
array = []
item = 1
array.append(item)
print(array) # [1]
Remove item in an array at index .pop()
:
array = [1, 2, 3]
array.pop(1)
print(array) # [1, 3]
Create a condition (if, else if and else) Compare strings
string = 'STOP'
if string == "STOP" or string == "stop" :
# Do something
if string =="STOP" and string == "stop":
# Do something
elif string == "toto":
# Do something
else :
# Do something
Compare two numbers
nombre_a = 0
nombre_b = 2
if nombre_a != nombre_b:
print("nombre_a et nombre_b sont différents")
Compare a true/false condition
win = False
if not win:
print("Not a winner")
else:
print("A winner")
Create a loop
You can find my Python training on Excercism
# Build in local
docker build -f Dockerfile . -t test
# Build and deploy in GCP
docker build . -t eu.gcr.io/deploy-276111/equideow_script:latest
docker push eu.gcr.io/deploy-276111/equideow_script:latest