Game Development Using Python - Lecture#1,2 & 3
Game Development Using Python - Lecture#1,2 & 3
What Is Python?
Python is a general-purpose interpreted, interactive, object-
oriented, and high-level programming language. It was created by
Guido van Rossum during 1985- 1990. Like Perl, Python source
code is also available under the GNU General Public License (GPL).
1
6/27/2021
2
6/27/2021
Applications of Python
Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax. This
allows the student to pick up the language quickly.
Easy-to-read − Python code is more clearly defined and visible to the eyes.
Easy-to-maintain − Python's source code is fairly easy-to-maintain.
A broad standard library − Python's bulk of the library is very portable and cross-
platform compatible on UNIX, Windows, and Macintosh.
Interactive Mode − Python has support for an interactive mode which allows interactive testing
and debugging of snippets of code.
Portable − Python can run on a wide variety of hardware platforms and has the same interface
on all platforms.
Extendable − You can add low-level modules to the Python interpreter. These modules enable
programmers to add to or customize their tools to be more efficient.
Databases − Python provides interfaces to all major commercial databases.
GUI Programming − Python supports GUI applications that can be created and ported to many
system calls, libraries and windows systems, such as Windows MFC, Macintosh, and the X
Window system of Unix.
Scalable − Python provides a better structure and support for large programs than shell scripting.
Prerequisites
You should have a basic understanding of Computer
Programming terminologies. A basic understanding of any of the
programming languages is a plus.
3
6/27/2021
Python Script
4
6/27/2021
Python Identifiers
A Python identifier is a name used to identify a variable, function, class,
module or other object. An identifier starts with a letter A to Z or a to z or an
underscore (_) followed by zero or more letters, underscores and digits (0 to
9).
Python does not allow punctuation characters such as @, $, and %
within identifiers. Python is a case sensitive programming language.
Thus, Manpower and manpower are two different identifiers in Python.
Here are naming conventions for Python identifiers −
➢ Class names start with an uppercase letter. All other identifiers start with a
lowercase letter.
➢ Starting an identifier with a single leading underscore indicates that the
identifier is private.
➢ Starting an identifier with two leading underscores indicates a strongly
private identifier.
➢ If the identifier also ends with two trailing underscores, the identifier is a
language- defined special name.
10
5
6/27/2021
Reserved Words
11
However, the
12
6
6/27/2021
Multi-Line Statements
Statements in Python typically end with a new line. Python does,
however, allow the use of the line continuation character (\) to
denote that the line should continue. For example −
13
Quotation in Python
Python accepts single ('), double (") and triple (''' or """) quotes
to denote string literals, as long as the same type of quote
starts and ends the string.
The triple quotes are used to span the string across multiple lines. For
example, all the following are legal
−
14
7
6/27/2021
15
16
8
6/27/2021
Here, 100, 1000.0 and "John" are the values assigned to counter, miles, and name variables,
respectively. This produces the following result −
17
Multiple Assignment
Python allows you to assign a single value to several variables
simultaneously. For example −
Here, an integer object is created with the value 1, and all three
variables are assigned to the same memory location. You can also
assign multiple objects to multiple variables. For example −
18
9
6/27/2021
➢ String
➢ List
➢ Tuple
➢ Dictionary
19
10