Answer:
u can find tricks on <em>scholars.google.com</em>
The simplest line of code to test if the word "BASIC" is stored in the variable text1 is :
if ( text1 == "BASIC" ):
Explanation:
- The simplest if-statement has two parts, a boolean "test" within parentheses ( ) followed by "body" block of statements within curly braces { }.
- The test can be any expression that evaluates to a boolean value true or false. The if-statement evaluates the test and then runs the body code only if the test is true.
- You should use the equals() method of the String class to compare Strings.
- == will do an object comparison between the strings in this situation, and although the value may be the same of the String objects, the objects are not the same.
- Equals: a == b. The double equals sign =. A single symbol a = b would mean an assignment
Answer:
Following are the code to this question:
def get_initials(the_name): #defining a method get_initials
name = the_name.split(" ") #defining name variable that splits value
val = ''#defining a string variable val
for n in name: #defining loop to convert value into upper case and store first character
val = val + n[0].upper() + "." # use val variable to hold value
return val # return val
print(get_initials("Gloria kind of a big deal Tropalogos"))#call method and print return value
print(get_initials("Homer J Simpson"))#call method and print return value
print(get_initials("John Q Public")) #call method and print return value
Output:
J.Q.P.
H.J.S.
G.K.O.A.B.D.T.
Explanation:
In the given code, the last is incorrect because if we pass the value that is "Gloria kind of a big deal Tropalogos" so, will not give G.O.O.D. instead of that it will return G.K.O.A.B.D.T. So, the program description can be given as follows:
- In the given python code, a method "get_initials" is declared, that accepts "the_name" variable as a parameter, inside the method "name" variable is declared, which uses the split method that splits all values.
- In the next step, a string variable "val" and for loop is used, in which the "val" variable converts the first character of the string into the upper case and stores its character with "." symbol in "val" variable and return its value.
- In the last step, the print method is used, that passes the string value and prints its sort value.
The network operator , the person overseeing the network operations