...

/

Puzzles 34 to 37

Puzzles 34 to 37

Grasp the concepts of joining strings, arithmetic calculation, and list modification in a loop. Also, learn about binary search.

Puzzle 34

What is the output of the following code?

Note: Enter the output you guessed. Then, press the Run button, and your new Elo will be calculated. Don’t forget to save your Elo rating.

Press + to interact
Elo
1000
#############################
## id 367
## Puzzle Elo 1437
## Correctly solved 53 %
#############################
def concatenation(*args, sep="/"):
return sep.join(args)
print(concatenation("A", "B", "C", sep=","))

Enter the input below

Joining strings

String concatenation is the process of creating a string by appending string arguments.

The given function takes an arbitrary number of string arguments specified by the *args keyword. The parameter sep declares the separator string to be used to glue together two strings. The separator string comes as a keyword argument. The reason is that the *args argument comprises an arbitrary number of values. The keyword argument helps differentiate whether the last parameter is part of *args or the sep argument.

The function concatenation is a wrapper for the join function to concatenate strings. The join function is defined in the string object sep. It concatenates an arbitrary number of strings using the separator to glue them together. Both functions achieve the same thing, but the first may be more convenient because the separator is a normal argument.

Solution

The correct solution is A,B,C ...

Access this course and 1400+ top-rated courses and projects.