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]
3 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]3 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
A Windows systems administrator should use the Administrator account ________.a. As little as possible, and only when needed b.
torisob [31]

Answer:

a. As little as possible, and only when needed

Explanation:

6 0
3 years ago
. Write a recursive function names factorial to compute the factorial of the parameter. Also write the main function, where you
r-ruslan [8.4K]

Answer:

Following are the code in c language

#include <stdio.h> // header file

long int factorial(int n); // declaration of factorial function

int main() // main function

{

   int n; // variable declaration

   printf("Enter a positive integer: ");

   scanf("%d", &n); // input number

   while(n<0) // checking the condition if number is negative

{

    printf("please enter a positive number:");

    scanf("%d", &n);

}

   printf("Factorial of %d = %ld", n, factorial(n)); // calling  factorial function

   return 0;

}

long int factorial(int n1) // recursive definition of factorial

{

   if (n1 >= 1)

       return n1*factorial(n1-1);

   else

       return 1;

}

Explanation:

In this program, it ask for a positive number input. if the value enter by user is negative then it again ask for positive input i.e positive number. Then it calls the recursive function of factorial. the recursive function factorial calculate the factorial recursively. suppose user input 4 then it goes to the if  part of program i.e return n*factorial(n-1); that means return 4*factorial(3) again recursive function call itself .this process repeated until it meets the base condition.  when a base condition meets, it return factorial of the given number.

output

Enter a positive integer: 5

factorial of 5=120

Enter a positive integer: -8

please enter a positive number:4

factorial of 4=24

4 0
3 years ago
What does the line of red semicircles mean on a weather map
Aliun [14]

A line of red semicircles indicates a warm front on a weather map

Explanation:

Weather fronts are those visible colorful lines that we see moving across weather maps. They represent boundaries that separate two air masses of different air temperatures and humidity. A good example of weather fronts are warm fronts. A Warm frontal type is warm air that moves and advances rapidly towards the cold air to replace the rather cooler air that stands in its path. It sort of collides with the cold air. When this happens, the weather becomes more humid and warm. It is symbolized by a red curved line with red semicircles. The red semicircles are pointed towards the direction of the warm air.

Learn more about Weather fronts in the links attached below

brainly.com/question/3596743

brainly.com/question/828505

#LearnWithBrainly

5 0
3 years ago
Select the correct answer from each drop-down menu.
mihalych1998 [28]

Answer:

i dont know

Explanation:

they block every thing for smoe reason

3 0
3 years ago
If cost of 1 kg sugar is 36 find price of 3 kg sugar​
SashulF [63]

Answer:

the answer is 108

Explanation:

3×36=108

7 0
3 years ago
Other questions:
  • Public class Car {
    15·1 answer
  • Write a short Python function, is_multiple(n, m), that takes two integer values and returns True is n is a multiple of m, that i
    9·1 answer
  • Name the months that have 30 days​
    6·2 answers
  • What are reserved words in C programming?
    9·1 answer
  • Why won’t my Nintendo Switch connect to the internet?
    7·1 answer
  • Why transport layer is usingconnectionless services if network layer is providing connection oriented services?
    10·1 answer
  • Which statement in switch case structure transfers the control flow outside the structure? switch statement break statement case
    5·2 answers
  • State the name of each of the storage devices described below.
    14·1 answer
  • Write a program that repeatedly reads in integers until a negative integer is read. The program keeps track of the largest integ
    9·1 answer
  • (I'm confused, might as well ask for help)
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!