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...
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
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);...
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...
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:...
Given the following code segment, int x = 20; int y = 7; what is the data type of the value of the expression (x % y) ? (3 points) Question 1 options: 1) int 2) double 3) numeric 4) Error: possible loss of precision 5) Unable to be determined Question 2 (3 points) Given the following code segment, double x = 42.3; double y = 11.7; what is the data type of the value of the expression (x %...
c#
QUESTION 1 owing code segment? What is the output for the foll Stack myStack new Stack0: myStack.Push One"); myStack.Pushl Two"); myStack.Push( Three"); myStack Push Four" myStack.Push Five" Console.WriteLine(myStack.PopO): O One Two O Three O Four Five QUESTION 2 What must x be to print out a 'G' in the the following code fragment? char i = (char)((int)x + 3); Console.WriteLine(); O charx 65; O charx 75; char x = 'A'; O char x-D O intx 68; QUESTION 3 What...
Question 28 What is the size of groceryList after the code segment? ArrayList<String> groceryList; groceryList = new ArrayList<String>(); groceryList.add("Bread"); groceryList.add("Apples"); groceryList.add("Grape Jelly"); groceryList.add("Peanut Butter"); groceryList.set(1, "Frozen Pizza"); Group of answer choices 5 4 3 Error: index out of bounds