I am doing a beginner Python programming course and this is my final assignment. I HAVE ONLY ATTACHED THE ASSIGNMENT PAPER but in order to do the exercises i have a total of 11 other text files. The...

1 answer below »
I am doing a beginner Python programming course and this is my final assignment. I HAVE ONLY ATTACHED THE ASSIGNMENT PAPER but in order to do the exercises i have a total of 11 other text files. The support (John) told me that I can send these to you with the email ID afterwards because I was only allowed to attach 5 files here. N.B. Since I am doing a beginners course(started 6months ago), the programming does not have to be very complex. The topics we discussed in class were: Data types, Loops, Conditionals, Functions, Files, Tuples, Modules, Programmer-defined types
The exercises should be possible to be answered with these topics. If you have any other question then let me know please.


Final Assignment  Language Processing in Python  Due date and time:  This assignment is due on ​Friday the 15th of January at 23:59 CET​. Make sure you submit  your assignment well in time, because the assignment submission system on Brightspace  will close at 23:59 CET sharp.  Assignment and submission instructions:   For coding questions answers in Python code are preferred. If you get stuck, answer as  much as you can, in pseudocode, natural language or a combination of code and language.  You can get some points for solving part of the task and/or showing that you've thought  through the steps that need to be taken.  In ​Repl.it​, create a separate .py file (using the "Add file" button) for each exercise. Name  each of those .py files something like final_ex_01.py, etc. You can then write code (or use  comments to answer in written text) in each separate exercise script. To run that code,  you'll then have to import each of your separate exercise scripts into the main script called  main.py by typing import (leaving out the .py extension at the end of the  filename). It should look something like this:    When you've finished the assignment, download all your files at once (i.e. your entire "repl")  using the "Download as zip" option in ​Repl.it​, add your student number to the filename of  that .zip file, and then upload the .zip file to Brightspace (under "Assignments").  1 https://repl.it/ https://repl.it/ Exercises:    1. Indicate for the following tasks whether it would be better to do it manually or to  write a Python script for it and explain your choice.    a) You have a digital book in a text file and want to count the distribution of the  different determiners.  b) You have three books in three text files and you want to count the number of  chapters in each book  c) You have 200 tweets and want to determine of each one whether it is sarcastic or  not.  d) You are giving a big party and have to send 100 invitations. For most invitations  only the header (Dear Xxx) differs, but for seven close friends you want to send a  more personal invitation.  e) Your nephew is going to primary school and gets a list of 100 sums (additions with  numbers 1-20) as homework. You want to check his answers.    2. On Brightspace you can find the file triviaquiz.py. It contains python code for playing  a little quiz. It contains 5 errors. Your task is to run the code, describe the error you  come across and how you resolved it, run the script again and repeat until the script  is free from errors. Finally, give the script without the errors. ​Note ​that not all of the  errors in the script will cause an error message; that is, there are some  semantic/logical errors in the script. (​Hint:​ To test the script properly, make sure  you check both the right and the wrong answer to a quiz question as input.)    3. On Brightspace you can find the file top3000words.txt with the 3000 most frequent  English words. Write a script that contains a function that creates a wordstring  starting from a word given by the user, using the words in the file. The words are  strung together in such a way that the last letter of a word and the first letter of the  next word are the same (like word​s-s​tring​s-s​an​d-d​irec​t-t​oo​l-l​ik​e-e​tcetera). The  function is called with two arguments: the word given by the user and the wordlist  from the file. It should return the length of the wordstring that is created and the  wordstring itself. Two further restrictions: each word can appear only once in the  wordstring and the order of the list with words should be random.    In this exercise you have to give your answer in a Python script. On Brightspace you can  find the file wordstring.txt in which this problem is broken down to smaller steps. If you  want, you can use this and convert the steps in it to Python code.    2 4. Wednesday 16-12-20 was Pythagorasday. It is called after the famous law of  Pythagoras: a²+b²=c². In this case it means that day*day + month*month =  year*year, because 16² + 12² = 20². Write a script that computes all Pythagoras days  in a century and prints them to screen.    5. On Brightspace you can find a text file called "map_task_transcript.txt", which  contains a transcript of two participants playing the ​Map Task​ (this transcript was  taken straight from the ​HCRC Map Task Corpus​). This is a task where one participant  (known as the instruction-giver; denoted "g" in the transcript) gives instructions to  another participant (known as the instruction-follower; denoted "f" in the transcript)  telling them how to draw a route on a map. Below is an example of what the  transcript looks like:    Imagine you're a language scientist who is interested in how often the ​continuer  (a.k.a. ​backchannel​) "mmhmm" is used in this type of task-oriented conversation.  Write a script that counts how many lines pass by between each time the  instruction-follower ("f") says "mmhmm". Your script should return the ​maximum  number of lines that passes by between two uses of "mmhmm" by the follower in  this transcript. (Note: The transcription is standardised in such a way that  "mmhmm" is always spelled exactly as "mmhmm".)    6. On Brightspace you can find the file 3tspl.txt. Your task is to count the percentage of  five groups of characters: vowels, consonants, digits, spaces and punctuation in the  text. Thus we get five numbers that add up to 100 (because of rounding errors, this  can deviate a tiny bit): that of letters a,e,i,o,u that of all other letters, that of all digits,  that of all spaces and that of all other characters.    7. On Brightspace you can find the files I_and_you.txt and you_and_I.txt. You have to  append the second file to the first, but before doing so, you have to change the ‘I’ in  the second file to ‘you’ and vice versa. While doing so you have to make sure that  the sentences stay grammatical. Thus ‘I am’ becomes ‘you are’ etc.    For example: the sentence ‘​I am​ running with ​you​ and​ your​ brother’ becomes ​‘You  are​ running with ​me​ and ​my​ brother’.            3 http://groups.inf.ed.ac.uk/maptask/maptask-description.html http://groups.inf.ed.ac.uk/maptask/ https://glossary.sil.org/term/continuer https://en.wikipedia.org/wiki/Backchannel_(linguistics) 8. A DNA sequence consists of many occurrences of four basic elements: represented  by A, C, G, T. Genomic DNA is double-stranded. This means that for each strand of  DNA with a given sequence, there is an opposite strand that contains the  complementary sequence where A complements T and G complements C. When  representing both strands of the DNA molecule, we need to write both the forward  and reverse strands, following the Watson-Crick rule that says that every A=T and  vice versa and every G=C and vice versa. The forward strand is written in the 5’->3’  orientation, whereas the reverse strand is written in the 3’->5’ orientation. This is  noted by putting 5’- at the beginning of the string and -3’ at the and, or the other  way round.    For example:   5’- ATCGTGCA-3’ is a forward strand and its opposite strand is 3’-TAGCACGT-5’. Thus  the order is the same, but A and T are swapped, as are C and G and 5’ and 3’.    Write a script that contains two functions. The first takes two DNA sequences as  parameters and checks whether one is the opposite strand of the other. The second  function takes one DNA sequence and produces the opposite strand. On  Brightspace you will find two files on which you have to apply your respective  functions: DNA_two_strands.txt (with a forward and its opposite strand (or vice  versa), separated by a space) and DNA_one_strand.txt. Write the result in two  separate files.     9. On Brightspace you can find a text file called "itsy_bitsy_text.txt", which contains the  nursery rhyme​ Itsy Bitsy Spider​ (known as ​Hansje Pansje Kevertje​ in Dutch) in plain  text, as well as a text file called "itsy_bitsy_phonetic.txt", which contains a phonetic  transcription of the same nursery rhyme according to the ​International Phonetic  Alphabet​ (IPA). Your task is to find out for each pair of lines in this nursery rhyme  whether they are a case of "​eye rhyme​" (where ​two words are spelled similarly but  pronounced differently) or whether the final syllables of the two sentences are really  pronounced the same. In both text files, syllables are separated by the dot/full stop  character: ".". However, what matters for checking whether two lines rhyme is not  the entire final syllable, but only the final, "​rime​", part of the final syllable (i.e. the  nucleus+coda of the syllable; for those of you familiar with ​syllable structure​). In the  file ​"itsy_bitsy_phonetic.txt", ​the rime part of each syllable is separated from the  beginning (i.e. onset) of the syllable by an underscore: "_". Here's an example of  what the first two lines of​ Itsy Bitsy Spider​ looks like with that transcription format:    Here,​ sp_aʊt ​ is the final syllable of the first line, and ​aʊt ​ is the rime (i.e.  nucleus+coda) of that syllable.  4 https://en.wikipedia.org/wiki/International_Phonetic_Alphabet_chart https://en.wikipedia.org/wiki/International_Phonetic_Alphabet_chart https://en.wikipedia.org/wiki/Eye_rhyme https://en.wikipedia.org/wiki/Syllable#Rime https://en.wikipedia.org/wiki/Syllable#Grouping_of_components Write a script that does the following for each ​pair of lines​ (i.e. lines 1-2, lines 3-4,  etc.) ​in the phonetic transcription file "itsy_bitsy_phonetic.txt"​:  1. Checks whether the rime of the final syllable of both lines is the same.  2. If the outcome of check 1 is False, we have a case of eye rhyme. (Because as  you can see in the plain text file "itsy_bitsy_text.txt", each of the rimes of the  final syllables do have the same spelling.)   3. Your script should give as output a dictionary that contains the line pair  numbers as keys (e.g. "1-2" for the first pair of lines, "3-4" for the second pair  of lines, etc.), and Booleans as the corresponding values, which should be  True if that line pair is a case of eye rhyme, and False otherwise.      5
Answered 6 days AfterJan 07, 2021

