ITECH1400 Fundamentals of Programming: Sonnets and Doublets Project

Verified

Added on  2025/07/24

|14
|827
|170
AI Summary
Desklib provides solved assignments and past papers to help students succeed.
Document Page
ITECH1400 FUNDAMENTALS OF PROGRAMMING
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Table of Contents
Introduction................................................................................................................................3
Part-I...........................................................................................................................................4
Sonnets...................................................................................................................................4
Implementation of algorithm into Python code:-...................................................................5
Demonstration........................................................................................................................6
OUTPUTS..............................................................................................................................7
Part-II.........................................................................................................................................9
Doublets.................................................................................................................................9
Implementation of Algorithm into Python code:-................................................................10
Demonstration......................................................................................................................11
OUTPUTS............................................................................................................................12
Conclusion................................................................................................................................13
References................................................................................................................................14
2
Document Page
Introduction
This topic is related to the python programming language. In which, there is one assignment
which is divided into two parts sonnets and doublets which we have to complete using the
python programming. Basically, python is a dynamic interpreted language which is very easy
to code. And there is some timelines and expectations to complete this project like time
expectation is 20 hours and deadline date is 30 august 2019.
3
Document Page
Part-I
Sonnets
Algorithm in pseudo-code.
Import the collection package.
Take a function and pass a parameter.
Open the file and use the counter to store the result in dictionary format.
Use the for loop to print the result in the form of dictionary using the counter.
For the second part take an empty list.
Then open the file and read the words of the file and split them.
Append the total length of words in the empty list.
Count the words and store in the new variable.
Then print the counted words using a key and value.
For the third part take a function and pass a value as a parameter.
Open the file and return a counter class method to read and split the words.
Using the for loop read the items from starting to the ending.
Print the result in the form of key and value.
Exit
4
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Implementation of algorithm into Python code:-
Figure 1
Figure 2
5
Document Page
Figure 3
Demonstration
Here is the description of the above given codes. In first part we import all the packages.
Then we made a function and a pass a parameter in it. After that we open the file and using
the counter we store the elements in the form of dictionary which uses the keys and values.
Then using for loop we print the letters by passing the counter class object in for loop. And
print the result in the form of keys and values.
In the second part again we import the packages. And take an empty list. Then we open the
file and using for loop we read the words and split them using the split function. Then we
append the length of words in the empty list. Then we make a variable and passed a
parameter using the counter to print the result in the form of keys and values. Then we print
the key and values using the for loop from that variable.
In the third part, import all the packages, then we made a function and pass a parameter in it.
After that open the file and using the counter, store the words in the form of a dictionary.
Then using the for loop we print the result using the text file.
6
Document Page
OUTPUTS
Figure 4
Figure 5
7
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Figure 6
8
Document Page
Part-II
Doublets
Algorithm in pseudo-code.
Import all the packages that are necessary for the program.
Take two different functions, one is for words and other is for a text file.
Take two variables to store the values one is of list type and other is of set type.
Take another variable to store the values in the form of dictionary.
Append the values in the list type of variable.
Use the for loop to compare the words.
Return the set type variable.
Take the starting and stopping words and store them in two different variables.
Using the while loop print the values in between the words without repeating the
words.
Exit.
9
Document Page
Implementation of Algorithm into Python code:-
Figure 7
10
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Figure 8
Demonstration
To solve the doublets task, first import all the necessary packages. Then using the os package
give the path of text file. Then make two different functions and pass the words and file as a
parameter. Make two different variable one is of list type and other is of set type. Take
another variable to store the values in form of dictionary. Then append the values in the list
type of variable. Then using the for loop compare the values and return it to the set type of
variable. Take the starting and stopping values and printing the values without repeating
them.
11
Document Page
OUTPUTS
Figure 9
12
chevron_up_icon
1 out of 14
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]