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
Lyrx [107]
4 years ago
14

"Players The files SomePlayers.txt initially contains the names of 30 football play- ers. Write a program that deletes those pla

yers from the file whose names do not begin with a vowel."

Computers and Technology
1 answer:
kumpel [21]4 years ago
8 0

Answer:

I am writing a Python program that deletes players from the file whose names whose names do not begin with a vowel which means their names begin with a consonant instead. Since the SomePlayers.txt is not provided so i am creating this file. You can simply use this program on your own file.

fileobj= open('SomePlayers.txt', 'r')  

player_names=[name.rstrip() for name in fileobj]  

fileobj.close()  

vowels = ('a', 'e', 'i', 'o', 'u','A','E','I','O','U')

player_names=[name for name in player_names  

                     if name[0] in vowels]

fileobj.close()

print(player_names)

Explanation:

I will explain the program line by line.

First SomePlayers.txt is opened in r mode which is read mode using open() method. fileobj is the name of the file object created to access or manipulate the SomePlayers.txt file. Next a for loop is used to move through each string in the text file and rstrip() method is used to remove white spaces from the text file and stores the names in player_names. Next the file is closed using close() method. Next vowels holds the list of characters which are vowels including both the upper and lower case vowels.

player_names=[name for name in player_names  

                     if name[0] in vowels]

This is the main line of the code. The for loop traverses through every name string in the text file SomePlayers.txt which was first stored in player_names when rstrip() method was used. Now the IF condition checks the first character of each name string. [0] is the index position of the first character of each players name. So the if condition checks if the first character of the name is a vowel or not. in keyword is used here to check if the vowel is included in the first character of every name in the file. This will separate all the names that begins with a vowel and stores in the list player_names. At the end the print statement print(player_names) displays all the names included in the player_names which begin with a vowel hence removing all those names do not begin with a vowel.

You might be interested in
What were the advantages and disadvantages of agricultural technology to us.
Digiron [165]

Advantages of technology in agriculture include expediting crop production rate and crop quantity, which in turn reduces costs of production for farmers and food costs for consumers, and even makes crops more nutritious and livestock bigger and meatier.

The excessive use of chemicals by the help of machines reduces the fertility of the land.Lack of practical knowledge the farmers cant handle the machines properly.While the cost of maintenance is very high.Overuse of machines may lead to environmental damage.It is efficient but has many side effects and drawbacks.

5 0
3 years ago
Read 2 more answers
Which button is used to set up the pen color?
Mrac [35]
C. custom slideshow because this is where you can customise everything you do eg. pen colour, don't etc.
5 0
4 years ago
Read 2 more answers
Java 2D Drawing Application. The application will contain the following elements:
kenny6666 [7]

Answer:

sadness and depression is my answer

Explanation:

5 0
3 years ago
If your computer requires that you install memory in pairs, it doesn't matter if the two memory modules are the same type, size,
monitta

Answer:

False

Explanation:

If your computer requires that you install memory in pairs you should always keep in mind that

1. Both are the same type(DDR4+DDR4, DDR3+DDR3, DDR2+DDR2...)

2. Both are the same size (2GB+2GB, 4GB+4GB, 8GB+8GB...)

3. Both are the same speed (800MHz+800MHz, 1666MHz+1666MHz, 3200MHz+3200MHz...)

This is important, because of the predefined slots that are located on the Motherboard.

Although you can change the RAM speed from the BIOS you can not change the predefined slot values

5 0
4 years ago
Letter diagrams are least useful for showing:
ser-zykov [4K]
The answer is c .....
4 0
3 years ago
Other questions:
  • What are the main types of software? Explain with appropriate examplesWhat are the main types of software? Explain with appropri
    12·2 answers
  • 2. Because technology is always changing, there are new applications being developed constantly. (1 point)
    9·2 answers
  • The jaws of ________ chucks are advanced and retracted independently of each other and allow for fine-tuning the position of the
    6·1 answer
  • Is there anyone who is learning coding if so then can you tell me how to be perfect in coding​
    14·1 answer
  • What process does a system use to officially permit access to a file or a program CIS 502 ?
    11·1 answer
  • Worksheet titles and subtitles should be as wordy as possible.<br> a. True<br> b. False
    9·2 answers
  • The two fundamental approaches to moving data through a network of links and switches are
    9·1 answer
  • Use knowledge of the actions and adverse effects of NSAIDs to choose the correct statement.
    13·1 answer
  • Select the correct answer.
    5·1 answer
  • Name the major types of computer systems from slowest to fastest. ​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!