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
Basic python coding, What is the output of this program? Assume the user enters 2, 5, and 10.
r-ruslan [8.4K]

Answer:

17.0

Explanation:

after first loop numA = 0.0 + 2 = 2.0

after second loop numA = 2.0 + 5 = 7.0

after third loop numA = 7 + 10 = 17.0

8 0
3 years ago
What can multivariable calculus show for a data set.
dalvyx [7]

Answer:

They can help to explain the relationship between the output and input variables.

Hope this Helps!

5 0
2 years ago
The function below takes one parameter: a list of numbers (num_list). Complete the function to return a new list containing only
agasfer [191]

Answer:

Following are the program in the Python Programming language.

#define function

def negative_num(num_list):

 #set list type variable

 nlist=[]

 #set the for loop

 for n in num_list:

   #check negative numbers

   if(n<0):

     #add the value of n in list

     nlist.append(n)

 #return list

 return nlist

#set new list type variable that store list

newl=[-5,8,-6,3,-4,9,-7]

#print and call the function

print(negative_num(newl))

<u>Output</u>:

[-5, -6, -4, -7]

Explanation:

Here, we define the function "negative_num" and pass an argument "num_list" in its parameter and inside the function.

  • Set new list data type variable "nlist".
  • Set the for loop which iterate as the list.
  • Set the if conditional statement to check the value of the list is less than 0 then, add that negative values in the variable "nlist".
  • Then, return the new list.

Finally, we set a variable "newl" which store the list of negative and positive numbers then, we print and call the function.

6 0
3 years ago
Can someone help me?
alina1380 [7]

*☆*――*☆*――*☆*――*☆*――*☆*――*☆*――*☆*――*☆**☆*――*☆*――*☆*――*☆

Answer: Try restarting the computer

I hope this helped!

<!> Brainliest is appreciated! <!>

- Zack Slocum

*☆*――*☆*――*☆*――*☆*――*☆*――*☆*――*☆*――*☆**☆*――*☆*――*☆*――*☆

6 0
3 years ago
Read 2 more answers
Most common level of education for a programmer or software developer
shusha [124]

c/c+ also java would be one

8 0
3 years ago
Other questions:
  • An administrator has just added a new update to the WSUS server and she wants to test the update to the test group. Which of the
    9·1 answer
  • You need to put cabling for connecting two new computers in a room, which did not have any network infrastructure. Because of th
    9·2 answers
  • Write a program that prompts the user to enter the weight of a person in kilograms and outputs the equivalent weight in pounds.
    8·1 answer
  • Write a C++ program that determines if a given string is a palindrome. A palindrome is a word or phrase that reads the same back
    6·1 answer
  • You can use the ____ utility to zero in on the service or other program that is slowing down startup. 1. gpupdate 2. MSconfig 3.
    9·1 answer
  • While doing online research you enter this keyword search with a truncation character: man* Which of the following would not be
    15·1 answer
  • During which part of geologic time were dinosaurs most common?
    11·2 answers
  • What was the basic invention that has evolved into the modern automobile?
    13·1 answer
  • JUST MAXED OUT THE COMMENTS anyways come here
    7·2 answers
  • Please help me ASAP!
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!