-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture "Algorithms", exercise 1 #4
Comments
The result is 2
First test, is A in C? A is in C ---> score is increased by 1 --> 0 + 1 = 1 |
The output will be "2" because both "HTML" and "Peroni" are in the bibliographic entry. |
The output is 2, given the fact that both HTML and Peroni are included in the bibliographic entry. |
Following the flowchart in Fig. 4 I wrote a Python algorithm to find the result:
The output is 2! |
The result (return) =2 since both the words "HTML" and "Peroni" are contained in the bibliographic entry. |
string1 = "Peroni" bibentry = "Peroni, S., Osborne, F., Di Iorio, A., Nuzzolese, A. G., Poggi, F., Vitali, F., Motta, E. (2017). Research Articles in Simplified HTML: a Web-first format for HTML-based scholarly articles. PeerJ Computer Science 3: e132. e2513. DOI: https://doi.org/10.7717/peerj-cs.132" if string1 or string2 in bibentry: if string1 and string2 in bibentry: print (sum) output: 2 |
The output would be 2 because both strings/words, "Peroni" and "HTML", are included in the bibliographic entry, if you consider them both together. If instead you consider just one of them at time, the output would be 1. |
Both the words "Peroni" and "HTML" are contained in the bibliographic entry, so the output is 2. |
Bibliographic entry: Both "HTML" and "Peroni" appear in the bibliographic entry, therefore the result is 2. |
output = 2 |
“Peroni” and “HTML” are both parts of the input value. Hence, the result is 2. Followed Path: … —> Initialise the result value to 0 —> The first word (“Peroni”) is in the bibliography entry —> Sum 1 to the result value —> The second word (“HTML”) is in the bibliography entry —> Sum 1 to the result value —> Return the result value (“2”) —> … |
@delfimpandiani, while the answer to the exercise is correct, the pseudocode describe a different flow, in particular in the instruction:
This instruction will be executed if and only if the condition in the previous Similarly, @simayguzel and @ilsamoano, the two |
Hi Prof,
If I change both the values of A and B the result is 0 despite “Computer” is a word in Def
|
Sorry guys, you are totally right. I really don't know how I've read "elif" instead of "if". Apologies. |
What is the result of the execution of the algorithm in Figure 4 using
"Peroni"
,"HTML"
, and"Peroni, S., Osborne, F., Di Iorio, A., Nuzzolese, A. G., Poggi, F., Vitali, F., Motta, E. (2017). Research Articles in Simplified HTML: a Web-first format for HTML-based scholarly articles. PeerJ Computer Science 3: e132. e2513. DOI: https://doi.org/10.7717/peerj-cs.132"
as input values?The text was updated successfully, but these errors were encountered: