credits: Codecademy
What is Programming?

It is a collaboration between Humans and Computers.
Programming is everywhere and surrounds us. Automatic washing machines, Traffic signals, microwaves, smart televisions, videos games, everywhere it exists. It is impacting our everyday life and making it more comfortable. Tech companies are no longer recognizable as just software companies – instead, they bring food to our door, help us get a taxi, influence outcome of elections, or can also act as a personal trainer.
Programming is giving a set of instructions to a computer to execute.
What is difference between Programming and Coding?
Sometimes used interchangeably, programming and coding actually have different definitions.
- Programming is the mental process of thinking up instructions to give to a machine (like a computer)
- Coding is the process of transforming those ideas into a written language that a computer can understand.
“The problem with programming is not that the computer isn’t logical—the computer is terribly logical, relentlessly literal-minded.”
Ellen Ullman, Life in Code
Computers interpret instructions in a very literal manner, so we have to be very specific in how we program them. Think about instructing someone to walk. If you start by telling them, “Put your foot in front of yourself,” do they know what a foot is? Or what front means? (and now we understand why it’s taken so long to develop bipedal robots…). In coding, that could mean making sure that small things like punctuation and spelling are correct. Many tears have been shed over a missing semicolon (;) a symbol that a lot of programming languages use to denote the end of a line.
Who is GOOD at what?
Humans:
Thinks creatively.
Communicates through inference.
Detects patterns to make sense of world.
Inconsistent
Can get bored.
Computer:
No creativity (Follows given instructions)
Limited hard-wired knowledge
Calculates information quickly.
Consistent
Does not lose focus.
======================================================================================================================
Programming Language: Python
Python is a programming language. As we discussed earlier, like any other language, it gives us a way to communicate
ideas. In the case of programming language, these ideas are “commands” that people use to communicate with a Computer.
We convey our commands to the computer by writing them in a text file using a programming language. These files are called
programs.
Running a program means telling a computer to read the text file, translate it to the set of operations that it understands,
and perform those actions.
“””
my_name = “Yash”
print(“Hello and welcome ” + my_name + “!”)
“””
2. Text written in a program but not run by the computer is called a comment. Python interprets anything after a # as a
comment.
Comments achieve following tasks:
a) Provide context for why something is written the way it is.
b) Help other people reading the code understand it faster.
c) Ignore a line of code and see how a program will run.
3. Print
Now what we are going to do is teach our computer to communicate. The gift of speech is valuable: a computer can answer many questions we have about “how” or “why” or “what” it is doing.
In Python, the print() function is used to tell a computer to talk. The message to be printed should be surrounded by quotes.
“””
print(“My name is Yash”)
“””
The printed words that appear as a result of the print() function are referred to as output.
4. Strings
Computer programmers refer to blocks of text as strings. In our last exercise, we created the string “Hello world!”. You can use both single quotes and double quotes, but don’t mix, otherwise you will syntax error.
Something like this:
“””
File “script.py”, line 1
print(“Yash’)
^
SyntaxError: EOL while scanning string literal
“””
5. Variables
Programming languages offer a method of storing data for reuse. If these is a greeting we want to present, a date we need to reuse, or a user ID we need to remember we can create a variable which can store a value.
In python we assign variables by using the equals sign (=).
Variables can’t have spaces or symbols in their names other than underscore, also they shouldn’t start with number, nor you can use reserved words like if, print, else as variable name, since they are parsed differently by python.
“””
message_string = “Hello there”
“””
“””
File “script.py”, line 21
1print = “meal”
^
SyntaxError: invalid syntax
“””
6. Errors
Humans are prone to making mistakes. Humans are also typically in charge of creating computer programs. To compensate, programming languages attempt to understand and explain mistakes made in
their programs. Pythoin refers to these mistakes as errors and will point to the location where an error occurred with a ^ character. When programs throw errors that we didn’t expect to encounter we call those errors
bugs.
Programmers call the process of updating the program so that it no longer produces unexpected errors debugging.
Two common errors that we encounter while writing Python are:
a) SyntaxError: Means there is something wrong with the way your program is written –punctuation that does not belong, a command where it is not expected, or a missing parenthesis can all triggers a SyntaxError.
b) NameError: A NameError occurs when the Python interpreter sees a word it does not recognize. Code that contains something that looks like a variable but was never defined will throw a NameError.