This file contains 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 fizz_buzz(start, stop, fizz_val, buzz_val): | |
for i in range(start, stop): | |
str_out = "" | |
if i % fizz_val == 0: | |
str_out += "Fizz" | |
if i % buzz_val == 0: | |
str_out += "Buzz" | |
if str_out == "": | |
str_out += str(i) | |
print(str_out) |
This file contains 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
Public Sub FizzBuzz() | |
For i = 1 to 100 | |
result = "" | |
If (i mod 3) = 0 Then result = result & "Fizz" | |
If (i mod 5) = 0 Then result = result & "Buzz" | |
If result = "" result = str(i) | |
Debug.Print (result) | |
Next i | |
End Sub |
This file contains 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 numpy as np | |
# Create spinner function | |
def spin(): | |
return np.random.randint(0,5) | |
spin_categories = { | |
0: 'pig', | |
1: 'dog', | |
2: 'sheep', |
This file contains 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 relevant libraries | |
import pyodbc # needed for database call | |
import pandas # needed for data frame functionality | |
import shutil # needed for file copying | |
import datetime # needed to find dates for file paths | |
import xlwings # needed to populate the spreadsheet | |
# COPY FILE STEP | |
# determine destination directory to save a copy of the file | |
# file folders are nested according to month and year, so we do a bit of work |
This file contains 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
# The purpose of this script is to generate a random Mandarin syllable pairing for use in tone | |
# practice drills. The random syllable pair is used to populate a grid that does not have tones. | |
# The tone_table has the tones of the two syllables. The student then tries to say the random | |
# pairing with the tones they see. The partner then tries to guess which tones were meant. | |
# | |
# The script generates the syllables from scratch, starting with all possible vowel and consonant | |
# pairings. Then it uses a very complicated string of regex to exclude out invalid syllables. | |
# My goal with this script was to make the tone tables, but it was also meant to learn some | |
# useful regex, which is why I indulged in it rather than just typing out all possible syllables | |
# (which would have been much faster at my typing speed than finding all the exclusions I needed). |
This file contains 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
# Chapter 13 Exercise 2 | |
""" | |
Go to Project Gutenberg (http://gutenberg.org) and download | |
your favorite out-of-copyright book in plain text format. | |
Modify your program from the previous exercise to read the | |
book you downloaded, skip over the header information at the | |
beginning of the file, and process the rest of the words as |
This file contains 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
Public Sub AddSingleQuotes() | |
Dim rng as Range | |
Set rng = Selection | |
Dim cell as Range | |
Dim booFirst as Boolean | |
booFirst = True | |
With rng | |
For Each cell in rng | |
If booFirst = True Then |
This file contains 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
Public Sub RollDays() | |
Dim wksCd As Worksheet, wksPd As Worksheet | |
Dim rngCd As Range, rngPd As Range | |
Dim lngCdLc as Long, lngPdLc as Long, lngMaxLc as Long | |
Dim lngCdLr As Long, lngPdLr As Long, lngMaxLr As Long | |
With ThisWorkbook | |
Set wksCd = .Worksheets("Current Day") | |
Set wksPd = .Worksheets("Prior Day") |
This file contains 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
Public Sub WriteTextFile(ByVal strMessage As String) | |
Dim objFile As FileSystemObject | |
Set objFile = New FileSystemObject | |
Dim txtStream As TextStream | |
Dim strPath As String | |
strPath = ThisWorkbook.Path & "\" | |
NewerOlder