PYTHON
Create a function called squareValue. squareValue will calll the function getValue() to square the value and return it back to the main portion of the program. In main call squareValue which will call getValue.
def getValue():
val = int(input("Enter a number"))
return val
myValue = getValue()
print("The value entered is ", myValue)
Process:
call the getValue() function and store the data returned by the getValue() into variable called 'val'. Then return the square of variable 'val'.
Algorithm:
squareValue():
1. val=getValue()
2. return val*val
Code:
#getValue() - already given
def getValue():
val = int(input("Enter a number: "))
return val
#squareValue()
def squareValue():
'''
Process:
call the getValue() function and store the data returned by
the getValue() into variable called 'val'.
Then return the square of variable 'val'
'''
val=getValue()
return val*val
#main portion
myValue=squareValue() #calling squareValue()
print("Square: ",myValue)
Output:
Enter a number: 5
Square: 25
Please refer to the screenshots below for correct indentations

![(AMD64)] on win32 Type help, copyright, credits or license() for more information. == RESTART: C:\Users\hee\Videos16.](http://img.homeworklib.com/questions/77154d20-3b3a-11ec-a7b0-d3ef5a755f8d.png?x-oss-process=image/resize,w_560)
PYTHON Create a function called squareValue. squareValue will calll the function getValue() to square the value...
Hello everyone! I am working on my assignment for C++ and I'm having a bit of trouble on the value producing functions, I am creating a program wherein I have to input a value and I need to create a function called square value where in it will square the value I have input. I cannot seem to figure out this part. Here is the code that I have so far, and thank you for any help. I greatly appreciate...
Python: Create a function count_target_in_list that takes a list of integers and the target value then counts and returns the number of times the target value appears in the list. Write program in that uses get_int_list_from_user method to get a list of 10 numbers, then calls the count_target_list method to get the count then prints the number of times the target was found in the list. def get_int_list_from_user(): lst=[] y = int(input("Enter number of numbers")) for x in range(y): lst.append(int(input("Enter...
1. Create a Python script file called Assignment_Ch06-02_yourLastName.py. (Replace yourLastName with your last name.) 2. Write a Python program that prompts the user for a sentence, then replaces all the vowels in the sentence with an asterisk: '*' Your program should use/call your isVowel function from Assignment_Ch06-01. You can put the isVowel() function in a separate .py file, without the rest of the Ch06-01 code, and then import it. 6-01 CODE: def isVowel(x): if x in "aeiouyAEIOUY": return True else:...
My module page is correct but I don't believe I am using the main() function properly. One of my .py files is supposed to contain my definitions, which is the module file. My second .py file is supposed to properly call a main function that does what my program asks it to: First name, last name, age, and respond based off of input. For some reason I am struggling with using the main() function so that my program works. Any...
import mathdef limitReached(val,last): return abs(val - last) < 1e-2def improvateEstimate(val,n): return (val + n / val) * 0.5def squareroot(n): val = n while True: last = val val = improvateEstimate(val,n) if limitReached(val,last): break return valwhile True: n=(input(' Enter a positive number or enter/return to quit: ')) if n=='': break else: print('The program\'s estimate is :',squareroot(eval(n))) print('Python\'s estimate is :', math.sqrt(eval(n))) print()
Implement a Python function that prints integers from a to b.
The main part of the program should ask the user to input a and b
and call the function.
# Display integers a, a+1, a+2, ..., b def display(a,b): ## complete your work here ## return a = int(input("Please prvide a value for a: ")) b = int(input("Please prvide a value for b: ")) display(a,b)
Can someone fix this python program? I'm trying to do three things: Create a function that takes in a string as a parameter. Then create a dictionary of characters to integers, where the integer represents how many times the number of times the character appears in the word. Create a function that takes two lists as parameters and returns the elements they have in common of the two lists. Ask the user to create a list of numbers and keep...
For Python debugExercise12.py is a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. By debugging these programs, you can gain expertise in program logic in general and the Python programming language in particular. def main(): # Local variable number = 0 # Get number as input from the user. number = int(input('How many numbers to display? ')) # Display the numbers. print_num(number) # The print_num function is a a recursive function #...
I'm trying to run the code in Python below and keep getting invalid syntax. What's wrong? Thanks for any help! def even(n): if n%2==0 #Enter a Number def main(): n=int(input("Enter a number: ")) #If even print "Number is even" if(even(n)): print("The number is even") #If odd print "Number is odd" else: print("The number is odd") main() #Call the main function
Write a python program write a function numDigits(num) which counts the digits in int num. Answer code is given in the Answer tab (and starting code), which converts num to a str, then uses the len() function to count and return the number of digits. Note that this does NOT work correctly for num < 0. (Try it and see.) Fix this in two different ways, by creating new functions numDigits2(num) and numDigits3(num) that each return the correct number of...