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]
2 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]2 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
Which amendment discussed in the unit do you think has the greatest effect on your life? Why?
lora16 [44]
The 13th amendment (freed the slaves) for me because I am black
6 0
3 years ago
Which source would provide the best way to find valid information about climate change
igor_vitrenko [27]
Primary sources would be best
4 0
2 years ago
Spreadshet formula to add totals​
frozen [14]

Answer:

=SUM(Range value)

like =SUM(A1:A7) or =SUM(A1:H1)

Explanation:

We need to make use of the SUM function, and then we need to mention the cells or range value that references a series of cells row-wise or column-wise. Like a range value of A1:A7 means A1,A2,A3,A4,A5,A6,A7 and the range value of A1:H1 means A1, B1,C1,D1,E1,F1,G1,H1. And similarly, you can represent various cells depending upon the code you come up it, and finally, you need to sum them all using the SUM function.

7 0
3 years ago
Which guideline should you follow when selecting the font for a presentation
Sladkaya [172]
My school requires us to use Arial and double space it but we have to use font size 30 for title and 24 for the paragraphs.
3 0
3 years ago
You are photographing your friend in a local park which of the following might be supporting details you want to include in the
rodikova [14]

The color of the leaves. or the scenery

5 0
3 years ago
Other questions:
  • When a dynamic array with a class for a base type is declared, which constructor is called?
    5·1 answer
  • Another html/css assignment, drop css code below, thank you
    15·1 answer
  • Assuming the Direct Hashing function and the Subtraction preprocessing algorithm is used to map keys into indices, give the inde
    15·1 answer
  • Kris is the project manager for a large software company. Which part of project management describes the overall project in deta
    11·2 answers
  • Excel files have a default extension of ?
    12·1 answer
  • A computer is performing a binary search on the sorted list of 7 numbers below. What is the maximum number of iterations needed
    15·1 answer
  • 2. Explain the difference between a JMP instruction and CALL instruction
    6·1 answer
  • Help please i will mark brainlist!
    7·1 answer
  • Molly claims that she doesn’t have to proofread her code for typos because the interpreter will catch her mistakes for her. Is s
    10·1 answer
  • 30 Points!!
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!