# terminal command to install library
! pip install emoji
! Collecting emoji
! Downloading emoji-2.5.1.tar.gz (356 kB)
...
! Successfully installed emoji-2.5.1

Requirement already satisfied: emoji in /home/zachpeltz/nighthawk/zach_2025/venv/lib/python3.12/site-packages (2.12.1)
Requirement already satisfied: typing-extensions>=4.7.0 in /home/zachpeltz/nighthawk/zach_2025/venv/lib/python3.12/site-packages (from emoji) (4.12.2)
/bin/bash: line 1: Collecting: command not found
/bin/bash: -c: line 1: syntax error near unexpected token `('
/bin/bash: -c: line 1: ` Downloading emoji-2.5.1.tar.gz (356 kB)'
/bin/bash: line 1: Successfully: command not found
#!pip install emoji
from emoji import emojize 
print(emojize(":thumbs_up: Python is awesome! :grinning_face:"))
👍 Python is awesome! 😀
#!pip install newspaper3k
! from newspaper import Article
from IPython.display import display, Markdown


urls = ["http://cnn.com/2023/03/29/entertainment/the-mandalorian-episode-5-recap/index.html", 
        "https://www.cnn.com/2023/06/09/entertainment/jurassic-park-anniversary/index.html"]

for url in urls:
   ! article = Article(url)
   ! article.download()
   ! article.parse()
    # Jupyter Notebook Display
    # print(article.title)
   ! display(Markdown(article.title)) # Jupyter display only
   ! display(Markdown(article.text)) # Jupyter display only
   ! print("\n")
/bin/bash: line 1: from: command not found


/bin/bash: -c: line 1: syntax error near unexpected token `('
/bin/bash: -c: line 1: ` article = Article(url)'
/bin/bash: -c: line 2: syntax error: unexpected end of file
/bin/bash: -c: line 2: syntax error: unexpected end of file
/bin/bash: -c: line 1: syntax error near unexpected token `Markdown'
/bin/bash: -c: line 1: ` display(Markdown(article.title)) # Jupyter display only'
/bin/bash: -c: line 1: syntax error near unexpected token `Markdown'
/bin/bash: -c: line 1: ` display(Markdown(article.text)) # Jupyter display only'
/bin/bash: -c: line 1: syntax error near unexpected token `"\n"'
/bin/bash: -c: line 1: ` print("\n")'
/bin/bash: -c: line 1: syntax error near unexpected token `('
/bin/bash: -c: line 1: ` article = Article(url)'
/bin/bash: -c: line 2: syntax error: unexpected end of file
/bin/bash: -c: line 2: syntax error: unexpected end of file
/bin/bash: -c: line 1: syntax error near unexpected token `Markdown'
/bin/bash: -c: line 1: ` display(Markdown(article.title)) # Jupyter display only'
/bin/bash: -c: line 1: syntax error near unexpected token `Markdown'
/bin/bash: -c: line 1: ` display(Markdown(article.text)) # Jupyter display only'
/bin/bash: -c: line 1: syntax error near unexpected token `"\n"'
/bin/bash: -c: line 1: ` print("\n")'
#!pip install wikipedia
import wikipedia 
from IPython.display import display, Markdown # add for Jupyter

terms = ["Python (programming language)", "JavaScript"]
for term in terms:
    # Search for a page 
    result = wikipedia.search(term)
    # Get the summary of the first result
    summary = wikipedia.summary(result[0])
    print(term) 
    # print(summary) # console display
    display(Markdown(summary)) # Jupyter display
Python (programming language)

Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly procedural), object-oriented and functional programming. It is often described as a “batteries included” language due to its comprehensive standard library. Guido van Rossum began working on Python in the late 1980s as a successor to the ABC programming language and first released it in 1991 as Python 0.9.0. Python 2.0 was released in 2000. Python 3.0, released in 2008, was a major revision not completely backward-compatible with earlier versions. Python 2.7.18, released in 2020, was the last release of Python 2. Python consistently ranks as one of the most popular programming languages, and has gained widespread use in the machine learning community.

JavaScript

JavaScript (), often abbreviated as JS, is a programming language and core technology of the Web, alongside HTML and CSS. 99% of websites use JavaScript on the client side for webpage behavior. Web browsers have a dedicated JavaScript engine that executes the client code. These engines are also utilized in some servers and a variety of apps. The most popular runtime system for non-browser usage is Node.js. JavaScript is a high-level, often just-in-time compiled language that conforms to the ECMAScript standard. It has dynamic typing, prototype-based object-orientation, and first-class functions. It is multi-paradigm, supporting event-driven, functional, and imperative programming styles. It has application programming interfaces (APIs) for working with text, dates, regular expressions, standard data structures, and the Document Object Model (DOM). The ECMAScript standard does not include any input/output (I/O), such as networking, storage, or graphics facilities. In practice, the web browser or other runtime system provides JavaScript APIs for I/O. Although Java and JavaScript are similar in name, syntax, and respective standard libraries, the two languages are distinct and differ greatly in design.

import inspect 
! from newspaper import Article

# inspect newspaper Article function
! print(inspect.getsource(Article))
/bin/bash: line 1: from: command not found
/bin/bash: -c: line 1: syntax error near unexpected token `inspect.getsource'
/bin/bash: -c: line 1: ` print(inspect.getsource(Article))'
import sys
from typing import Union

