Informatique/obligatoire/Cours/cours1.py

112 lines
1.3 KiB
Python
Raw Normal View History

2019-11-23 15:22:53 +01:00
1+1
#2
print('Hello world !')
help(print)
print('Hello World !', file=open('essai.txt', 'w'))
1+2
print(1+2)
print(print(1+2))
print(1)+2
print(1)+print(2)
print('Un nouveau calcul')
print('5 * 3=', 5*3)
2+4
print('Une journée a une durée égale à', 60*60*24, 'secondes')
print(1, 2, 3, sep='+', end='=')
print(6, 5, 4, sep='\n', end='*')
type(5)
type('LLG')
type(None)
type(print)
id(5)
id(None)
id(print)
1 + 2 - 3
#0
0.1 + 0.2 - 0.3
#5.5...... e-17
23 // 3
23 % 3
24 // 4
24 % 4
int(2.3333)
int(-2.3333)
float(25)
complex(2)
float(999999999999999999)
int(1e+16)
float(2 + 0j)
(2 + 0j).real
(2 + 0j).imag
import numpy as np
np.sin(1.571)
np.sqrt(2)
np.pi
from math import exp
exp(1)
np.exp(1)
(4 + 3) < 11 and not 'alpha' > 'omega'
(1 + 1 == 3) != ('Henri 4' > 'Louis-le-Grand')
largeur = 12.45
longueur = 42.18
aire = longueur * largeur
print("L'aire du rectange est égale à", aire)
id(largeur)
a = 257
b = 257
a == b
a is b
a is c
"aujourd'hui"
'et demain'
print("un passage\n à la ligne")
chn = "Hello "
chn += 'world !'
print(chn)
chn*3
'123' + '1'
123 + 1
'123' + 1
int('123') + 1
'123' + str(1)
ch = 'Louis-Le-Grand'
ch[4]
ch[0] + ch[6] + ch[9]
print(ch[-8]*2 + ch[-5])
len(ch)
ch[3:-3]
ch[6:] + ch[:6]
ch[::2]
ch[1::2]
ch[::-1]
s = '12345678'
s[-1::-2] + s[0::2]