why is the main function always the first one? Doesn’t that mean that when we call the main function in terminal it won’t know which one to use? How do atom and the terminal “talk” to each other?

I’ll group these together. When we type python3 firstProg.py, Python doesn’t really talk to atom. Rather, it sees that there is a file on the disk called firstProg.py, opens it, and starts reading it line-by-line - just as you do. We use atom to help us read the file; Python uses what is called a parser and interpreter to figure out what the program wants to do. When it sees def main(), it identifies that a procedure is being defined. It’s sort of like writing a recipe to cook later. When it sees the call to main() later, it checks to see if there is a procedure called main() and runs it. This is sort of like cooking the recipe that you wrote on the card before.

What data type would alphanumeric values fall under?

This would be a string – a string can be any characters including alphanumeric as well as special symbols.

What will be the differences between implementing floats and ints? Luckily, we won’t have to worry about this. We only need to focus on how we use them. The power of abstraction is that we don’t have to know all the details to get something to work.

What does low-level language do?

Good question. If you want to have full control on how disk space, or memory is managed; if you want to write algorithms to encrypt a message; if you need a program to run fast (a C++ program can accomplish a hard problem 5 times faster with the same algorithm).

When I type print(“3+4”), it prints out “7” instead of “3+4”

That’s odd. Try it again and let me or a ninja know if it still does this: >>> print("3+4") 3+4

What’s the biggest mistake people make when commenting?

Forgetting to do it, or doing it in a way that doesn’t really help someone else understand it. I’d say the second problem is learning to be concise. It’s a fine balance.

What sort of project would python not be good for?

Doing stuff that is really close to talking with the hardware (computer parts). It can do it, but it’s not as useful. Also, a lot of high-powered applications. Recently, though, a common practice is to use Python on top of really high-powered code in a language like C++, or Javascript. So you can use Python to communicate with a program written in a different language. This is really nice for writing programs because it means you don’t have to be proficient in a dozen languages.

It seems like we are telling the computer to run the program twice when we enter main() in atom and run the program in terminal. Why?

atom doesn’t do anything itself. It’s just a program for us to type what we want. Nothing happens until we actually tell Python to read the program we are writing. It’s sort of like typing an email. It doesn’t get sent until you hit the send button, you can write, edit, and delete to your heart’s content prior to that.

I am still confused why there is the need to add comments to a program - why are they necessary?

Programs get complex - hundreds to thousands of lines of code. And while Python is English-like, it is not easy for a human to grok all that complexity. The comments allow us to explain the algorithms we are writing. We can also document things e.g., “Prof. Soni, this is the part that I couldn’t get to work”.

How many functions can tide along inside def main() so that main runs them

This is week 5 material. But we can define any number of functions we want to. You can think of each button on your phone as calling a function e.g., volumeUp() or volumeDown().You can define more functions if you want more capabilities.

Do we have to put the computer in script mode at the beginning of every program?

Script mode just means that we ask Python to read a file that you’ve written.
We don’t have to turn it on or off, it figures out by the fact that you typed

python file.py on the command line

what does $ pwd do?

Print Working Directory - tells you which folder you are in. This can be helpful if you need to switch from your lab directory to the inclass directory because you wanted to look at an example we did in class.

Are we always going to use python via the terminal?

Yes!

Why don’t lines have to end with ;

The beauty of Python. Other programming languages require that to end a line, Python uses whitespace (hitting the Enter key). It’s simpler and our programs are easier to read.

How do you know when to switch from terminal to atom?

When you want to see if the code you have written works, you save it and try to run it in the terminal. It is useful to have a terminal open next to atom because you will constantly go back-and-forth (no program works the first time you write it).