1.0
// is the floor division operator.
So, num1 // num2 = 20 // 10 = 2
/ in Python 3.0+ does the floating point division of the operands,
Hence, 2/num3 = 2/2 = 1.0
in python 3.0 please Question 3 (1 point) What is the value of result after the...
Question 3 (1 point) Question 3) METHODs to our Madness: Use the pseudocode methods below to answer the questions starting on the next page. FIRST METHOD: COMMENT parameters should be integers METHOD largestValue(parameters: num1, num2) BEGIN IF(num1 >= num2) THEN result ← num1 ELSE result ← num2 ENDIF END largestValue SECOND METHOD: COMMENT parameters should be doubles METHOD largestValue(parameters: num1, num2) BEGIN IF(num1 >= num2) THEN result ← num1 ELSE result ← num2 ENDIF RETURN...
Please answer both questions thank you.
Question 49 (1 point) What is wrong with the following code snippet? for (int i 1; i <= 5; i++) { int squared = i + i; System.out.println(i + IT "! squared = + squared); } System.out.println("Last square = " + squared); calculation error variable scope error O nothing incorrect use of for loop Question 47 (1 point) What are the values of num1 and num2 and result after the execution of mystery (num1,...
Please answer both questions thank you.
Assuming that a user enters 8, 15, and 11 as input values one after another, separated by spaces, what is the output of the following code snippet? int num1 = 0; int num2 = 0; int num3 = 0; Scanner in = new Scanner (System.in); System.out.print("Enter a number: "); numl - in.nextInt(); System.out.print("Enter a number: "); num2 = in.nextInt(); System.out.print("Enter a number: "); num3 = in.nextInt(); if (numl > num2) if (numl > num3)...
Write code that sets the value of a variable named result to the sum of the values in the variables num1 and num2, unless that sum is in the range 20 to 30, inclusive, in which case set result to 0. Assume num1 and num2 already have values (code in Python).
Refer the program in the next page: Assume the starting address of data segment: 0x10010000. What is the address of label num3? _______________________________ Write the common syscall code to print string for the blank marked as #Question 2 _________________________________ Write proper comments for the lines marked as #Question 3 ________________________________________________________ Write the machine code for the line marked as #Question 4 in both binary and hex. Binary:_______________________________________ Hex:___________________ Write the machine code for the line marked as #Question 5 in...
I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import arithmetic as a def multiply(num1, num2): product = num1 * num2 result = a.add(product, product) return result def main(): num1 = 4 num2 = 3 answer = multiply(num1, num2) print("The answer is", answer) if __name__ == "__main__": main() arithmetic module: def add(x, y): z = x + y return z Refer to Code...
Question 5 (1 point) userGuess ← 0, secretNumber ← 5 PRINT “Enter a number between 1 and 10” READ userGuess WHILE (userGuess < 1 OR userGuess > 10) PRINTLINE “That is not between 1 and 10. Try again.” READ userGuess ENDWHILE IF (userGuess == secretNum) THEN PRINTLINE “That’s right! ”, userGuess, “ is the secret!” ELSE PRINTLINE userGuess, “ is not the secret!” ENDIF What is the first WHILE loop being used for? Question 5 options: Input validation Random number...
please help to solve the following problem on python 3.0 please Translate the following problem descriptions into Python. If score is greater than or equal to 90, then grade is set to ‘A’. a) Assume the variables p, v, and r have been assigned some values we want to test. If the expression t / (p – v) is greater than 10, then r is set to 0. If the result is not greater than 10, r is set to...
Please, explain clearly each line of code with your answers. Question 1 Consider the following code snippet: int ctr = 0; int myarray[3]; for (int i = 0; i < 3; i++) { myarray[i] = ctr; ctr = ctr + i; } cout << myarray[2]; What is the output of the code snippet? Question 2 Consider the following code snippet: int cnt = 0; int numarray[2][3]; for (int i = 0; i < 3; i++) { for (int j =...
Question 15 (1 point) What does this program print? Please make sure your spacing is exact. public class Test { System.out.print("39 + 3"); System.out.println(39 + 3); } 1 A/ Question 5 (1 point) Consider a file called input.txt that has the following 4 lines: Trace the program when it is 89 lines 78.5 is average. Isn't it? What would be the value of count after the following code snippet executes? Scanner in = new Scanner (new File("input.txt")); int count 0;...