def Boff(intNum): intA=7 intA = intNum + 2 + intA if intA <=3: print(3*intA,end = "xx") else: if intA > 7: print(7*intA, end="yy") def main(): intA=4 Boff(intA) Boff(intA) intA = 2 Boff(intA) main()
def Boff(intNum): intA=7 intA = intNum + 2 + intA if intA <=3: print(3*intA,end = "xx")...
5. What is the output of the below program? (14 marks) def Fungsi (xx): print ("x is ", xx) values=[8 ,2 , 6 , 6 ,2 ,6) c=0 for i in range (len (values)): if (values[i] == xx): C=C+1 if c> 0 : print ("Return ", c) return c else: C = 100 print ("Return ", c) return c A = Fungsi (2) print ("The A is ", A) B= Fungsi (6) + Fungsi (7) print ("The Bis", B)
12. What is the output of this program? Your answer: 1 def main(): 2 print('The numbers are:') 3 for i in range (2,25): 4 isone (i) 5 def isone (number): isOne = True i = 2 while i < number and is one: if number % i == 0: 10 isOne = False 11 i += 1 Lou if isOne == True: 13 print("\t', i) 14 main() 12 13. What is the output of this program? Your answer: for i...
#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
print(" |",end=' ')
for i in range(1,10):
print(i,end=' ')
print()
for i in range(0,11):
print('-',end=' ')
print()
for i in range(1,10):
for j in range(0,11):
if j==0:
print(i,end=' ')
elif j==1:
print('|',end=' ')
elif i==9 and j==10:
print(i*(j-1),end=' ')
elif i>=4 and j>=4:
print('*',end=' ')
else:
print(i*(j-1),end=' ')
print()
This code is not working I need help
1 2 3 4 5 6 7 8 9 --- --- -------------------- -------------------- 5 10 15 X 6 12 18 X 7 8...
def st_petersburg_lottery(): print("###### St. Petersburg Lottery ######") print("Instructions:") print("You will select any number greater than 0.") print("Up to the number of times you chose, we will randomly choose 0 or 1.") print("If a 1 is chosen before the last drawing, then you lose.") print("If a 1 does not appear at all, then you lose.") print("You win if 1 is chosen for the first time exactly on the last drawing.") print() def first_to_a_word(): print("###### First to a Word ######") print("Instructions:") print("You...
def seuss(myName): print('I am %s.' % myName, end=' ') print(myName, 'I am.') print('Do you like green eggs and ham?') print() The end argument was discussed in the book in Section 2.8. Also, the last line of the function (the print with empty parentheses) prints out a blank line. propose a reason the first call to print uses the output formatting operator %, while the second one doesn't ?
Code Example 14-3 class Multiplier: def __init__(self): self.num1 = 0 self.num2 = 0 def getProduct(self): return self.num1 * self.num2 def main(): m = Multiplier() m.num1 = 7 m.num2 = 3 print(m.num1, "X", m.num2, "=", m.getProduct()) if __name__ == "__main__": main() Refer to Code Example 14-3: When this code is executed, what does it print to the console? a. 7 X 3 = 0 b. 3 X 7 = 0 c. 7 X 3...
Code Example 10-1 1. phone_number input("Enter phone number: ").strip() 2. if len(phone_number)10: 3. phone_number""+phone_number[:3]")" + phone_number[3:6] + "-" + phone_number[6:] 4. print("Phone number:", phone_number) 5. else 6. print("Phone number:", "Phone number must be 10 digits") Referto Code Example 10-1. Iftheuserenterstwo extra spacesattheend of a phonenumber what will happen? a. The length of thenumber wil begreater than 10 so theelse clause willexecute. b. The strip) method on line 1 will strip away the extra whitespace. C. The else clause will be...
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...