blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
2ff0ad0f64a712916bbd47c43d4afcf7b4d47a85 | egalli64/pythonesque | /pcc3/ch15/e1f_scatter_points.py | 587 | 4.0625 | 4 | """
Python Crash Course, Third Edition https://ehmatthes.github.io/pcc_3e/
My notes: https://github.com/egalli64/pythonesque/pcc3
Chapter 15 - Generating Data - Plotting a Simple Line Graph - Plotting a Series of Points with scatter()
"""
import matplotlib.pyplot as plt
plt.style.use('seaborn')
fig, ax = plt.subplots... |
d06e7fd2371d62a2e88c209dc8e0ce117e177102 | egalli64/pythonesque | /hr/numpy/arrays.py | 405 | 4.0625 | 4 | """
HackerRank Python Numpy Arrays
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.hackerrank.com/challenges/np-arrays/problem
given a space separated list of numbers, print a reversed NumPy array with the element type float
"""
import numpy as np
def solution(arr):
retu... |
01b5811d981e0477fca27fe9b70152cc38c6e416 | egalli64/pythonesque | /cip/karel/ch09.py | 956 | 3.75 | 4 | """
Karel the Robot - Learns Python
Source: https://compedu.stanford.edu/karel-reader/docs/python/en/intro.html
My notes: https://github.com/egalli64/pythonesque/cip/karel
Chapter 9: Painting corners
https://compedu.stanford.edu/karel-reader/docs/python/en/chapter9.html
"""
from stanfordkarel import *
def main():
... |
7ce6c6508baf180ac4bc049f3f8d9ccd5dc26778 | egalli64/pythonesque | /hr/ctci/balanced_brackets.py | 617 | 3.84375 | 4 | """
HackerRank Tutorials Cracking the Coding Interview Stacks: Balanced Brackets
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2017/02/hackerrank-stacks-balanced-brackets.html
https://www.hackerrank.com/challenges/ctci-balanced-brackets
"""
def solution(data):
matches = {'(': ')', ... |
4345b43c0c8ae520d52246ca97c1a6646c2c26f0 | egalli64/pythonesque | /hr/numpy/transpose_flatten.py | 448 | 3.765625 | 4 | """
HackerRank Python Numpy Transpose and Flatten
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.hackerrank.com/challenges/np-transpose-and-flatten/problem
given a NxM integer array matrix (N rows and M columns), print the transpose and flatten results
"""
import numpy as np
... |
0f77898fbf2729192f7162b8bc47b165e47f4c10 | egalli64/pythonesque | /dive/plural_names_iterator_test.py | 753 | 3.734375 | 4 | """
Plural Names Iterator
Based on Dive into Python 3
Chapter 7 Classes & Iterators, sections 6
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
http://www.diveintopython3.net/
"""
import unittest
from dive.plural_names_iterator import plural
class TestPluralNames(unittest.TestCase):
d... |
dbf1f2250c4c21748f4855741c9d4f1f3e883846 | egalli64/pythonesque | /pcc3/ch05/e1_conditional.py | 984 | 4.125 | 4 | """
Python Crash Course, Third Edition https://ehmatthes.github.io/pcc_3e/
My notes: https://github.com/egalli64/pythonesque/pcc3
Chapter 5 -If Statement - Conditional Tests
"""
cars = ['audi', 'bmw', 'subaru', 'toyota']
for car in cars:
if car == 'bmw':
print(car.upper())
else:
print(car.title... |
737b416abe121bd269464f2a04e3cc7a1948d438 | egalli64/pythonesque | /ce/c067.py | 393 | 3.5625 | 4 | """
CodeEval Hex To Decimal
author: Manny egalli64@gmail.com
info: https://www.codeeval.com/open_challenges/67/
http://thisthread.blogspot.com/
"""
import sys
if __name__ == '__main__':
if len(sys.argv) == 2:
with open(sys.argv[1], 'r') as file:
for test in file:
print(int... |
67a54e8e68ad136984ca6c70ab074c0b8c07a12e | egalli64/pythonesque | /cisco/pe1/2_1.py | 718 | 3.65625 | 4 | """
Cisco Network Academy
Python Essentials 1: https://skillsforall.com/course/python-essentials-1
My notes: https://github.com/egalli64/pythonesque - cisco/pe1 folder
PE1: Module 2 Section 1 "Hello, World!"
"""
# escape for newline: \n
print("The itsy bitsy spider\nclimbed up the waterspout.")
# no-arg print, to prin... |
8558e067e324f5492b02e3824d01477e1f98d984 | egalli64/pythonesque | /pcc3/ch06/e1_dictionary.py | 1,196 | 4.09375 | 4 | """
Python Crash Course, Third Edition https://ehmatthes.github.io/pcc_3e/
My notes: https://github.com/egalli64/pythonesque/pcc3
Chapter 6 - Dictionaries - Working with Dictionaries
"""
# create a dictionary
alien = {'color': 'green', 'points': 5}
# accessing value by key
print(alien['color'], alien['points'])
print... |
33d9dd7e95c6a13d41f4b249ed15865085d12a69 | egalli64/pythonesque | /hr/algorithms/ds/linked_list/print.py | 1,080 | 3.828125 | 4 | """
HackerRank Data Structures Linked Lists Print the Elements of a Linked List
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list/problem
Write a function named printLinkedList() that print the passed node and all ... |
687f0602365ec81cfd06b9593300c40235979fe9 | egalli64/pythonesque | /ce/c202_test.py | 731 | 3.5 | 4 | # Stepwise word
# author: Manny egalli64@gmail.com
# info: http://thisthread.blogspot.com/2017/01/codeeval-stepwise-word.html
# https://www.codeeval.com/open_challenges/202/
import unittest
from c202 import solution
class TestStepwiseWord(unittest.TestCase):
def test_provided_1(self):
result = sol... |
710fa3997f68242aac1662426bd60f64c746f447 | egalli64/pythonesque | /pcc3/ch10/e1_read.py | 1,401 | 3.90625 | 4 | """
Python Crash Course, Third Edition https://ehmatthes.github.io/pcc_3e/
My notes: https://github.com/egalli64/pythonesque/pcc3
Chapter 10 - Files and Exceptions - Reading from a File
"""
from pathlib import Path
# the script is supposed to run in the current folder!
pi_file = 'pi_digits.txt'
path = Path(pi_file)
#... |
363125b893608815709d852f1a0306ebda31f30d | egalli64/pythonesque | /cip/w6/ex_index.py | 1,109 | 4.03125 | 4 | """
Code in Place 2023 https://codeinplace.stanford.edu/cip3
My notes: https://github.com/egalli64/pythonesque/cip
Week 6: #1 Index
"""
import random
def main():
# 1. Understand how to create a list and add values
# A list is an ordered collection of values
names = ['Chris', 'Mehran', 'Simba', 'Brahm', '... |
607969a73c215f74bae35f4690710280bc978b4f | egalli64/pythonesque | /ce/c027.py | 436 | 3.5625 | 4 | """
CodeEval Decimal to Binary
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.codeeval.com/open_challenges/27/
"""
import sys
if __name__ == '__main__':
if len(sys.argv) == 2:
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
print('{... |
11993869116be473eac4410b1b123fc88a8e0786 | egalli64/pythonesque | /algs200x/w2/d_fibonacci_modulo_test.py | 1,006 | 3.609375 | 4 | """
Calculate Fibonacci modulo m
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2018/02/fibonacci-modulo-with-pisano-period.html
https://www.edx.org/course/algorithmic-design-techniques-uc-san-diegox-algs200x
"""
import unittest
from algs200x.w2.d_fibonacci_modulo_1 import solution as na... |
f676b512aa664ef11633d22261943885b504d1a2 | egalli64/pythonesque | /hr/algorithms/ds/linked_list/del_print_reverse.py | 1,207 | 3.71875 | 4 | """
HackerRank Data Structures Linked Lists
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
Delete a Node:
https://www.hackerrank.com/challenges/delete-a-node-from-a-linked-list/problem
Print in Reverse:
https://www.hackerrank.com/challenges/print-the-elements-of-a-linke... |
747681a64cb80bac3c87f559442010cb5777f4e8 | egalli64/pythonesque | /hr/ctci/array_left_rotation.py | 482 | 3.734375 | 4 | """
HackerRank Tutorials Cracking the Coding Interview Arrays: Left Rotation
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2017/02/hackerrank-arrays-left-rotation.html
https://www.hackerrank.com/challenges/ctci-array-left-rotation
"""
def solution(values, size, shift):
return value... |
143a2f2910db4680f61fdb5fa7831d85f64b22c0 | egalli64/pythonesque | /hr/numpy/array_mathematics.py | 592 | 3.59375 | 4 | """
HackerRank Python Numpy Array Mathematics
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.hackerrank.com/challenges/np-array-mathematics/problem
Given two arrays of dimensions NxM, print the results of
add(), subtract(), multiply(), divide(), mod(), power()
"""
import nump... |
6ac682768813f24c85fff9d25e7b1b4925079f1c | egalli64/pythonesque | /algs200x/w3/b_max_loot.py | 874 | 3.546875 | 4 | """
Maximizing the Value of a Loot
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2018/02/half-dozen-of-greedy-problems.html
https://www.edx.org/course/algorithmic-design-techniques-uc-san-diegox-algs200x
week 3 - greedy algorithms
"""
def solution(capacity, items):
result = 0.... |
6db7364faa410416aa5577b396d915d85bddc876 | egalli64/pythonesque | /pcc3/ch08/e1_function.py | 483 | 3.78125 | 4 | """
Python Crash Course, Third Edition https://ehmatthes.github.io/pcc_3e/
My notes: https://github.com/egalli64/pythonesque/pcc3
Chapter 8 - Functions - Defining a Function
"""
def greet_user():
"""define a function with no parameter"""
print("Hello!")
# invoke a function
greet_user()
def greet_user(use... |
c332dd4bca1aa794792f0b8f6fbe5021166fbbdc | egalli64/pythonesque | /cisco/pe1/3_8.py | 2,062 | 3.9375 | 4 | """
Cisco Network Academy
Python Essentials 1: https://skillsforall.com/course/python-essentials-1
My notes: https://github.com/egalli64/pythonesque - cisco/pe1 folder
PE1: Module 3 Section 8 – Test
"""
print("-2- dynamic type")
x = 1
x = x == x
print(x)
print("-3- while loop")
i = 0
while i <= 3:
i += 2
prin... |
b7041785aaf35ab3b759053d6f5b401fe340bd6c | egalli64/pythonesque | /algs200x/w3/b_max_loot_test.py | 626 | 3.734375 | 4 | """
Maximizing the Value of a Loot
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2018/02/half-dozen-of-greedy-problems.html
https://www.edx.org/course/algorithmic-design-techniques-uc-san-diegox-algs200x
week 3 - greedy algorithms
"""
import unittest
from algs200x.w3.b_max_loot imp... |
f2e3ead949e5db5d9d577f1a773a7d93b021748d | egalli64/pythonesque | /ce/c053.py | 691 | 3.5 | 4 | """
CodeEval Repeated Substring
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.codeeval.com/open_challenges/53/
"""
import sys
def solution(line):
for size in range(len(line) // 2, 0, -1):
for i in range(0, len(line) - 2 * size + 1):
candidate = line[i... |
bd3b9b6afd62bbe8ccf87a447409c73123f9343a | egalli64/pythonesque | /dive/fibonacci_iterator.py | 1,137 | 3.96875 | 4 | """
Fibonacci Iterator
Based on Dive into Python 3
Chapter 7 Classes & Iterators, section 7.5
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2017/02/fibonacci-iterator.html
http://www.diveintopython3.net/
"""
import unittest
class Fibonacci:
def __init__(self, top):
self.top =... |
af1f573196497220cb46decb593b86403e6b7df4 | egalli64/pythonesque | /dive/plural_names_generator_test.py | 799 | 3.859375 | 4 | """
Plural Names Generator
Based on Dive into Python 3
Chapter 6 Closures & Generations, sections 2, 3, 4
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2017/03/plural-names-generator.html
http://www.diveintopython3.net/
"""
import unittest
from dive.plural_names_generator import plural
c... |
36beb54b64042f18e8b8e5f8151d0d758681a976 | egalli64/pythonesque | /hr/algorithms/warmup/time_conversion.py | 632 | 3.5625 | 4 | """
HackerRank Algorithms Warmup Time Conversion
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.hackerrank.com/challenges/time-conversion/problem
07:05:45PM -> 19:05:45
"""
def timeConversion(s):
comps = s.split(':')
pm = True if comps[2][2] == 'P' else False
hh ... |
2bb2f219844d2a28e9dd14a48d9dcf5957d654f0 | egalli64/pythonesque | /cisco/pe1/2_6.py | 1,126 | 4.1875 | 4 | """
Cisco Network Academy
Python Essentials 1: https://skillsforall.com/course/python-essentials-1
My notes: https://github.com/egalli64/pythonesque - cisco/pe1 folder
PE1: Module 2 Section 6 Interaction with the user
"""
print("Tell me anything...")
anything = input()
print("Hmm...", anything, "... Really?")
anythin... |
e21000a7a19dea22bdb4d940c9c570b2e73237c8 | egalli64/pythonesque | /hr/ctci/contacts_chunk.py | 1,262 | 3.703125 | 4 | """
HackerRank Tutorials Cracking the Coding Interview Tries: Contacts - chunk version
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2017/02/hackerrank-tries-contacts.html
https://www.hackerrank.com/challenges/ctci-contacts
"""
class Node:
def __init__(self, data=None):
sel... |
c216caddda33b075c15d8ed66a4be7db881686a8 | egalli64/pythonesque | /ce/c023.py | 254 | 3.78125 | 4 | """
CodeEval Multiplication Tables
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.codeeval.com/open_challenges/23/
"""
for i in range(1, 13):
for j in range(1, 13):
print('{:4}'.format(i*j), end='')
print()
|
34f8ae3022d1c0eaad2e3ab08654184011497e75 | egalli64/pythonesque | /ce/c225.py | 795 | 3.765625 | 4 | """
Testing
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2017/01/codeeval-testing.html
https://www.codeeval.com/open_challenges/225/
"""
import sys
def solution(line):
data = line.split(' | ')
bugs = 0
for i in range(len(data[0])):
if data[0][i] != data[1][i]:
... |
4702f51e0e9622e2699d41f88085ee55ec660c60 | egalli64/pythonesque | /algs200x/w5/d_lcs2.py | 857 | 3.5 | 4 | """
Longest Common Subsequence of Two Sequences
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2018/02/longest-common-subsequence-of-two.html
https://www.edx.org/course/algorithmic-design-techniques-uc-san-diegox-algs200x
week 5 - Dynamic Programming 1
"""
def solution_dp(lhs, rhs)... |
a2f3c2932395a027a7b27c38f28c3897457af0d9 | egalli64/pythonesque | /ce/c066.py | 628 | 3.734375 | 4 | """
CodeEval Pascals Triangle
author: Manny egalli64@gmail.com
info: https://www.codeeval.com/open_challenges/66/
http://thisthread.blogspot.com/
"""
import sys
def solution(depth):
results = []
for i in range(depth):
value = 1
for k in range(i+1):
results.append(value)
... |
53b2dfe34d8ee645acc2f3ae239eeee931d5478b | egalli64/pythonesque | /cip/w2/exercise.py | 1,327 | 3.796875 | 4 | """
Code in Place 2023 https://codeinplace.stanford.edu/cip3
My notes: https://github.com/egalli64/pythonesque/cip
Section Week 2: Spread Beepers
- Custom world. Karel is on (1,1), facing east
- There is a pile of beepers on (2,1), Karel has to spread them out along the row
"""
from stanfordkarel import *
def main()... |
1be1c5fb3478f59a287184a745f8aff058f37864 | egalli64/pythonesque | /cip/w5/3.py | 717 | 3.578125 | 4 | """
Code in Place 2023 https://codeinplace.stanford.edu/cip3
My notes: https://github.com/egalli64/pythonesque/cip
Diagnostic 3
Write a program that has Karel draw four small "waves". Each wave is a triangle made up of three beepers. There is a gap between each wave.
"""
from stanfordkarel import *
def main():
... |
8ca1649b68800b5ee0b35d7690ac7bc27474e651 | egalli64/pythonesque | /pcc3/ch16/e1a_csv.py | 1,160 | 3.71875 | 4 | """
Python Crash Course, Third Edition https://ehmatthes.github.io/pcc_3e/
My notes: https://github.com/egalli64/pythonesque/pcc3
Chapter 16 - Downloading Data - The CSV File Format
"""
import matplotlib.pyplot as plt
from pathlib import Path
from datetime import datetime
import csv
# run the script from the current ... |
d1fc06458090fe202243bba9239751316ccb39c4 | egalli64/pythonesque | /ce/c230.py | 763 | 3.859375 | 4 | """
Football
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/2017/01/codeeval-football.html
https://www.codeeval.com/open_challenges/230/
"""
import sys
def solution(line):
teams = {}
for country, clubs in enumerate(line.split(' | '), start=1):
for team in map(int, clubs.sp... |
3cfc03803b848b003d43caecb1b383af99481649 | egalli64/pythonesque | /cisco/pe1/2_4.py | 1,375 | 4.53125 | 5 | """
Cisco Network Academy
Python Essentials 1: https://skillsforall.com/course/python-essentials-1
My notes: https://github.com/egalli64/pythonesque - cisco/pe1 folder
PE1: Module 2 Section 4 Variables – data-shaped boxes
"""
# an integer variable
var = 1
# a float variable
account_balance = 1000.0
# a string variable... |
dfd7159e850dee35694970197582de70436c36e9 | egalli64/pythonesque | /ce/c101.py | 1,080 | 3.90625 | 4 | """
CodeEval Python Find A Square
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
https://www.codeeval.com/open_challenges/101/
"""
import sys
import ast
def solution(line):
vertices = ast.literal_eval(line)
vertices = sorted(vertices)
a = (vertices[0][0] - vertices[1][0]) ** ... |
40076c4289b77293d60d3b3ae8f6eddb1346247d | egalli64/pythonesque | /algs200x/w2/a_fibonacci_1.py | 212 | 3.578125 | 4 | """
Naive Fibonacci calculator
Make some sort of sense only for very low input
"""
def calc_fib(n):
if n <= 1:
return n
return calc_fib(n - 1) + calc_fib(n - 2)
print(calc_fib(int(input())))
|
b917246f0b5096511a963c789bfdb9ffcd79a7e4 | egalli64/pythonesque | /dive/plural_names_iterator.py | 1,162 | 3.921875 | 4 | """
Plural Names Iterator
Based on Dive into Python 3
Chapter 7 Classes & Iterators, sections 6
author: Manny egalli64@gmail.com
info: http://thisthread.blogspot.com/
http://www.diveintopython3.net/
"""
import re
def match_apply(pattern, search, replace):
def match(word):
return re.search(pattern, w... |
e47fea4389c57b1a89fc27997dd830fbe833a580 | zanedamico/SudokuSolver | /sudoku.py | 2,607 | 3.59375 | 4 | """Sudoku by Zane D'Amico"""
from copy import deepcopy
#Currently set to Diabolical Level Sudoku problem from Los Angeles Times
board = [
[0, 6, 0, 0, 8, 0, 0, 0, 0],
[9, 0, 2, 0, 0, 0, 0, 0, 5],
[0, 0, 1, 0, 0, 0, 9, 0, 2],
[0, 0, 0, 0, 4, 6, 0, 0, 9],
[0, 0, 0, 7, 0, 9, 0, 0, 0],
[8, 0, 0, 0,... |
b84493cbc8bc7277c0836bcb908888e083870d5f | Artur-Aghajanyan/VSU_ITC | /Artur_Aghajanyan/Python/25_05_2021/perfect_number.py | 373 | 3.828125 | 4 | number = input("Enter a number for checking: ")
if not number.isdigit():
print("Input is string or small than 0")
else:
number = int(number)
sum = 0
for i in range(1,number):
if number%i == 0:
sum = sum + i
if(sum == number):
print(number, "is a perfect number")
els... |
d494031d8661c6c725c6c6c95bc57e8f6016072c | Artur-Aghajanyan/VSU_ITC | /Artur_Aghajanyan/Python/25_05_2021/pascal.py | 241 | 3.859375 | 4 | n = input("Row: ")
def printPascal(n):
for line in range(1, n + 1):
el = 1
for i in range(1, line + 1):
print(el, end = " ");
el = int(el * (line - i) / i);
print("")
printPascal(int(n))
|
391b84fabccc57fbc3d671c9f1ad6448ac7cf6d5 | Artur-Aghajanyan/VSU_ITC | /Zina_Yeghiazaryan/python/27_05_2021/n_name.py | 3,094 | 4.1875 | 4 | def word_count(str):
'''
word_count function has 1 string type argument. Function finds words whose letters are uppercase or whose only first letter starts with uppercase and returns them as a list.
'''
counts = dict()
words = str.split()
num = 0
for word in words:
a = ... |
701ce2ea934b24378be29cc58be1409c3330924b | Artur-Aghajanyan/VSU_ITC | /Nare_Mkrtchyan/python/26_05/package/str_funcs/mod2.py | 169 | 3.875 | 4 | def concat(str1,str2,sym):
return str1+sym+str2
def rtrim(str1):
c = len(str1) - 1
while str1[len(str1)-1] == " ":
str1 = str1[:-1]
return str1
|
4d4ac0d46888aaf92c3c3a339e192e7c839ac136 | Artur-Aghajanyan/VSU_ITC | /Lusine_Shahbazyan/python/printDic/printDicItems.py | 1,913 | 3.828125 | 4 | import operator
def printResult(dic, n):
sortedDic = {}
sortedDic = dict(sorted(dic.items(), key=operator.itemgetter(1), reverse=True))
for key, value in dict(sortedDic).items():
if value == 1:
del sortedDic[key]
for key,value in sortedDic.items():
if n == 0:
... |
fa15f2dcb532266e72b8cd0b08a7acef57f989a2 | Artur-Aghajanyan/VSU_ITC | /Anna_Mayilyan/python/25_05/perfect_num.py | 351 | 3.859375 | 4 | def is_Perfect(n):
S = 0
for i in range(1, n):
if(n % i == 0):
S = S + i
if (S == n):
print(" %d is a Perfect Number" % n)
else:
print(" %d is not a Perfect Number" % n)
try:
n = int(input(" Enter number: "))
is_Perfect(n)
except ValueError:
print("Enter... |
8893f742e9148925156a8949f59f6993e3623fe5 | neozhaoliang/pywonderland | /src/gifmaze/gifmaze/gentext.py | 932 | 4.3125 | 4 | from PIL import Image, ImageDraw, ImageFont
def generate_text_mask(size, text, fontfile, fontsize):
"""
This function helps you generate a black-white image with text
in it so that it can be used as the mask image in the program.
The black pixels are considered as 'blocked' and white pixels
are co... |
2325c3a684f78614fdbf4442eac23bc4dcdceefd | neozhaoliang/pywonderland | /src/gifmaze/example_game_of_life.py | 4,021 | 3.703125 | 4 | """
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Make gif animations of Conway's game of life
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For more patterns see
"https://bitstorm.org/gameoflife/lexicon/"
:copyright (c) 2018 by Zhao Liang
"""
import os
import numpy as np
from tqdm import tqdm
from gifmaze import... |
2fb745745139256c6240ab5e4e3d7eda656a30c2 | neozhaoliang/pywonderland | /src/polytopes/polytopes/povray.py | 1,776 | 3.609375 | 4 | """
Some POV-Ray stuff.
"""
def concat(arr, sep=",\n", border=None):
"""Concatenate items in an array using seperator `sep`.
"""
if border is None:
return sep.join(str(x) for x in arr)
return border.format(sep.join(str(x) for x in arr))
def pov_vector(v):
"""Convert a vector to POV-Ray f... |
2efde3ba165898265a6f9108554d902cde4db388 | neozhaoliang/pywonderland | /src/gifmaze/example_langton_ant.py | 2,148 | 3.90625 | 4 | """
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Make gif animation of Langton's ant
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reproduce the image at
"https://en.wikipedia.org/wiki/Langton%27s_ant"
:copyright (c) 2018 by Zhao Liang
"""
from gifmaze import create_animation_for_size
ncols, nrows = 80, 80 # grid size
cell_size ... |
7ffc54dd6c5a5ac8c218f69a341c40ad008a6ea6 | nicoseng/Projet-5-OFF | /product_extractor.py | 3,186 | 3.53125 | 4 | """Internal imports"""
import requests
class ProductExtractor:
"""
To extract the product datas for each category
from the file called category_extractor.py
"""
@staticmethod
def get_new_category_url(page_size, category_name, retry=3):
"""
To return URL of each category... |
1c68dc6e192e69652fa6481b2c6b659b0c1b770c | tadeoa23/ayed1-iresm-2021 | /Unidad_5/ejercicio5.9.py | 2,749 | 3.953125 | 4 | '''
##**Ejercicio 5.9 (Empresa de Taxis)**
El programa debe:
* Simular una empresa de taxis que cuente con tres Autos con sus respectivos cheferes
```
Taxis=[["auto_1","auto_2","auto_3"],["chofer_1","chofer_2","chofer_3"],[45,50,30]]
```
* Cada auto cuenta con un chofer y no hace recorridos mayores a lo q se le ... |
ea3612ed34118bbf22b586638b2bd5342a163fe9 | tadeoa23/ayed1-iresm-2021 | /Unidad_5/ejercicio5.15/main.py | 1,688 | 4.25 | 4 | """
##**Ejercicio 5.15 (Base de peliculas)**
El programa debe:
* Simular una base de datos de peliculas y series con la capacidad de agregar, buscar, eliminar y filtrar peliculas y series.
* Debe comenzar con las siguientes peliculas y series en un diccionario:
```
base = {
"peliculas" : ["El hombre araña", "L... |
9dd28985de91a444e08d61442ef28c684adf8975 | tadeoa23/ayed1-iresm-2021 | /Unidad_6/programa6.4/Vehiculos.py | 3,203 | 3.84375 | 4 | """
###**Ejercicio 6.4**
Crear una clase padre Vehiculos:
* Constructor debe incluir los atributos (patente,marca,año,origen)
* Crear metodos para esta clase de:
1. Presentarse (patente,marca,año,origen)
2. Indicar tipos de vehiculo(Clases heredadas)
3. Metodos que luego modificarán las clases hijas.... |
acd2d2abf420da0d67ef3cb3b5b9263c60c9b5c8 | tadeoa23/ayed1-iresm-2021 | /Unidad_5/5.10cande/funciones.py | 2,644 | 3.8125 | 4 | def alfabeto (alfabeto_a):
try:
print("-----------------------------------ALFABETO-----------------------------------")
print(f"{alfabeto_a}")
except:
print("ERROR.")
def alfabeto_moorse (alfabeto_b):
try:
print("------------------------------ALFABETO EN CÓDIGO MORSE--------... |
a7a7fde803df65569414012e9c248be481fd8928 | tadeoa23/ayed1-iresm-2021 | /Unidad_6/programa6.3/gestorDePeliculas.py | 4,973 | 4 | 4 | """El programa debe: gestorDePeliculas
* Tener un menu con 7 opciones:
1. Crear una pelicula y guardar su nombre (instancia) en una lista de peliculas.
2. Verificar si la pelicula deseada existe en la lista de peliculas (a partir del nombre).
3. Pedir a la lista de peliculas, todas las de un año.
4. P... |
79ba7e3429319e50e5cc3a2e915375c0618792bb | tadeoa23/ayed1-iresm-2021 | /Unidad_6/programa6.3/ClasePelicula.py | 1,735 | 4.03125 | 4 | """
Crear una clase de Peliculas:
* Cuyo constructutor debe inicializar los atributos nombre, año, genero, nacionalidad, puntuacion
* Se deben crear 4 metodos en la clase:
1. Presentar la pelicula: La pelicula {nombre} de {genero} del {año} obtuvo una puntuacion de {puntuacion}
y fue filmada en {naci... |
7d37173332e02a09c1bd84688f68006d7a811a51 | weckoe/teachmeskills | /pervoe_dz.py | 4,502 | 3.796875 | 4 | #сделал все в одном файле(для удобства просмотра)
#1. Записать число 254 в разных системах исчесления
print(int(254))
print(bin(254))
print(hex(254))
print(oct(254))
#2. Посчитать количество целых недель в году и сколько дней "лишних"
a = 365 #количество дней в году
b = 7 #количество дней в неделе
c = a // b #деление ... |
1edb14a89a3533b3ec60f40929fd997ce601f139 | DreGorski2/udacity-unscramble-comp-sci-problem | /task4.py | 1,671 | 4 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
import os
path = os.getcwd()
def text_data(path):
with open(path + '/data_files/texts.csv', 'r') as t:
reader = csv.reader(t)
texts = list(reader)
return texts
def call_data(path):
with... |
24214a56707611a0d7915377bcee121856955eef | lumafragoso/Funcoes_Plot_Funcao_Randint | /main.py | 1,675 | 3.921875 | 4 | import random
import matplotlib.pyplot as pyplot
def principal():
i = int(input('Inteiro inicial do intervalo? '))
f = int(input('Inteiro final do intervalo? '))
num = int(input('Quantidade de escolhas? '))
funcaoElementos(i, f, num) #chama a função num
def funcaoElementos(inicial, final , n):
list... |
051ae141e35374affda7bd52ac17ea7cf01bb8bb | JhaPrashant1108/leetcode | /leetCode79/79_Word_Search.py | 1,035 | 3.703125 | 4 | class Solution:
def exist(self, board, word):
m, n, p = len(board), len(board[0]), len(word)
def finder(r, c, pos):
if pos >= p:
return True
elif 0 <= r < m and 0 <= c < n and board[r][c] == word[pos]:
temp = board[r][c]
board[... |
99c20ebaf26c29bc623741ac37dd34c50972be52 | JhaPrashant1108/leetcode | /leetCode94/94_Binary_Tree_Inorder_Traversal.py | 1,140 | 3.671875 | 4 | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def inorderTraversal(self, root):
stack = []
val = []
if root == None:
return val
curr = root
while c... |
26ef9be3b3acd2d890981b8a0019d1622c713cf7 | AnandBenjamin/daily-pgms-juniors | /OOPS/Live_Coding/ducktyping.py | 289 | 3.625 | 4 | #Duck Typing
class Bird:
def fly(self):
print("Fly with Wings")
class Aeroplane:
def fly(self):
print("Fly with Fuel")
class Fish:
def swim(self):
print("Swim in water")
for obj in Bird(),Aeroplane(),Fish():
obj.fly()
|
87e84b4ac2e38ce491f644e5741fadd0ef286edf | AnandBenjamin/daily-pgms-juniors | /OOPS/Live_Coding/Inheritance.py | 486 | 4 | 4 | #inheritance----by NAVEEN UH!!!!
class Animal:
def __init__(self,a,b):
self.a=a+5
self.b=b+5
print("Animal",self)
print(self.a,self.b)
def speak(self):
print("swega animal")
class dog(Animal):
def __init__(self,a,b):
print("Dog",self)
#super().__init_... |
3caf0fb1bc8359b872c3d8d4d92f34fb75126ef3 | AnandBenjamin/daily-pgms-juniors | /Yasar/join_fun.py | 110 | 3.625 | 4 | #Concatenating Strings
characters=['y','a','s','a','r']
word="".join(characters)
print(word)
#ouput:yasar
|
1c84dc4c98ef23c3a9f84799bdd53b46b52dbf86 | AnandBenjamin/daily-pgms-juniors | /OOPS/Practice/encapsulation.py | 1,102 | 3.9375 | 4 | #using atribute
class Person:
def __init__(self):
self.name = 'Naveen'
self.__age = 20
def __display(self):
print("private method")
def Printage(self):
self.__display()
return self.name +' ' + str(self.__age)
P = Person()
print(P.name)
print(P.Printage())
#print(P.__displ... |
2d069597eaa239f51efa8aac260df90aa5362eee | AnandBenjamin/daily-pgms-juniors | /Yasar/test1.py | 467 | 3.71875 | 4 | class Employee:
age=0
def __init__(self,agefromuser):
self.age=agefromuser
print("Inside constructor")
#print(self)
def ageeligibility(self):
if self.age>20:
print("adult")
else:... |
e3866c3b4ea28081ebb2f6e89d2ba754b4312336 | CapitanS/hillel_flask | /database_hw3.py | 1,269 | 3.59375 | 4 | import os
import sqlite3
database_name = 'db_hw3.sqlite3'
DEFAULT_PATH = os.path.join(os.path.dirname(__file__), database_name)
def init_database():
"""
Create database in current folder.
Create table 'customers' with columns 'id', 'FirstName', 'LastName'.
Create table 'tracks' with columns 'id', 'Tr... |
a631f0dbc9dc3e21f70fa61105d800b0aefddd49 | frilox042/Steamgifts | /stat.py | 1,003 | 3.5 | 4 | import sqlite3
from sg_requests import SgRequests
def nb_entry():
conn = sqlite3.connect(SgRequests.sqlite_db_name)
c = conn.cursor()
q = 'SELECT count(*) FROM ENTRY'
c.execute(q)
nb_entry = c.fetchone()[0]
conn.close()
return nb_entry
def average_point():
conn = sqlite3.connect(SgRequ... |
5b4b846afa908d9292562d6f0ab8ecdaef29eaa4 | ReezanVisram/Project-Euler | /Problem-25-1000-Digit-Fibonacci-Number.py | 277 | 3.734375 | 4 | def fibonacci(n):
arr = [i for i in range(n + 1)]
arr[0] = 0
arr[1] = 1
for i in range(2, n + 1):
arr[i] = arr[i - 1] + arr[i - 2]
return int(arr[n])
n = 2
while True:
n += 1
if (len(str(fibonacci(n))) >= 1000):
break
print(n)
|
e123e071f9304a435c71015b89c93876917729ea | ReezanVisram/Project-Euler | /Problem-5-Smallest-Multiple.py | 686 | 3.859375 | 4 | # Project Euler Problem 5
# What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
# Starts off the counter at 20
i = 20
""" Loops until the number is divisible by everything between 1 and 20 (Didn't have to check all numbers because if that number times 2 is less than 20,
an... |
0ab344621ab6d3521a28999b286b593c0a5f711d | ReezanVisram/Project-Euler | /Problem-20-Factorial-Digit-Sum.py | 864 | 3.828125 | 4 | <<<<<<< HEAD
# Project-Euler Problem 20
# Find the sum of the digits in the number 100!
# A recursive factorial function (Could have used the math library)
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
# Assigns 100! to a variable
num = factorial(100)
total = 0
# Goe... |
c015229017b981eaf01ba8930b5bdff9e1e10193 | chinocai/fablab | /ejer3.py | 3,022 | 3.921875 | 4 | print ("bienvenidos a Automotores Carlitos")
nombre=input ("Ingresá tu nombre: ")
monto=int(input("Por favor " + nombre + " ingrese el monto disponible para la compra."))
if (monto < 1000000):
print ("no se poseen autos de ese rango de precios, debera reingresar el monto nuevamente.")
monto=int(input("reingr... |
cb9a6b30967d21b25a469f596cbd24a88762dfc2 | ScreamKing13/CompGraph-Lab_2 | /Lab_2(test).py | 1,992 | 3.609375 | 4 | import matplotlib.pyplot as plt
import numpy as np
A, B, D, N = 2, 3, 1, 10 # Константы
def make_ornament(period, radius): # Функция, создающая орнамент, вращая осн. рисунок по кругу с радиусом radius
fig5 = plt.figure(figsize=(8, 7)) # и периодом period, при этом изменяя его форму.
plt.ti... |
91e9cc8217fb0a619555315a262a20da7808b6f4 | deepti-chauhan/Data_Structures_in_python | /queue.py | 3,379 | 4.25 | 4 |
''' Like stack, queue is a linear data structure that stores items in First In First Out (FIFO) manner.
With a queue the least recently added item is removed first.
A good example of queue is any queue of consumers for a resource where the consumer that came first is served first.'''
class Queue(obje... |
08c139cd1c86ecdc3831dc18593380bfb45840d2 | moog2009/Python | /ex7_add.py | 581 | 3.78125 | 4 | # -*- coding: utf-8 -*-
#打印字符串
print "Mary had a little lamb"
#打印字符串,snow为字符串
print "Its fleece was white as %s." %'snow'
#打印字符串
print "And everywhere that Mary went."
#打印字符*10次
print "."*10 # what'd that do
#字符串赋值
end1="C"
end2="h"
end3="e"
end4="e"
end5="s"
end6="e"
end7="B"
end8="u"
end9="r"
end10="g"
end11="e"
... |
c2fa7db660f0535cb3b2f4d6941bba106c883ab1 | moog2009/Python | /ex42.py | 811 | 4.09375 | 4 | # -*- coding: utf-8 -*-
## Animal is-a object (yes, sort of confusing) look at the extra credit
class Animal(object):
pass
## is-a
class Dog(Animal):
def __init__(self,name):
## is-a
self.name=name
## is-a
class Cat(Animal):
def __init__(self,name):
## is-a
self.name=name
## is-a
class Person(object... |
6ab9239d6e41481a6a3e309d1031df04663ead78 | moog2009/Python | /ex6_add.py | 968 | 4.1875 | 4 | # -*- coding: utf-8 -*-
#赋值字符变量x
x="There are %d types of people." %10
#赋值字符变量binary
binary="binary"
#赋值字符变量
do_not="don't"
#赋值字符变量y (字符串包含字符串)
y="Those who know %s and those who %s." %(binary,do_not)
#打印变量X
print x
#打印变量y
print y
#打印含变量X的字符串 (字符串包含字符串)
print "I said: %r" %x
#打印含变量y的字符串 (字符串包含字符串)
print "I also sai... |
c4cf86c22ce66a3d308bda9f6c514891f5990755 | gil-golan/Coding | /Computational Thinking/Conditionals.py | 1,318 | 3.625 | 4 | def driving(driving):
if driving<17:
driving=False
if driving>16:
driving=True
return driving
print(driving(16))
print(driving(25))
def id_triangle(a,b,c):
if a**2+b**2 == c**2:
id_triangle="Triangle is right angled"
if a**2+b**2 > c**2:
id_triangle="Triangle is acu... |
04f4f8189059341bf17207a9753df2bc47884834 | LikithNarukurthi/advDataStructuresPy | /Week3/ArrayStack.py | 1,570 | 3.90625 | 4 | import random
class ArrayStack:
def __init__(self):
self.revdata = []
self.data = []
def __len__(self):
return len(self.data) # 221910307033 ( Likith Narukurhti)
def is_empty(self):
return len(self.data) == 0
def push(self, ele):
... |
6dba967f10171e6d75fb1d025af742ae6ca8151d | lauramayol/laura_python_core | /week_02/labs/05_functions/Exercise_03.py | 510 | 4.0625 | 4 | '''
Write a program with 3 functions. Each function must call
at least one other function and use the return value to do something.
'''
def concat_delim(word, delim):
message = word + delim + word
return message
def print_z(wordz, z, delimz):
message = ""
for y in range(0, z):
print(do_x(wo... |
9153fd8991b51e5d45853fab31e263bb8212716e | lauramayol/laura_python_core | /week_02/labs/04_conditionals_loops/Exercise_01.py | 563 | 4.40625 | 4 | '''
Write a program that gets a number between 1 and 1,000,000,000
from the user and determines whether it is odd or even using an if statement.
Print the result.
NOTE: We will be using the input() function. This is demonstrated below.
'''
num = int(input())
check = 0
while check == 0:
if num > 0 and num <= 10000... |
7c8276be69cca221a53ed736cf3c85cfef2b4081 | lauramayol/laura_python_core | /week_03/labs/06_strings/Exercise_05.py | 617 | 4.625 | 5 | '''
Write a script that takes a user inputed string
and prints it out in the following three formats.
- All letters capitalized.
- All letters lower case.
- All vowels lower case and all consonants upper case.
'''
user_input = input()
print("All letters capitalized: " + user_input.upper())
print("All lette... |
6098a224ef49862b6dab88589ab33071360e3244 | lauramayol/laura_python_core | /week_03/labs/06_strings/Exercise_02.py | 162 | 4.09375 | 4 | '''
Complete Exercise 8.3 (p.95) from the textbook.
'''
def is_palindrome(word):
if word == word[::-1]:
return True
else:
return False
|
bc8e3c4a38632ee50cda77074ee4218f86e30f17 | lauramayol/laura_python_core | /week_03/labs/12_files/12_03_duplicates.py | 1,711 | 4.09375 | 4 | '''
In a large collection of MP3 files, there may be more than one copy of
the same song, stored in different directories or with different file
names. The goal of this exercise is to search for duplicates.
Write a program that searches a directory and all of its subdirectories,
recursively, and returns a list of comp... |
6758fff3217529cf525aec33c8f0c862eda13800 | lauramayol/laura_python_core | /week_03/mini_projects/random_hashtag.py | 893 | 4.28125 | 4 | '''
--------------------------------------------------------
RANDOM HASHTAG GENERATOR
--------------------------------------------------------
Programmatically generate random hashtags by picking from a word list.
Tip: In UNIX systems you can access a dictionary file at this path:
/usr/share/d... |
b3d4923c7686c6992f6115458da5f41597419733 | lauramayol/laura_python_core | /week_02/labs/03_variables_statements_expressions/Exercise_09.py | 457 | 4.28125 | 4 | '''
Receive the following arguments from the user:
- miles to drive
- MPG of the car
- Price per gallon of fuel
Display the cost of the trip in the console.
'''
#Note: the below code did not work in Sublime but it worked in Python interpreter. I tried installing SublimeREPL as per some web forums but it ... |
5620de22200edf9563aed28bf86caa10b904c678 | lauramayol/laura_python_core | /week_05/mini_projects/Follow_Birds_Project/followbirds.py | 2,596 | 3.65625 | 4 | '''
Using the tweepy package, build a script that classifies a twitter handle
into different groups according to the number of their followers.
The classes can be whatever you like (e.g. I used ASCII art birds ;)
CHALLENGE: Also fetch the number of their friends and display the ratio
between followers and friends in ... |
a8e4a897889cd72c753ea28a6928fe69755752d7 | MadJayQ/CasinoGame | /Craps/Craps Gamee.py | 1,764 | 3.9375 | 4 | __author__ = 'William'
import random
moneys= 0
bet=0
froll=False
roll=0
def money():
global moneys
moneys=int(input("How much money are you starting with?"))
print("Your overall balnce is",moneys)
return moneys
def betm():
global bet
bet=int(input("What amount would you like to bet."))... |
1627a68275767f88350de1793971b20d37bf1fb4 | richyhoopd/data-structures-and-algorithms | /bubble_sort.py | 420 | 4.1875 | 4 | import random
def bubble_sort(numbers):
for pass_num in range(len(numbers) - 1, 0, -1):
for i in range(pass_num):
if numbers[i] > numbers[i + 1]:
numbers[i], numbers[i + 1] = numbers[i + 1], numbers[i]
return numbers
if __name__ == '__main__':
numbers = [random.randint... |
422305f08b87312578fbf21cfe206ae4e9e1c05b | Arpit-Atriwal/Assigment | /Untitled-2.py | 239 | 3.765625 | 4 | from typing import List
def singleNumber(nums: List[int]) -> int:
for i in nums:
if(nums.count(i) == 1):
return(i)
nums = [4,1,2,1,2]
num = [2,2,1]
print(singleNumber(num))
|
59011d0e2dcdd3ad569ce4f483fe7f632e6a11f7 | bsantos2/DataStructuresAlgos2 | /problem_6.py | 5,075 | 3.875 | 4 | class Node:
def __init__(self, value):
self.value = value
self.next = None
def __repr__(self):
return str(self.value)
class LinkedList:
def __init__(self):
self.head = None
self.next = None
self.tail = None
def __str__(self):
cur_head = self.he... |
ed7f679341d07c64a184689858c4ca5c443b0043 | khedodhiambo/Python_examples | /date_manipulation.py | 706 | 4.21875 | 4 | import datetime
# currentDate = datetime.date.today()
# print(currentDate.year)
# print(currentDate.month)
# print(currentDate.day)
# print(currentDate.strftime('%a %d %B, %Y'))
userDate = input("Enter that magic day(dd/mm/yyyy): ") # 12/05/2016
startDays = datetime.datetime.strptime(userDate, '%d/%m/%Y').date()
... |
747fa7f70c500ae1b5b0fb7d1ffbade44c17e706 | rachelktyjohnson/treehouse-py-project1 | /guessing_game.py | 2,624 | 4.3125 | 4 | """
Python Web Development Techdegree
Project 1 - Number Guessing Game
--------------------------------
For this first project we will be using Workspaces.
NOTE: If you strongly prefer to work locally on your own computer, you can totally do that by clicking: File -> Download Workspace in the file menu after y... |
b2030b070650673a88d71b19e614070cc9180848 | weblancaster/python-studies | /days/day_09.py | 745 | 4.09375 | 4 | """
Day 09
Decorators
"""
import functools
def do_something(method):
@functools.wraps(method)
def my_decorator():
print("at decorator")
method()
print("after")
return my_decorator
@do_something
def my_function():
print("my function")
my_function()
def decorator_with_arg... |
5c253ec4dd29c2cf1275a6de89fa2812e223a19f | weblancaster/python-studies | /test/test_sum.py | 454 | 3.875 | 4 | """
Day 29
Getting started with unit test in python, understandin the envirnment, setup and maybe some quirks?
"""
def sum_values(val_a, val_b):
"""[Sum two values received in arguments]
Arguments:
val_a {[Number]}
val_b {[Number]}
Returns:
[Number] -- [sum of arguments]
"""
... |
85e9b1d1118f67ec4aed42095e3e84bdf2349d5f | fragroute/python | /ex15.py | 616 | 4.34375 | 4 | from sys import argv #import a module which named argv
script,filename = argv #read input and assign them to the variables
txt = open(filename) #use function open a file from input
print "Here's your file %r:" % filename #print the filename
print txt.read() #call a function on txt named read, and pr... |
18d0fcfccab0080b769d34f74e6ad1a317bd1695 | JuanCarlos-A01376511/Mision_02 | /clase.py | 726 | 4.03125 | 4 | # Autor: Juan Carlos Flores García, A01376511
# Descripcion: Programa que calcula el total de alumnos inscritos y el porcentaje de hombres y mujeres.
# Escribe tu programa después de esta línea.
mujeresNumero = float(input("Teclea el número de mujeres incritas: "))
hombresNumero = float(input("Teclea el número de homb... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.