Answer To: I am doing a beginner Python programming course and this is my final assignment. I HAVE ONLY...

Swapnil answered on Jan 14 2021
140 Votes
# Q3--------------------------------------------------------------------------
def FirstAndLast(string):
for i in range(len(string)):
if i == 0:
print(string[i], end = "")
if i == len(string) - 1:
print(string[i], end = "")
if string[i] == " ":
print(string[i - 1],
string[i + 1], end = "")
if __name__ == "__main__":
string = "words strings sand direct tool like etce"
FirstAndLast(string)
# Q4 ---------------------------------------------------------------------------
def pythagoreanTriplets(limits) :
c, m = 0, 2
while c < limits :
for n in range(1, m) :
a = m * m - n * n
b = 2 * m * n
c = m * m + n * n
if c > limits :
break
print(a, b, c)
m = m + 1
if __name__ == '__main__' :
limit = 20
pythagoreanTriplets(limit)
# Q5--------------------------------------------------------------------------------------
import sys
def maxLines(n, x1, y1, x2, y2):
s = [];
slope=sys.maxsize;
for i in range(n):
if (x1[i] == x2[i]):
slope = sys.maxsize;
else:
slope = (y2[i] - y1[i]) * 1.0 /(x2[i] - x1[i]) * 1.0;
s.append(slope);
return len(s);
n = 2;
x1 = [ 1, 2 ];
y1 = [1, 2];
x2 = [2, 4];
y2 = [2, 10];
print(maxLines(n, x1, y1, x2, y2));...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here