Question

Swap Cases - Write a python program to swap cases. LowerCase letters to Upper case and...

Swap Cases

- Write a python program to swap cases. LowerCase letters to Upper

case and vice versa (10 points)

Input :

Www.PyDev.com

Output:

wWW.pYdEV.COM

Input: Pythonist 2

Output: pYTHONIST 2

b)

Manipulate Strings

- Insert a sequence of characters into the specified position in

the given String(10 points)

Input : First Line contains the string to be manipulated

Second Line contains the string to be inserted and the position Number

Output : The modified string

Sample Input & Output:-

Input : howyou

are 4

Output :howareyou

C)

Split And Join

- Given an input string split each word and then join the text using

specified join character(10 points)

Input : First Line - Contains a String

Second Line - Contains the split Character

Output: The modified String

Sample Input & Output:

Input :

hey how are you doing

-

Output:

hey-how-are-you-doing

0 0
Add a comment Improve this question Transcribed image text
Answer #1
# program to convert the uppercase character to lowercase and vice-versa

# read string input
in_str = input('Input: ')

# empty string to store the result
out_str = ''

# loop for all characters in the input string
for i in in_str:

  # convert lowercase to uppercase
  # and store result
  if i.islower():
    out_str += i.upper()

  # convert uppercase to uppercase
  # and store result
  elif i.isupper():
    out_str += i.lower()

  # if not a character add the character to result as it is
  else:
    out_str += i

# display resulted string
print('Output:', out_str)

# program to insert the string the at a certain position of the given string

# read string input
string = input('Input String: ')
in_str = input('Enter the string to insert: ')
in_pos = int(input('Enter the position to insert: '))

# empty string to store the result
out_str = ''

# loop for all characters in the input string
for i in range(len(string)):

  # insert the string at the desired position
  if i == (in_pos-1):
    out_str += in_str
    out_str += string[i]
  
  # else add the characters to result string
  else:
    out_str += string[i]

# display resulted string
print('Output:', out_str)

# program to perform split and join on a string input

# read string input and character to split
in_str = input('Input String: ')
split_char = input('Enter the string to insert: ')

# split the string entered
split_str = in_str.split()

# join the string using the character entered by user
join_str = split_char.join(split_str)

# display result
print('Output: ', join_str)

For help please comment.
Thank You

Add a comment
Know the answer?
Add Answer to:
Swap Cases - Write a python program to swap cases. LowerCase letters to Upper case and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list : A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all n squad soldiers to line up on the parade ground. By the military charter the soldiers should stand in the order of non-increasing of their height. But as there's virtually no time...

  • C Program In this assignment you'll write a program that encrypts the alphabetic letters in a...

    C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...

  • In this lab you will write a spell check program. The program has two input files:...

    In this lab you will write a spell check program. The program has two input files: one is the dictionary (a list of valid words) and the other is the document to be spellchecked. The program will read in the words for the dictionary, then will read the document and check whether each word is found in the dictionary. If not, the user will be prompted to leave the word as is or type in a replacement word and add...

  • JAVA PROGRAMMING File Name You can not just take the file and send it. When Polycarp...

    JAVA PROGRAMMING File Name You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the social network topic. In this case, the file is not sent and an error message is displayed. Determine the...

  • C++ Write A Program: //Please DONT use stdio.h or fancy things like classes Given the following...

    C++ Write A Program: //Please DONT use stdio.h or fancy things like classes Given the following header: vector<string> split(string target, string delimiter); implement the function split so that it returns a vector of the strings in target that are separated by the string delimiter. For example: split("10,20,30", ",") should return a vector with the strings "10", "20", and "30". Similarly, split("do re mi fa so la ti do", " ") should return a vector with the strings "do", "re", "mi",...

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

  • Write a c++ program in that file to perform a “Search and Replace All” operation. This...

    Write a c++ program in that file to perform a “Search and Replace All” operation. This operation consists of performing a case-sensitive search for all occurrences of an arbitrary sequence of characters within a file and substituting another arbitrary sequence in place of them. Please note: One of the biggest problems some students have with this exercise occurs simply because they don’t read the command line information in the course document titled “Using the Compiler’s IDE”. Your program: 1. must...

  • Use sorting techniques in the language Python 3 Devise an algorithm and implement it in a program to solve the following problem, similar to one often faced by an MP3 player. For our purposes, a song...

    Use sorting techniques in the language Python 3 Devise an algorithm and implement it in a program to solve the following problem, similar to one often faced by an MP3 player. For our purposes, a song consists of the following data fields: title (a nonempty ASCII string) composer (a (possibly empty) ASCII string), running time (a positive integer). Input consists of n songs and an integer k with 1 Sksn. Your program must find the k songs with longest running...

  • For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java...

    For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java program that will input a file of sentences and output a report showing the tokens and shingles (defined below) for each sentence. Templates are provided below for implementing the program as two separate files: a test driver class containing the main() method, and a sentence utilities class that computes the tokens and shingles, and reports their values. The test driver template already implements accepting...

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list : Vanya and his friends are walking along the fence of height h and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed h. If the height of some person is greater than h he can bend down and then he surely won't be noticed by the guard....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT