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
// Gist https://gist.github.com/f6d31d8630589c2e8986de8ce6238350 | |
#include <iostream> | |
int main(int argc, char const *argv[]) { | |
// Constant tip rate of 15% expressed as a decimal of 0.15 | |
const double kTipRate{0.15}; | |
std::cout << "What was the bill's sum? "; | |
double bill; |
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
#!/usr/bin/env python3 | |
# | |
# Clearing the terminal three different ways. | |
# | |
# Gist https://gist.github.com/da88307f3b58b7a82bd26a8e998d6ce5 | |
# | |
def simple(): | |
# you can make it fancier by figuring out how many rows | |
# the terminal has and replace the hard-coded 24. |
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
#!/usr/bin/env python3 | |
# Gist: https://gist.github.com/mshafae/0ca00a411cab94a106d5585451f62dff | |
"""Example solutions to the CA/US quiz using the us_state.pckl and ca_county.pckl pickle files.""" | |
from collections import namedtuple | |
import pickle | |
import locale |
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
// cpsc120_trunc_convert_double.cc | |
// Gist https://gist.github.com/mshafae/7b281ca822da831d8ffb85982034c917 | |
#include <cmath> | |
#include <iostream> | |
#include <limits> | |
int main(int argc, char const *argv[]) { | |
// This is a really large number, a 1 with 308 zeros after it. | |
// double decimal_number{1.0e308}; |
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
// Gist https://gist.github.com/mshafae/77d3cda92a90746210f3224c1cf83555 | |
// Filename cpsc120_double_comparison.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_double_comparison.cc | |
// Demonstrating how doubles are approximating Real numbers and how direct | |
// comparison must be avoided. | |
#include <iomanip> | |
#include <iostream> | |
// lhs stands for "left hand side" |
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
// Gist https://gist.github.com/mshafae/4d282935ea5deaf8c2e6aca83a9fcac8 | |
// Filename cpsc120_filelines_to_vector.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_filelines_to_vector.cc | |
// Read a file line by line and place contents into a std::vector | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
#include <vector> |
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
// Gist https://gist.github.com/mshafae/4d282935ea5deaf8c2e6aca83a9fcac8 | |
// Filename cpsc120_filelines_to_vector.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_filelines_to_vector | |
// Read a file line by line and place contents into a std::vector | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
#include <vector> |
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
// Gist https://gist.github.com/mshafae/eb239941e0171dcf564d91a3f75c64a7 | |
// Filename cpsc120_2D_vector.cpp | |
// CompileCommand clang++ -std=c++17 cpsc120_2D_vector.cpp | |
// Create a vector of vectors, the inner vectors contain strings | |
// Note that C++ is row major order. | |
#include <iostream> | |
#include <string> | |
#include <vector> |
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
// Gist https://gist.github.com/mshafae/ff7818bd3514ad0539e90b5d2f8933b3 | |
// Filename cpsc120_vector.cc | |
// CompileCommand clang++ -std=c++17 cpsc120_vector.cc | |
// Working with C++ vectors. | |
#include <iostream> | |
#include <vector> | |
int main(int argc, char const* argv[]) { |
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
// Gist https://gist.github.com/mshafae/759d0d17b0bb03873516dcc9e16f5dca | |
// Filename cpsc120_2D_vector_pt2.cpp | |
// CompileCommand clang++ -std=c++17 cpsc120_2D_vector_pt2.cpp | |
// Create a vector of vectors, the inner vectors contain strings | |
// Note that C++ is row major order. | |
#include <iostream> | |
#include <string> | |
#include <vector> |