# Define types for mean function, trying to analyze input possibilities
Number = Union[int, float]  # Number can be either int or float type
Numbers = list[Number] # Numbers is a list of Number types
Scores = Union[Number, Numbers] # Scores can be single or multiple 

def mean(scores: Scores, method: int = 1) -> float:
    """
    Calculate the mean of a list of scores.
    
    Average and Average2 are hidden functions performing mean algorithm

    If a single score is provided in scores, it is returned as the mean.
    If a list of scores is provided, the average is calculated and returned.
    """
    
! def average(scores): 
!        """Calculate the average of a list of scores using a Python for loop with rounding."""
!        sum = 0
!        len = 0
!        for score in scores:
!            if isinstance(score, Number):
!               sum += score
!                len += 1
!            else:
!                print("Bad data: " + str(score) + " in " + str(scores))
!                sys.exit()
!        return sum / len
    
! def average2(scores):
!        """Calculate the average of a list of scores using the built-in sum() function with rounding."""
!        return sum(scores) / len(scores)

    # test to see if scores is  a list of numbers
! if isinstance(scores, list):
! if method == 1:  
            # long method
!            result = average(scores)
! else:
            # built in method
!            result = average2(scores)
! return round(result + 0.005, 2)
    
! return scores # case where scores is a single valu

# try with one number
singleScore = 100
! print("Print test data: " + str(singleScore))  # concat data for single line
! print("Mean of single number: " + str(mean(singleScore)))

! print()

# define a list of numbers
testScores = [90.5, 100, 85.4, 88]
! print("Print test data: " + str(testScores))
! print("Average score, loop method: " + str(mean(testScores)))
! print("Average score, function method: " +  str(mean(testScores, 2)))

! print()

badData = [100, "NaN", 90]
! print("Print test data: " + str(badData))
! print("Mean with bad data: " + str(mean(badData)))
/bin/bash: -c: line 1: syntax error near unexpected token `('
/bin/bash: -c: line 1: ` def average(scores):'
/bin/bash: line 1: Calculate the average of a list of scores using a Python for loop with rounding.: command not found
sum: '=': No such file or directory
sum: 0: No such file or directory
/bin/bash: line 1: len: command not found
/bin/bash: -c: line 2: syntax error: unexpected end of file
/bin/bash: -c: line 1: syntax error near unexpected token `score,'
/bin/bash: -c: line 1: `            if isinstance(score, Number):'
sum: '+=': No such file or directory
sum: score: No such file or directory
/bin/bash: line 1: len: command not found
/bin/bash: line 1: else:: command not found
/bin/bash: -c: line 1: syntax error near unexpected token `"Bad data: "'
/bin/bash: -c: line 1: `                print("Bad data: " + str(score) + " in " + str(scores))'
/bin/bash: -c: line 2: syntax error: unexpected end of file
/bin/bash: line 1: return: sum: numeric argument required
/bin/bash: line 1: return: can only `return' from a function or sourced script
/bin/bash: -c: line 1: syntax error near unexpected token `('
/bin/bash: -c: line 1: ` def average2(scores):'
/bin/bash: line 1: Calculate the average of a list of scores using the built-in sum() function with rounding.: command not found
/bin/bash: -c: line 1: syntax error near unexpected token `('
/bin/bash: -c: line 1: `        return sum(scores) / len(scores)'
/bin/bash: -c: line 1: syntax error near unexpected token `scores,'
/bin/bash: -c: line 1: ` if isinstance(scores, list):'
/bin/bash: -c: line 2: syntax error: unexpected end of file
/bin/bash: -c: line 1: syntax error near unexpected token `('
/bin/bash: -c: line 1: `            result = average(scores)'
/bin/bash: line 1: else:: command not found
/bin/bash: -c: line 1: syntax error near unexpected token `('
/bin/bash: -c: line 1: `            result = average2(scores)'
/bin/bash: -c: line 1: syntax error near unexpected token `('
/bin/bash: -c: line 1: ` return round(result + 0.005, 2)'
/bin/bash: line 1: return: scores: numeric argument required
/bin/bash: line 1: return: can only `return' from a function or sourced script
/bin/bash: -c: line 1: syntax error near unexpected token `"Print test data: "'
/bin/bash: -c: line 1: ` print("Print test data: " + str(singleScore))  # concat data for single line'
/bin/bash: -c: line 1: syntax error near unexpected token `"Mean of single number: "'
/bin/bash: -c: line 1: ` print("Mean of single number: " + str(mean(singleScore)))'
/bin/bash: -c: line 2: syntax error: unexpected end of file
/bin/bash: -c: line 1: syntax error near unexpected token `"Print test data: "'
/bin/bash: -c: line 1: ` print("Print test data: " + str(testScores))'
/bin/bash: -c: line 1: syntax error near unexpected token `"Average score, loop method: "'
/bin/bash: -c: line 1: ` print("Average score, loop method: " + str(mean(testScores)))'
/bin/bash: -c: line 1: syntax error near unexpected token `"Average score, function method: "'
/bin/bash: -c: line 1: ` print("Average score, function method: " +  str(mean(testScores, 2)))'
/bin/bash: -c: line 2: syntax error: unexpected end of file
/bin/bash: -c: line 1: syntax error near unexpected token `"Print test data: "'
/bin/bash: -c: line 1: ` print("Print test data: " + str(badData))'
/bin/bash: -c: line 1: syntax error near unexpected token `"Mean with bad data: "'
/bin/bash: -c: line 1: ` print("Mean with bad data: " + str(mean(badData)))'