Convertir Kelvin en Celsius en Python

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

Convertir Fahrenheit en Celsius en Python

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

Convertir Celsius en Fahrenheit

Celsius = float(input("Enter a temperature in Celsius: "))

Fahrenheit = 9.0 / 5.0 * Celsius + 32

print("Temperature:", 
 Celsius, "Celsius = ", 
 Fahrenheit, " Fahrenheit")

Convertir-Celsius-en-Fahrenheit


Enter a temperature in Celsius: 10
Temperature: 10.0 Celsius = 50.0 Fahrenheit

Convertir Celsius en Kelvin

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

 

Créer un fond écran pour iOS avec Python

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 17-4123 TCX Niagara (750×1334)
PANTONE 17-4123 TCX Niagara (1536×2048)

Pantone 448 C n’est pas une couleur comme les autres !

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 :

PANTONE 448 C (750x1334)
PANTONE 448 C (750×1334)
PANTONE 448 C (1536x2048)
PANTONE 448 C (1536×2048)