Python Language Problems
1.
isdigit()
A. Returns True if this string is just a digit.
B. Returns True if this string contains only number characters.
C. Return True if this string has at least one number character.
D. is not a valid function.
2.
Pick the most accurate interpretation for the if construct:
if letter in words:
print("Got it")
A. If the character letter existed in the string words, it prints "Got it".
B. It traverse through the string words, every time it finds the character letter, it prints "Got it".
C. If the character letter existed in the string words, it prints "Got it"; letter could only be an alphabet
D. If letter existed in the string words, it prints "Got it"; letter could be either a single character or a string with multiple characters.
3.
Given that Cake is a class, what do we call this statement with respect to object and class:
my_large_lemon_cake = Cake(3, 'L')
A. Assignment B. Constructor C. Initializer D. Function Call E. None of the Above
4.
The instance of a class is
A. member function B. member variable C. an object D. also a class E. All of Above
5.
The attributes of an object can be categorized into
A.
1. Data
2. Non Data
3. Modules
B.
1. Modules
2. Sub-Modules
3. Behavior
C.
1. Member Variables
2. Member Functions
D.
1. Imported Modules
2. Local Modules
1. B. Returns True if this string contains only number characters. 2. D. If letter existed in the string words, it prints "Got it"; letter could be either a single character or a string with multiple characters. 3. B. Constructor 4. C. an object 5. C. 1. Member Variables 2. Member Functions
Python Language Problems 1. isdigit() A. Returns True if this string is just a digit. B....
Define a function ValidRoom() that passes in a string parameter and returns true if the string parameter obeys all rules for a building's room address, else returns false. The rules are: (1) Must be two or three characters long. (2) First two characters must be digits, (3) If third character exists, must be a letter (upper or lowercase). Examples of strings yielding true: "65", "00", "21L". Examples of strings yielding false: "356", "7", "A23", " 65", "45AB". Recall some available...
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...
1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if the first two characters and the last two characters of the string are the same. It returns false otherwise. In addition, if the string is empty or has only one character, it also returns false. For example, these are the strings with their expected return values false falsc "AB" true "ABA" false "ABAB" trus "ABBA" false "ABCABC false "ABCCAB" true 1.2 Write a function...
D.1 [3] Define a function called funD1...) that receives a string and returns a new string with all the characters in the original string in an EVEN position. As an example, the following code fragment: print (funD1('abcde')) should produce the output: ace D.2 [6] Define a function funD2(...) which receives a list ist that contains single letters, single digits and single special characters and the list contains at least one element of each type). The function returns a string that...
C++ / Visual Studio Implement the member function below that returns true if the given value is in the container, and false if not. Your code should use iterators so it works with any type of container and data. template< typename Value, class Container > bool member( const Value& val, const Container& cont ); just implement this function in the code below #include <iostream> #include <array> #include <deque> #include <list> #include <set> #include <string> #include <vector> using namespace std; #define...
IN PYTHON Implement a function easyCrypto() that takes as input a string and prints its encryption defined as follows: Every character at an odd position i in the alphabet will be encrypted with the character at position i + 1, and every character at an even position i will be encrypted with the character at position i - 1. In other words, ‘a’ is encrypted with ‘b’, ‘b’ with ‘a’, ‘c’ with ‘d’, ‘d’, with ‘c’, and so on. Lowercase...
Write a Python function called more() that takes three string inputs and outputs a string Formally, the function signature and output are given by rucharist, char: str words str) > str Use the same names for the input arguments as shown above Note that charl and char2 will always be a string of length 1 (ie, it is a single character. The function checks which of charl or char2 appears more often in the word string and returns that character...
in C ++
containsTwice Language/Type: Related Links: Cboolean string caturn stine stlih Write ea function named containsTwice that accepts a string and a character as parameters and returns true if that character occurs two or more times in the string. For example, the call of cantainsTaice("helle", 1') should return true because there are two '1' characters in that sto Type your Ce solution code here: C lutson coe here h function cerce e C ntion
The isdigit() method of a string returns a. true if the string contains only digits b. the digits that are in the string c. the string if it only contains digits d. true if the string contains only digits and a decimal point Which of the Python examples that follow can not be used to create a string named n2? a. numbers = ["8", "17", "54", "22", "35"] n2 = "".join(numbers) b. numbers = "817542235" n2 = numbers.replace("2", "") c....
1. DOES A DIGIT APPEAR IN AN INTEGER, Write a recursive function appears(n,i) that returns true if the digit i appears in the positive (base 10) integer n, false if it does not in c++. ex. Enter a positive integer: 54321 Enter a digit: 7 The digit 7 does NOT appear in the integer 54321. 2. IS AN INPUT STRING A PALINDROME? A palindrome is a string in which the letters are the same in both directions, disregarding capitalization and...