- Go to
Run and Debug
- Go to
Add Configuration
Django
- Add the way to your
manage.py
relatively to where your launched VS Code.
a = b = c = 5 |
a = [1, 2, 3] | |
b = [1, 2, 3] | |
print(a == b) | |
# True | |
print(a is b) | |
# False |
SyntaxErrors: Maj / Min errors, usage of reserved words | |
NameErrors : usage of undefined variable, etc. | |
TypeErrors : When you try to perform a function that doesn't take the right type of variable | |
SemanticErrors: The script doesn't return the wished result. Usage of debugger is adviced in order to comprehend programmer logic. |
from random import randint, uniform, randrange | |
# Randint make inclusiv calls, 5 is here included. It calls integers in the intervall 1-5 | |
a = randint(1,5) | |
# Uniforms is basically the same as Randint but call floats in the specified intervall | |
b = uniform(1,5) | |
# randrange makes exclusiv calls like range function, returns integers between 0 and 999 here, step can be specified | |
c = randrange (999) | |
d = randrange(5,999,2) |
# add path to a specified folder in project | |
import os | |
chemin = r"C:\Users\ouali\OneDrive\Bureau\Formations\Formation Python\la-formation-complete-python-master\test" | |
folder = os.path.join(chemin, "dossier") | |
print(folder) | |
# Create new folder, works fine if the folder already exists. | |
os.makedirs(folder, exist_ok=True) |
import random | |
import os | |
# list all functions in a module | |
print(dir(os)) | |
# get a description of the function, don't add the parenthesis! | |
help(random.randint) |
fruit = "banana" | |
# length of a string | |
l = len(fruit) | |
# iterating through a string | |
for letter in fruit: | |
print(letter) | |
# checking if a string or a substring exists in another | |
print("anana" in fruit) | |
# comaparing maj and min | |
fruit_upper = 'BANANA' |
greet = ' Hello Python ' | |
>>greet.lstrip() | |
'Hello Python ' | |
>>greet.rstrip() | |
' Hello Python' | |
>>greet.strip() | |
'Hello Python' | |
nom = ";,: olom',;:" | |
>>>print(nom.strip(";,: '")) |
xfile = open('course.txt') | |
for line in xfile: | |
print(line) | |
# clean from spaces at end | |
xfile = open('course.txt') | |
for line in xfile: | |
line = line.rstrip() | |
print(line) |