TUTORIAL 3 - Python

Tutorial
Quarto
Literate Programming
Python
Published

January 19, 2023

IMPLEMENTING PYHTON IN QUARTO

I relied heavily on the Quarto documentation for this tutorial.

The basic things I learned were:

  1. Install Python (again). I downloaded the newest version from the Python website.
  2. Install the `jupyter’ package using the terminal:
  • Windows: py -m pip install jupyter
  • Mac: python3 -m pip install jupyter
  1. Install the modules you need using the terminal (Mac examples below):
  • python3 -m pip install numpy
  • python3 -m pip install matplotlib

After I did this, the code from the Quarto website example (below) seemed to work!

QUARTO EXAMPLE CODE

For a demonstration of a line plot on a polar axis, see ?@fig-polar.

Code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pandas as pd
Code
options = webdriver.SafariOptions()
driver = webdriver.Safari(options=options)

def test_eight_components():
    driver = webdriver.Chrome()

    driver.get("https://www.selenium.dev/selenium/web/web-form.html")

    title = driver.title
    assert title == "Web form"

    driver.implicitly_wait(0.5)

    text_box = driver.find_element(by=By.NAME, value="my-text")
    submit_button = driver.find_element(by=By.CSS_SELECTOR, value="button")

    text_box.send_keys("Selenium")
    submit_button.click()

    message = driver.find_element(by=By.ID, value="message")
    value = message.text
    assert value == "Received!"

    driver.quit()