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 –
Example code how to import and use these modules :
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?
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 –
y = ‘local’
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’
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
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