Skip to content

Simple RGB-HEX converter with guessing game made in python

Notifications You must be signed in to change notification settings

maciekt07/RGB-HEX-convert-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

RGB-HEX-convert-py

Simple RGB-HEX converter with guessing game made in python

hex-rgb convert.py

print("1. convert rgb to hex format")
print("2. convert hex to rgb format")
choice = input(":")
def choice1(): # rgb to hex
  r = int(input("R: "))
  g = int(input("G: "))
  b = int(input("B: "))
  wynik = '#%02x%02x%02x' % (r, g, b);
  print("rgb", r, g, b, "to hex format is:", wynik) 
def choice2(): # hex to rgb
    hex_code = input("enter hexcode: ")
    hex_code = hex_code.replace("#", "")
    print("hex",hex_code, "to rgb format is:", tuple(int(hex_code[i:i+2], 16) for i in (0, 2, 4)))
if (choice == "1"):
   choice1()
if (choice == "2"):
    choice2()

rgb-hex-guessing-game.py

import random
r = random.randint(0,255);
g = random.randint(0,255);
b = random.randint(0,255);
solution = '#%02x%02x%02x' % (r, g, b);
print("replace RGB to HEX game, author: github.com/maciekkoks");
print("RGB:", r, g, b);
input1 = input("Enter a hex code:");
if (input1 == solution or input1 == solution.upper()): 
  print("the answer is correct!");
else: 
  print("the answer is not correct, the correct answer is:" ,solution);
input("press enter to exit");

About

Simple RGB-HEX converter with guessing game made in python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages