Skip to content

Instantly share code, notes, and snippets.

View RobertTalbert's full-sized avatar

Robert Talbert RobertTalbert

View GitHub Profile
# The first recursive function we saw.
# Turns out it has the closed formula f(n) = n(n+2) although we didn't prove it.
def f(n):
if n == 0: return 0
else: return f(n-1) + 2*n + 1
# AKA the factorial function:
def g(n):
\section{Appendix B: MTH 225 Learning Targets}
\label{sec:learning-targets}
\begin{subsubsection}{Module 1: Computer Arithmetic}
\begin{description}
\tightlist
\item[CA.1] \textbf{(CORE)} \ I can represent an integer in base 2, 8, 10, and 16 and represent a negative integer in base 2 using two's complement notation.
\item[CA.2] I can perform addition, subtraction, multiplication, and division in binary.
\end{description}

Course module structure: The course content is split up into five modules:

  • Module 1: Computer arithmetic. Representing integers in binary, octal, and hexadecimal; binary arithmetic; the Division Algorithm and modular arithmetic.

  • Module 2: Logic. Logical propositions, conditional statements, truth tables, predicates, and quantification.

Course-level learning objectives: Upon completion of MTH 225, you will be able to:

  • Represent integers using different number bases, and perform integer arithmetic using different bases and modular arithmetic.

  • Formulate, manipulate, and determine the truth of logical expressions using symbolic logic.

  • Formulate and solve computational problems using sets and functions.

MTH 225 Learning Objectives

By module

  • Module 1: Arithmetic
    • Given an integer in base 2, 8, 10, or 16, represent it using another base.
    • Add, subtract, multiply, and divide integers in base 2, 8, and 16.
    • Use two's complement to represent a negative integer in binary.
  • State the Division Algorithm and use it to find the quotient and remainder when dividing one positive integer by another.
# Code for generating Five-Question Summary reports.
# Import basic packages
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
# Read in student response data; change name of file as needed
col_names = ["Challenge", "Support", "Competence", "Autonomy",
"Relatedness"]

Semper Libero condimentum praesent consectetuer eget ornare aliquam sagittis ligula nonummy. Placerat libero laoreet sed orci vitae id sit vestibulum sit mi mattis. Eleifend sollicitudin phasellus litora sem sociis vel ac dignissim auctor venenatis hendrerit ornare dolor inceptos ante class. Praesent lectus conubia bibendum class iaculis odio potenti fermentum amet fusce vulputate ultricies cum phasellus sed volutpat ligula. Eros. Dictum sociis ultricies accumsan mus. Congue est convallis elit velit facilisis a commodo convallis torquent feugiat.

Parturient, pharetra mattis felis nam magnis. Dolor tristique. Eu Sagittis quis hendrerit tempus scelerisque mus aliquam ipsum, commodo senectus mattis adipiscing inceptos. Proin molestie ad aliquam curae; ligula habitasse curae; sem gravida magna scelerisque tortor nisl eleifend sapien aptent cum accumsan sociis porttitor mi. Primis. Netus sagittis et, aliquam erat sit posuere nonummy tellus euismod donec vivamus. Ad sollicitudin Quis platea netus id lectus velit a

def fib(n):
if n == 0 or n == 1:
return 1
else:
return fib(n-1) + fib(n-2)
def A(n):
if n == 1:
return 1
elif n == 2:
return 4
else:
return A(n-1) + 2*A(n-2)
@RobertTalbert
RobertTalbert / weightedgraphs.py
Last active October 16, 2020 16:46
Sage code for generating random weighted undirected graph
## Generates a random weighted undirected graph.
## n = number of nodes
## p = probability that two nodes are adjacent; must be between 0 and 1.
## lower_weight and upper_weight = lower and upper edge weights, respectively. If left out, the defaults are 1 and 100.
##
## Examples of usage:
## g = random_weighted_graph(20, 0.5) <-- Uses default lower and upper weights of 1 and 100.
## h = random_weighted_graph(10, 0.35, 5, 50) <-- Weights will be integers between 5 and 50.
## g.show(edge_labels = True) <-- Include the argument to display the weights
## h.show() <-- leave the argument out to hide the weights