Commonly Used Built-In Modules In Python-Local Variables And Global Variables In Python

What are python modules? Name some commonly used built-in modules in Python?

What Are Python Modules? Name Some Commonly Used Built-In Modules In Python?
What Are Python Modules? Name Some Commonly Used Built-In Modules In Python?

Python Module is a file which is created by developers where they placed the definitions of program to be used them in a script. In simple words, it’s a file that contains Python definitions and statements.
Some commonly used built-in-modules in Python are –
a.) math
b.) random
c.) os
d.) Csv
e.) urllib
f.) types
g.) sys
h.) datetime
i.) collections
j.) itertools

Example code how to import and use these modules :

For math,
import math # import
math.ceil(number) # return the ceil of number
math.sqrt(number) # return the square root of number

What are local variables and global variables in Python?

What Are Local Variables And Global Variables In Python?
What Are Local Variables And Global Variables In Python?

Also see List and tumple

a). Local Variables are the variables that are defined inside the function’s body and therefore it cannot be directly used outside the function.
Example code –
def func():
y = ‘local’
print(y)
print(y) —- Output : Error will generate
print(func()) —- Output : local

b). Global Variables are the variables that are defined outside the function’s body and therefore it can be accessed inside or outside of the function.
Example code –
y = ‘global’
def func():
print(y)
print(y) —- Output : global
print(func()) —- Output : global

Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers.

Below is the Python code for the program

input = list(map(int, input().split(‘,’))) # comma separated inputs

tuple_input = tuple(input) # return tuple of input

list_input = list(input) # return list of input

Summary :

In this article we saw Commonly Used Built-In Modules In Python-Local Variables And Global Variables In Python so about this section any query then free to ask me

Also see python operator

Intern name who share this Task : Mohd Mujtaba

Github : https://github.com/mujtaba-786

I am the founder of Pythonslearning, a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Leave a Comment