Python Class 17 - Python Built-in Functions

preview_player
Показать описание

The Python interpreter has a number of functions and types built into it that are always available.

Python Built-in Functions, Types of Functions, User Defined Functions, Strings Functions, Math Functions, and Input & Output Functions.

Python Functions, What is Function?, Types of Python Functions, Create Python Functions, Calling a Python Function, and Functions Advantages.

1. What is Function?
2. Types of Functions in Python
3. Advantages of Functions
4. User-Defined Functions
5. Python Function with return a value
6. Python Function with returns nothing
7. Python Functions with Arguments
8. Python Function with default parameters

There are mainly two types of functions in Python.

1. User-defined functions – The user-defined functions are those defined by the user to perform the specific task.

2. Built-in functions – The built-in functions are those functions that are pre-defined in Python.

Python Complete Tutorial

Python Videos PlayList

Python Programming Syllabus

Python Programming Quiz

Python Interview Questions for Fresher
--------------------------------------------------
1. Introduction to Python Programming Language

2. Download and Install Python

Python Environment Setup (Using PyCharm IDE)

3. Python Language Syntax

4. Python Keywords and Identifiers

5. Comments in Python

6. Python Variables

7. Python Data Types

8. Python Operators

9. Python Conditional Statements

10. Python Loops

11. Python Branching Statements

12. Python Numbers

13. String Handling in Python

14. Python Data Structures - Lists

15. Python Data Structures - Sets

16. Python Data Structures - Tuples

17. Python Data Structures - Dictionaries

18. Python User Defined Functions

19. Python Built-in Functions

20. Python Modules

21. Python User Input

22. File Handling in Python

23. Python Date and Time

24. Python Exception Handling

25. Python Regular Expressions

26. Python Object Oriented Programming

27. Inheritance in Python

28. Polymorphism in Python

29. Abstraction in Python
--------------------------------------------------
Рекомендации по теме
Комментарии
Автор

Python Complete Tutorial

Python Videos PlayList

Python Programming Syllabus

Python Programming Quiz

Python Interview Questions for Fresher

1. Introduction to Python Programming Language

2. Download and Install Python

Python Environment Setup (Using PyCharm IDE)

3. Python Language Syntax

4. Python Keywords and Identifiers

5. Comments in Python

6. Python Variables

7. Python Data Types

8. Python Operators

9. Python Conditional Statements

10. Python Loops

11. Python Branching Statements

12. Python Numbers

13. String Handling in Python

14. Python Data Structures - Lists

15. Python Data Structures - Sets

16. Python Data Structures - Tuples

17. Python Data Structures - Dictionaries

18. Python User Defined Functions

19. Python Built-in Functions

20. Python Modules

21. Python User Input

22. File Handling in Python

23. Python Date and Time

24. Python Exception Handling

25. Python Regular Expressions

26. Python Object Oriented Programming

27. Inheritance in Python

28. Polymorphism in Python

29. Abstraction in Python

gcreddy
Автор

Class Notes:
Python Class 17: Python Functions Part-3

I. Python User Defined Functions
II. Python Function Examples
III. Python Built-in Functions
1. abs() Function
2. round() Function

3. ord() Function

It returns the number representing the Unicode of a specified character.

Example:

x=ord("A")
print(x) #65

x=ord("a")
print(x) #97

x=ord("Z")
print(x) #90

x=ord("z")
print(x) #122

x=ord("1")
print(x) #49

x=ord("9")
print(x) #57

4. chr() Function

It returns the character that represents the specified Unicode.

Example:

x=chr(70)
print(x)#F

x=chr(120)
print(x)#x

x=chr(50)
print(x)#2

5. input() Function

It allows User Input.

Example:

x=input("Enter a Value: ")
print(x)
print(type(x))#str

x=int (input("Enter a Value: "))
print(x)
print(type(x))#int

x=float (input("Enter a Value: "))
print(x)
print(type(x))#float

6. int() Function

It converts the specified number into an integer number

Example:

a=input("Enter a Value: ")
print(type(a))#str

x=int(a)
print(type(x))#int

x=int('145')
print(x)#145

x=int(1234)
print(x)#1234


x=int(1.45)
print(x)#1

x=int(1.99)
print(x)#1

7. float() Function

It converts the specified value into floating point number

Example:

a=input("Enter a Value: ")
print(type(a))#str

x=float(a)
print(type(x))#float

x=float('14.5')
print(x)#14.5

x=float(1234)
print(x)#1234.0

8 str() Function

It converts the specified value into a string

Example:

a=input("Enter a Value: ")
print(type(a))#str

x=str(10)
y=str(10.2)
print(x+y)

9. len() Function

It returns the number items in an object

Example:

mylist = [10, 20, 30, 4.56, "India", True]
x= len(mylist)
print(x) #6

mytuple = (10, 20, 30, 4.56, "India", True)
x= len(mytuple)
print(x) #6

myset = {10, 20, 30, 4.56, "India", True}
x= len(myset)
print(x) #6

mydict = {"Name": "Raja", "Age":40, "City": "Hyderabad"}
x= len(mydict)
print(x)#3

mystring = "India is my Country"
x= len(mystring)
print(x)#19

10. type() Function

It returns the type of the specified object.

Example:

a=["apple", "banana", "cherry"]
b=(10, 20, 3.4, "India")
c= {1, 2, 4, 5, 78}
d={"Name": "Raja", "Age":40}
e="India"
f=123
g=12.3
h=False
i=12j

print(type(a)) #'list'
print(type(b)) #'tuple'
print(type(c)) #'set'
print(type(d)) #'dict
print(type(e)) #'str'
print(type(f)) #'int'
print(type(g)) #'float'
print(type(h)) #'bool'
print(type(i)) #'complex'

11. max() Function

It returns the largest number

Example:

x=max(1234, 523, 499, 2345, 5678)
print(x) #5678

x=max(12.34, 52.3, 49.9, 23.45, 5.678)
print(x) #52.3

12. min() Function

It returns the lowest number

Example:

x=min(1234, 523, 499, 2345, 5678)
print(x) #499

x=min(12.34, 52.3, 49.9, 23.45, 5.678)
print(x) #5.678

13. range() Function

It returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and stops before a spcified number.

Example:

n=range(5)
for i in n:
print(i)
'''Output
0
1
2
3
4'''
print("")
n= range(10, 16)
for i in n:
print(i)
'''Output
10
11
12
13
14
15'''
print("")
n= range(10, 101, 10)
for i in n:
print(i)
print("")
for i in range(10, 0, -1):
print(i)

gcreddy