1. Given the variable 's' containing the string value below,
determine the value for the variable result
after each of the following statements is executed or specify error
if a Python exception would be
thrown:
s = "One plus Two plus Three = 6"
a.) result = s.replace('plus', '+')
b.) result = s[26].isdigit()
c.) result = s[29] + s[0]
d.) result = s[4:8] + s[13:17]
e.) result = s.upper()
f.) result = s.find('6')
g.) result = s[0:4].isalnum()
h.) result = s[::-1]
i.) result = s[10] * 3
j.) result = len(s)
k.) result = 'on' in s
l.) result = s.replace('=', 'equals'.upper())
m.) result = s[0] + s[19]
n.) result = s[::3]
o.) result = s.title()
p.) result = s[7:10].replace(" ", "i")
q.) result = s[11]
r.) result = s[24:27].title()
s.) result = s.lower()
t.) result = s.capitalize()
u.) result = s[9:12][::-1].upper()
v.) result = s[::-1].lower()[2]
w.) result = s.replace("plus", "+").replace('6', "Six")
One + Two + Three = 6 True IndexError: string index out of range plusplus ONE PLUS TWO PLUS THREE = 6 26 False 6 = eerhT sulp owT sulp enO www 27 False One plus Two plus Three EQUALS 6 Oh O uT uTe= One Plus Two Plus Three = 6 siT o = 6 one plus two plus three = 6 One plus two plus three = 6 OWT = One + Two + Three = Six
1. Given the variable 's' containing the string value below, determine the value for the variable...
The variable "s" contains a string value. Which of the following will print each character in this string exactly one time? # Option A for ch in s: print(ch) # Option B countB = 0 while countB < len(s): print(s[countB]) countB += 1 # Option C countC = len(s) - 1 while countC >= 0: print(s[countC]) countC -= 1 Option A Option B Option C All of the above None of the above
Given 11. String test- "a1b2c3", 12. String tokens test.split("ld") 13. for(String s: tokens) System.out.print(s+""), What is the result? A. a b c B. 1 23 C. a1b2c3 D. a1 b2 c3 E. Compilation fails. F. The code runs with no output. G. An exception is thrown at runtime. Given 11. String test- "a1b2c3", 12. String tokens test.split("ld") 13. for(String s: tokens) System.out.print(s+""), What is the result? A. a b c B. 1 23 C. a1b2c3 D. a1 b2 c3 E....
1.Method name: findSmallestPositiveNumber Parameter(s): A String containing integer numbers separated by spaces. There must be at least one positive number in the String. Return value: An int value that is the smallest number greater than 0 in the input string. Example: findSmallestPositiveNumber("2 -4 5") should return 2. Note: Even though I put this first, I would consider working on this later. The other methods are basically just applying the patterns we looked at in class. This one is similar but...
What value does this Processing code store in the s variable? String str = ""; int[] a = {4, 8, 7, 8}; for (int i = 0; i < a.length; i++) { str = a[i] + str; } String s = str;
QUESTION 1 If an exception is thrown None listed all listed execution terminates if there is no catch block handling the same data type as the exception thrown execution continues if the catch block handles the same data type as the exception thrown 10 points QUESTION 2 An exception is handled using an if-else statement an assignment statement a loop statement a try-catch block 10 points QUESTION 3 In program 9.4, what is the data type being thrown?...
Question 29 (1 point) What is the value in the variable result? You do not need to put " "around your answer. String message "Sunday Funday"; String result ""; int n = message.length(); for (int i = 0; i < n; i = i + 2) { char ch message.charAt(i); result = result + ch; System.out.println(result); A/
Page 3 of 7 (Python) For each substring in the input string t that matches the regular expression r, the method call re. aub (r, o, t) substitutes the matching substring with the string a. Wwhat is the output? import re print (re.aub (r"l+\d+ " , "$, "be+345jk3726-45+9xyz")) a. "be$jk3726-455xyz" c. "bejkxyz" 9. b. "be$jks-$$xyz" d. $$$" A object a- A (2) 10. (Python) What is the output? # Source code file: A.py class A init (self, the x): self.x-...
Python The Python "<" and ">" comparison operators can be used to compare which string variable has a greater value based on comparing the ASCII codes of the characters in each string, one by one. To take some examples: "tets" > "test" returns True because the third letter of the first string, "t", has a greater value than the third letter of the second string, "s". "testa" > "test" returns True because—while the first four letters in both words are...
Given the following classes: StringTools.java: public class StringTools { public static String reverse(String s){ char[] original=s.toCharArray(); char[] reverse = new char[original.length]; for(int i =0; i<s.length(); i++){ reverse[i] = original[original.length-1-i]; } return new String(reverse); } /** * Takes in a string containing a first, middle and last name in that order. * For example Amith Mamidi Reddy to A. M. Reddy. * If there are not three words in the string then the method will return null * @param name in...
C++ with comments please! // numberverifier.cpp #include <iostream> #include <exception> using std::cout; using std::cin; using std::endl; #include <cmath> #include <cstring> class nonNumber : public exception { public: /* write definition for the constructor */ -- Message is “An invalid input was entered” }; int castInput( char *s ) { char *temp = s; int result = 0, negative = 1; // check for minus sign if ( temp[ 0 ] == '-' ) negative = -1; for ( int i...