Skip to content

Instantly share code, notes, and snippets.

View mtlynch3's full-sized avatar

Melissa Lynch mtlynch3

  • Hunter College, CUNY
  • New York, NY
View GitHub Profile
def getYear():
year = int(input("Enter year: "))
while year <= 2000 or year >= 2021:
#not a valid year
#continue to prompt user
year = int(input("Enter year: "))
return year
import pandas as pd
df = pd.read_csv("stars.csv")
max_temp = df["Temperature"].max()
F = (max_temp - 273.15)*9/5 + 32
print(F, "degrees F")
supergiants = df.groupby("Star type").get_group("Supergiant")
#making images!
import matplotlib.pyplot as plt
import numpy as np
imgZeros = np.zeros((10,10,3))
imgOnes = np.ones((10,10,3))
imgZeros[0,5,1] = 1.0
imgOnes[5,0,0] = 0.0
# Assume input characters are only the lowercase letters a-z
# Forumula: Encrypted Character = (Original Character + Shift Amount) % 26
# For the formula to work correctly, we must represent the letters of the alphabet as the numbers 0 to 25
# We can caculate this number position using ASCII codes: ord(original_character) - ord("a")
# This will get the distance from "a", which matches the correct mapping of letters to numbers
# That is, "a" is 0, "b" is 1, "c" is 2, ..., "z" is 25
original = "hello"
coded_message = ""
import { useEffect, useState } from 'react';
function UserList() {
// users is an empty list by default
const [users, setUsers] = useState([]);
async function getDataAsync() {
try {
const response = await fetch('https://jsonplaceholder.typicode.com/users/');
const data = await response.json();
#include <iostream>
#include <vector>
using namespace std;
//Constants
string ANSWER = "melons";
vector<string> HANGMEN = {
" +---+\n | |\n |\n |\n |\n |\n=========",
" +---+\n | |\n O |\n |\n |\n |\n=========",
C
B
B
B
A
B
D
B
B
C
@mtlynch3
mtlynch3 / App.jsx
Created March 26, 2023 19:52
Class component vs function component
import CounterClass from "./components/CounterClass";
import CounterFunc from "./components/CounterFunc";
function App() {
return (
<div>
<CounterClass value="Hello, World!"/>
<CounterFunc value="Hello, World!"/>
</div>
);
@mtlynch3
mtlynch3 / Blog.jsx
Created March 22, 2023 21:30
Example using Material UI with a custom theme
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { purple } from '@mui/material/colors';
import { Box, Button, Container, Paper, Typography } from '@mui/material';
const theme = createTheme({
palette: {
primary: {
main: "#00f",
},
@mtlynch3
mtlynch3 / App.jsx
Last active March 17, 2023 15:05
React Router setup
import { Routes, Route, Link } from "react-router-dom";
function App() {
return (
<div className="App">
<Routes>
<Route index element={<Home />} />
<Route path="about" element={<About />} />
</Routes>
</div>