# Reverse Color Picker:

Hello!

This is not spam. I am making edits while working on a project.

I am currently trying to build a code in PyCharm that allows you to input the name of a color (I.E. Pink, Red, Blue, Green, Brown, Yellow) and then outputs the HEX and RGB numbers for the color. I am trying to build my project off of an examply my teacher gave us for a calculator that gives you your student grade average. so far my HTML code looks like this:

I am struggling to figure out how to enter my strings properly… I would sincerely appreciate Github’s Help in cleaning up my code!

``````_author_ ='Melissa'

# Input List: color\_name
# Output List: color\_rgb, color\_hex

# Function Char, String get\_color\_name()
# Declare Char color\_name
#
# Display "Please enter the color name:"
# Input color\_name
# Return color\_name
# End Function

def get_color_name():
color\_name=""

color_name = char(input("Please enter the color name:"))
return color_name

# Function String convert\_color\_number(Char color\_name)
# Declare String color\_rgb
# Declare String color\_hex
#
# If color\_name == "Pink" Then
# color\_rgb = "(255, 192, 203)"
# color\_hex = " #ffc0cb"
# Else If color\_name == "Blue" Then
# color\_rgb = "(0, 0, 255)"
# color\_hex = " #0000ff"
# If color\_name == "Green" Then
# color\_rgb = "(0, 128, 0)"
# color\_hex = " #008000"
# If color\_name == "Yellow" Then
# color\_rgb = "(255, 255, 0)"
# color\_hex = " #ffff00"
# If color\_name == "Red" Then
# color\_rgb = "(255, 0, 0)"
# color\_hex = " #ff0000"
# If color\_name == "Orange" Then
# color\_rgb = "(255, 165, 0)"
# color\_hex = " #ffa500"
# If color\_name == "Purple" Then
# color\_rgb = "(128, 0, 128)"
# color\_hex = " #800080"
# If color\_name == "Black" Then
# color\_rgb = "(0, 0, 0)"
# color\_hex = " #000000"
# If color\_name == "White" Then
# color\_rgb = "(255, 255, 255)"
# color\_hex = " #ffffff"
# If color\_name == "Gray" Then
# color\_rgb = "(128, 128, 128)"
# color\_hex = " #808080"
# If color\_name == "Brown" Then
# color\_rgb = "(165, 42, 42)"
# color\_hex = " #a52a2a"
# End If
# Return color\_rgb, color\_hex
#End Function
``````

here is an update to my code. I can’t get it to read properly.

``````_author_ ='Melissa'

# Input List: color\_name
# Output List: color\_rgb, color\_hex

# Function String, String get\_color\_number()
# Declare String color\_name
#
# Display "Please enter the color name:"
# Input color\_name
# Return color\_name
# End Function

def get\_color\_number():
color\_name=""

color_name = String(input("Please enter the name of the color:"))
return color_name

# Function String convert\_color\_number(String color\_name)
# Declare String color\_rgb
# Declare String color\_hex
#
# If color\_name == "Pink" Then
# color\_rgb = "(255, 192, 203)"
# color\_hex = " #ffc0cb"
# Else If color\_name == "Blue" Then
# color\_rgb = "(0, 0, 255)"
# color\_hex = " #0000ff"
# Else If color\_name == "Green" Then
# color\_rgb = "(0, 128, 0)"
# color\_hex = " #008000"
# Else If color\_name == "Yellow" Then
# color\_rgb = "(255, 255, 0)"
# color\_hex = " #ffff00"
# Else If color\_name == "Red" Then
# color\_rgb = "(255, 0, 0)"
# color\_hex = " #ff0000"
# Else If color\_name == "Orange" Then
# color\_rgb = "(255, 165, 0)"
# color\_hex = " #ffa500"
# Else If color\_name == "Purple" Then
# color\_rgb = "(128, 0, 128)"
# color\_hex = " #800080"
# Else If color\_name == "Black" Then
# color\_rgb = "(0, 0, 0)"
# color\_hex = " #000000"
# Else If color\_name == "White" Then
# color\_rgb = "(255, 255, 255)"
# color\_hex = " #ffffff"
# Else If color\_name == "Gray" Then
# color\_rgb = "(128, 128, 128)"
# color\_hex = " #808080"
# Else If color\_name == "Brown" Then
# color\_rgb = "(165, 42, 42)"
# color\_hex = " #a52a2a"
# End If
# Return color\_rgb, color\_hex
#End Function

def convert\_color\_number(color\_name):
color_name =""

if color_name =="Pink":
color_rgb ="(255, 192, 203)"
color_hex =" #ffc0cb"
elif color_name =="Blue":
color_rgb ="(0, 0, 255)"
color_hex =" #0000ff"
elif color_name =="Green":
color_rgb ="(0, 128, 0)"
color_hex =" #008000"
elif color_name =="Yellow":
color_rgb ="(255, 255, 0)"
color_hex =" #ffff00"
elif color_name =="Red":
color_rgb ="(255, 0, 0)"
color_hex =" #ff0000"
elif color_name =="Orange":
color_rgb ="(255, 165, 0)"
color_hex =" #ffa500"
elif color_name =="Purple":
color_rgb ="(128, 0, 128)"
color_hex =" #800080"
elif color_name =="Black":
color_rgb ="(0, 0, 0)"
color_hex =" #000000"
elif color_name =="White":
color_rgb ="(255, 255, 255)"
color_hex =" #ffffff"
elif color_name =="Gray":
color_rgb ="(128, 128, 128)"
color_hex =" #808080"
elif color_name =="Brown":
color_rgb ="(165, 42, 42)"
color_hex =" #a52a2a"

else:
color_name =""
return color_name, color_rgb, color_hex

# Module output\_number(String color\_name, color\_rgb, color\_hex)
# Display "The RGB number of",color\_name,"is", color\_rgb
# Display "The HEX number of",color\_name,"is", color\_hex
#
# End Module

def output\_number(color_name, color_hex, color_rgb):
print("The RGB number of", color_name, "is", color_rgb)
print("The HEX number of", color_name, "is", color_hex)

# Module convert\_color\_integer()
# Declare String color\_name
# Declare String color\_rgb
# Declare string color\_hex
#
# Set color\_name = color\_rgb, color\_hex
# Set color\_rgb = convert\_color\_rgb(color\_rgb)
# Set color\_hex = convert\_color\_hex(color\_hex)
# Call output\_number (color\_name, color\_hex, color\_number)
# End Module

def convert\_color\_integer():
color\_name =""
color_rgb =""
color_hex =""

color_name = color_rgb, color_hex()
color\_rgb = convert_color_rgb(color_rgb)
color_hex = convert_color_hex(color_hex)
output_number (color_name, color_hex, color_number)

convert_color_integer()
``````