Is there a way to shorten the code of the function

Assignment Help Python Programming
Reference no: EM132400508

Reading and understanding Python code

Consider the following function, in which the names for the function, parameters and local variables (i.e., variables inside the function) are deliberately not made meaningful:
 
def a(b):
b = b.upper()
c = b.split()
d = " "
for e in c:
d + e[0]

return d

a. What will be printed to the screen when the function is used in the following way?

with open('computer_terms.txt., encoding-'utf8') as infile:

for line in infile:

print(a(line.strip()))

1 # run the above code and show the results

b. Explain step by step each function statement, by referring to the data type involved, and the manipulation performed.

• your

• step

• by

• step

• explanation

• here (double click to edit).

c. Redefine the function by using appriopriate and meaningful names for function, parameter, and local variables. In [ ): I # your code here

d. Is there a way to shorten the code of the function? If so, what do you propose as shorter code?

2. Alliterated names

Write a function alliterated_names ( filename) that reads lines of a text file with personal information (first name, last name, and age, in that order; consult names_ages . txt ), checks the first and last name on alliteration (i.e., first name and last name start with the same letter), and returns a list of alliterated names consisting of last name and first name, in that order, and without age.

3. Loquacious locutions

a. Implement a function longest_worde (filename) that reads a file, tokenizes it, and returns the 10 longest words with their length.

b. Implement a function most_frequent_long_worde (filename) to report the 10 most frequently used long words (15 letters or more) in a file.

Reference no: EM132400508

Questions Cloud

What has been the most difficult component : Identify the components of implementing your evidence-based practice project. What has been the most difficult component, and why? What do you think has gone.
What actions need to be taken to prepare for the survey : What is the relationship between an organization's achievements in meeting National Patient Safety Goals and the results of the Joint Commission survey?
What gaps in the findings did you encounter : When reviewing the literature and different types of evidence for your project, what gaps in the findings did you encounter? How could these gaps influence.
How would each of the findings be used : What is the difference between statistically significant evidence and clinically significant evidence? How would each of these findings be used to advance.
Is there a way to shorten the code of the function : What will be printed to the screen when the function is used in the following way? Explain step by step each function statement.
What are the benefits of the recommendation : Through a published schedule and set of guidelines, the Centers for Disease Control and Prevention (CDC) and public health officials recommend that every child.
L/615/2702 managing continuous organisational improvement : Unit L/615/2702 Managing Continuous Organisational Improvement Assignment Help and Solution, ATHE Level 7 Diploma in Management - Assessment Writing Service
Why specific article is important to your course project : Cite the article and provide your own analysis of it. Use the general outline for analyzing a research article from the Analyze Results page (link given in the)
How do you see improvement ideas integrated into work : Discuss if your own project might work as an improvement project. How do you see improvement ideas integrated into your own work? Post according to the Faculty.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd