Module 1 · Mathematical Language and Quantitative Reasoning Lesson 1 of 120
Variables, Constants, Expressions, and Equations
A wallet reconciliation that actually balances.
Transcript
26 sentences · select one to jump thereCheck your understanding
What happens if outflows become 200?
Code lab
Run it yourself
The lesson source in 7 languages. Edit it, run TypeScript and Python right here, and compare with the expected output.
/**
* Fintech Math Bootcamp · Lesson 001 of 120
* Variables, Constants, Expressions, and Equations
* Module 01: Mathematical Language and Quantitative Reasoning
*
* Scenario: A wallet reconciliation that actually balances
* Rule: ending = opening + inflows − outflows
*
* Try it: What happens if outflows become 200?
*
* Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/variables-constants-expressions-and-equations/
* Free course: https://courses.thefintechbuilder.com
* Synthetic teaching example, not financial advice or a production library.
*/
export function lesson001() {
const opening = 1000;
const inflows = 250;
const outflows = 120;
const ending = opening + inflows - outflows;
const result = ending;
return result;
}
export const checkedResult = 1130;
// Run this file directly: npx tsx lessons/01-mathematical-language-and-quantitative-reasoning/001-variables-constants-expressions-and-equations.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
console.log(JSON.stringify(lesson001(), null, 2));
}
Your output
Press Run to execute the code in your browser.
Expected output
1130"""
Fintech Math Bootcamp · Lesson 001 of 120
Variables, Constants, Expressions, and Equations
Module 01: Mathematical Language and Quantitative Reasoning
Scenario: A wallet reconciliation that actually balances
Rule: ending = opening + inflows − outflows
Try it: What happens if outflows become 200?
Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/variables-constants-expressions-and-equations/
Free course: https://courses.thefintechbuilder.com
Synthetic teaching example, not financial advice or a production library.
Run it: python main.py
"""
import json
def lesson001() -> float:
opening = 1000
inflows = 250
outflows = 120
ending = opening + inflows - outflows
result = ending
return result
if __name__ == "__main__":
print(json.dumps(lesson001(), indent=2))
Your output
Press Run to execute the code in your browser.
Expected output
1130/**
* Fintech Math Bootcamp · Lesson 001 of 120
* Variables, Constants, Expressions, and Equations
* Module 01: Mathematical Language and Quantitative Reasoning
*
* Scenario: A wallet reconciliation that actually balances
* Rule: ending = opening + inflows − outflows
*
* Try it: What happens if outflows become 200?
*
* Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/variables-constants-expressions-and-equations/
* Free course: https://courses.thefintechbuilder.com
* Synthetic teaching example, not financial advice or a production library.
*
* Run it: javac Main.java && java Main
*/
public class Main {
static double lesson001() {
double opening = 1000;
double inflows = 250;
double outflows = 120;
double ending = opening + inflows - outflows;
double result = ending;
return result;
}
public static void main(String[] args) {
System.out.println(num(lesson001()));
}
// Formats a double the way JSON.stringify does: whole numbers without ".0", null for NaN or infinity.
static String num(double x) {
if (Double.isNaN(x) || Double.isInfinite(x)) return "null";
if (x == Math.rint(x) && Math.abs(x) < 1e15) return String.valueOf((long) x);
return String.valueOf(x);
}
}
No browser runner for Java yet
Read the code here, then run it in your own toolchain or a ready-made cloud workspace.
Expected output
1130// Fintech Math Bootcamp · Lesson 001 of 120
// Variables, Constants, Expressions, and Equations
// Module 01: Mathematical Language and Quantitative Reasoning
//
// Scenario: A wallet reconciliation that actually balances
// Rule: ending = opening + inflows − outflows
//
// Try it: What happens if outflows become 200?
//
// Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/variables-constants-expressions-and-equations/
// Free course: https://courses.thefintechbuilder.com
// Synthetic teaching example, not financial advice or a production library.
//
// Run it: go run main.go
package main
import (
"encoding/json"
"fmt"
)
func lesson001() float64 {
opening := 1000.0
inflows := 250.0
outflows := 120.0
ending := opening + inflows - outflows
result := ending
return result
}
func main() {
printJSON(lesson001())
}
// printJSON prints a value as JSON indented with two spaces, like JSON.stringify(value, null, 2).
func printJSON(value any) {
out, err := json.MarshalIndent(value, "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(out))
}
No browser runner for Go yet
Read the code here, then run it in your own toolchain or a ready-made cloud workspace.
Expected output
1130/**
* Fintech Math Bootcamp · Lesson 001 of 120
* Variables, Constants, Expressions, and Equations
* Module 01: Mathematical Language and Quantitative Reasoning
*
* Scenario: A wallet reconciliation that actually balances
* Rule: ending = opening + inflows − outflows
*
* Try it: What happens if outflows become 200?
*
* Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/variables-constants-expressions-and-equations/
* Free course: https://courses.thefintechbuilder.com
* Synthetic teaching example, not financial advice or a production library.
*
* Run it: g++ -std=c++17 -o main main.cpp && ./main
*/
#include <charconv>
#include <cmath>
#include <iostream>
#include <string>
// Formats a double the way JSON.stringify does: shortest round-trip form, null for NaN or infinity.
std::string num(double x) {
if (!std::isfinite(x)) return "null";
char buffer[32];
auto [end, error] = std::to_chars(buffer, buffer + sizeof buffer, x);
(void)error;
return std::string(buffer, end);
}
double lesson001() {
const double opening = 1000;
const double inflows = 250;
const double outflows = 120;
const double ending = opening + inflows - outflows;
const double result = ending;
return result;
}
int main() {
std::cout << num(lesson001()) << "\n";
}
No browser runner for C++ yet
Read the code here, then run it in your own toolchain or a ready-made cloud workspace.
Expected output
1130//! Fintech Math Bootcamp · Lesson 001 of 120
//! Variables, Constants, Expressions, and Equations
//! Module 01: Mathematical Language and Quantitative Reasoning
//!
//! Scenario: A wallet reconciliation that actually balances
//! Rule: ending = opening + inflows − outflows
//!
//! Try it: What happens if outflows become 200?
//!
//! Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/variables-constants-expressions-and-equations/
//! Free course: https://courses.thefintechbuilder.com
//! Synthetic teaching example, not financial advice or a production library.
//!
//! Run it: rustc main.rs && ./main
fn lesson001() -> f64 {
let opening = 1000.0;
let inflows = 250.0;
let outflows = 120.0;
let ending = opening + inflows - outflows;
let result = ending;
result
}
fn main() {
println!("{}", num(lesson001()));
}
/// Formats a number the way JSON.stringify does: shortest round-trip form, null for NaN or infinity.
fn num(x: f64) -> String {
if x.is_finite() {
format!("{}", x)
} else {
"null".to_string()
}
}
No browser runner for Rust yet
Read the code here, then run it in your own toolchain or a ready-made cloud workspace.
Expected output
1130/**
* Fintech Math Bootcamp · Lesson 001 of 120
* Variables, Constants, Expressions, and Equations
* Module 01: Mathematical Language and Quantitative Reasoning
*
* Scenario: A wallet reconciliation that actually balances
* Rule: ending = opening + inflows − outflows
*
* Try it: What happens if outflows become 200?
*
* Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/variables-constants-expressions-and-equations/
* Free course: https://courses.thefintechbuilder.com
* Synthetic teaching example, not financial advice or a production library.
*
* Run it: dotnet run (inside a console project that holds this Program.cs)
*/
using System.Text.Json;
Console.WriteLine(JsonSerializer.Serialize(Lesson001()));
static double Lesson001()
{
const double opening = 1000;
const double inflows = 250;
const double outflows = 120;
const double ending = opening + inflows - outflows;
const double result = ending;
return result;
}
No browser runner for C# yet
Read the code here, then run it in your own toolchain or a ready-made cloud workspace.
Expected output
1130Prefer your own machine? Every file is in the course repository · open it in Codespaces.
Lesson notes
The rule
ending = opening + inflows − outflows