What is wrong with the following function?
def print_circle_area(radius):
print(3.14*radius**2)
a) the function body(code) is not indented correctly
b) radius should be r
c) it's missing a return value
d) nothing seems to be wrong with this
def print_circle_area(radius):
print(3.14*radius**2)
It is correct code
The program is like this :
def print_circle_area(radius):
print(3.14*radius**2)
radius=int(input("Enter radius:"))
print(print_circle_area(radius))
Sample output:
Enter radius:4
50.24
Option d
What is wrong with the following function? def print_circle_area(radius): print(3.14*radius**2) a) the function body(code) is not...
What is wrong with the following code snippet? print("Hello") print("World!") The print function cannot be called twice The print function is missing an argument Nothing, the program prints Hello World on the same line The second line should not be indented
Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default values for balance #and annual interest rate are 100 and e, respectively). #INITIALIZER METHOD HEADER GOES HERE #MISSING CODE def getId(self): return self._id def getBalance(self): #MISSING CODE def getAnnualInterestRate(self): return self.___annualInterestRate def setBalance(self, balance): self. balance - balance def setAnnualInterestRate(self,rate): #MISSING CODE def getMonthlyInterestRate(self): return self. annualInterestRate/12 def getMonthlyInterest (self): #MISSING CODE def withdraw(self, amount): #MISSING CODE det getAnnualInterestRate(self): return self. annualInterestRate def setBalance(self,...
pick two answers
12 points). The function swap() should swap two integers and main() should print those two swapped integers. What (if anything is wrong with this code? Select all that apply. oooo. No ure W..Ni def main(): X = 10 y = 2 x, y = swap(x,y). print(x,y) def swap(a,b): a = b temp = a b = temp main N on line 9, it is illegal syntax to introduce a new variable named temp. Instead, temp should be...
Question 4 2 pts What is the output of the following code? def count(word): d = {} for char in word: if char in d: d[char] += 1 else: d[char] = 1 return d dictionary = count("Morgan Bears") print(dictionary["a"] + dictionary["r"])
#Which function has the most parameters? def Menu(): print ("Your Name Main Menu") print("1. Sum") print("2. Product") print("3. information") print("4. Quit") def Sum(x): x= x* 2 y = 10 answer = x+y return x,y,answer def Product(w,z): answer = w*z print (answer) def Calc(a,b,c): return a*b*c Question options: Product Calc Menu Sum
def plusThetaeigenket(theta):
return np.array([np.cos(theta/2),np.sin(theta/2)])
print("|+theta> = ",plusThetaeigenket,"\n")
def minusThetaeigenket(theta):
return np.array([-np.sin(theta/2),np.cos(theta/2)])
print("|-theta> = ",minusThetaeigenket,"\n")
Can you please help to solve where this python code went wrong
for display the correct eigen ket value for theta? Thank you
|<+y|-y>l^2 = 0.9999999999999996 ||<+y|-x>l^2 = 0.4999999999999998 -4 print("*Exercise 30.5\n"), -5 #function defination for plus and minus theta eigenkets -6 def plusThetaeigenket(theta): +7 return np.array([np.cos(theta/2), np.sin(theta/2)]), -8 print("[+theta> = ",plusThetaeigenket,"\n"), *Exercise 30.5 -9 +theta> = <function plus Thetaeigenket at Ox00000160BCO9CD08> o def minus Thetaeigenket(theta):...
Need help writing this code in python.
This what I have so far.
def display_menu():
print("======================================================================")
print(" Baseball Team Manager")
print("MENU OPTIONS")
print("1 - Calculate batting average")
print("2 - Exit program")
print("=====================================================================")
def convert_bat():
option = int(input("Menu option: "))
while option!=2:
if option ==1:
print("Calculate batting average...")
num_at_bats = int(input("Enter official number of at bats:
"))
num_hits = int(input("Enter number of hits: "))
average = num_hits/num_at_bats
print("batting average: ", average)
elif option !=1 and option !=2:
print("Not a valid...
What will be printed upon running following code: alist = [3, 50, "Kity", [50, 52, "Rover"], [ ], 3.14, False, 'a'] print(len(alist[3]))alist = [3, 50, "Kity", [50, 52, "Rover"], [ ], 3.14, False, 'a'] print(len(alist[3])) 8 7 2 an error 3 Select the best reason why the code below returns True, False, False respectively? a = 256 b = 256 print(id(a) == id(b)) c = 5.1 d = 5.1 print(id(c) == id(d)) x = 257 y = 257 print(id(x) ==...
In Python: How many prints will run in the following code? def myfun(var1,var2): print(var1) print(var2) print(var1**var2) return var1+var2 print(var2**2) print(var1*var2)
Which of the following programs defines and calls a function to compute and print the cube of "2"? (There could be more than one correct answer.) def cube(n): return n * n * n print(cube(2)) def cube(n): return n ** 3 print(8) def cube(a): b = a * a return b * a c = 2 d = cube(c) print(d) def cube(n): n ** 3 print(cube(2))