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
/* | |
Write a program that randomly places nickels ($0.05), dimes ($0.10), | |
and quarters ($0.25) into an empty piggy bank until it contains at least $20.00. | |
Display the running balance of the piggy bank after each deposit, | |
formatting it with an appropriate width and precision. | |
*/ | |
package main | |
import ( |
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
package main | |
import "fmt" | |
func main() { | |
piggyBank := 0.0 | |
for i := 0; i < 11; i++ { | |
piggyBank += 0.1 | |
} | |
fmt.Println("Using addition 11 times", piggyBank) |
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
package main | |
import "fmt" | |
func main() { | |
fmt.Println("1. Division First") | |
celsius := 21.0 | |
fmt.Print((celsius/5.0*9.0)+32, "° F\n") | |
fmt.Print((9.0/5.0*celsius)+32, "° F\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
gen = (random.randrange(1, 100, 2) for _ in itertools.count()) | |
# or | |
gen = (random.randrange(1, 100, 2) for _ in itertools.cycle("Happy Coding!")) | |
# usage: | |
for n in gen: | |
print(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
import urllib.request | |
import json | |
from pprint import pprint | |
url = "<some_url>" | |
values = { | |
"first_name": "Vlad", | |
"last_name": "Bezden", | |
"email": "[email protected]", |
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
package main | |
import ( | |
"flag" | |
"fmt" | |
"time" | |
) | |
var n int |
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
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "build", | |
"type": "shell", | |
"command": "go build <project name>", | |
"group": { | |
"kind": "build", | |
"isDefault": true |
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 asyncio | |
import random | |
import logging | |
from collections import namedtuple | |
import uuid | |
import string | |
logging.basicConfig(level=logging.INFO) | |
Message = namedtuple("Message", ["msg_id", "inst_name"]) |
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 logging as logger | |
from logging.handlers import RotatingFileHandler | |
logger.basicConfig( | |
level=logger.INFO, | |
format="%(asctime)s - %(levelname)s - %(message)s", | |
datefmt="%Y-%m-%d %H:%M:%S", | |
handlers=[ | |
RotatingFileHandler( | |
"log_info.log", maxBytes=1_000_000, backupCount=10 |
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.Timestamp("2019-04-12") | |
print(f"{df}, {df.dayofweek}, {df.weekday_name}") | |
# 2019-04-12 00:00:00, 4, Friday |