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
Natali [406]
3 years ago
13

Python programming questions:

Computers and Technology
1 answer:
Aleksandr-060686 [28]3 years ago
7 0

Answer:

Following are the program in the Python Programming Language:

1.)

l=['Ruby','Dale','Kate']

n=input('Enter the name: ')

if(n in l):

   print('Hello {}'.format(n))

else:

   print('No {}'.format(n))

Output:

Enter the name: Dale

Hello Dale

2.)

file=open("text1.txt", "r+") #open file

str=file.read()  #read file

txt=str.replace('\n', ' ') #replace spaces

word=txt.split(' ') #split words in ' '

for words in word: #set for loop

   word2=' '

   for i in range(len(words)):  #set for loop

       if(words[i].isalpha()):  #set if statement

           word2 += words[i].lower()

   word[word.index(words)]=word2

while(' ' in word):  #set while loop

   word.remove(' ')  #remove spaces

st=set(word)

print('The ', len(st),' unique words which appears in document are ' \

     '(in no particular order): ')

for words in st:  #set for loop

   print('-', word)

file.close()  #close file

3.)

file=open("text1.txt", "r+") #open file

str=file.read()  #read file

txt=str.replace('\n', ' ') #replace spaces

word=txt.split(' ') #split words in ' '

for words in word: #set for loop

   word2=' '

   for i in range(len(words)):  #set for loop

       if(words[i].isalpha()):  #set if statement

           word2 += words[i].lower()

   word[word.index(words)]=word2

while(' ' in word):  #set while loop

   word.remove(' ')  #remove spaces

dic={}  #set dictionary

for words in word:  #set for loop

   if(words not in dic):  #set if statement

       dic[words]=1

   else:

       dic[words] +=1

print('\033[4m' + 'word   frequency' + '\033[0m')

for words in dic:

   print(format(words, '15s'), format(dic[words], '5d'))

file.close() #close file

Explanation:

1.) Here, we define the list data type variable 'l' then, set the variable 'n' and assign value by get input from the user,

  • we set if conditional statement and pass condition is that the variable 'n' is in the variable l then, print message.
  • otherwise, we print No message.

2.) Here, we define the variable "file" in which we open file and save that file in it.

Then, we set variable st which read the file then we set the variable in which we apply the replace().

Then. we set variable in which we split the by suing split()

2.) Here, we define the variable "file" in which we open file and save that file in it.

Then, we set variable st which read the file then we set the variable in which we apply the replace().

Then. we set variable in which we split the by suing split()

Then, we apply all that given in the question.

You might be interested in
How does a typewriter involve math and science?
patriot [66]
You have a specific number of words typed a minute and you need to know the science involved in making it
8 0
3 years ago
Read 2 more answers
In summary, McKibben argues that the inhabitable planet is shrinking because (select all that apply):
Artist 52 [7]

MCKibben argues that the inhabitable planet is shrinking because:

  • Consistently higher temperatures will likely make certain areas uninhabitable
  • Desertification will reduce the amount of harvestable land
  • Coastlines are being lost to sea level rise.

<h3>What is Shrinking?</h3>

This is the process in which an object or place becomes smaller as a result of various activities.

The most suitable options which explains why the planet is shrinking is as a result of a reduction in the areas in which humans can live as a result of the factors mentioned above.

Read more about Planet here brainly.com/question/11157969

7 0
2 years ago
Explain the two filter options available when filtering by a column
dexar [7]
Can you prove more information?
8 0
3 years ago
Read 2 more answers
What should you do if the drive on which you want to install windows server 2012 already has a partition on it containing an ope
Alinara [238K]
Delete those partitions and reformat the drive.
4 0
3 years ago
Computer __ is any part of the computer that can be seen and touched​
iogann1982 [59]
Hardware
Answer. physical parts of computer which can be seen and touched are called Hardware.
3 0
3 years ago
Other questions:
  • Consider the following sequence, defined from n=2 to 15 (inclusive). Pn=n2−1. Produce a list named primes which only contains va
    10·1 answer
  • Who developed the idea of a universal network?
    11·1 answer
  • Survey data are collected by using all of these methods EXCEPT
    12·1 answer
  • A high school in a low-income area offers special programs to help students acquire the technical skills needed to find jobs as
    12·1 answer
  • In our discussion of Computer Hardware, we talked about three essential hardware components that are there inside every computer
    14·1 answer
  • 3.4 lesson practice quiz edhesive
    11·1 answer
  • Explain logic circuit​
    8·1 answer
  • In the program below, numA is a _____.
    8·2 answers
  • Explain the different features available in Print command?
    10·1 answer
  • A hard drive cannot be partitioned until the device <br> is set.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!