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
PROCEDURE: Therapeutic infusion of saline solution with 5% dextrose IV, 500 ml for dehydration, lasting 48 minutes. what is the
Valentin [98]

Answer:

no

Explanation:

yes<em><u> </u></em><em><u>b</u></em><em><u>e</u></em><em><u>c</u></em><em><u>o</u></em><em><u>u</u></em><em><u>c</u></em><em><u>e</u></em><em><u> </u></em><em><u>n</u></em><em><u>o</u></em><em><u>t</u></em><em><u> </u></em><em><u>a</u></em><em><u>r</u></em><em><u>a</u></em><em><u>n</u></em><em><u>c</u></em><em><u>e</u></em><em><u> </u></em><em><u>t</u></em><em><u>h</u></em><em><u>e</u></em><em><u> </u></em><em><u>n</u></em><em><u>a</u></em><em><u>m</u></em><em><u>e</u></em><em><u> </u></em><em><u>o</u></em><em><u>f</u></em><em><u> </u></em><em><u>f</u></em><em><u>e</u></em><em><u>g</u></em><em><u>e</u></em><em><u>u</u></em><em><u>r</u></em><em><u> </u></em><em><u>s</u></em><em><u>p</u></em><em><u>e</u></em><em><u>c</u></em><em><u>h</u></em>

6 0
3 years ago
When making college visits, you may be able to....
solmaris [256]
-schedule a tour to college campuses
- Attend a class to find out how its feels like
5 0
3 years ago
Read 2 more answers
Janice is making her resume in which section should she include information about her previous employers , positions held , and
Volgvan

Generally, Janice should post information about her past employment in the Experience section, also often called as Professional Experience. The information that she should include is the name of the organization or company which previously employed her, her positions there, length of each position, and a description of what she did in the position.

4 0
3 years ago
_______ are fasteners that connect parts and are intended to resist pulling forces. A. Extension springs B. Compression springs
madam [21]
The answer is Lock washers
6 0
4 years ago
I have python homework and I’m struggling with it
melamori03 [73]

Answer:

okay

Explanation:

what's the question

5 0
3 years ago
Other questions:
  • When jump starting a vehicle , once the stalled vehicle is successfully started remove the cable in same order in which they wer
    13·1 answer
  • What is the rationale behind the development of an operating system in computing?
    15·1 answer
  • Which of the following is an Example of a technical (“hard”) skill
    6·2 answers
  • Which of the following is not a SQL*Loader file?
    11·1 answer
  • (((PLEASE HELP QUICK))) When writing research questions you should begin with ____.
    13·2 answers
  • Not sure where I should ask this sorry
    15·1 answer
  • See the lseek_example.c file. Modify the lseek_example.c, such that it reads from an input file (named "start.txt") and will pri
    6·1 answer
  • Which measurement symbol is this?<br>PLS HELP<br>​
    14·1 answer
  • CSS At-rules provide a way for designers to define "if this, then that" scenarios.
    8·1 answer
  • Select the correct answer.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!