blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e284753f4bee31a5722ed0e0947d2639c141aac6
kaismithereens/realpython
/pages 0-100/exercises_pg91.idea.py
1,483
3.65625
4
#How many times the die has fallen on each number in 10000 roles from random import randint number_1 = 0 number_2 = 0 number_3 = 0 number_4 = 0 number_5 = 0 number_6 = 0 for simulation in range(1,10001): number = randint(1,6) if number == 1: number_1 = number_1 + 1 elif number == 2: number_2 = number_2 + 1 e...
d68d94382e691af903aa6b25de8d6d87bb856256
kaismithereens/realpython
/tuples.py
454
3.859375
4
my_tuple = ("you'll", "never", "change", "me") print(my_tuple) print(my_tuple[2]) print(my_tuple.index("me")) def adder_subtractor(num1, num2): add = num1 + num2 subtract = num1 - num2 return add, subtract print(adder_subtractor(3, 2)) test = adder_subtractor(4, 3) print(test) print(type(test)) coordinates = 4....
901e369c5a3ae8f25a8b2a2e529dc12711f67926
kaismithereens/realpython
/capital_city_loop.py
500
4.125
4
from capitals import capitals_dict import random state = random.choice(list(capitals_dict.keys())) capital = capitals_dict[state] def my_function(state, capital): while True: guess = input("What is the capital of {}?".format(state)) if guess == "exit" or guess == "EXIT" or guess == "Exit": print("The capital ...
1e49370442ae50da33a3e8060881be44b57864d7
kaismithereens/realpython
/pages 0-100/exercises_pg59.py
208
4.03125
4
for n in range(2, 11): print(n) num = 2 while(num < 11): print(num) num = num + 1 def doubles(number): result = number while(result < (number * 8)): result = result * 2 print(result) doubles(2)
9e96caddf4532f1f2fbd232841740b5926b0461c
kaismithereens/realpython
/dictionaries.py
964
3.578125
4
phonebook = {"Jenny": "867-5309", "Mike Jones": "281-330-8004", "Destiny": "900-783-3369"} print(phonebook) print(phonebook["Jenny"]) phonebook["Obama"] = "202-456-1414" print(phonebook) phonebook["Jenny"] = "555-0199" print(phonebook) del(phonebook["Destiny"]) print(phonebook) print(phonebook.keys()) names = phone...
c2ad44bb6dc7a4f09fd9d1f99dad8fbd36c9d52e
WillingGithubDude/Cozyeto
/modules/minesweeper.py
5,208
3.65625
4
class Tile: def __init__(self, displayValue, value, x_pos, y_pos): self.displayValue = displayValue self.value = value self.position = x_pos, y_pos self.revealed = False def reveal(self, board): self.revealed = True if self.displayValue != "[₱]": if self.value == "X": return...
d215b16102f797093d621e6d34cb3fe81eda4a21
indhu1-dev/pythonProject1
/online movie ticket.py
3,164
3.640625
4
fc_ticket=[] sc_ticket=[] ticket_cost_fc=250 ticket_cost_sc=150 count=0 name=[] for i in range(1,10): fc_ticket.append(i) for j in range(11,50): sc_ticket.append(j) for k in range(1,50): name.append(k) while True: print("""enter your choice 1.book ticket 2.delete...
295611aac3a5915b5bc6fe64320d719db554a530
PyaePanSan/coding-sprint
/ex34.py
597
3.953125
4
animals = ['bear', 'python3.6', 'peacock', 'kangaroo', 'whale', 'zebra'] print(f"The animal at 1 is the 2nd animal and is a {animals[1]}.") print(f"The third (3rd) animal is at 2 and is a {animals[2]}.") print(f"The first (1st) animal is at 0 and is a {animals[0]}.") print(f"The animal at 3 is the 4th animal and is a ...
2ca97ec96695c94fbdaf6dde04d835cd4c07bb4d
yachmeneva/hello-world
/conditions.py
1,369
3.84375
4
#encoding: utf-8 print("Привет, OY!") p = 'red' if p == 'green': print("You won 5 points") elif p == 'yellow': print("Your won 10 points") else: print("You won nothing.") colors = ['red', 'green', 'blue'] if 'red' in colors: print('Red is allowed.') if 'redd' not in colors: print('Redd is not allowed') #users =...
0e7fd6a2e0f7aba44af2a6d893b433d96ff121b6
IDK601/magic-8-ball
/8ball.py
548
3.59375
4
#The Magic 8 Ball import time from random import randint replies =["Yes","No","Possibly", "Ask again later", "IDK"] def question(): print ("What is your question?") question = input() print ("Thinking...") time.sleep(3) print (replies [randint(0,4)]) end()...
6b56b08ad463163978f217507d6a51b96dca9dd3
Sarat-Python/techmojo
/time_diff.py
527
3.78125
4
import pandas as pd import datetime from datetime import datetime import numpy as np df = pd.read_csv('test.csv', sep = ",") time_lst = df['time'].tolist() ''' Function to calculate the time difference ''' def timeavg(time_lst): new =[] # declare an empty list for i in range(len(time_lst)): h,m,s = t...
c158d424ba5e600442addd11667ab3135b9326cb
fouad89/Python-Analytics
/user_gui.py
751
3.796875
4
from tkinter import * window=Tk() file=open('user_gui.txt','a+') def add(): file.write(entry.get()+'\n') #to get file from window entry entry.delete(0,END) def save(): global file file.close() file=open('user_gui.txt','a+') def close(): file.close window.destroy() ''' Text entry field ''' us...
dbf90a32282e4640497dac009c169ad87e939df6
usunday/python_examples
/sun_angle.py
433
3.59375
4
from datetime import datetime from datetime import timedelta def sun_angle(time): #replace this for solution now=datetime.strptime(time,"%H:%M") now_dt=timedelta( minutes=now.minute+now.hour*60 - 6*60) if now_dt < timedelta( minutes=0) or now_dt > timedelta(minutes=60*12): return "i cannot see...
2fd9a15c835262fd5e19b6ea9ae7388ea92f6cfe
usunday/python_examples
/radiz.py
276
3.90625
4
def radix(str_number :str, radix: int): sum=0 for e in str_number: if e.isnumeric(): sum += radix*e if e.isalpha(): sum += (ord(e) - 55) print(sum) return sum print((ord('F') - 55)) #exit() r=radix("AF", 16) print(r)
2f08974606892d995bab221ce761fa1834acae5a
albert55albert/Text-based-apps-python
/Text-based programs/Jocul fantomelor.py
572
3.890625
4
#Jocul fantomleor from random import randint print("Jocul fantomelor") feeling_brave = True score = 0 while feeling_brave: ghost_door = randint(1, 3) print("Exista trei usi...") print("In spatele uneia se afla o fantoma...") print("Ce usa doresti sa deschizi ?") door = input ("1, 2 sau 3 ?") door_num =...
e58613890dab2fd3c77a6cb7e2fff2a0437666e6
cindyvillanuevads/python-exercises
/list_comprehensions.py
5,287
4.3125
4
# 17 list comprehension problems in python fruits = ['mango', 'kiwi', 'strawberry', 'guava', 'pineapple', 'mandarin orange'] numbers = [1,2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 17, 19, 23, 256, -8, -4, -2, 5, -9] # Example for loop solution to add 1 to each number in the list numbers_plus_one = [] for number in numbers...
1db84a0f8c2f1b4e400aad088ba395a93493c329
zacgilby/cp1404practicals
/prac_04/total_income.py
830
4.09375
4
""" CP1404/CP5632 - Practical A program that calculates the cumulative amount of income over a number of months and displays it in a report format.. """ def main(): incomes = [] number_of_months = int(input("How many months? ")) for month in range(number_of_months): monthly_income = float(input("...
51944c784d557f43f08645d6ec8e4f314d1c4787
zacgilby/cp1404practicals
/prac_02/files.py
575
4
4
""" Ask the user for their name and write it to a file called "name.txt" """ OUTPUT_FILE = "name.txt" out_file = open(OUTPUT_FILE, 'w') print("Bob", file=out_file) out_file.close() in_file = open(OUTPUT_FILE, 'r') name = in_file.read() print("Your name is {}".format(name)) in_file.close() in_file = open("numbers.txt...
a8f187e350c6abcbb8e2344333678820f4e37d3a
huanghe34/CS61A
/test.py
6,241
3.859375
4
def multiadder(n): assert n > 0 if n == 1: return lambda x: x else: return lambda a: lambda b: multiadder(n - 1)(a + b) def compose1(f, g): def h(x): return f(g(x)) return h def repeat_sum(f, x, n): total, k = 0, 0 while k <= n: total = total + x x =...
ed85760372206d04cfbc6cb70a6de549ab185fb9
menard-noe/LeetCode
/Sqrt(x).py
726
3.921875
4
import math class Solution: def mySqrt(self, x: int) -> int: if x < 2: return x left = 1 right = x while left != right: middle = int(math.floor((left + right)/2)) middle_squared = middle * middle if middle_squared == x: ...
26620889f815b5e8935f960ab444bff8e37346bc
menard-noe/LeetCode
/Excel Sheet Column Title.py
527
3.5625
4
from typing import List class Solution: def convertToTitle(self, n: int) -> str: result = "" alphabets = 'ZABCDEFGHIJKLMNOPQRSTUVWXY' alphabets = list(alphabets) while n > 0: d = n % 26 result = alphabets[d] + result n = n // 26 if ...
b6ada8d549d3072cbbdde3675d31a39f1f29eb90
menard-noe/LeetCode
/Find Words That Can Be Formed by Characters.py
966
3.78125
4
from typing import List class Solution: def countCharacters(self, words: List[str], chars: str) -> int: word_count = [] dico_chars = dict() for word in words: dico = dict() for char in word: dico[char] = dico.get(char, 0) + 1 word_count.a...
8e3487b731abdc429e6c707a104b3874adc6d2ed
menard-noe/LeetCode
/Subtree of Another Tree.py
1,085
3.921875
4
import math # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def isSubtree(self, s: TreeNode, t: TreeNode) -> bool: def sameTree(s: TreeNode, t: TreeN...
d8cc887172f5bed6f134ca55248c3532a2879e10
menard-noe/LeetCode
/Duplicate Zeros.py
692
3.53125
4
from typing import List class Solution: def duplicateZeros(self, arr: List[int]) -> None: cum_zero = [] sum_zero = 0 for val in arr: cum_zero.append(sum_zero) if val == 0: sum_zero += 1 for i in range(len(arr) - 1, -1, -1): new_...
a90461eab18e6b58888f270bc452a990f83b646d
menard-noe/LeetCode
/Power of Three.py
373
3.6875
4
from typing import List class Solution: def isPowerOfThree(self, n: int) -> bool: res = 1 while res <= n: if res == n: return True res *= 3 return False if __name__ == "__main__": # execute only if run as a script nums = 9 solution = S...
ede5bc94e8563f6def0b645e5970298499375b8a
menard-noe/LeetCode
/Decrypt String from Alphabet to Integer Mapping.py
596
3.75
4
import heapq from typing import List class Solution: def freqAlphabets(self, s: str) -> str: heap = [] i = len(s) - 1 while i >= 0: if s[i] == '#': heap.append(chr(int(s[i-2:i]) + 96)) i = i - 3 else: heap.append(chr(i...
08a8124f9aea261515c892d126f0d1a6d72c4f52
menard-noe/LeetCode
/Sum of Square Numbers.py
478
3.546875
4
# Definition for a binary tree node. import math class Solution: def judgeSquareSum(self, c: int) -> bool: dico = dict() for i in range(0, int(math.floor(math.sqrt(c))) + 1): dico[i*i] = 1 for key in dico: if c - key in dico: return True retu...
8885877f7fc0d8b8375bc8c3c57358c2fd3b3b84
menard-noe/LeetCode
/Consecutive Characters.py
571
3.59375
4
from typing import List class Solution: def maxPower(self, s: str) -> int: if len(s) == 0: return 0 prev = s[0] current = 1 max_val = current for i in range(1, len(s)): if s[i] == prev: current += 1 else: ...
183131dd6bebfdebb8117bd12b1e2b7b35a449cd
menard-noe/LeetCode
/Sum of Left Leaves.py
917
3.765625
4
import math class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def sumOfLeftLeaves(self, root: TreeNode) -> int: if root is None: return 0 def util(leaf: TreeNode, left: bool...
96b308d9bcc6f7b031725fe654c3d5083ba197ce
menard-noe/LeetCode
/Reverse Linked List.py
629
3.84375
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def reverseList(self, head: ListNode) -> ListNode: prev_node = None current_node = head while current_node is not None: ...
25ff4590cc25741b78e5c8416e1cfb9f98bf0ab3
menard-noe/LeetCode
/Arranging Coins.py
511
3.6875
4
import math class Solution: def arrangeCoins(self, n: int) -> int: left, right = 0, n while left <= right: k = (right + left) // 2 curr = k * (k + 1) // 2 if curr == n: return k if n < curr: right = k - 1 el...
35e7eca625c21461ea40448c6160f477139119af
menard-noe/LeetCode
/Minimum Depth of Binary Tree.py
862
3.765625
4
# Definition for a binary tree node. import math class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def __init__(self): self.ans = [] def minDepth(self, root: TreeNode) -> int: if r...
bf036ab472cb4d25df1076e0482a38585041f005
menard-noe/LeetCode
/Convert a Number to Hexadecimal.py
519
3.6875
4
import math from typing import List class Solution: def toHex(self, num: int) -> str: if num == 0: return '0' map = '0123456789abcdef' res = "" if num < 0: num += 2 ** 32 while num > 0: rest = num % 16 num = (num) // 16 ...
a298e8afa71eef8a96f948d0dcb6acfbafe29c50
menard-noe/LeetCode
/Count Primes.py
1,152
4.0625
4
from typing import List # Definition for singly-linked list. class Solution: def countPrimes(self, n: int) -> int: ## TIME COMPLEXITY : O(NLogN) ## ## SPACE COMPLEXITY : O(N) ## isPrime = [False, False] + [True] * (n - 2) i = 2 while ( i * i < n): # Loop's...
7f02faac7ed5617c1e978849eeed8a97142a5b43
menard-noe/LeetCode
/Lucky Numbers in a Matrix.py
908
3.5
4
from typing import List class Solution: def luckyNumbers(self, matrix: List[List[int]]) -> List[int]: dico = dict() for row in matrix: index_min = -1 min_row = float("inf") for j, val in enumerate(row): if val < min_row: min_...
cf846f20a434d9612351ea37e66ce78238082ea5
menard-noe/LeetCode
/Can Make Arithmetic Progression From Sequence.py
816
3.5625
4
import math from typing import List class Solution: def canMakeArithmeticProgression(self, arr: List[int]) -> bool: if len(arr) <= 2: return True first_min, second_min = float('inf'), float('inf') for n in arr: if n <= first_min: first_min, second_min...
5542dd30f8aa8e84bf957e72bb44ac3cd1badedd
menard-noe/LeetCode
/Plus One.py
659
3.59375
4
from typing import List class Solution: def plusOne(self, digits: List[int]) -> List[int]: for i, e in reversed(list(enumerate(digits))): print(i, e) if e < 9: digits[i] += 1 return digits else: if i == 0: ...
7362a08b1296f1c6dbcad76003adf7e8f16ca5aa
menard-noe/LeetCode
/Non-decreasing Array.py
686
3.796875
4
from typing import List class Solution: def checkPossibility(self, nums: List[int]) -> bool: wrongplace = None for i in range(0, len(nums) - 1): if nums[i] > nums[i + 1]: if wrongplace is None: wrongplace = i else: ...
9794e16c10eea8f9d584cd5e1f393f4475f68672
menard-noe/LeetCode
/Shortest Distance to a Character.py
618
3.625
4
# Definition for a binary tree node. import math from typing import List class Solution(object): def shortestToChar(self, S, C): prev = float('-inf') ans = [] for i, x in enumerate(S): if x == C: prev = i ans.append(i - prev) prev = float('inf') for ...
0f3aaea69808c239b235c44f472f9e05b0f6e1ab
menard-noe/LeetCode
/Contains Duplicate .py
443
3.859375
4
import math from typing import List class Solution: def containsDuplicate(self, nums: List[int]) -> bool: dico = dict() for num in nums: if num in dico: return True else: dico[num] = 0 return False if __name__ == "__main__": # e...
fc66d4eabd9373e690acd6293114b11695f829da
menard-noe/LeetCode
/Lemonade Change.py
932
3.5625
4
from typing import List class Solution: def lemonadeChange(self, bills: List[int]) -> bool: dico = dict() dico[5] = 0 dico[10] = 0 for bill in bills: if bill == 5: dico[5] = dico[5] + 1 elif bill == 10: if dico[5] > 0: ...
f9e38d6cdf0f983b77d567a92a11b6e848f1406f
dnabanita7/outreachy
/2022-round-2/dnabanita7/nx_tutorial_script.py
502
3.90625
4
import networkx as nx # Create a DiGraph G = nx.DiGraph() # Add nodes to the graph nodes = [7, "Nabanita", ("ABCD", 56.8)) G.add_nodes_from(nodes) # Add edges between the nodes edges = [ (7, "Nabanita"), ("Nabanita", ("ABCD", 56.8)), (("ABCD", 56.8), 7), ("Nabanita", 7) ] G.add_edges_from(edges) # Find shortest pa...
33703a0819359bf511dcea32765c77cb23e1a8b4
dnabanita7/outreachy
/2022-round-1/0ddoes/nx_tutorial_script.py
1,008
3.640625
4
""" ======================== Importing libraries ======================== """ import networkx as nx import matplotlib.pyplot as plt """ ==================================================== Creating a DiGraph Object and adding nodes and edges ==================================================== """ G = nx.DiGraph() G.a...
7e6e265ed0cbb52b9656e014ec64f5d242a857e7
dnabanita7/outreachy
/2022-round-1/NikitaSharma1/nx_tutorial_script.py
680
3.609375
4
''' ----------------------------------- NX_TUTORIAL_SCRIPT ----------------------------------- ''' import networkx as nx ''' Declaration of Directed Graph ''' G=nx.DiGraph() # Adding edges will automatically declare the nodes G.add_edge(5,6) G.add_edge(1,(10,11)) G.add_edge("spam",5) G.add_edge((10,11),1) ...
35f10ed19418230b9881b46570fda14a9931f34e
sourovamin/PasswordGenerator
/pwgtor.py
4,284
3.765625
4
import string from random import * class PwGtor: """ Method to generate password. @type limit: int or list @param x: range of the password characters @type lowerCase: boolean @param lowerCase: lower case characters in password or not @type upperCase: boolean @param upperCase: upper ...
f4c58d822cf5aa2cc0d80ea8732cb5cb93aa7b04
jonathanqbo/moncton-python-2020
/week7/homework/andy_text_1024.py
671
3.71875
4
import turtle def c(x,y,color='purple',size=2,pencolor='blue',pensize=2,heading=90,hide=False): t=turtle.Turtle() if hide: t.hideturtle() t.shape('turtle') t.color(color) t.setheading(heading) t.pensize(pensize) t.pencolor('gold') t.penup() t.goto(x,y) t.speed('fastest'...
a98f24117cfc27159500c074844cbb1d1f8e5a53
jonathanqbo/moncton-python-2020
/week4/homework5.py
287
3.859375
4
def cube_volume(width, height, length): return width * height * length print('volume of cube', [10, 10, 10], ' is', cube_volume(10, 10, 10)) print('volume of cube', [10, 20, 30], ' is', cube_volume(10, 20, 30)) print('volume of cube', [16, 18, 19], ' is', cube_volume(16, 18, 19))
7adafff3d5b06199fd72f3f77d4f5e4ff4cb6ec7
jonathanqbo/moncton-python-2020
/week6/draw_line.py
606
3.734375
4
import turtle def draw_line(weight, x1, y1, x2, y2): myturtle = turtle.Turtle() myturtle.speed('fastest') myturtle.pensize(weight) myturtle.penup() myturtle.goto(x1, y1) myturtle.pendown() myturtle.goto(x2, y2) y_max = turtle.window_height()//2 x_max = turtle.window_width()//2 line_weigh...
d01855a2b5d57eb57bba4d84c609e4f03fb5f491
jonathanqbo/moncton-python-2020
/week7/homework/JunHuang_Task4_CreateAFunctionWithDefaultArgumentValueAndInvokeItUsingKeywordArguments.py
871
3.875
4
import turtle turtle.bgcolor('black') def shape(x, y, size=10, color='black', pen_color='blue', pen_size=2, heading=90, long=10): shape_turtle = turtle.Turtle() shape_turtle.shape('turtle') shape_turtle.color(color) shape_turtle.hideturtle() shape_turtle.penup() shape_turtle.goto...
bf9f7ea6538983df23e9267f7cdab576efbb1efc
jonathanqbo/moncton-python-2020
/week6/homework/ranran_3_draw_circle(1).py
924
3.71875
4
import turtle import random turtlecircledrawer = turtle.Turtle() turtlecircledrawer.hideturtle() turtlecircledrawer.speed('fastest') turtle.bgcolor('black') colors = ['blue', 'green', 'red', 'purple', 'orange', 'yellow'] def drawing_line_random(x, y): turtlecircledrawer.penup() turtlecircledrawer...
281225ffba42c6178a412e18d52e8cad89381f38
jonathanqbo/moncton-python-2020
/week8/tkinter_layout.py
536
3.53125
4
import tkinter window = tkinter.Tk() window.title('tkinter layout and widgets') window.geometry('800x800') label = tkinter.Label(window, text='Tkinter Layout and Widgets', background='yellow') label.pack(side='top') entry = tkinter.Entry(window, background='yellow') entry.pack(side='left') # background color doesn'...
b7dfdccfd565aa99fcb0b4fc67ce7b0b98862753
jonathanqbo/moncton-python-2020
/week8/homework/ranran_task3_guess_number.py
3,773
3.90625
4
# text, guess, and most import turtle # number import random # stops import time max_target_number = 25 colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'cyan', 'magenta', 'black'] speeds = ['slowest', 'slow', 'normal', 'fast', 'fastest'] boolean = [True, False] guess_number = 0 def crea...
7b1bc9ebde49afb1603a68f700662b59f8e2ac9a
jonathanqbo/moncton-python-2020
/week3/homework/art.py
342
3.65625
4
import turtle colors = ["red", "purple", "blue", "green", "orange", "yellow"] turtle.bgcolor("black") painter = turtle.Turtle() painter.pensize(3) painter.speed('fastest') for x in range(500): # keep loop each color by using % operator painter.pencolor(colors[x % 6]) painter.forward(x) painter.left...
2d9911d4a50cfab5a596980205b5be2c3e3a7b74
jonathanqbo/moncton-python-2020
/week11/dict_basic.py
1,019
3.984375
4
# create empty dict dict_empty = {} print(type(dict_empty)) dict_empty2 = dict() # create dict dict0 = {'ranran':'be a superman', 'jerry': 'be a billionaire', 'zijun': 'save world'} # create dict using keyword params. same with above dict0 = dict(ranran='be a superman', jerry='be a billionaire', zi...
9bc9ed99c145798d9e233b3867d2d38183bb7db5
zachary-hamilton/cs-module-project-iterative-sorting
/src/searching/searching.py
959
4.25
4
def linear_search(arr, target): ''' not sure if this counts as linear search if target in arr: return arr.index(target) ''' for i in range(len(arr)): if arr[i] == target: return i return -1 # not found # Write an iterative implementation of Binary Search def binar...
2549378751be1e4953a03936881f464cc0a364a1
RyanProbyn52/RandomProjects
/toilet.py
1,874
3.953125
4
import random import numpy as np import matplotlib.pyplot as plt #Define scenario: 0 - seat MUST be put down after use, 1 - seat is left in after use position #Define the percentage of use in which the seat is used in the down position loop = 10000 #define how many 'toilet uses' simulated def main(i): #runn...
ebfe098fe374d41ced1b6f80b8c191f7eccc6c7b
dc-cefleet/DC_weekly_work
/functions.py
2,003
4.1875
4
import random noun_dict = {} nouns = ["house", "water", "wolf", "brick", "mortar", "red", "coffee"] verb_dict = {} verbs = ["Blow", "Sneak", "Drink", "Lay", "Bake", "Sit"] def random_sentence(): noun1 = nouns[random.randint(0, len(nouns)-1)] verb1 = verbs[random.randint(0, len(verbs)-1)] noun2 =...
e824081b4e8c571fac2edcd787b4427ee552dab2
guilhermedotcom/portfolio
/Algoritmos e Estrutura de Dados/metodo de ordenação1.py
302
3.828125
4
vet=[0,0,0,0,0,0] for i in range (0,6,1): vet[i]=int(input("Digite um valor")) for cont in range (5,-1,-1): for i in range (0,cont,1): if (vet[i]>vet[i+1]): aux=vet[i] vet[i]=vet[i+1] vet[i+1]=aux for i in range(0,6,1): print(vet[i],"")
2be74f4978b088e78049562271b43e92c594f89b
guilhermedotcom/portfolio
/Algoritmos e Estrutura de Dados/numeroperfeito.py
412
4.125
4
def numeropfto(n): cont=1 soma=0 while (cont<n): if (n%cont)==0: soma = soma + cont cont = cont + 1 else: cont = cont + 1 return (soma) num = int(input("digite o numero: ")) numeroperfeito=numeropfto(num) if numeroperf...
4c6aa8ea066dc96fbf83526b972989c13078dbb6
mike292/pythonOOP
/rock_paper_scissors.py
1,924
4.34375
4
import random user_score = 0 computer_score = 0 print("Let's play.") while True: if user_score >= 3: print("You have won!") break elif computer_score >= 3: print("Game over!") break player = input("Rock, Paper, Scissors? ").lower() if player == "rock" or player == "...
72c0cc102965bba3b1b812751f76f666d5b16f52
Matthews3301/payments-api
/accounts/accounts.py
1,452
3.6875
4
# A class to represent an Account with an id and integer balance class Account: # Member properties: # id: Integer id # balance: Integer balance # locked: Boolean locked # Note that these property names match the column names def __init__(self, id, balance, locked): self.id = id self.ba...
e5f2254a4cb327fa9c9204c163d45f005e065ed2
optroodt/bestbefore
/bestbefore.py
522
3.53125
4
#!/usr/bin/python ''' Spotify Best Before puzzle, found on http://www.spotify.com/nl/jobs/tech/best-before/ ''' import itertools import datetime import sys def main(): date = sys.stdin.readline().strip() parts = [ int(part) for part in date.split('/') ] dates = [] for d in itertools.permutations(parts): try: ...
b770e802d7facf19e31632e1fee65dc99f9c30e1
ACNoonan/SME.SE
/index_query.py
1,997
3.59375
4
#Additional steps are suggested that aren't already in place: # 1. Stemming query words # 2. Make everything .lower() # 3. Remove puntuation #Starting with Standard Queries (One Word): def one_word_query(word, invertedIndex): pattern = re.compile('[\W_]+') word = pattern.sub(' ',word) if word in invertedInde...
7c1004d9aba7181f0a54e1a4fd8e656f2ed0831a
codingSince9/Advent-of-Code-2020
/day09/day09.py
1,313
3.53125
4
numbers = [int(number) for number in open("day09.txt")] def findBadNumber(): preamble = [] for nextNumber in numbers: if len(preamble) < 25: preamble.append(nextNumber) continue else: foundBadNumber = True for x in preamble: if ne...
daa13e9ae9a234dbffcf665dec83f8efbd7c160e
netfanely/pythonCalculator
/calculadora.py
636
3.609375
4
from Tkinter import * def Sumar(): varres.set( "La Suma es : " + str( float(vartxt1.get()) + float(vartxt2.get()))) ventana = Frame(height=250,width=500) ventana.pack(padx=5,pady=5) vartxt1 = StringVar() lblNum1=Label(text="Numero 1: ").place(x=30,y=40) txt1 = Entry(ventana,textvariable=vartxt1).place(x=100,y=35...
5819af50f6a712000aeed5f6b467db4d4658f6d9
ocoleman/pns-init
/Week4/collatz.py
172
3.953125
4
#Owen Coleman v = int(input("Please enter a positive integer:")) while v > 1: print(int (v)) if v % 2 == 0: v = v / 2 else: v = (v * 3) + 1
5e6f772e77e51fa230592a4c3ad106cdd788873e
ocoleman/pns-init
/Week7/es.py
817
4.125
4
#Owen Coleman #Weekly Task 7 #Write a program that reads in a text file and outputs the number of e's it contains. The program should take the filename from an argument on the command line. #Imports the sys module import sys #Using the sys.argv command to read a command line input given by the user. #In this case it ...
4fcd834bc091a69dd59b39f86a6416d6776ac6d1
ocoleman/pns-init
/Week6/functions.py
234
4.125
4
#Owen Coleman #A function to square numbers. def f(x): ans = x * x return ans print(f(2)) def power(x, y): ans = x y = y - 1 while y > 0: ans = ans * x y = y - 1 return ans #print (power(3, 6))
d7cfd2a884f79cb6d6fc255d206313b3347e21f6
BeatMil/programming_excersice
/hackerearth/basic_input_output.py
66
3.5
4
number = int(input()) text = input() print(number*2) print(text)
fbc60ca9ae3a63cf02a351dd6ad91b6b30a979b4
BeatMil/programming_excersice
/old/reverse_array.py
238
3.65625
4
# Imma try using recursion for this glob = [1,2,3,4,5] box = [] def reverse_array(glob: list): if len(glob) > 0: box.append(glob[-1]) glob.pop() reverse_array(glob) reverse_array(glob) print(glob) print(box)
d9ac0248c3cd4f5fac5f270a3f505c83054e3d2a
BeatMil/programming_excersice
/old/snakeoil.py
280
3.765625
4
amount = 16 price = 17 shipping = 0 total = 0 if amount < 10: price += 20 # shipping 20 total = price * amount elif amount >= 10 and amount <= 100: shipping += 500 total = (price * amount) + shipping else: total = price * amount total *= 0.97 print(total)
b10ed225706a08dfcbc81ecaed0f34b63634a589
BeatMil/programming_excersice
/old/concate_list.py
175
3.8125
4
box1 = [1,2,3] box2 = ['a','b','c'] box3 = [] for i in range(len(box1)): box3.append(box1[i]) for j in range(len(box2)): if i == j: box3.append(box2[j]) print(box3)
99a101333369c1be00035024d944e1ac0a8edca3
BeatMil/programming_excersice
/old/car_beat01.py
389
3.59375
4
class Car: def __init__(self, name): self.name = name self.speed = 0 def __str__(self): return "%s\n%s"%(self.name,self.speed) def speed_up(self, speed): self.speed += speed car01 = Car("Beat") car02 = Car("Ming") print(car01) car02.speed_up(100) print(car02) # car = Car("Beat") # print(car) # print...
a8410a6adaa8721578d4715816a14dd524f96f2c
SamB2653/ml_course
/ml_course/crash_course/feature_cross.py
9,020
3.890625
4
import numpy as np import pandas as pd import tensorflow as tf from tensorflow import feature_column from tensorflow.keras import layers from matplotlib import pyplot as plt # Define functions to create and train a model, and a plotting function def create_model(my_learning_rate, feature_layer): """Create and com...
dd723ab54364ba8748d19f0d3f8d9e7dab8af73c
hrushikute/peace
/First_program.py
965
4
4
print "Hello World"; class Node : def __init__(self,data): self.data = data self.next = None class LinkedList : def __init__(self): self.head = None def push(self,new_data): new_node =Node(new_data) new_node.next=self.head self.head ...
7c128e7a967b2bc9393d257b61037d8e5a68e1f3
giodueck/dbdatagen
/miscgen.py
354
3.53125
4
from datetime import date, time from datetime import timedelta as td from random import randrange as rr def gendate(startDate: date, endDate:date) -> date: '''Generate a date between startDate and endDate''' timeDiff = endDate - startDate dayDiff = timeDiff.days randNumOfDays = rr(dayDiff) return ...
e2b31a2c84d8479af998da026c33707b3ab3b728
Doniben/Python_start
/squeare_functions.py
342
3.8125
4
import turtle def main(): window = turtle.Screen() doni = turtle.Turtle() make_square(doni) turtle.mainloop() def make_square(doni): len = int(raw_input('Tamaño del cuadrado: ')) for i in range(4): make_line_and_turn(doni, len) def make_line_and_turn(doni, len): doni.forward(le...
486012aa716cfa3600015f3cbcc58207fce173f4
leni-mv/EpreuveDuFeu
/tri.py
107
3.71875
4
#!/bin/python3.6 a = input("nbr : ") a = list(a) b = a.sort() l = "" for i in a: l += i print(l)
58e64dae7d80d3a30936f1437042538b6904accd
42AbuDhabi/worst-hello-world
/tunji_hw.py
430
3.546875
4
_4 = "H" _2 = "e" a = "l" b = "l" u = "o" d = "W" h = "o" _a = "r" b = "l" i = "d" campus = "42_Abu-Dhabi" piscine = [] for x in range(len(campus)): piscine.append(_4) piscine.append(_2) piscine.append(a) piscine.append(b) piscine.append(u) piscine.append(" ") piscine.append(d) piscine.a...
36e9e7aaa82d399592cd15372406e94355ca13c8
sukesuke0718/AutomatedProcessPractice
/isPhoneNumber.py
613
4.03125
4
################################ # 電話番号かどうかを判定 ################################ def is_phone_number(text): if len(text) != 12: return False for i in range(0, 3): if not text[i].isdecimal(): return False if text[3] != '-': return False for i in range(4, 7): if...
a62a54f1e4d89eba235b1c685bd2f61997b4cc4b
hatfullr/pysplash
/lib/widgetcontroller.py
3,107
3.5625
4
from sys import version_info if version_info.major < 3: import Tkinter as tk else: import tkinter as tk # A widget controller controls only the widget states (so far). Any time # you wish to set the state of a widget based on multiple variables, you # should create a widget controller. When all widget control...
3618b1fed6128fde5d272a0e8f1199d6f99ec101
tectronics/netminx
/backend/address.py
2,160
4
4
""" Collection of methods that formats, validates and provides common utility functions for MAC addresses, IP addresses and hostnames. @author: Danny Y. Huang (yh1@cs.williams.edu), Chris Brauchli (cab1@williams.edu) """ import re class InvalidAddress(Exception): """ Raised when an address is invalid. ...
dd25a431d38f88563f382a6885bf10dc7fd1acb0
yoguz/LeetCode
/python3/Q148_sort_list.py
1,473
3.921875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def sortList(self, head: ListNode) -> ListNode: if head is None: return if head.next is None: return head ...
823d255f838f4500e0ca0c1c1d80df2d3d2c043f
K1Tech/Learn-SQLite-in-Python
/4-Database/1-SQLite/2-create-table.py
525
3.6875
4
# 0. import required lib import sqlite3 # 1. define connection conn = sqlite3.connect(r'D:\Code\py\4-Database\smalldata.db') # 2. define cursor method c = conn.cursor() # 3. define query create_table = """ CREATE TABLE IF NOT EXISTS table1 ( id integer PRIMARY KEY AUTOINCREMENT, ...
ea503cfa5ff58f5a1d2ef9c242d6c8f5fbb74fd9
vetrujillo/WeatherProject
/WeatherScript.py
2,517
3.625
4
#!/usr/bin/python3.6 from bs4 import BeautifulSoup import sys import requests import pandas as pd import smtplib import mimetypes from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.message import MIMEMessage location_url = "https://forecast.weather.gov/MapClick.php?lat=...
6473f2e70165fa3cb22579c7548599cde88810bd
MakeSchool-17/twitter-bot-python-beingadrian
/4_stochastic_sampling/stochastic_sampling.py
2,247
3.796875
4
import random import sys def convert_file_to_dict(file_name): file_name = open(file_name, 'r').readlines() dictionary = {} for line in file_name: key = "" val = 0 prev = "" for letter in line: try: try: current_int = int(lette...
8ae123da1737642c7926c6548d4094380422291b
Larissa-Rodrigues/Python3-CursoEmVideo
/Mundo1/ex006.py
295
4.03125
4
#DESAFIO 006: Crie um algoritmo que leia um número e mostre o seu dobro, triplo e raiz quadrada. num = int(input('Digite um número: ')) print('O dobro de {} é {}'.format(num, 2*num)) print('O triplo de {} é {}'.format(num, 3*num)) print('A raiz quadrada de {} é {}'.format(num, num**0.5))
ab8a3d354ac0fe9f96288ce583132588e70b8770
Larissa-Rodrigues/Python3-CursoEmVideo
/Mundo1/ex017.py
580
4.125
4
#DESAFIO 017: Faça um programa que leia o comprimento do cateto oposto e do cateto adjacente de um triângulo retângulo, calcule e mostre o comprimento da hipotenusa. from math import sqrt cateto_oposto = float(input('Comprimento do cateto oposto: ')) cateto_adjacente = float(input('Comprimento do cateto adjacente: ')...
ff49a578d8e5ff3c7101ae84870c9278220b4a62
Larissa-Rodrigues/Python3-CursoEmVideo
/Mundo1/ex019.py
448
3.875
4
#DESAFIO 019: Um professor quer sortear um dos seus quatro alunos para apagar o quadro. Faça um programa que ajude ele, lendo o nome deles e escrevendo o nome do escolhido. import random aluno1 = input('Primeiro aluno: ') aluno2 = input('Segundo aluno: ') aluno3 = input('Terceiro aluno: ') aluno4 = input('Quarto alun...
f079deedf4e8488c3ce54dd770382c1d5c9137a9
juliano-cunha/exercicios_python
/classes_3.py
2,516
3.6875
4
# 9.4 pág 254 # 9.6 pág 264 - modificações no exercicio class Restaurant(): """Criando classe restaurante""" def __init__(self, restaurant_name, cuisine_type): """Inicializa os atributos da classe""" self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self....
d70e953cc7b90e1f186fe8abb1f062f6e01bd472
juliano-cunha/exercicios_python
/biblioteca_padrao.py
1,132
4.09375
4
# 9.14 pág 274 from random import randint class Dice(): """Define as caracteristicas do dado """ def __init__(self, sides=6): self.sides = sides def roll_dice(self): random_roll = randint(1, self.sides) print("O dado de: " + str(self.sides) + " lados foi lançado e o resultado é...
5a2f8f20ef9aec0502c142d179e7021ecabc73be
juliano-cunha/exercicios_python
/dicionarios.py
3,177
3.90625
4
#6.1 pessoa_favorita = { 'first_name': 'Joaozinho', 'last_name': 'não sei', 'age': '30', 'city': 'são paulo', } print("o nome dela é " + pessoa_favorita['first_name'] + " e tem " + pessoa_favorita['age'] + " anos de idade") #6.2 numeros_favoritos = { 'pedro': '10', 'bin': '15', 'wica'...
c624a7653fdbf26fa42c04de76094670a3429f84
kunci115/omnilytics
/reader.py
875
3.765625
4
import re def regex(word): pattern_alphabet = re.compile("[a-z]+") pattern_integer = re.compile("[0-9]+") pattern_float = re.compile("[0-9]*.[0-9]+") pattern_alphanumeric = re.compile("[0-9a-z]+") if pattern_alphabet.fullmatch(word) is not None: print('{} {} {}'.format(word, " - ", "alpha...
f59a0709baf45cc30271941afb2895561d6f49c7
Abhinavsuresh21/python-
/operator/membop.py
298
4
4
a=int(input("Enter A value:")) b=int(input("Enter B value:")) list=[1,2,3,4,5]; if(a in list): print("a is available in given list") else: print("a is not avaiable in given list") if(b not in list): print("b is not avaiable in given list") else: print("b is available in given list")
dcb70c438ef17fd6c27cc2e4d1d5d1989cc04856
Abhinavsuresh21/python-
/gate/andgt2.py
184
3.625
4
a=int(input("Enter A value:")) b=int(input("Enter B value:")) AND=a&b; print("\t\t output \n\n") print("Entered A value:",a) print("Entered B value:",b) print("AND gate is:",AND)
c201af7b104d63a1b1533fe9c0a90850e337b4a7
Birat77/python-project-minesweeper
/initialutils.py
1,167
3.796875
4
# -*- coding: utf-8 -*- import global_vars as g def neighbours(i, j): #Return the list of coordinates of the neighbours of the (i, j) cell l = [] for (x, y) in [ (i-1, j-1), (i-1, j), (i-1, j+1), (i, j-1), (i, j+1), (i+1, j-1), (i+1, j), (i+1, j+1)]: if x in ...
d5c51244107566ee920a549be780cf7e18627dce
diezguerra/codingbat-python-solutions
/warmup-2.py
2,680
3.90625
4
def string_times(str, n): """ Given a string and a non-negative int n, return a larger string that is n copies of the original string. """ return str*n def front_times(str, n): """ Given a string and a non-negative int n, we'll say that the front of the string is the first 3 chars, or whatever is th...
22baf421344a8c447a0d2804b19ff7a6dc87444e
MaxGGx/Algoritmos-2020-2
/Tarea 2/Iñaki/Pregunta1_Draft.py
1,762
4
4
''' #funcion que halla todas las permutaciones def permutaciones(lista, B, act): if len(act) == B: print(act) return [act] for i in range(len(lista)): act2 = act.copy() act2.append(lista[i]) permutaciones(lista[i+1:], B, act2) return "fin" print(permutaciones([1,2,4,8,9], 3, [])) for x in len([1,3,43,...
8649e5c9c8e900c9cbe8708bd47267be12957aa5
muchemicarol/Learning-Repo
/attemptThreading3.py
1,322
4.46875
4
import threading import time '''Create a Thread with a function This function will print 5 lines in a loop and sleep for 1 second after''' def threadFunc(): for i in range(5): print("Thread {} Hello from new Thread".format(i)) time.sleep(1) # '''When called, the function will complete in around 5 seconds # As...
13ce5980d7eba305c700c963e68d46700566929a
yajoy/lc-500
/算法/贪心/316.py
540
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Author : Joey Wong @Time : 2021/3/11 19:04 @File : 316.py @Desc : m """ import collections def func(s): stack = [] dic = collections.Counter(s) for c in s: if c not in stack: while len(stack) > 0 and dic[stack[-1]] > 1 and c <= stack[-1...