Problem

Python

Write a Python script that is directly executable from the Git Bash command line, without any need to invoke python interpreter. The script should produce exactly the following output, including line breaks and separations. Each part of the output (separated by a line-break, or a new-line character '\n' from the rest) is generated by only and only one call to print function.

This is Python version 3.5.2 

Python is the best language for String manipulation!

!noitalupinam gnirtS rof egaugnal tseb eht si nohtyP

!otlpnmgit o gunlte h inhy

pYTHON IS THE BEST LANGUAGE FOR sTRING MANIPULATION!


The sentence 'Python is the best language for String manipulation!' contains 
4 'a' letters, and
0 'A' letters!

Python
is
the
best
language
for
String
manipulation!

PYTHON
IS
THE
BEST
LANGUAGE
FOR
STRING
MANIPULATION!


Here are some hints (all the information you need to answer this question can be found in the lecture notes):

  • To make the script executable, add the appropriate shebang to the script’s file.

  • Import the appropriate module to get the python version command, as we did in class. Use print function to print the Python version.

  • Define a String variable my_string which contains the string value “Python is the best language for String manipulation!” ( Of course, you can accomplish this question without defining a string variable, by only using the string value itself wherever needed… This is also totally fine at this point in our course if you prefer this method).

  • Then use the appropriate examples and external links provided in the lecture notes, to find the proper string methods that can manipulate this string variable/value to generate each of the outputs printed above.

  • Again, note that for each output, the entire output must result from one single call to function print.

  • Wherever needed, use the escape character value '\n' in print input arguments, in order to generate a line-break (or newline) in the output.

Solution

Python

A working Python script file can be downloaded from here.

Comments