Question

Show the source code if possible or code writen with output please and thank you <3...

Show the source code if possible or code writen with output please and thank you <3

6. Is the following a legal Python program?
def proc(x, y):
return 2*x + y*y
def main():
print(proc(5))
main()
7. Is the following a legal Python program?
def proc(x):
return 2*x
def main():
print(proc(5, 4))
main()
8. Is the following a legal Python program?
def proc(x):
print(2*x*x)
def main():
proc(5)
main()

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def proc(x, y):
    return 2*x + y*y

def main():
    #Add second argument
    print(proc(5, 4))
    
main()

26

########################

def proc(x):
    return 2*x

def main():
    # proc only accepting one argument
    #So, remove second argument
    print(proc(5))

main()

10

########################

#It is legal code
def proc(x):
    print(2*x*x)
def main():
    proc(5)
main()

50

Add a comment
Know the answer?
Add Answer to:
Show the source code if possible or code writen with output please and thank you <3...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Is the following program correct? If it is correct, what is the output? If it is...

    Is the following program correct? If it is correct, what is the output? If it is incorrect, please correct the code and write down the output of the program. def fac(n): i=0 sum=0 while i<=n: sum*=i return sum def main(): print(fac(5)) main() PYTHON PLEASE

  • need help on all parts please and thank you (e) What is the correct output of...

    need help on all parts please and thank you (e) What is the correct output of this code? (2 pts) >>> def func(x): >>> res = 0 >>> for i in range (len (x)): res i >>> return res >>> print (func(4)) ( 4 5 ) 6 ()7 ( What could be described as an immutable list? (2 pts) () a dimple ( ) a tuple ( ) a truffle () a dictionary (g) What is the result of the...

  • AND logic gate simulation in Python: Please fix the code below so that it efficiently performs...

    AND logic gate simulation in Python: Please fix the code below so that it efficiently performs the operation of the AND logic gate in Python. (Leave comments in the edited code about what you changed) #if both values are 1, return true, other wise return false print ("Logic Gate Simulation: AND gate") def AND(x, y):     if x == True and y == True:         return True        else:         return False    def main():     x = bool(input("Please...

  • Please use C++ and include source code and a picture of program output. You are required...

    Please use C++ and include source code and a picture of program output. You are required to write a C++ program that interactively reads three integers, adds the numbers, and prints the result. 1- The program should use a class and an object. 2- The program can use a public function such as int FindSum (int , int y, int z) to calculate the sum of the numbers. 3- The main function should read the numbers and passes them to...

  • Example (4) Trace the following program and find the output >> SOURCE CODE #include <iostream.h> int...

    Example (4) Trace the following program and find the output >> SOURCE CODE #include <iostream.h> int main0 // define two integers int x-3; int y = 4; //print out a message telling which is bigger if (x >y) i cout << "x is bigger than y" << endl: else cout << "x is smaller than y" << endl; return 0; Example (5) Write a C++ program that takes from the user a number in SR (Saudi Riyal) then the program...

  • 6) Show the output of the following program. You mus trace the code to show how...

    6) Show the output of the following program. You mus trace the code to show how you reached the answer. (5 points) #include <stdio.h> int x 18; int y = 5; int z ·e; void my first function) void my_second_function); int main() int ys y = x; if (z) my_first functionO else my-second-function(); x++ : if (z) my_first_function(); else my_second_function(); return e; void my_first_function) x+y); is %d\n", printf("The value of x+y in my-first-function() void my_second_function) ( x=100; is %d\n", x);...

  • Page 3 of 7 (Python) For each substring in the input string t that matches the...

    Page 3 of 7 (Python) For each substring in the input string t that matches the regular expression r, the method call re. aub (r, o, t) substitutes the matching substring with the string a. Wwhat is the output? import re print (re.aub (r"l+\d+ " , "$, "be+345jk3726-45+9xyz")) a. "be$jk3726-455xyz" c. "bejkxyz" 9. b. "be$jks-$$xyz" d. $$$" A object a- A (2) 10. (Python) What is the output? # Source code file: A.py class A init (self, the x): self.x-...

  • Please show all matlab code inputs if possible, please and thank you 3. Let x (n)...

    Please show all matlab code inputs if possible, please and thank you 3. Let x (n) = {1,-2,4,6, 5,8,10]. Generate and plot the samples of the following sequence (4 points) a) x1 (n) = 3x (n + 2) + x(n-4)-2x (n)

  • To insure that file output is written to the disk you need to execute what method?...

    To insure that file output is written to the disk you need to execute what method? a. commit() b. write() c. close() d. complete() The following is called the ________ of a function. def myFunction(x,y) : a. header b. footer c. sentinel d. index True or False: A commonly used program that uses regular expressions is grep. True or False: In Python exception handling provides a mechanism for passing control from the point of the error detection to a handler...

  • 11p Python Language Read the following code for oofraction. import oofraction class OOFraction: def main(): fl...

    11p Python Language Read the following code for oofraction. import oofraction class OOFraction: def main(): fl = oofraction.o0Fraction( 2, 5) f2 = oofraction.o0Fraction ( 1, 3) f3 = f1 + f2 print (str(3)) main() def __init__(self, Num, Den): self.mNum = Num self.mDen = Den return def_add_(self,other): num = self.mNumother.mDen + other.mNum*self.mDen den = self.mDen*other.mDen f = OOFraction(num,den) return f 1. Write the output below. def_str_(self): s = str( self.mNum )+"/" + str( self.mDen) returns 2. Write a class called wholeNum...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT