Writing essays for school can be difficult but
many students find that by researching their topic that they
have more to say and are better informed. Here are the university
we require many undergraduate students to take a first year writing requirement
so that they can
have a solid foundation for their writing skills. This comes
in handy for many students.
Different schools have different requirements, but everyone uses
writing at some point in their academic career, be it essays, research papers,
technical write ups, or scripts.
Data: studentdata.txt
joe 10 15 20 30 40
bill 23 16 19 22
sue 8 22 17 14 32 17 24 21 2 9 11 17
grace 12 28 21 45 26 10
john 14 32 25 16 89
Data: travel_plans.txt
This summer I will be travelling.
I will go to...
Italy: Rome
Greece: Athens
England: London, Manchester
France: Paris, Nice, Lyon
Spain: Madrid, Barcelona, Granada
Austria: Vienna
I will probably not even want to come back!
However, I wonder how I will get by with all the different languages.
I only know English!
The textfile, travel_plans.txt, contains the summer travel plans for someone with some commentary. Find the total number of characters in the file and save to the variable num.
Checkpoint5.15.2.
We have provided a file called emotion_words.txt that contains lines of words that describe emotions. Find the total number of words in the file and assign this value to the variable num_words.
Checkpoint5.15.3.
Assign to the variable num_lines the number of lines in the file school_prompt.txt.
Checkpoint5.15.4.
Assign the first 30 characters of school_prompt.txt as a string to the variable beginning_chars.
Checkpoint5.15.5.
Challenge: Using the file school_prompt.txt, assign the third word of every line to a list called three.
Checkpoint5.15.6.
Challenge: Create a list called emotions that contains the first word of every line in emotion_words.txt.
Checkpoint5.15.7.
Assign the first 33 characters from the textfile, travel_plans.txt to the variable first_chars.
Checkpoint5.15.8.
Challenge: Using the file school_prompt.txt, if the character βpβ is in a word, then add the word to a list called p_words.
Checkpoint5.15.9.
The hello function is in the scope,
while var_x is in the scope.
Checkpoint5.15.10.
:
What does the following code print? Be sure to examine the current state of the program what will happen on the next executable line. Select as many as apply.
an error
This is a correct. The code reads top to bottom and we hit an error of hello() not being defined before any prints happen.
5
Hmm, this is inside the hello() function. Does our code get that far?
Hello there, I am a method.
Hmm, this is inside the hello() function. Does our code get that far?
x
x is a variable, not the value. You can tell because it doesnβt have quotes
10
Hmm, this is at the bottom of our code. Does our code get that far?
Checkpoint5.15.11.
Given the image below, select the lines of code that call a function.
Remember, the () indicate a function (even if there is something between them) and that lines that start with def are DEFINING a function, not calling one.
import pickle as pimport random as rimport string as sdef say_hello():var_x = "Matilda":print("hi there ", var_x)def snacks():say_hello()print("I love snacks")say_hello()type_y ="say_hello()"