Fundamentals of algorithms and programs
First, please run the preparation cell with the code.
In [ ]:
Pkg.add(["HttpCommon", "EzXML"])
In [ ]:
# It may take about a minute to install a new library.
using HttpCommon, EzXML
print("Libraries are ready!")
Calculating the value of a simple mathematical expression
Calculate the value of the expression at the point .
In [ ]:
y = sin(2.1) + 13^2.1
Out[0]:
In [ ]:
function iseven_f(x)
if (x % 2) == 0
print("even number")
else
print("odd number")
end
end # comment
Out[0]:
Checking the function
In [ ]:
iseven_f(3)
In [ ]:
iseven_f(2)
Conclusion of HTML analysis results in a cycle-deadlines
The line with the HTML code is given:
<td valign="top">First</td><td width="580" valign="top">The second</td><td>The third</td>
Print the text of all the elements in the loop td, which have the property valign equally top.
In [ ]:
txt = """<td valign="top">The first one</td>"580" valign="top">The second one</td><td>Third</td>"""
doc = parsehtml(txt)
html = root(doc)
xpath = "//td[@valign=\"top\"]"
for el in findall(xpath, html)
print(el)
end