Question: a) Write a Python script that defines the string Welcome to Python and performs the following, where each operation must consist of one line
a) Write a Python script that defines the string "Welcome to Python" and performs the following, where each operation must consist of one line of Python code using slicing only: Prints all characters from the 6th to the 10th character. . Prints all characters after the 4th character. Prints the last five characters (without assuming the size). Checks and prints whether a given string s is a palindrome (same in reverse). b) Write a python program/script that creates a list that contains the following countries and capitals: "Istanbul", "Turkey", "Cairo", "Egypt", "Baghdad", "Iraq". "Delhi". "India". "Tehran", "Iran", "Riyadh", "Saudi Arabia", "Ankara", "Turkey"; and performs the following: Prints all items that are cities, i.e. elements at even indices Prints the list in reverse using slicing Finds and replaces elements Delhi and India with Muscat and Oman
Step by Step Solution
3.46 Rating (153 Votes )
There are 3 Steps involved in it
define the string welcomestringWelcome to Python we use the strlowhigh notation to slice strings and ... View full answer
Get step-by-step solutions from verified subject matter experts
