Lecture 4 - Intro to PyCharm

Lecture Date: Wednesday, January 27

We might not cover all of this today - but we definitely will over the next week. I’m keeping all the info together to make it easier to find.

What is PyCharm?

  • PyCharm is to coding as Word is to writing a paper
  • PyCharm is an integrated development environment (IDE) - that means it has lots of tools in it to make coding easier
  • PyCharm is built to actually do some prediction as to what you’re about to type

Starting up PyCharm

  • PyCharm works in projects
  • Think about each project being a different major thing
  • For example, you might have one project for in-class activities, one for POTDs, etc., but in the end it’s up to you
  • When you create a new project, you may have a choice between Pure Python and Educational
  • Pure Python is where you go to start a blank project for your coding assignments and in-class work
  • Educational is where you go to do some of the built-in tutorials (if you got the Educational edition)
  • When you create a new Pure Python project, make sure to put it somewhere you can find easily outside of PyCharm so you can copy the files out to submit for POTDs, etc.

Inside PyCharm

A few main windows to note here:

  • Project view (left vertical) - this shows you all your projects and files
  • Editor (big middle pane) - this is the blank thing in the middle
  • Console (appears at bottom when you run code) - the output from your programs appear here

Your First Program

  • When you start a new program, start by making a new python file: File -> New -> Python File
  • Give the file a name with all lowercase letters
  • The file should be automatically opened in the editor with an author tag - you should change it to your computing ID

Hello World

http://en.wikipedia.org/wiki/Hello_world_program

“While small test programs existed since the development of programmable computers, the tradition of using the phrase "Hello world!” as a test message was influenced by an example program in the seminal book The C Programming Language. The example program from that book prints “hello, world” (without capital letters or exclamation mark), and was inherited from a 1974 Bell Laboratories internal memorandum by Brian Kernighan, Programming in C: A Tutorial, which contains the first known version.“ Hello World is often the first program written for any language or any new platform.

The Parts of a Program

(this can mainly be found in your text)

hello.py
1
2
3
4
# Mark Sherriff (mss2x)

name = input("What is your name?: ")
print("Hello, " + name + "!")

To run the code, right-click in the editor and choose Run.

We’re not doing any fancy graphics yet, so the program runs in what is called the “console window.” Think of this just like a command prompt or a DOS prompt (if that means anything to you). Before Windows was created (or any other graphical user interface (GUI)) programs ran as plain text. And that’s how we’re starting out in this class. It’s simpler for now, trust me. I know it doesn’t look as cool, but we’ll do some graphics stuff later in the semester.

If we have time…

  • Looking at a project
  • Importing and Exporting projects
  • Taking this Hello World to the next level
  • More things to do in PyCharm!