Advance Comp Reviewer
Advance Comp Reviewer
CS 121 – Midterm
What is Python?
•Its high-level built in data structures, combined with dynamic typing and dynamic
binding, make it very attractive for Rapid Application Development, as well as for
use as a scripting or glue language to connect existing components together.
• Since it’s easy to understand, you can easily read and understand
someone else’s code. • Python is also easy to write because of its
simple syntax.
Because it is an easy language, it is used in schools and universities to introduce
students to programming. Python is for both startups and big companies.
2. Readable
The Python language is designed to make developers life easy. Reading a Python
code is like reading an English sentence. This is one of the key reason that makes
Python best for beginners.
3. Dynamically-Typed Language
So it displays errors while you’re running a line and displays the entire stack trace
for the error.
4. Dynamically-Typed Language
Python is not statically-typed like Java. You don’t need to declare data type while
defining a variable. The interpreter determines this at runtime based on the types
of the parts of the expression. This is easy for programmers but can create runtime
errors.
Python follows duck-typing. It means, “If it looks like a duck, swims like a duck
and quacks like a duck, it must be a duck.”
5. Object-Oriented
Python has one of the largest communities on StackOverflow and Meetup. If you
need help, the community will answer your questions.
7. Open-Source
The standard library is large and has many packages and modules with common
and important functionality. If you need something that is available in this
standard library, you don’t need to write it from scratch. Because of this, you can
focus on more important things.
You can also install packages from the PyPI (Python Package Index) if you want
even more functionality.
9. Platform-Independent
Python is extensible. You can use code from other languages like C++
in your Python code.
You can use Python to create GUI (Graphical User Interfaces). You can use
tkinter, PyQt, wxPython or Pyside for this.
Python programming is a skill that can be used in virtually any industry, as well as
in positions far beyond just software development. From industries like finance,
healthcare, and insurance, to fields like aerospace to entertainment — Python-
based tech is driving innovation and new solutions.
Data types:
REPL:
• Integers
They are often called just integers or ints, are positive or negative whole
numbers
with no decimal point.
• Float
Also called floats, they represent real numbers and are written with a
decimal point
dividing the integer and fractional parts. Floats may also be in scientific
notation, with
E or e indicating the power of 10 (2.5e2 = 2.5 x 102 = 250).
• Long
Also called longs, they are integers of unlimited size, written like integers
and followed by an
uppercase or lowercase L.
• Character
Python does not have a character or char type.
All single characters are strings with length one.
• String
Strings are sequences of character data. The string type in Python is called
str
A collection of one or more characters put in a single quote, double-quote or
triple quote.
Operator
Assignment Operator
Arithmetic and modulus Operator
Relational Operator
Logical Operator
ASSIGNMENT OPERATOR
ARITHMETIC OPERATOR
RELATIONAL OPERATOR
LOGICAL OPERATOR