Python is a popular programming language created by Guido van Rossum in 1991. It is easy to use, powerful, and versatile, making it suitable for beginners and experts alike. Python code can be written and executed in the browser using Google Colab, which provides a Jupyter notebook environment and access to computing resources like GPUs. The document then discusses installing Python using Anaconda, basic Python concepts like indentation, variables, strings, conditionals, and loops.
This Edureka Python tutorial is a part of Python Course (Python Tutorial Blog: https://goo.gl/wd28Zr) and will help you in understanding what exactly is Python and its various applications. It also explains few Python code basics like data types, operators etc. Below are the topics covered in this tutorial:
1. Introduction to Python
2. Various Python Features
3. Python Applications
4. Python for Web Scraping
5. Python for Testing
6. Python for Web Development
7. Python for Data Analysis
This Edureka Python Programming tutorial will help you learn python and understand the various basics of Python programming with examples in detail. Below are the topics covered in this tutorial:
1. Python Installation
2. Python Variables
3. Data types in Python
4. Operators in Python
5. Conditional Statements
6. Loops in Python
7. Functions in Python
8. Classes and Objects
This Edureka Python tutorial is a part of Python Course (Python Tutorial Blog: https://goo.gl/wd28Zr) and will help you in understanding what exactly is Python and its various applications. It also explains few Python code basics like data types, operators etc. Below are the topics covered in this tutorial:
1. Introduction to Python
2. Various Python Features
3. Python Applications
4. Python for Web Scraping
5. Python for Testing
6. Python for Web Development
7. Python for Data Analysis
This Edureka Python Programming tutorial will help you learn python and understand the various basics of Python programming with examples in detail. Below are the topics covered in this tutorial:
1. Python Installation
2. Python Variables
3. Data types in Python
4. Operators in Python
5. Conditional Statements
6. Loops in Python
7. Functions in Python
8. Classes and Objects
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Edureka!
( Python Training : https://www.edureka.co/python )
This Edureka “Python Programming" introduces you to Python by giving you enough reasons to learn it. It will then take you to its various fundamentals along with a practical demonstrating the various libraries such as Numpy, Pandas, Matplotlib and Seaborn. This video helps you to learn the below topics:
1. Why should you go for Python?
2. Introduction to Python Programming Language
3. How to work with Jupyter?
4. Python Programming Fundamentals: Operators & Data Types
5. Libraries: Numpy, Pandas, Matplotlib, Seaborn
** Python Certification Training: https://www.edureka.co/python **
This Edureka tutorial on "Python Tutorial for Beginners" (Python Blog Series: https://goo.gl/nKQJHQ) covers all the basics of Python. It includes python programming examples, so try it yourself and mention in the comments section if you have any doubts. Following are the topics included in this PPT:
Introduction to Python
Reasons to choose Python
Installing and running Python
Development Environments
Basics of Python Programming
Starting with code
Python Operators
Python Lists
Python Tuples
Python Sets
Python Dictionaries
Conditional Statements
Looping in Python
Python Functions
Python Arrays
Classes and Objects (OOP)
Conclusion
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Python tutorial for beginners - Tib academyTIB Academy
Get python training through simple tutorial from TIB Academy, through this python tutorial you can lean more topics of python. you can download python tutorial free as PPT
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Python is one of the powerful, high-level, easy to learn programming language that
provides a huge number of applications. Some of its features, such as being object-oriented
and open source, having numerous IDE’s, etc. make it one of the most in-demand
programming languages of the present IT industry.
According to TIOBE index, as of January 2020, Python is one of the popular programming
languages. By looking at the popularity of this programming language, many IT
professionals, both beginners as well as experienced alike, are willing to build their career
as a Python developer
Provides an introductory level understanding of the Python Programming Language and language features. Serves as a guide for beginners and a reference to Python basics and language use cases.
Youtube Link: https://youtu.be/woVJ4N5nl_s
** Python Certification Training: https://www.edureka.co/data-science-python-certification-course **
This Edureka PPT on 'Python Basics' will help you understand what exactly makes Python special and covers all the basics of Python programming along with examples.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. 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. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.
Introduction to python -easiest way to understand python for beginners
What is Python…?
Differences between programming and scripting language
Programming Paradigms
History of Python
Scope of Python
Why do people use Python?
Installing Python
This Presentation Helps for the beginners to understand easily Python Programming Language, because i had given an snapshot of each concepts. Those who are knowing C,C++ and Java they can easily understand my presentation.
This presentation educates you about Python and the reason for learning python, Key advantages of learning Python, Characteristics of Python, Hello World using Python syntax and Applications of Python.
For more topics stay tuned with Learnbay.
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Edureka!
( Python Training : https://www.edureka.co/python )
This Edureka “Python Programming" introduces you to Python by giving you enough reasons to learn it. It will then take you to its various fundamentals along with a practical demonstrating the various libraries such as Numpy, Pandas, Matplotlib and Seaborn. This video helps you to learn the below topics:
1. Why should you go for Python?
2. Introduction to Python Programming Language
3. How to work with Jupyter?
4. Python Programming Fundamentals: Operators & Data Types
5. Libraries: Numpy, Pandas, Matplotlib, Seaborn
** Python Certification Training: https://www.edureka.co/python **
This Edureka tutorial on "Python Tutorial for Beginners" (Python Blog Series: https://goo.gl/nKQJHQ) covers all the basics of Python. It includes python programming examples, so try it yourself and mention in the comments section if you have any doubts. Following are the topics included in this PPT:
Introduction to Python
Reasons to choose Python
Installing and running Python
Development Environments
Basics of Python Programming
Starting with code
Python Operators
Python Lists
Python Tuples
Python Sets
Python Dictionaries
Conditional Statements
Looping in Python
Python Functions
Python Arrays
Classes and Objects (OOP)
Conclusion
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Python tutorial for beginners - Tib academyTIB Academy
Get python training through simple tutorial from TIB Academy, through this python tutorial you can lean more topics of python. you can download python tutorial free as PPT
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Python is one of the powerful, high-level, easy to learn programming language that
provides a huge number of applications. Some of its features, such as being object-oriented
and open source, having numerous IDE’s, etc. make it one of the most in-demand
programming languages of the present IT industry.
According to TIOBE index, as of January 2020, Python is one of the popular programming
languages. By looking at the popularity of this programming language, many IT
professionals, both beginners as well as experienced alike, are willing to build their career
as a Python developer
Provides an introductory level understanding of the Python Programming Language and language features. Serves as a guide for beginners and a reference to Python basics and language use cases.
Youtube Link: https://youtu.be/woVJ4N5nl_s
** Python Certification Training: https://www.edureka.co/data-science-python-certification-course **
This Edureka PPT on 'Python Basics' will help you understand what exactly makes Python special and covers all the basics of Python programming along with examples.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. 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. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.
Introduction to python -easiest way to understand python for beginners
What is Python…?
Differences between programming and scripting language
Programming Paradigms
History of Python
Scope of Python
Why do people use Python?
Installing Python
This Presentation Helps for the beginners to understand easily Python Programming Language, because i had given an snapshot of each concepts. Those who are knowing C,C++ and Java they can easily understand my presentation.
This presentation educates you about Python and the reason for learning python, Key advantages of learning Python, Characteristics of Python, Hello World using Python syntax and Applications of Python.
For more topics stay tuned with Learnbay.
SAMCSCMLA SCACLSALS CS L LSLSL SAMCSCMLA SCACLSALS CS L LSLSL SAMCSCMLA SCACLSALS CS L LSLSL SAMCSCMLA SCACLSALS CS L LSLSL SAMCSCMLA SCACLSALS CS L LSLSL SAMCSCMLA SCACLSALS CS L LSLSL SAMCSCMLA SCACLSALS CS L LSLSL SAMCSCMLA SCACLSALS CS L LSLSL SAMCSCMLA SCACLSALS CS L LSLSL SAMCSCMLA SCACLSALS CS L LSLSL
Introduction, Terminology and concepts, Introduction to statistics, Central tendencies and distributions, Variance, Distribution properties and arithmetic, Samples/CLT, Basic machine learning algorithms, Linear regression, SVM, Naive Bayes
Module 4: Data visualization (8 hrs)
Introduction, Types of data visualization, Data for visualization: Data types, Data encodings, Retinal variables, Mapping variables to encodings, Visual encodings, Data Visualization in Python-Superset or in Microsoft Power BI
TIME STUDY: Time Study, Definition, time study equipment, selection of job, steps in time study. Breaking jobs into elements, recording information. Rating & standard Rating, standard performance, scale of rating, factors of affecting rate of working, allowances and standard time determination. Predetermined motion time study – Method time measurement (MTM)
MICRO AND MEMO MOTION STUDY: Charts to record moment at work place – principles of motion economy, classification of moments two handed process chart, SIMO chart, and micro motion study. Development, definition and installation of the improved method, brief concept about synthetic motion studies. Management
Unit 2 :
Work Study: Definition, objective and scope of work study. Human factors in work study. Work study and management.
Method Study: Definition, objective and scope of method study, activity recording and exam aids. Charts to record moments in shop operation – process charts, flow process charts, travel charts and multiple activity charts.
Work Study: Definition, objective and scope of work study. Human factors in work study. Work study and management.
Method Study: Definition, objective and scope of method study, activity recording index aids. Charts to record moments in shop operation – process charts, flow process charts, travel charts and multiple activity charts.
Industrial Management: Meaning, Definition, Objective, Need, Scope, Evolution and developments.
Productivity: Definition of productivity, Measurement of productivity, factors affecting the productivity, productivity improvement programs.
Industrial Management: Meaning, Definition, Objective, Need, Scope, Evolution and developments.
Productivity: Definition of productivity, Measurement of productivity, factors affecting the productivity, productivity improvement programs.
Industrial Management: Meaning, Definition, Objective, Need, Scope, Evolution and developments.
Productivity: Definition of productivity, Measurement of productivity, factors affecting the productivity, productivity improvement programs.
Industrial Management: Meaning, Definition, Objective, Need, Scope, Evolution and developments.
Productivity: Definition of productivity, Measurement of productivity, factors affecting the productivity, productivity improvement programs.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
3. Python ( What and Why ?)
• Python is the most popular programming language & choice for
Data Scientist / Data Engineer across the world
• Very rich libraries & functions
• Community support
• Easy to deploy in production
• Support for all the new state of the art technologies ( like deep
learning)
3
10. 10
"Python is easy to use, powerful, and versatile, making it a great choice
for beginners and experts alike." – codeschool.com
print("Python" +" is "+"cool!")
11. 11
print("Python" +" is "+"cool!")
"Python is easy to use, powerful, and versatile, making it a great choice
for beginners and experts alike." – codeschool.com
12. print("Python"+" is"+"cool!")
"Python is easy to use, powerful, and versatile, making it a great choice
for beginners and experts alike." – codeschool.com
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
12
13. print("Python"+" is"+"cool!")
"Python is easy to use, powerful, and versatile, making it a great choice
for beginners and experts alike." – codeschool.com
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
print("Hello world!")
13
14. 14
"Python is easy to use, powerful, and versatile, making it a great choice
for beginners and experts alike." – codeschool.com
print("Python" +" is "+"cool!")
15. ● Python works on Windows, Linux, Mac,
Raspberry Pi, NVidia boards (linux), PYNQ
FPGA etc.
● Few lines of Programming
● Prototyping of Python programming is fast
● Syntax is same as like normal English
language
● It relies on Indentation, whitespace, scope of
loops, functions and classes
● Latest version of python is version3 (3.9).
Why Python?.
16. Python IDE.
IDLE : Python Software foundation license
PYCHARM: Apache license
SPYDER: MIT license
17. ● Python is a popular programming language. It
was created by Guido van Rossum, and
released in 1991.
● Python is a programming language that lets
you work more quickly and integrate your
systems more effectively.
1. Web development
2. Handle Big data
3. Handles complex Mathematics
4. Software development
5. Connects to database systems
Python & Uses.
18. print("Python" +" is "+"cool!")
"Python is easy to use, powerful, and versatile, making it a great choice
for beginners and experts alike." – codeschool.com/ Pluralsight Platform
18
Big names using Python
19. "Python is easy to use, powerful, and versatile, making it a great choice
for beginners and experts alike." – codeschool.com
print("Python"+" is"+"cool!")
https://opencv.org/
Image Processing using Python
19
20. "Python is easy to use, powerful, and versatile, making it a great choice
for beginners and experts alike." – codeschool.com
print("Python"+" is"+"cool!")
https://www.pygame.org
Game Development using Python
20
21. "Python is easy to use, powerful, and versatile, making it a great choice
for beginners and experts alike." – codeschool.com
16
print("Python"+" is"+"cool!")
https://matplotlib.org/
Data Science using Python
22. "Python is easy to use, powerful, and versatile, making it a great choice
for beginners and experts alike." – codeschool.com
print("Python"+" is"+"cool!")
https://github.com/amueller/word_cloud
Natural Language Processing (NLP) and Text Mining using Python
22
23. print("Python" +" is "+"cool!")
Top programming languages 2019 by IEEE Spectrum
2
3
25. Google Colab
• Colaboratory, or “Colab” for short, is a product from
Google Research.
• Colab allows anybody to write and execute arbitrary
python code through the browser, and is especially well
suited to machine learning, data analysis and education.
• More technically, Colab is a hosted Jupyter notebook
service that requires no setup to use, while providing free
access to computing resources including GPUs (graphics
processing unit ).
29. Google Colab
How to open:
'py' is a regular python file. It's plain text and contains just your code. ...
'ipynb' is a python notebook and it contains the notebook code, the execution results and
other internal settings in a specific format.
30. How to install Python the Anaconda way
1. Download Anaconda (which includes Python):
https://www.anaconda.com/download/
2. Run the installer and follow the installation instructions
3. Run the Spyder editor and create your first Python program "helloworld.py"
PythonSetup
30
31. How to install Python the Anaconda way
1. Download Anaconda (which includes Python and
relevant libraries): https://www.anaconda.com/distribution/
2. Run the installer and follow the instructions
3. Run the Spyder editor or Jupyter Notebook and create your first Python program "helloworld.py"
PythonSetup
31
32. Installation Steps
Install using the instruction given in the below links -
1. Install Jupyter - http://jupyter.org/install
Preferred installation method is through Anaconda distribution.
Install Python 3.8 version.
2. Anaconda 5.2 For Linux Installer - https://www.anaconda.com/download/#linux
3. Anaconda 5.2 For macOS Installer - https://www.anaconda.com/download/#macos
4. Anaconda 5.2 For Windows Installer - https://www.anaconda.com/download/#windows
(You need to download the version compatible with your OS)
32
33. Python Install
33
Many PCs and Macs will have python already installed.
To check if you have python installed on a Windows PC, search in the start bar for Python or run the following on
the Command Line (cmd.exe):
C:UsersYour Name>python --version
To check if you have python installed on a Linux or Mac, then on linux open the command line or on Mac open the
Terminal and type:
python --version
Python is an interpreted programming language, this means that as a developer you write Python (.py) files in a text
editor and then put those files into the python interpreter to be executed.
The way to run a python file is like this on the command line:
C:UsersYour Name>python helloworld.py
34. Execute Python Syntax
34
As we learned in the previous page, Python syntax can be executed by writing directly in the Command Line:
print("Hello, Karunyans!")
Hello, Karunyans!
Or by creating a python file on the server, using the .py file extension, and running it in the Command Line:
C:UsersYour Name>python myfile.py
40. Indentation in python!!
40
Indentation refers to the spaces at the beginning of a code line.
(Where in other programming languages the indentation in code is for readability only, the indentation in Python is very
important)
Python uses indentation to indicate a block of code.
if 5 > 2:
print("Five is greater than two!")
Python will give you an error if you skip the indentation:
if 5 > 2:
print("Five is greater than two!")
The number of spaces is up to you as a programmer, but it has to be at least one.
if 5 > 2:
print("Five is greater than two!")
if 5 > 2:
print("Five is greater than two!")
You have to use the same number of spaces in the same block of code, otherwise Python will give you an error:
if 5 > 2:
print("Five is greater than two!")
print("Five is greater than two!")
Syntax Error:
41. Add two number.
a = 5.4
b = 4.6
sum = float(a) + float(b)
print(sum)
User Input.
a = input(“Enter number1: “)
b = input(“Enter number2: “)
sum = int(a) + int(b)
print(“The sum of {0} and {1} is
{2}”.format(a, b, sum))
42. Slicing
42
b = "Hello, World!"
print(b[2:5])
b = "Hello, World!"
print(b[:5])
b = "Hello, World!"
print(b[2:])
b = "Hello, World!"
print(b[-5:-2])
43. 43
• String is a sequence of characters, like "Python is cool"
• Each character has an index
•Accessing a character: string[index]
x = "Python i s cool"
print(x[10])
•Accessing a substring via slicing: s t r i n g [ s t a r t : f i n i s h ]
p r i n t ( x [ 2 : 6 ] )
String
P y t h o n i s c o o l
0 1 2 3 4 5 6 7 8 9 10 11 12 13
44. 44
>>> x = "Python is cool"
>>> "cool" in x
>>> len(x)
>>> x + "?"
>>> x.upper()
# membership
# length of string x
# concatenation
# to upper case
>>> x.replace("c", "k") # replace characters in a string
StringOperations
P y t h o n i s c o o l
0 1 2 3 4 5 6 7 8 9 10 11 12 13
45. >>> x = "Python is cool"
StringOperations:Split
P y t h o n i s c o o l
0 1 2 3 4 5 6 7 8 9 10 11 12 13
P y t h o n
0 1 2 3 4 5
i s
0 1
c o o l
0 1 2 3
x . s p l i t ( " " )
>>> x.split(" ") 45
46. >>> x = "Python is cool"
>>> y = x.split(" ")
>>> ",".join(y) 40
StringOperations:Join
P y t h o n , i s , c o o l
0 1 2 3 4 5 6 7 8 9 10 11 12 13
P y t h o n
0 1 2 3 4 5
i s
0 1
c o o l
0 1 2 3
" , " . j o i n ( y )
49. 49
• Cores of programming!
• Rely on boolean expressions which return either True or False
• 1 < 2 : True
• 1.5 >= 2.5 : False
• answer == "Computer Science" :
can be True or False depending on the value of variable answer
• Boolean expressions can be combined with: and, or, not
• 1 < 2 and 3 < 4 : True
• 1.5 >= 2.5 or 2 == 2 : True
• not 1.5 >= 2.5 : True
ConditionalsandLoops
52. If & Elif. a = 33
b = 33
if a > b:
print(“a is greater than b")
elif a == b:
print("a and b are same")
else:
print("b is greater than a")
AND | OR. a = 200
b = 33
c = 500
if a > b and c > a:
print("Both conditions are True")
#if a > b or c > a:
# print(“only one is True")
60. So far, we have seen (briefly) two kinds of collections:
string and list
For loops can be used to visit each collection's element:
60
ForLoops
for element i n collection:
code-block
for chr in "string":
print(chr)
for elem in [ 1 ,3,5]:
print(elem)
61. While.
i = 1
while i < 20:
print(i)
i += 1
FOR.
for x in range(10):
print(x)
for x in range(1, 10):
print(x)
for x in range(1, 10, 2):
print(x)
63. Expression and Arithmetic
63
a = 21
b = 10
c = 0
c = a + b
print ("Line 1 - Value of c is ", c)
c = a - b
print ("Line 2 - Value of c is ", c)
c = a * b
print ("Line 3 - Value of c is ", c)
c = a / b
print ("Line 4 - Value of c is ", c)
c = a % b
print ("Line 5 - Value of c is ", c)
a = 2
b = 3
c = a**b
print ("Line 6 - Value of c is ", c)
a = 10
b = 5
c = a//b
print ("Line 7 - Value of c is ", c)
ref: https://realpython.com/python-operators-expressions/
Extra notes
65. • Working with data heavily involves reading and writing!
• Data come in two types:
• Text: Human readable, encoded in ASCII/UTF-8, example: .txt, .csv
• Binary: Machine readable, application-specific encoding,
example: .mp3, .mp4, .jpg
Input/Output
65
67. python
is
cool
44
Input
cool.txt
x = open("cool. t x t " , " r " )
# read l i n e by l i n e
f o r l i n e i n x :
l i n e = l i n e . r e p l a c e ( " n " , " " )
p r i n t ( l i n e )
x . close( )
68. 68
python
is
cool
Input
cool.txt
x = open( "C: User s Desktop coo l . tx t " , " r " ) # absolute location
f o r l i n e i n x :
l i ne = l ine. r eplace(" n" , " " )
p r i n t ( l i n e )
x.close()
69. Output
# write mode
x = open( "cool.t x t " , "w")
x.write("and Interesting n")
x . close()
# append mode
69
x = open( "cool.t x t " , "a")
x.write(" and Interesting n ")
x . close()
Write mode overwrites files,
while append mode does not overwrite files but instead appends at the end of the files' content
76. Built-in Math Functions
76
x = min(5, 10, 25)
y = max(5, 10, 25)
print(x)
print(y)
x = abs(-7.25)
print(x)
x = pow(4, 3)
print(x)
import math
import math
x = math.sqrt(64)
print(x)
x = math.ceil(1.4)
y = math.floor(1.4)
print(x) # returns 2
print(y) # returns 1
x = math.pi
print(x)
77. 77
• Code made by other people shall be reused!
• Two ways of importing modules (= Python files):
• Generic form: importmodule_name
import math
print(math.sqrt(4))
• Generic form: from module_name import function_name
from math import sqrt
p r i n t ( s q r t ( 4 ) )
Imports
78. Math Methods
78
Method Description
math.acos() Returns the arc cosine of a number
math.acosh() Returns the inverse hyperbolic cosine of a number
math.asin() Returns the arc sine of a number
math.asinh() Returns the inverse hyperbolic sine of a number
math.atan() Returns the arc tangent of a number in radians
math.atan2() Returns the arc tangent of y/x in radians
math.atanh() Returns the inverse hyperbolic tangent of a number
math.ceil() Rounds a number up to the nearest integer
math.comb() Returns the number of ways to choose k items from n items without
repetition and order
math.copysign() Returns a float consisting of the value of the first parameter and the sign of
the second parameter
math.cos() Returns the cosine of a number
math.cosh() Returns the hyperbolic cosine of a number
math.degrees() Converts an angle from radians to degrees
math.dist() Returns the Euclidean distance between two points (p and q), where p and q
are the coordinates of that point
math.erf() Returns the error function of a number
math.erfc() Returns the complementary error function of a number
math.exp() Returns E raised to the power of x
math.expm1() Returns E
x
- 1
math.fabs() Returns the absolute value of a number
math.factorial() Returns the factorial of a number
math.floor() Rounds a number down to the nearest integer
math.fmod() Returns the remainder of x/y
math.frexp() Returns the mantissa and the exponent, of a specified number
math.fsum() Returns the sum of all items in any iterable (tuples, arrays, lists, etc.)
math.gamma() Returns the gamma function at x
math.gcd() Returns the greatest common divisor of two integers
math.hypot() Returns the Euclidean norm
math.isclose() Checks whether two values are close to each other, or not
math.isfinite() Checks whether a number is finite or not
math.isinf() Checks whether a number is infinite or not
math.isnan() Checks whether a value is NaN (not a number) or not
math.isqrt() Rounds a square root number downwards to the nearest integer
math.ldexp() Returns the inverse of math.frexp() which is x * (2**i) of the given numbers x and i
math.lgamma() Returns the log gamma value of x
math.log() Returns the natural logarithm of a number, or the logarithm of number to base
math.log10() Returns the base-10 logarithm of x
math.log1p() Returns the natural logarithm of 1+x
math.log2() Returns the base-2 logarithm of x
math.perm() Returns the number of ways to choose k items from n items with order and without
repetition
math.pow() Returns the value of x to the power of y
math.prod() Returns the product of all the elements in an iterable
https://www.w3schools.com/python/module_math.asp
79. Math Methods
79
math.radians() Converts a degree value into radians
math.remainder() Returns the closest value that can make numerator
completely divisible by the denominator
math.sin() Returns the sine of a number
math.sinh() Returns the hyperbolic sine of a number
math.sqrt() Returns the square root of a number
math.tan() Returns the tangent of a number
math.tanh() Returns the hyperbolic tangent of a number
math.trunc() Returns the truncated integer parts of a number
Math Constants
Constant Description
math.e Returns Euler's number (2.7182...)
math.inf Returns a floating-point positive infinity
math.nan Returns a floating-point NaN (Not a Number) value
math.pi Returns PI (3.1415...)
math.tau Returns tau (6.2831...)
80. cmath Module
80
Method Description
cmath.acos(x) Returns the arc cosine value of x
cmath.acosh(x) Returns the hyperbolic arc cosine of x
cmath.asin(x) Returns the arc sine of x
cmath.asinh(x) Returns the hyperbolic arc sine of x
cmath.atan(x) Returns the arc tangent value of x
cmath.atanh(x) Returns the hyperbolic arctangent value of x
cmath.cos(x) Returns the cosine of x
cmath.cosh(x) Returns the hyperbolic cosine of x
cmath.exp(x) Returns the value of E
x
, where E is Euler's number (approximately
2.718281...), and x is the number passed to it
cmath.isclose() Checks whether two values are close, or not
cmath.isfinite(x) Checks whether x is a finite number
cmath.isinf(x) Check whether x is a positive or negative infinty
cmath.isnan(x) Checks whether x is NaN (not a number)
cmath.log(x[, base]) Returns the logarithm of x to the base
cmath.log10(x) Returns the base-10 logarithm of x
81. cmath Module
81
cmath.phase() Return the phase of a complex number
cmath.polar() Convert a complex number to polar coordinates
cmath.rect() Convert polar coordinates to rectangular form
cmath.sin(x) Returns the sine of x
cmath.sinh(x) Returns the hyperbolic sine of x
cmath.sqrt(x) Returns the square root of x
cmath.tan(x) Returns the tangent of x
cmath.tanh(x) Returns the hyperbolic tangent of x
cMath Constants
Constant Description
cmath.e Returns Euler's number (2.7182...)
cmath.inf Returns a floating-point positive infinity value
cmath.infj Returns a complex infinity value
cmath.nan Returns floating-point NaN (Not a Number) value
cmath.nanj Returns coplext NaN (Not a Number) value
cmath.pi Returns PI (3.1415...)
cmath.tau Returns tau (6.2831...)
82. Creating a Function -recap
82
• A function is a block of code which only runs when it is called.
• You can pass data, known as parameters, into a function.
• A function can return data as a result.
In Python a function is defined using the def keyword:
def my_function():
print("Hello from a function")
Calling a Function
my_function()
83. Creating a Function -recap
83
Arguments
• Information can be passed into functions as arguments.
• Arguments are specified after the function name, inside the parentheses.
• You can add as many arguments as you want, just separate them with a comma.
• The following example has a function with one argument (fname). When the function is called, we pass along a first
name, which is used inside the function to print the full name:
def my_function(fname):
print(fname + “ Keep doing")
my_function(“John")
my_function(“SAM")
my_function(“Raj")
84. Creating a Function -recap
84
Parameters or Arguments?
The terms parameter and argument can be used for the same thing: information that are passed into a function.
From a function's perspective:
A parameter is the variable listed inside the parentheses in the function definition.
An argument is the value that is sent to the function when it is called.
Number of Arguments
By default, a function must be called with the correct number of arguments. Meaning that if your function expects
2 arguments, you have to call the function with 2 arguments, not more, and not less.
If you try to call the function with 1 or 3 arguments, you will get an error:
def my_function(fname, lname):
print(fname + " " + lname)
my_function("Samuel", "Abhishek")
85. Creating a Function -recap
85
Arbitrary Arguments, *args
• If you do not know how many arguments that will be passed into your function, add a * before the parameter name in the
function definition.
• This way the function will receive a tuple of arguments, and can access the items accordingly:
def my_function(*kids):
print("The youngest child is " + kids[2])
my_function(“John", “SAM", “Raj")
Keyword Arguments
You can also send arguments with the key = value syntax.
This way the order of the arguments does not matter.
def my_function(child3, child2, child1):
print("The youngest child is " + child3)
my_function(child1 = “John", child2 = “SAM", child3 = “Raj")
86. Creating a Function -recap
86
Arbitrary Keyword Arguments, **kwargs
If you do not know how many keyword arguments that will be passed into your function, add two asterisk: ** before the parameter name
in the function definition.
This way the function will receive a dictionary of arguments, and can access the items accordingly:
def my_function(**kid):
print("His last name is " + kid["lname"])
my_function(fname = “John", lname = “Sam")
Default Parameter Value
The following example shows how to use a default parameter value.
If we call the function without argument, it uses the default value:
def my_function(country = "Norway"):
print("I am from " + country)
my_function("Sweden")
my_function("India")
my_function()
my_function("Brazil")
87. Creating a Function -recap
87
Passing a List as an Argument
You can send any data types of argument to a function (string, number, list, dictionary etc.), and it will be treated as
the same data type inside the function.
E.g. if you send a List as an argument, it will still be a List when it reaches the function:
def my_function(food):
for x in food:
print(x)
fruits = ["apple", "banana", "cherry"]
my_function(fruits)
Return Values
To let a function return a value, use the return statement:
def my_function(x):
return 5 * x
print(my_function(3))
print(my_function(5))
print(my_function(9))
88. Creating a Function -recap
88
The pass Statement
function definitions cannot be empty, but if you for some reason have a function definition with no content, put in the pass statement
to avoid getting an error.
def myfunction():
pass
Recursion
Python also accepts function recursion, which means a defined function can call itself.
Recursion is a common mathematical and programming concept. It means that a function calls itself.
This has the benefit of meaning that you can loop through data to reach a result.
The developer should be very careful with recursion as it can be quite easy to slip into writing a function
which never terminates, or one that uses excess amounts of memory or processor power. However,
when written correctly recursion can be a very efficient and mathematically-elegant approach to
programming.
89. Creating a Function -recap
89
def tri_recursion(k):
if(k > 0):
result = k + tri_recursion(k - 1)
print(result)
else:
result = 0
return result
print("nnRecursion Example Results")
tri_recursion(6)
In this example, tri_recursion() is a function that we have defined to call itself ("recurse").
We use the k variable as the data, which decrements (-1) every time we recurse.
The recursion ends when the condition is not greater than 0 (i.e. when it is 0).
To a new developer it can take some time to work out how exactly this works, best way to find out is by
testing and modifying it.
90. How to include pandas & numpy?
90
import numpy as np
import pandas as pd