Python:
1) What output is generated by the following code segment?
table = [["T", "U", "V"], ["W", "X", "Y"]] print(table[0])
Group of answer choices
a- T
b- ["T", "W"]
c- ["T", "U", "V"]
d- [["T", "U", "V"], ["W", "X", "Y"]]
2) Consider the following code segment:
values = [4, 12, 0, 1, 5] print(values[1])
What is displayed when it runs?
Group of answer choices
a- 0
b- 1
c- 4
d- 12
3) Consider the following code segment:
x = [5, 3, 7] y = sorted(x) print(x)
What is displayed when it executes?
Group of answer choices
a- []
b- [3, 5, 7]
c- [5, 3, 7]
d- [7, 5, 3]
4) Given the following code snippet, what is printed?
nums = [1, 2, 3, 4, 5] nums2 = [5, 4, 3, 2, 1] if nums == nums2 : print("lists are equal") else : print("lists are not equal")
Group of answer choices
a- lists are equal
b- lists are not equal
c- lists are equallists are not equal
d- an error occurs and nothing is printed
5) What is the value of states after the following code segment has run?
element = "Ohio" states = ["Alaska", "Hawaii", "Florida", "Maine", "Ohio", "Florida"] states.remove(element)
Group of answer choices
a- ["Alaska", "Hawaii", "Florida", "Maine"]
b- []
c- ["Alaska", "Hawaii", "Florida", "Maine", "Ohio", "Florida"]
d- ["Alaska", "Hawaii", "Florida", "Maine", "Florida"]
1) ['T', 'U', 'V'] 2) 12 3) [5, 3, 7] 4) lists are not equal 5) ['Alaska', 'Hawaii', 'Florida', 'Maine', 'Florida']
Python: 1) What output is generated by the following code segment? table = [["T", "U", "V"],...
Python: 1) Consider the following code segment: try : inputFile = open("lyrics.txt", "r") line = inputFile.readline() print(line) _____________________ print("Error") What should be placed in the blank so that the program will print Error instead of crashing if an exception occurs while opening or reading from the file? Group of answer choices a- except RuntimeError : b- except EnvironmentError : c- except IOError : d- except IndexError : 2) Consider the following code segment: line = "hello world!" parts = line.split()...
1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...
Problem 4 (7 points): What is the output (printed to command prompt) of the following code (Exam2Prob4.m)? DO NOT USE MATLAB for solving this problem. ZERO CREDIT if all steps are not shown. You should explain the output of each code as if you are executing the code. (answer 2 points; process, with each step - 8 points) Exam2 Prob4.m clc; clear; close all; p=4; q = 3; r5; (x, y] = user Defined (p, q, r); fprintf('x- $d, y=%d',x,y);...
1. How many times does the message, “Hello” get printed out by the code segment below? int count = 0; while (count < 32) { printf(“Hello\n”); count = count+4; } 2. What is the value of sum at the end of the following code segment? int sum = 0, index; for (index = 0; index < 5; index++) sum += 5; Group of answer choices
Question 17 (3 points) Predict the output of the following code segment: a = 99.98 if a + 0.01 >= 100: print('A') elif a + 0.02 >= 100: print('B') print('c') else: print('D') print('E') Question 16 (3 points) Predict the output of the following code segment: X = 6 if x % 2 == 0: print ("x is even.") else: print ("x is odd.") Please use the decimal point to distinguish int and float. For example, number 3 + number 4...
Show that the following is a valid argument. 1. y V t 2. (w V u) ^(w V x) 3. (q V r) rightarrow w 4. s V p 5. (y ^r) rightarrow x 6. (p ^q) rightarrow (t V r)
20) What is the output of the following segment of C code: int avg(int n, int* a); int main () { int array[4]={1,0,6,9}; printf("%d", avg(4, array)+ 1); system("pause"); return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...
1. Consider the following code segment. String str = "AP"; str += "CS " + 1 + 2; System.out.println(str); What is printed as a result of executing the code segment? A: CS AP12 B: AP CS3 C: CSAP 12 D: APCS 12 E: APCS 3 2. Consider the following code segment. String dessert = "pie"; dessert += "straw" + dessert + "berry"; What is the value of dessert after the code segment has been executed? A: strawpieberry B: piestrawpieberry C:...
solved item S, T, U, V, W, X, Y, Z The demand for subassembly S is 100 units in week 7. Each unit of S requires 2 units of T and 1 unit of U. Each unit of T requires 1 unit of V, 2 units of W, and 1 unit of X. Finally, each unit of U requires 1 unit of Y and 2 units of Z. One firm manufactures all items. It takes 2 weeks to make S,...
Greeting! Kindly help me to solve my finals in PYTHON, I don't have a knowledge in PYTHON, new student. Please, please, I'm begging, Kindly answers all the questions. I'm hoping to grant my request. Thanks in advanced. 1.) What is the output of the following snippet? l1 = [1,2] for v in range(2): l1.insert(-1,l1[v]) print(l1) a.) [1, 2, 2, 2] b.) [1, 1, 1, 2] c.) [1, 2, 1, 2] d.) [1,...