Adventures in parseltongue
ISO Python IDE to love and cherish
Terminal
Pro: outputs only the info I want to see. I feel like I’m in the Matrix and/or 1997
Con: can’t edit inline
Spyder
Pro: seems cool
Cons: not launching in my Python 2.7 env for some reason. Also, the runfile paths 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.
Will keep using PyCharm for now.
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 + “.”)
Markdown is interacting with my copy/paste Python from Terminal. Having to manually insert indents and line breaks. Some may be missing. This is really not the best format for this material.
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
name, hex = “Seafoam Blue”, “89BBBC”
print (name)Seafoam Blue
print (hex)
89BBBC
print (“#” + hex)
#89BBBC
x = “Earnest loves {} and {}.”
print(x.format(“treats”,”hugs”))Earnest loves treats and hugs.
Things to be learned
Something going wrong here with the line breaks
’’’
… As the wise Ralph said
… My cats breath smells like cat food
… This was a haiku
… ‘’’‘\nAs the wise Ralph said\nMy cats breath smells like cat food\nThis was a haiku\n’
I don’t understand line breaks and escape characters. Research later.
Learn how to call values from dictionaries
MyColor = {‘name’: ‘seafoam blue’, ‘hex’: ‘89BBBC’}
print(MyColor.hex)Traceback (most recent call last):
File “
", line 1, in AttributeError: ‘dict’ object has no attribute ‘hex’
print(hex.MyColor)
Traceback (most recent call last):
File “", line 1, in
AttributeError: ‘builtin_function_or_method’ object has no attribute ‘MyColor’