Categories

Get Started Now

Python Parley

featured (3)

Editor’s Note: Steve Barth, CBT Nugget’s resident video producer, who you may remember from our NuggetCast video series, is bringing his knack for explaining IT in fun ways, to our blog — to bring his unique perspective to some IT concepts that may sound intimidating to beginners. Here’s his first post.

Early fall mornings in Oregon can be chilly and wet, with a quick dash from the car to the office front door to avoid starting the day drenched. Last week, I made one of those quick runs from my vehicle and entered the office out of breath, cold and ready for my hot cocoa to officially start my day. As I walked harried through the office, I ran into one of my co-workers, who is a programmer.

“Morning, Sam!” I said, while trying to keep my laptop bag’s strap from slipping off my shoulder.

“null GreetPerson(char name[]){printf(“Good Morning %s”,name);printf(“How was your evening?”);”

I stared at him blankly. What was he trying to say? A little befuddled, I responded ”Umm… Excuse me? Are you asking me about me evening?”

His reply was not at all helpful. ”if (name == “Steve”) { printf(“Add anything new to your Star Wars collection?”) }else { printf(“You should be more like Steve”) }}” he stated, matter of factly.

“Yes… My name is Steve. You know that. What is with you today? Why do you keep saying CURLY BRACKET?!”

“int main(){char name[] = {‘S’,’t’,’e’,’v’,’e’,’\0′};GreetPerson(name); return 0;}”

Now he was just making me mad. ”What is wrong with you?! Why are you SPELLING my name? What does that have to do with my Star Wars Collection? And to where should I be returning?!?”

He moved to the break room, obviously needing some coffee, while I stood there still confused about he was trying to say.

I continued on toward my desk, but soon ran into another co-worker. “Morning Randy! Hey, have you talked to Sam today? I think he’s having another breakdown.”

Randy’s response, while similar and still confusing, felt a little bit different.

def GreetPerson(name):

  print(“Good Morning %1”, name)

  print(“How was your evening?”)

Thinking maybe I had entered the Twilight Zone, at least I could understand him. There were unusual pauses in his speaking, unlike Sam’s constant pounding of gibberish, but I could make out what he was going for in this conversation. “My evening? Not bad! At least my 2-year-old kept his pants off his head for once.”

  if (name == “Steve”):

print(“Add anything new to your Star Wars collection?”)

else:

print(“You should be more like Steve and get some Star Wars action figures.”)

GreetPerson(“Steve”)

Again, still odd, but understandable. This was a conversation I could engage in. “Nope, no new Star Wars toys. ToysRUs still hasn’t restocked since Force Friday. But I keep hoping. And no, people should not be more like me and buy more action figures; that leaves less for me to buy, but I appreciate the sentiment.”

As I finished my trip up the stairs, I pondered these two conversations. After the first one, I was confused, annoyed, and I had no idea what was happening, much like computer codes that dominated the programming scene for the last 20 years. But the second conversation, I could understand and engage in, much like the experience today’s programmers get from languages such as Python.

What in the world is Python? Python is a general purpose programming language used by thousands of web programmers. It was conceived by Guido van Possum in the late 1980s as a replacement of the “ABC” language, and was designed as something fun to use, hence the name “Python,” named after the playfulness of Monty Python (not a scary snake). Today, Python is used for all kinds of things, from testing microchips, to powering video games with its PyGame library, to making Instagram more efficient. It’s easy to type and read, very closely resembling the English language, and has hundreds of existing third-party libraries, making it very flexible for all your coding needs. Here are a few key things that really stand out to me for understanding the basics of Python:

Readability
Python, as I illustrated in my story, more closely resembles normal English than traditional programming languages. By using words like “not” and “in,” it allows you to often read a program or script aloud to someone else and not feel like you’re speaking some difficult-to-understand language. Helping with this readability is Python’s strict punctuation rules, which makes it so that you don’t have curly brackets ({ }) all over your code.

Python also has a set of rules, known as PEP 8, that tell every Python developer how to format their code. This means you always know where to put new lines and, more importantly, that pretty much every other Python script you pick up, whether it was written by a novice or a seasoned professional, will look very similar and be just as easy to read. Code written by beginners can look just like the code written by advanced professionals. PEP 8 keeps it all unified.

Libraries
Python features a collection of code, on https://pypi.python.org, (pronounced “pie-pee-eye” or, more commonly called the “CheeseShop.”) This library, slowly built over the last 20 years, is an open source language gold mine, available for all to use. You can install this software on your system to be used in your own projects. For example, if you want to use Python to build scripts with commandline arguments, you’d install the “click” library and then import it into your scripts and use it. Libraries can be found and referenced for all of your coding needs, from mathematical calculations, to image manipulation, to server automation.

Community
Python has a giant community of developers all over the world, usually called PUGs. They discuss Python not just online, but at major conferences all over the planet. PyCon NA, the largest Python conference in North America, will have its next annual convention in Portland in 2016, providing Pyhon content during a span of nine days to nearly 3,000 attendees. And, reflecting Python’s commitment to diversity, it has has more than 30% women speakers. Beginning in 2013, PyCon NA also started a trend of offering “Young Coder” workshops, where attendees taught Python to kids between 9 and 16 years of age for a day, teaching them the basics of the language — and helping them hack and mod some games on the Raspberry Pis.

Python really does have a lot to offer, from easy readability, large resources to help you along the way, to a community of professionals, dedicated to diversity and sharing their knowledge with future generations. There is a lot to get excited about in Python.

Now I just need to get Sam converted, so we can return to having normal conversations!

Ready to learn Python? Start watching CBT Nuggets’ “Python Programming” training course today!

 

Not a CBT Nuggets subscriber? Start your free week now.

CBT Nuggets has everything you need to learn new IT skills and advance your career — unlimited video training and Practice Exams, Virtual Labs, validated learning with in-video Quizzes, Accountability Coaching, and access to our exclusive community of IT professionals.

Learn more about the CBT Nuggets Learning Experience.

 

Comments are closed.