Skip to content

Instantly share code, notes, and snippets.

View aambrioso1's full-sized avatar
🏠
Working from home

Alex Ambrioso aambrioso1

🏠
Working from home
View GitHub Profile
@aambrioso1
aambrioso1 / GeneralizedColorings.py
Last active July 17, 2019 18:50
GeneralizedColorings.py
"""
Counts the number of colorings possible if n walls are colored with n colors. Also partitions the set of all colors by the number of colors used.
Uses itertools product function to comtrol the number of nested for loops. The itertools library
contains functions for creating iterators for efficient looping.
See:
https://docs.python.org/3/library/itertools.html#itertools.product
for detailed documentation.
"""
@aambrioso1
aambrioso1 / GeneralizedColorings.py
Last active July 16, 2019 18:16
GeneralizedColorings.py
"""
Vince list rewritten to use itertools product function. This calculates the cartesian product of input iterables. It operates like nested for loops.
See:
https://docs.python.org/3/library/itertools.html#itertools.product
for detailed documentation.
My goal is too generalize the count to n colors.
"""
@aambrioso1
aambrioso1 / weather.py
Last active July 7, 2019 16:11
weather.py
"""
quickWeather.py - Prints the weather for a location from the command line.
A program from Automate the Boring Stuff
I reworked it so that it finds the weather from the location assigned to the
location variable. The code for running the program from the command line is
commented out.
"""
import json, requests, sys
@aambrioso1
aambrioso1 / webbrowsertest.py
Created July 2, 2019 12:35
webbrowsertest.py
# import webbrowser
# import requests, os, bs4
# webbrowser.open('http://inventwithpython.com/')
#! python3
# lucky.py - Opens several Google search results.
import requests, sys, webbrowser, bs4
@aambrioso1
aambrioso1 / Regex.py
Created June 20, 2019 18:02
Regex.py
import re
"""
This program demonstrates two regexes: one for matching vowels and one for matching social socurity numbers (SSN's'). The program requests some text from the user to use to demo the vowel matching. For the SSN matching, the text assigned to text3 is searched for SSN's.
"""
print('Input some text.\n')
text = input()
# A regex for matching vowels.
vowelRegex = re.compile(r'[aeiouAEIOU]')
mo = vowelRegex.findall(text)
@aambrioso1
aambrioso1 / RegexLesson.py
Created June 19, 2019 09:09
RegexLesson.py
"""
This program searches the text in a file for
email addresses and phone numbers. It copies
them to a list called matches and prints them
them neatly amd in a standard format.
This a slight midification of a progtam found at https://automatetheboringstuff.com/chapter7/
See also the documentstion at Python.org for the re library (regular expressions operations) here https://docs.python.org/3/library/re.html#re.ASCII
"""
import re
@aambrioso1
aambrioso1 / RegexLesson.py
Created June 19, 2019 09:04
RegexLesson.py
"""
This program searches the text in a file for
email addresses and phone numbers. It copies
them to a list called matches and prints them
them neatly amd in a standard format.
This a slight midification of a progtam found at https://automatetheboringstuff.com/chapter7/
See also the documentstion at Python.org for the re library (regular expressions operations) here https://docs.python.org/3/library/re.html#re.ASCII
"""
import re
from tkinter import *
import time
gui = Tk()
gui.title('Animation Test')
gui.geometry('400x400')
c = Canvas(gui ,width=400 ,height=400)
c.pack()
oval = c.create_oval(5,5,60,60,fill='pink')
xd = 5
yd = 10
@aambrioso1
aambrioso1 / LawofLargeNumbers.py
Created May 10, 2019 01:45
LawofLargeNumbers.py
# We will demonstrate the Law of Large Numbers by simulating die rolls. As the number of die rolls increases the relative frequency of each number should aprroach the theoretical probability of 1/6.
# We will use the function randint from the random library. The function is described below.
from random import randint
# The function randint(1,6) simulates a die roll by returning a random integer between 1 and 6.
# Roll a die once.
print('We rolled a die once and roll a %i.\n' % (randint(1,6)))