Kelvin = float(input("Entrez une température en Kelvin : ")) Celsius = Kelvin - 273.15 print("Température:", Kelvin, "Kelvin = ", Celsius, " Celsius")
Entrez une température en Kelvin : 286.15 Température: 286.15 Kelvin = 13.0 Celsius
Kelvin = float(input("Entrez une température en Kelvin : ")) Celsius = Kelvin - 273.15 print("Température:", Kelvin, "Kelvin = ", Celsius, " Celsius")
Entrez une température en Kelvin : 286.15 Température: 286.15 Kelvin = 13.0 Celsius
Fahrenheit = float(input("Enter a temperature in Fahrenheit: ")) Celsius = (Fahrenheit - 32) * 5.0 / 9.0 print("Temperature:", Fahrenheit, "Fahrenheit = ", Celsius, " Celsius")
>> Enter a temperature in Fahrenheit: 50 >> Temperature: 50.0 Fahrenheit = 10.0 Celsius
Celsius = float(input("Enter a temperature in Celsius: ")) Fahrenheit = 9.0 / 5.0 * Celsius + 32 print("Temperature:", Celsius, "Celsius = ", Fahrenheit, " Fahrenheit")
Enter a temperature in Celsius: 10 Temperature: 10.0 Celsius = 50.0 Fahrenheit
Celsius = float(input("Enter a temperature in Celsius: ")) Kelvin = 273.15 + Celsius print("Temperature:", Celsius, "Celsius = ", Kelvin, " Kelvin")
Enter a temperature in Celsius: 13 Temperature: 13.0 Celsius = 286.15 Kelvin
def hex_to_rgb(value): value = value.lstrip('#') lv = len(value) return tuple(int(value[i:i+lv//3], 16) for i in range(0, lv, lv//3))
def rgb_to_hex(rgb): return '#%02x%02x%02x' % rgb
print(hex_to_rgb("#D53547")) > (213, 53, 71)
print(rgb_to_hex((213, 53, 71))) > #d53547
Sous Pythonista :
import os from PIL import Image from PIL import ImageDraw, ImageFont folder_picture='fashion-color-report-spring-2017' if not os.path.exists(folder_picture): os.mkdir(folder_picture) def wallpaper(v, h, r, g, b, filename): im = Image.new("RGB", (v, h), (r, g, b)) im.save(folder_picture + '/' + filename + " (" + str(v) + "x" + str(h) + ").jpg", "JPEG")
Exemple :
# PANTONE 17-4123 TCX Niagara wallpaper(1536, 2048, 84, 135, 164, 'PANTONE 17-4123 TCX Niagara') wallpaper(750, 1334, 84, 135, 164, 'PANTONE 17-4123 TCX Niagara')
Résultat :
Pantone 448 C n’est pas une couleur comme les autres, bien au contraire. Elle a en effet été élue couleur la plus laide du monde !
from PIL import Image def wallpaper(v, h, r, g, b, filename): im = Image.new("RGB", (v, h), (r, g, b)) im.save(filename + " (" + str(v) + "x" + str(h) + ").jpg", "JPEG") # PANTONE 448 C wallpaper(1536, 2048, 74, 65, 42, 'PANTONE 448 C') wallpaper(750, 1334, 74, 65, 42, 'PANTONE 448 C')
Résultat :
import hashlib nomdufichier = 'DB.Browser.for.SQLite-3.10.0.dmg' print("sha256:", hashlib.sha256(open(nomdufichier, 'rb').read()).hexdigest())
Résultat :
import hashlib nomdufichier = 'sqlite-tools-osx-x86-3200100.zip' print("sha1:", hashlib.sha1(open(nomdufichier, 'rb').read()).hexdigest())
Résultat :
Résultat sous Pythonista :
import zipfile filezip = zipfile.ZipFile('backup.zip', 'w', zipfile.ZIP_DEFLATED) filezip.write('sqldiff') filezip.write('sqlite3') filezip.write('sqlite3_analyzer') filezip.close()
Contrôle du contenu du fichier ZIP :
filezip.printdir()
Résultat :
Résultat sous Pythonista :
Source sous Pythonista :