Write a python program to print a poem of your own choice. Then count how many words in each line, use a print statement to add the number of words in each line and display it. Hint: use print(3+5+4+6), for example.
My poem: 'Tis better to have loved and lost Than never to have loved at all.'
The code will be
poem='Tis better to have loved and lost Than never to have loved at all.'
print(poem)
print('Number of words - ',len(poem.split()))
The output is

Write a python program to print a poem of your own choice. Then count how many...
Using a Python environment of your choice - 1. Write a program which will, a). read an ASCII file. b). display all of its contents in upper case c). count the total number of words
IN PYTHON 3: Write a Python program to read the attached text file containing words, count the occurrence of each unique word and store the words in alphabetical order in a text file listing the word and the total count of that word. You cannot use any advanced features such as dictionaries. The program requires user input to determine the name of the file. (example of the text file that needs to be read = for a brief moment I...
1. Write a Python function to count how many python function definitions in a given Python program. 2. Write a Python function to return the number of word wrapped lines of given number of characters in a given text file. Inside your function you must do it in a single line of code except docstring and comments.
Write a python program that reads in 5 strings from the keyboard. Count the number of strings that start with 'th'. Display this count. Use a loop
Write a Python program to read lines of text from a file. For each word (i.e, a group of characters separated by one or more whitespace characters), keep track of how many times that word appears in the file. In the end, print out the top twenty counts and the corresponding words for each count. Print each value and the corresponding words, in alphabetical order, on one line. Print this in reverse sorted order by word count. You can assume...
# 3. PUT IN PYTHON CODE # Write a program that prints a count of how many occurrences of the letter "a" # there are in q. Do to this you will have to use a loop within a loop. q = ["apple", "beans", "orange", "tangerine", "butter", "watermelon", "vinegar"] # Type your answer here:
IN PYTHON Write a program in Python with the use of the for function to print a pyramid of letters of n levels To get the pyramid level, ask the user to capture an integer between 1 and 26 Example: 3 output A A B A A B C B A
Write a PYTHON program that asks the user for the name of the file. The program should write the contents of this input file to an output file. In the output file, each line should be preceded with a line number followed by a colon. The output file will have the same name as the input filename, preceded by “ln” (for linenumbers). Be sure to use Try/except to catch all exceptions. For example, when prompted, if the user specifies “sampleprogram.py”...
Python 3:Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order An example file along with the correct output is shown below: example.txt the quick brown fox jumps over the lazy dog Enter the input file name: example.txt brown dog fox jumps lazy over quick the
Homework No.2 CSC 222 Write a shell script program called "countf.sh" that will count how many files or directories recursively. beside the file counts, also report how many files for each types (directory or regular files). It will either take arguments for specific directories and no argument. If no argument, it will read the current working directory as the starting point. Please also provide -h option to print out how to use your countf.sh program % ./countf.sh % ./countf.sh file1...