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
Daniel makes changes to a workbook named “Results.” He saves the file as “New Results” but did not realize that a worksheet name
elena55 [62]
All he would need to do is go into the sheet and change the name again. This will change the HTML so the computer will not be confused. The name should make sense, but he completely different from the original name :)
7 0
3 years ago
Consider the classes below, declared in the same file: class A { int a; public A() { ​ a = 7; } } class B extends A { int b; pub
DiKsa [7]

Answer:

2. <em>A reference of type A can be treated as a reference of type B</em> - False

Base class or its objects are not related to their derived class (or its objects).

Explanation:

class A {

   int a;

   public A() {

       a = 7;

   }

}

class B extends A {

   int b;

   public B() {

       b = 8;

   }

}

///////////////////////////////////////////////////////////////////////////////////////////////////////

1. <em>After the constructor for class B executes, the variable a will have the value 7 </em>- True.

When an object of a derived class is declared, the constructor of base class is called before the constructor of derived class (is called).

3. <em>Both variables a and b are instance variables </em>- True.

Classes can have instance, or member, variables and methods.

4.<em> After the constructor for class B executes, the variable b will have the value 8</em> - True.

When object of class B is declared, its constructor was called, which initialized variable b to 8.

4 0
3 years ago
Norman Bates has a very unusual hobby what is it?
Allushta [10]

Answer:

<h3>Norman only likes to stuff birds, not other animals.</h3>
8 0
3 years ago
What is the error in the following pseudocode?
kykrilka [37]
I do not know the answers sorryy
4 0
2 years ago
Pls help due tonight<br>Will give brainiest
katrin2010 [14]
HIPPA law is Health Insurance Portability and Accountability Act of 1996. It’s a federal law that helps consumers maintain their insurance coverage.
8 0
3 years ago
Read 2 more answers
Other questions:
  • When you are shopping online and finalizing your order, you usually fill in forms for your name, address, email, and payment met
    6·1 answer
  • “Green Technology” is also known as what?
    11·1 answer
  • Which of the following controls will provide an area in the form for the user to enter a name? a. button b. label c. text box d.
    8·1 answer
  • What is the value of variable num after the following code segment is executed?
    5·1 answer
  • 1. Write a recursive method to determine if a character is in a list of characters in O(logN) time. Mathematically prove (as we
    13·1 answer
  • Oxnard Casualty wants to ensure that their e-mail server has 99.98 percent reliability. They will use several independent server
    14·1 answer
  • ________ allows the computer to get its configuration information from the network instead of the network administrator providin
    5·1 answer
  • Which of the following is true of information systems?
    15·1 answer
  • 8.2 Code Practice Edhesive
    6·1 answer
  • CODEHS- Please help!
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!