0% found this document useful (0 votes)
36 views15 pages

Intro To Python Pro

Python is a high-level, interpreted programming language known for its simplicity and popularity, supporting object-oriented concepts and powerful scripting capabilities. Developed by Guido Van Rossum in the early 90s, Python has applications in web development, data analysis, machine learning, and game development. Its strengths include ease of learning, portability, extensive libraries, and database connectivity, while it also features various string functions and function types for programming tasks.
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)
36 views15 pages

Intro To Python Pro

Python is a high-level, interpreted programming language known for its simplicity and popularity, supporting object-oriented concepts and powerful scripting capabilities. Developed by Guido Van Rossum in the early 90s, Python has applications in web development, data analysis, machine learning, and game development. Its strengths include ease of learning, portability, extensive libraries, and database connectivity, while it also features various string functions and function types for programming tasks.
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/ 15

Introduction to Python

Programming Language

🡪 Python is a high-level programming language

🡪 Python is interpreted language

🡪 Python is a simple and popular language

🡪 Python supports Object oriented concepts

🡪 Python is a powerful scripting language


Brief History of Python
⚫Python was developed by Guido
Van Rossum in the Netherlands.
⚫Python early versions were
released in early 90’s but popular
after 3.x versions
⚫Source code is available under GPL
⚫It’s name came from “Monty
Python's Flying Circus” (TV comedy
show)
Uses of Python
⚫Python can be used as a script to
automate some tasks to save time
⚫Python can be used for
WebDevelopment
⚫Python can be used in Data Analysis
⚫Python can be used in Machine
Learning
⚫Python can be used to develop
games
Strengths And Weaknesses of Python

⚫Strengths of Python
⚫Easy to Learn (no complex syntax)
⚫Free to Use(www.python.org)
⚫Portable (Windows, Mac, Linux,
Raspberry Pi) –platform independent
⚫Interpreted - bytecode - line by line
⚫Extensible and Extensive Libraries
⚫Embeddable
⚫Data base connectivity
Strings
⚫A string is a consecutive sequence
of characters.
⚫Each char of a string is accessed by
index or subscript starting from 0
⚫subscript can be positive, negative
or zero
⚫Ex : mystring = 'Learn Python‘
⚫stringThree = '''Learn Python with
tutorialsimpact'''
Positive and negative Index
⚫ mystring =
⚫G REAT
⚫ 0 1 2 3 4 (Positive Index)
⚫ -5-4-3-2-1 (Negative Index)

⚫ Examples :
⚫ mystring[ 0 ] = mystring[ -5 ] = G
⚫ mystring[ 0 : 4 ] - range of char’s
Comparing Strings
Ex1:
if name1 == name2:
print('The names are the same.')
else:
print('The names are NOT the
same.')
Ex2:
if month != 'October':
print('This is the wrong time for fest!')
String Functions
⚫ len()
upper()
lower()
islower()
isupper()
strip() –
⚫replace() -
swapcase()
find()
Nested - if
score = int(input('Enter your test score: '))
if score >= 70:
print('Your grade is A.')
else:
if score >= 60:
print('Your grade is B.')
else:
if score >= 50:
print('Your grade is C.')
else:
print('Your grade is D.')
if - elif - else
score = int(input('Enter your test score:
'))
if score >= 70:
print('Your grade is A.')
elif score >= 60:
print('Your grade is B.')
elif score >= 50:
print('Your grade is C.')
else:
print('Your grade is D.')
Void Functions and Value-
Returning Functions
def main():
print('I m from main function.')
message()
print('Goodbye!')
def message():
print('I am Ram,')
print('Vizag.')
main()
passing parameters to functions
def main():
value = 99
print('The value is', value)
change_me(value)
print('Back in main the value is',
value) def change_me(arg):
print('I am changing the value.')
arg = 0
print('Now the value is', arg)
main()
Keyword Arguments
def show_interest(principal, rate,
periods):
interest = principal * rate * periods
print('The simple interest will be
$', format(interest, ',.2f'), sep='')

show_interest(rate=0.01, periods=10,
principal=10000.0)
show_interest(10000.0, rate=0.01,
periods=10)
Built-in Functions
Generating Random Numbers
import random
for count in range(5):
print(random.randint (1, 100))

number = random.randrange(0,
101, 10)
Value-Returning Functions
def get_regular_price():
price = float(input("Enter item
price: "))
return price
reg_price = get_regular_price()

You might also like