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

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

1 Expert Approved Answer
Step: 1 Unlock

define the string welcomestringWelcome to Python we use the strlowhigh notation to slice strings and ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!