<jupyter_start><jupyter_text>Assignment No 3<jupyter_code>Q1. Why are functions advantageous to have in your programs?

Solution :- 1.Functions reduce the need for duplicate code. This makes programs shorter, easier to read, and easier to update.
            2.Function is a piece of code or any logic that performs the specific operation.
            3.It helps to divide the large programs into small groups so that we can read the code, and debug the program faster and better.
            4.Python Functions stop us from writing the same logic various times. We can bind the logic in one function and then call the same over and over.
Q2. When does the code in a function run: when it's specified or when it's called?

Solution:- Whenever we called function then Execute The program comes to a line of code containing a "function call".
Q3. What statement creates a function?

Solution :- The “def” keyword is a statement for defining a function in Python.
Q4. What is the difference between a function and a function call?

Solution :- Funtion:- A function is procedure to achieve a particular result while function call is using this function to achive that task.
            Function Call :- Using a function to do a particular task any point in program is called as function call.
 Q5. How many global scopes are there in a Python program? How many local scopes?
    
Solution :- 1. Global Scope :- There is only one global scope as per program execution.
            2. Local Scope :- Python Provide most four active Python local scope, enclosing,and built-in—depending on where you are in the code.
Q6. What happens to variables in a local scope when the function call returns?

Soltuion :- When the execution of the function terminates (returns), the local variables are destroyed. Codelens helps you visualize this because the local variables disappear after the function returns.
Q7. What is the concept of a return value? Is it possible to have a return value in an expression?

Solution :- A return statement is used to end the execution of the function call and returns the result (value of the expression following the return keyword) to the caller. The statements after the return statements are not executed. If the return statement is without any expression, then the special value None is returned.
            A Python function will always have a return value.
Q8. If a function does not have a return statement, what is the return value of a call to that function?

Solution:- If no return statement appears in a function definition, control automatically returns to the calling function after the last statement of the called function is executed. the return value of the called function is undefined.If a return value isn't required, declare the function to have void return type.
Q9. How do you make a function variable refer to the global variable?

Solution :- if we create outside the function then we directly write x = "Bhushan" but if we create inside the function then we will use Global Keywords. 
Q10. What is the data type of None?

Solution :- The None keyword is used to define a null value, or no value at all. None is not the same as 0, False, or an empty string. None is a data type of its own (NoneType) and only None can be None.
Q11. What does the sentence import areallyourpetsnamederic do?

Solution:- That import statement imports a module named areallyourpetsnamederic.
Q12. If you had a bacon() feature in a spam module, what would you call it after importing spam?

Solution :- This function can be called with spam.bacon().
Q13. What can you do to save a programme from crashing if it encounters an error?

Solution:- If an error occurs in a program, we don't want the program to unexpectedly crash on the user. Instead, error handling can be used to notify the user of why the error occurred and gracefully exit the process that caused the error.
Q14. What is the purpose of the try clause? What is the purpose of the except clause?

Solution:- The try and except block is used to catch and handleling the exceptions.<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0375701390583069, 'fraction_numerical': 0.006586972432300561, 'mean_word_length': 3.8520710059171597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '93771', 'license': 'MIT', 'n_tokens_mistral': 997, 'n_tokens_neox': 943, 'n_words': 670, 'path': 'Assignment No 3.ipynb', 'repo_name': 'bhushanasati25/Python-Assignment-', 'size': '4099'}