0% found this document useful (0 votes)
7 views37 pages

Department of Computer Science and Engineering: Programming in Python

The document outlines a programming course in Python for the ME program, covering fundamental concepts such as data, expressions, and statements. It introduces key terminology like interpreters and compilers, explaining how Python, as a high-level language, allows for easier programming compared to machine language. Additionally, it discusses the installation of Python and the importance of debugging skills in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views37 pages

Department of Computer Science and Engineering: Programming in Python

The document outlines a programming course in Python for the ME program, covering fundamental concepts such as data, expressions, and statements. It introduces key terminology like interpreters and compilers, explaining how Python, as a high-level language, allows for easier programming compared to machine language. Additionally, it discusses the installation of Python and the importance of debugging skills in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

Department of Computer Science and Engineering

Programming in Python
Open Elective VII Semester ME
(9th Sep – 10th Jan 2024 )

Dr. Mallanagouda Patil


Module-1

Introduction,
Data, Expressions,
Statements
Introduction
Creativity and motivation:

When you first start, you will be both the programmer and the end user of your programs. As you gain skill as a
programmer and programming feels more creative to you, your thoughts may turn toward developing programs for
others.

Computer hardware architecture:

Before we start learning the language


we speak to give instructions to
computers to develop software, we
need to learn a small amount about
how computers are built.
Introduction
Understanding programming
Terminology: Interpreter and compiler
Python is a high-level language intended to be relatively straightforward for humans to read and write and for
computers to read and process.

The CPU understands a language we call machine language. Machine language is very simple and frankly very
tiresome to write because it is represented all in zeros and ones:

Since machine language is tied to the computer hardware, machine language is not portable across different
types of hardware.

Programs written in high-level languages can be moved between different computers by using a different
interpreter on the new machine or recompiling the code to create a machine language version of the program for
the new machine.

These programming language translators fall into two general categories: (1) interpreters and (2) compilers.
Terminology: Interpreter and compiler
An interpreter reads the source code of the program as written by the programmer, parses the source code, and
interprets the instructions one line at a time.

Python is an interpreter where we can type a line of Python (a sentence) and Python processes it immediately
and is ready for us to type another line of Python.

Some of the lines of Python tell that you want it to remember some value for later. We need to pick a name for
that value to be remembered and we can use that symbolic name to retrieve the value later. We use the term
variable to refer to the labels we use to refer to this stored data.

A compiler needs to be handed the entire program in a file, and then it runs a
process to translate the high-level source code into machine language and then
the compiler puts the resulting machine language into a file for later execution.
Terminology: Interpreter and compiler
If you have a Windows system, often these executable machine language programs have a suffix of “.exe” or
“.dll” which stand for “executable” and “dynamic link library” respectively.

In Linux and Macintosh, there is no suffix (or extension) that uniquely marks a file as executable. If you were to
open an executable file in a text editor, it would look completely crazy and be unreadable:

The Python interpreter is written in a high-level language called “C”


Writing a program
We tell Python interpreter to read its source code from the file “hello.py” instead of prompting us for
lines of Python code interactively
Running Python Program
One of the challenges of getting started with Python is that you might have to install Python and related software
on your computer. If you are familiar with your operating system, and especially if you are comfortable with the
command-line interface, you will have no trouble installing Python. But for beginners, it can be painful to learn
about system administration and programming at the same time. To avoid that problem, I recommend that you
start out running Python in a browser.

The Python interpreter is a program that reads and executes Python code. Depending on your environment, you
might start the interpreter by clicking on an icon, or by typing python on a command line. When it starts, you
should see output like this:
Running Python Program
Running Python Program
Because we all grow up speaking natural languages, it is sometimes hard to adjust to formal languages. The
difference between formal and natural language is like the difference between poetry and prose, but more so:
Learning to debug can be frustrating, but it is a valuable skill that is useful for many
activities beyond programming.

You might also like