adventures in parseltongue

notes on coding and AI projects

View the Project on GitHub HannimalCrackers/parseltongue

Adventures in parseltongue

 

I just learned how to create syntax highlighted code blocks on GitHub!

 

1. ISO Python IDE to love and cherish

My futile search for a clean, simple code editor user experience

Terminal

Pros: outputs only the info I want to see. Also, I feel like I’m in the Matrix and/or 1997.
Con: can’t edit inline

Spyder

Pro: seems cool
Con: the runfile path/directory printing doubled up in the console at every single run makes it hard to read output

Example: print (2+5)
yields: runfile(‘/Users/hhouse/.spyder-py3/temp.py’, wdir=’/Users/hhouse/.spyder-py3’) 7

Sublime Text

Pro: I like it for editing HTML and CSS at work
Con: Very annoying time counter with every output. I tried to customize to quiet build environment but I didn’t work. I guess I did it wrong.

BBEdit

Pro: Easier to read output (though still annoying extra stuff present)
Con: Maybe doesn’t accept input. Getting error: EOFError: EOF when reading a line

Visual Studio Code

Pro: Looks like it would be useful if I had any idea what I was doing
Con: I don’t have any idea, and I need something that is simpler to understand and get using

Brackets

Pro: Again, looks like it would be handy if I wasn’t so noo
Con: Needs other things loaded or added in order to accept inputs

PyCharm CE

The version I downloaded is free and has a good rep. About to test it out. Maybe 7th time’s the (py)charm!

Pro: “Run” is a clearly displayed option in the menu toolbar. Easy to find!
Con: SIGH. Extraneous output. When everything runs correctly still get “Process finished with exit code 0” message. It’s annoying, but it seems like I can’t escape this output quirk in any option.

UPDATE: PyCharm turned into a massive headache. It suddenly stopped being able to find files, and overall seems overkill for the simple practice I’m doing. I’ve gone back to Spyder.

Currently using Spyder

   

2. Practice code

 

2e. Loops

While loop

opts = ["friend", "Friend"]
        
enter = input("Speak friend and enter. ")
while enter not in opts:
    enter = input("Speak friend and enter. ")
else:
    print ("\n")
    print ("Welcome to Moria!")

   

2d. List comprehensions

set = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

evens = [num for num in set if num%2==0]

print(evens)

   

2c. Calling values from dictionaries

MyColor = {"name": "seafoam blue", "hex": "#89BBBC"} 
print(MyColor["hex"])

 

BrandBlue = {"name": "seafoam blue", "hex": "#89BBBC"} 
print("The correct hex formula for Brand Blue is", BrandBlue["hex"])

   

2b. More practice code

Is it a palindrome?

test = input("Hello, please type in a word. ")

if test[0:] == test[::-1]:
    print("Hello, ", test, "is a palindrome.")
else:
    print("Hello, ", test, "is not a palindrome.")

   

Polite math bot

num = int(input("Hello, let's do some division. Please tell me a number. "))
print("Thank you for the number", num, ".")

check = int(input("Hello, what number would you like me to divide that by? "))
print("Thank you. You'd like me to divide", num, "by", check, ".")

if num % check == 0:
    ans = num/check
    print ("\n")
    print (num, "divided by", check, "is", int(ans), ". ")
else:
    print ("\n")
    print("I'm sorry. That's too hard.")

   

Tell me a number

num = int(input("Hello, tell me a number: "))
print("Thank you.")

if num % 2 == 0: 
    print ("That was an even number.")
else:
    print("That was an odd number.")

   

My first Python script

name = input("Hello, what is your name? ")
age = input("Hello again, how old are you? ")
age = int(age)
year = str((100-age)+2018)
print ("\n")
print ("Hello, " + name + ". You will be 100 years old this time of year in " + year + ".")

   

2a. Mathing with pet names

   

Earnest = 10000
print(Earnest)

10000

 

Earnest = 5 < 8
print (Earnest)

True

 

print(“Duvel” + “Bear”)

DuvelBear

 

print (“Duvel “ + “Bear”)

Duvel Bear

 

ExtraKitty = 100
print (ExtraKitty > 6)

True

 

print (“Duvel “ * 3)

Duvel Duvel Duvel

 

ss = “Extra Kitty”
print(ss.upper())

EXTRA KITTY

 

Earnest = “I’m going to eat too fast and puke and then eat that”
print (len(Earnest))

52

 

Duvel = “Little orange sunshine”
“ “.join(Duvel)

‘L i t t l e o r a n g e s u n s h i n e’

 

print(““.join(reversed(Duvel)))

enihsnus egnaro elttiL

 

print(“ ; “.join([“Earnest”, “Extra Kitty” , “Duvel”]))

Earnest ; Extra Kitty ; Duvel

 

Duvel = “Little orange sunshine”
print (Duvel.split())

[‘Little’, ‘orange’, ‘sunshine’]

 

NewList = (Duvel.split()) print (NewList)

[‘Little’, ‘orange’, ‘sunshine’]

 

print (“ ; “.join(NewList))

Little ; orange ; sunshine

 

x = “Earnest loves {} and {}.”
print(x.format(“treats”,”hugs”))

Earnest loves treats and hugs.

   

3. Things to be learned

 

Something going wrong here with the line breaks

’’’
… As Ralph likes to say
… My cats breath smells like cat food
… This was a haiku
… ‘’’

‘\nAs Ralph likes to say\nMy cats breath smells like cat food\nThis was a haiku\n’

 

I don’t understand line breaks and escape characters. Research later.

       

< There’s no place like home