Skip to content

Repository files navigation

Python initiation

Priscilla Joly - 3iS school

 python3 --version
#Python 3.10.8

Utilities

Python documentation

Docstring : Apprendre Python de A à Z (YouTube - 7h)

Time to learn basics on Python

Execute a Python script

 python3 fileName.py

Project

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

Conditions in Python

  • 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 ?") # Priscillaprint(response) # Priscilla
name="Priscilla"print(f"Bonjour {name}") # Bonjour Priscilla

Get length of an array with len() :

array= [1]
item=1size=len(array)
print(size) # 1

Add item in an array with .append() :

array= []
item=1array.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'ifstring=="STOP"orstring=="stop" :
# Do somethingifstring=="STOP"andstring=="stop":
# Do somethingelifstring=="toto":
# Do somethingelse :
# Do something

Compare two numbers

nombre_a=0nombre_b=2ifnombre_a!=nombre_b:
print("nombre_a et nombre_b sont différents")

Compare a true/false condition

win=Falseifnotwin:
print("Not a winner")
else:
print("A winner")

Create a loop

Excercism

You can find my Python training on Excercism

Deploy Dockerfile

# 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

About

3IS

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages