0 of 8 questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Your time:
Time has elapsed
Good work attempting the practice problems!
Please leave a comment below if you require any clarifications or send an email to [email protected] if you have any comments about this quiz.
You have completed this lesson!
Write a python program that uses a global variable s = “I love Python programming”. Then write a function that prints the value of this variable.
This response will be reviewed and graded after submission.
Write a python program that is used to declare a local variable, a = 20, inside a function and prints the value on the screen?
This response will be reviewed and graded after submission.
Write a python program that fetches an integer from the user. This is stored in a global variable.
Now write a function that fetches the global variable, gets another value from the user and returns back their sum?
Hint: Remember that fetching values from the user gets you string values by default. To get them as integer you need to convert them using the int() built-in.
This response will be reviewed and graded after submission.
Write a python program that declares a global variable and a local variable to a function with same names and prints their values?
Global variable:
string1 = “Learn one thing at a time. Don’t rush.”
Local variable inside your function:
string1 = “Taking short breaks improves your learning.”
The function must print its local value. Outside the function print the global value.
This response will be reviewed and graded after submission.
Write a python program that is used to modify a global variable within a function?
Modify the same code from the previous problem so that now the global string gets modified inside the function.
This response will be reviewed and graded after submission.
Write a python program that contains:
Run this program and then compare the three functions to see how we’re using local and global variable.
Write this program even if you feel that you can do it. The practice of writing the code is what is important and will not only help you retain the concept for a lot longer but free up your mind so that you can focus on advanced concepts as well.
This response will be reviewed and graded after submission.
Write a python program in which the value of a local variable to a function can be stored into a global variable?
This response will be reviewed and graded after submission.
Write a python program to implement a basic calculator by using only local variables?
Write 5 functions: sum, divide, multiply, subtract and one function “get_data” that will call any of these functions depending upon the choice entered by the user.
Accept two values from the user and pass it into the functions.
This response will be reviewed and graded after submission.