Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Nothing

Rating
-
Sold
-
Pages
332
Uploaded on
02-09-2023
Written in
2023/2024

Lecture notes of 332 pages for the course Programing at Programing (NA)

Institution
Course

Content preview

, Python Basics
With Illustrations from the Financial Markets




QuantInsti Quantitative Learning Pvt. Ltd.
- India -

,Contents

1 Introduction 1
1.1 What is Python? . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Where is Python used? . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Why Python? . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 History of Python . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 Python 3 versus Python 2 . . . . . . . . . . . . . . . . . . . . 7
1.6 Key Takeaways . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2 Getting Started with Python 11
2.1 Python as a Calculator . . . . . . . . . . . . . . . . . . . . . . 11
2.1.1 Floating Point Expressions . . . . . . . . . . . . . . . 14
2.2 Python Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2.1 Literal Constants . . . . . . . . . . . . . . . . . . . . . 17
2.2.2 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2.3 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2.4 Comments . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2.5 print() function . . . . . . . . . . . . . . . . . . . . . 20
2.2.6 format() function . . . . . . . . . . . . . . . . . . . . 22
2.2.7 Escape Sequence . . . . . . . . . . . . . . . . . . . . . 23
2.2.8 Indentation . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3 Key Takeaways . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3 Variables and Data Types in Python 27
3.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.1.1 Variable Declaration and Assignment . . . . . . . . . 27
3.1.2 Variable Naming Conventions . . . . . . . . . . . . . 28
3.2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.2.1 Integer . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

i

, 3.2.2 Float . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.2.3 Boolean . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.2.4 String . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.2.5 Operations on String . . . . . . . . . . . . . . . . . . . 38
3.2.6 type() function . . . . . . . . . . . . . . . . . . . . . . 41
3.3 Type Conversion . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.4 Key Takeaways . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4 Modules, Packages and Libraries 47
4.1 Standard Modules . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.2 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.3 Installation of External Libraries . . . . . . . . . . . . . . . . 53
4.3.1 Installing pip . . . . . . . . . . . . . . . . . . . . . . . 54
4.3.2 Installing Libraries . . . . . . . . . . . . . . . . . . . . 54
4.4 Importing modules . . . . . . . . . . . . . . . . . . . . . . . . 56
4.4.1 import statement . . . . . . . . . . . . . . . . . . . . . 56
4.4.2 Selective imports . . . . . . . . . . . . . . . . . . . . . 57
4.4.3 The Module Search Path . . . . . . . . . . . . . . . . . 59
4.5 dir()function . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.6 Key Takeaways . . . . . . . . . . . . . . . . . . . . . . . . . . 63

5 Data Structures 65
5.1 Indexing and Slicing . . . . . . . . . . . . . . . . . . . . . . . 65
5.2 Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.2.1 Visualizing an Array . . . . . . . . . . . . . . . . . . . 67
5.2.2 Accessing Array Element . . . . . . . . . . . . . . . . 68
5.2.3 Manipulating Arrays . . . . . . . . . . . . . . . . . . . 68
5.3 Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
5.3.1 Accessing tuple elements . . . . . . . . . . . . . . . . 71
5.3.2 Immutability . . . . . . . . . . . . . . . . . . . . . . . 72
5.3.3 Concatenating Tuples . . . . . . . . . . . . . . . . . . 72
5.3.4 Unpacking Tuples . . . . . . . . . . . . . . . . . . . . 73
5.3.5 Tuple methods . . . . . . . . . . . . . . . . . . . . . . 73
5.4 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.4.1 Accessing List Items . . . . . . . . . . . . . . . . . . . 75
5.4.2 Updating Lists . . . . . . . . . . . . . . . . . . . . . . 75
5.4.3 List Manipulation . . . . . . . . . . . . . . . . . . . . . 77
5.4.4 Stacks and Queues . . . . . . . . . . . . . . . . . . . . 80

ii | Table of Contents

Written for

Course

Document information

Uploaded on
September 2, 2023
Number of pages
332
Written in
2023/2024
Type
Class notes
Professor(s)
Nandini
Contains
All classes

Subjects

$18.89
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
dangetinandini

Get to know the seller

Seller avatar
dangetinandini Self
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions