1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
irinina [24]
3 years ago
11

2. Write a program with a function that accepts a string as an argument and returns a copy of the string with the first characte

r of each sentence capitalized. For instance, if the argument is "hello. my name is Joe. what is your name?" the function should return the string "Hello. My name is Joe. What is your name?" The program should let the user enter a string and then pass it to the function. The modified string should be displayed.

Computers and Technology
1 answer:
Oduvanchick [21]3 years ago
4 0

Answer:

Following are the code to this question:

def capital(val):#defining a method that takes string value as parameter

   x=True#defining boolean variable

   r=''#defining string variable  

   for i in val:#defining loop to convert the first character into upper case

       if i.isalpha() and x:#defining condition to check input value is string

           r=r+i.upper()#change value into uppercase and hold value in r variable

           x=False#assign value false in boolean variable

       elif i=='.' or i=='?' or i=='!':#check symbols

           r=r+i#add value in r variable

           x=True#assign value True in boolean variable

       else:

           r=r+i#add all value in r variable

   return r#return r variable value

val=input()#input value in val variable

print(capital(val))#called the function which print the return value

Output:

please find the attachment.

Explanation:

  • In the above python program, a method "capital" is declared, which accepts a "val" a string value in its parameter, and inside the method one boolean "x" and one string "r" variable is used, in which r stores return value.
  • In the next step, for loop is declared, inside the loop, the conditional statement is used, in if the block it checks string value and converts the first character into upper case and assigns value false in the boolean variable.  
  • In the next step, elif block is defined that adds value in r variable and at the last, it will return function value, at the last step "val" variable is declared that input value from the user and pass into the method and print its return value.

You might be interested in
You can use your student ID card to get discounts in all of the following except
Anna007 [38]

tuition - apex

hope it helped

5 0
3 years ago
Read 2 more answers
From what tab can you format individual cell data like any other text?
Readme [11.4K]
I think the answer is D
5 0
4 years ago
What does the Disk Defragmenter tool do
Kobotan [32]
Disk Defragment Free will quickly defragment files on your hard drive, optimize file placement and consolidate free space to ensure the highest data access speed possible.
6 0
3 years ago
Quick question... HOW DO YOU FREAKING PUT THE "GREATER THAN EQUAL TO" SYMBOL ON GOOGLE? (sorry i'm frustrated)
satela [25.4K]
On what device are you trying to type it on ? iphone ? android ? computer ?
3 0
3 years ago
Read 2 more answers
A banded table appears with
Triss [41]

Answer:

banded rows and banded columns with alternate rows and columns in different colors and shades.

And hence, A different shading colors for odd even rows.

Explanation:

Suppose you have a plenty of data in a spreadsheet. It has been found that if the rows and columns are being shown through color banding, then they look quite pleasant to our eyes. And the options for the columns and rows banding  helps us in developing bands that are formed alternatively, and one being colored and the other being shaded. And all these are rows and columns. So we have banded rows and banded columns. And you can make this by converting the sheet to table, and then using the table style.

7 0
4 years ago
Other questions:
  • What are three ways to call attention to the text on a web page?
    6·2 answers
  • Who is the person responsible for creating the original website content?
    14·1 answer
  • Write a program that records high-score data for a fictitious game. the program will ask the user to enter five names, and five
    12·1 answer
  • You just bought a hard drive, you plan on using this a secondary storage, once installed, what needs to be done to the drive and
    6·1 answer
  • When _______ wordart, you need to consider both the font size of the text and the size of the text box that contains wordart?
    15·1 answer
  • Jared recently sent an email to all the members of his department asking them for their opinions about where the department shou
    11·1 answer
  • Which tool can be used to increase the space between a bullet point or a number and text?
    11·2 answers
  • Write long answer to the following question. a. Define microcomputer. Explain the types of microcomputers in detail.​
    5·2 answers
  • WILL GIVE A BRAINLIEST!!! PLS HELP!!!
    5·1 answer
  • How do you start using the Internet?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!