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
Amiraneli [1.4K]
3 years ago
6

Please use Python 3 to solve the following problem. Please also show all outputs and share code.The variable sentence stores a s

tring. Write code to determine how many words in sentence start and end with the same letter, including one-letter words. Store the result in the variable same_letter_count.Hard-coded answers will receive no credit.sentence = "students flock to the arb for a variety of outdoor activities such as jogging and picnicking"
Computers and Technology
1 answer:
Harman [31]3 years ago
5 0

Answer:

The code is given in Python below with its output.

Explanation:

"""

User is asked to enter the input in sentence

"""

sentence=input("Enter the sentence :")

"""

sentence is converted to list named words

"""

words=sentence.split()

same_letter_count=0

"""

In for loop we access each word

and check character at index 0 and at last index

is same or not.

"""

for word in words:

 if word[0] == word[len(word)-1]:

   same_letter_count+=1

 

print("The same letter count is",same_letter_count)

<u>OUTPUT:: </u>

TEST CASE 1::

Enter the sentence :students flock to the arb for a variety ofoutdoor activities such as jogging and picknicking

The same letter count is 2

TEST CASE 2::

Enter the sentence :i am a bit madam

The same letter count is 3

You might be interested in
Client computers cannot function unless they are connected to the network because they cannot access an operating system.
Shtirlitz [24]

Answer: true

Explanation:

As the operating system cannot run from an external device and in a distributed operating system all the clients needs to be connected to the network to share resources via the distributed or network operating system.

8 0
2 years ago
What was the first carbonated drink to be introduced in the US?
adelina 88 [10]
Taco bell...........................................................................................................................................................................

6 0
3 years ago
Aaron bought a photo-editing software package for personal use. He makes two copies of the software, in case the original softwa
Korvikt [17]

Aaron's action is considered legal, as you are allowed to make a backup copy of a legal copy of a software, but it can only be used in case the original software is destroyed or unusable.

5 0
3 years ago
SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick R
Ne4ueva [31]

Answer:

Check the explanation

Explanation:

CODE:-

import java.util.*;

class UserName{

  ArrayList<String> possibleNames;

  UserName(String firstName, String lastName){

      if(this.isValidName(firstName) && this.isValidName(lastName)){

          possibleNames = new ArrayList<String>();

          for(int i=1;i<firstName.length()+1;i++){

              possibleNames.add(lastName+firstName.substring(0,i));

          }  

      }else{

          System.out.println("firstName and lastName must contain letters only.");

      }

  }

  public boolean isUsed(String name, String[] arr){

      for(int i=0;i<arr.length;i++){

          if(name.equals(arr[i]))

              return true;

      }

      return false;

  }

  public void setAvailableUserNames(String[] usedNames){

      String[] names = new String[this.possibleNames.size()];

      names = this.possibleNames.toArray(names);

      for(int i=0;i<usedNames.length;i++){

          if(isUsed(usedNames[i],names)){

              int index = this.possibleNames.indexOf(usedNames[i]);

              this.possibleNames.remove(index);

              names = new String[this.possibleNames.size()];

              names = this.possibleNames.toArray(names);

          }

      }

  }

  public boolean isValidName(String str){

      if(str.length()==0) return false;

      for(int i=0;i<str.length();i++){

          if(str.charAt(i)<'a'||str.charAt(i)>'z' && (str.charAt(i)<'A' || str.charAt(i)>'Z'))

              return false;

      }

      return true;

  }

  public static void main(String[] args) {

      UserName person1 = new UserName("john","smith");

      System.out.println(person1.possibleNames);

      String[] used = {"harta","hartm","harty"};

      UserName person2 = new UserName("mary","hart");

      System.out.println("possibleNames before removing: "+person2.possibleNames);

      person2.setAvailableUserNames(used);

      System.out.println("possibleNames after removing: "+person2.possibleNames);

  }

}

Kindly check the attached image below for the code output.

5 0
3 years ago
What two tabs does Outlook have that PowerPoint does not? View and Send/Receive Folder and Home Folder and Home Send/Receive and
grin007 [14]
<h2>What are the ribbon tabs in Microsoft Outlook?</h2>

The main Outlook menu has a ribbon tab with default commands. File, Home, Send/Receive, Folder, and View are commands on the main ribbon tab. The Backstage view is where you can see information and options pertaining to the user account and settings.

3 0
2 years ago
Other questions:
  • A laptop computer has two internal signals: An unplugged signal, which is '1' if the laptop's power supply is connected, and '0'
    5·1 answer
  • If Denise specifies Jan? as a search criterion, Excel will locate all of the following records EXCEPT ____.
    9·1 answer
  • Write a code that makes a 2D square array with 20×20 elements. Fill the array with random numbers initially. Then, "draw" a squa
    9·1 answer
  • You need to write a program that calculates and displays the revenue earned from ticket sales at a movie theater. Input: Prompt
    11·1 answer
  • Which term describes the second core IPSec security protocol; it can perform authentication to provide integrity protection, alt
    13·1 answer
  • Which of the selection below does not represent a workable IP address?
    9·1 answer
  • Which page feature is used in long documents to assist readers in quickly finding information in the document without having to
    11·2 answers
  • I’m gonna ask this again because I REALLY need an answer.
    10·2 answers
  • Can someone help me so I don’t fail this class:(
    14·1 answer
  • What causes the hidden node problem in a wireless local area network (wlan)?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!