This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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=========", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C | |
B | |
B | |
B | |
A | |
B | |
D | |
B | |
B | |
C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CounterClass from "./components/CounterClass"; | |
import CounterFunc from "./components/CounterFunc"; | |
function App() { | |
return ( | |
<div> | |
<CounterClass value="Hello, World!"/> | |
<CounterFunc value="Hello, World!"/> | |
</div> | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
NewerOlder