Q 1: What are the differences between List and Tuples?
Answer: The mentioned below is list differences between List and Tuples
List
|
Tuples
|
List elements can be changed as they are mutable
|
Tuples elements cannot be modified as they are immutable.
|
Normally, lists are slower compared to tuples during execution
|
Normally, tuples are faster than lists during execution of the program.
|
The list is created using open and close rectangular brackets
|
Tuples are created using open and close simple brackets
|
e.g. country_list = [“US”, “INDIA”, “UK”]
|
e.g. region_tuple = (“NA”, “APAC”, “LA”)
|
Q 2: Explain Multithreading concepts in Python?
Answer: The multithreading in Python is explained as below
- In order to achieve multithreading i.e. executing the program in parallel, Python has a multi-threading package.
- The concept named the Global Interpreter Lock (GIL) is used in Python. It is the responsibility of GIL to make sure that only one ‘threads’ can execute at any a time.
- The thread acquires GIL for processing business logic. Once processing is completed, it passes the GIL onto the next thread.
- This processing happens very quickly so to the human eye. On the surface, it looks like threads are running in parallel, but they are really just taking turns using the same CPU core.
- The extra overhead of working with GIL will cause extra processing time.
Q 3: What are the rules or standards for global and local variables in the Python language?
Answer: The basic guidelines for local and global variables are as below
Global variables: The variables which are only referenced inside a function are implicitly global.
Local variables: The local variables are those variables for which a new value is assigned within the function's body.
Q 4: What are the supported data types in Python?
Answer: The supported data types in Python are
- Number
- String
- List
- Tuple
- Dictionary
Here, the Number data type can include integer and float values.
You can refer the video below to learn more about Python programming -
You can refer the video below to learn more about Python programming -
Q 5: Is it possible to convert Integer value to String value and vice-versa in the Python language?
Answer: Yes, we can convert an integer value into the String value. Also, we can convert the String value to integer value.
Normally, if we get input from the user is comes as String even it is number. So in such cases, we need to convert the String value to an integer value as
user_input = input("Enter any number")
int_value = int(user_input)
print(int_value * 5)
No comments:
Post a Comment
Please do not enter any spam link in the comment box.