blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
9b5e4adb5cdb97f1185d3baa4d6e315aeb20c466
Mr-Loony/Lottery-Python
/GamblingLottery.py
660
3.890625
4
from random import randint, random num2 = [] numm3 = [] maxnr = 0 minnr = 100 print("Welcome to Solomon's Lottery!") n = int(input("Enter sum: ")) for k in range(5): m = int(input("Please enter number: ")) num2.append(m) y = 0 num=[] for i in range(10): random=randint(1,20) while random in num: ...
38a960b6810f1602463d2d870539e97259886fb8
Hi-Tree/Phys661
/Assignment2.py
2,714
3.625
4
#### Meri Khurshudyan #### Assignment 2 from itertools import product from collections import Counter import numpy as np import matplotlib.pyplot as plt import random #@@@@@@@@@@@@@@@@@@@@@@@ Needed Functions @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ######################## Ideal Case 2 Dice ############################# def...
489b43668b8cabd8c72506a32119f58462a22a70
kvizconde/Pokemon-Tamagotchi
/user_interface.py
4,110
4.21875
4
from constants import Constants from egg import Egg class UserInterface: """ This is the user interface class where the game gets executed by the user The class consists of the menRus that the user uses to interact with their pokemon """ @staticmethod def menu(pokeball): """ T...
7646890051144b6315cd22fd1b5e04a44d9b266a
jabedude/python-class
/projects/week3/jabraham_guessing.py
1,625
4.1875
4
#!/usr/bin/env python3 ''' This program is an implementation of the "High-Low Guessing Game". The user is prompted to guess a number from 1 to 100 and the program will tell the user if the number is greater, lesser, or equal to the correct number. ''' from random import randint def main(): ''' This function i...
fcdebbb78ba2d4c5b41967801b0d537c35e85c3a
jabedude/python-class
/chapter5/ex6.py
384
4.125
4
#!/usr/bin/env python3 def common_elements(list_one, list_two): ''' returns a list of common elements between list_one and list_two ''' set_one = set(list_one) set_two = set(list_two) return list(set_one.intersection(set_two)) test_list = ['a', 'b', 'c', 'd', 'e'] test_list2 = ['c', 'd', 'e', 'f', ...
973a9b54dcc92e28d4695050050ae0efc85f7982
jabedude/python-class
/chapter4/ex4.py
628
4.03125
4
#!/usr/bin/env python3 text_set = set() freq_dict = dict() duplicate_count = 0 while 1: data = input("Please enter a line (q to quit): ") if data == "q": break for word in data.split(): if word in text_set: duplicate_count += 1 freq_dict[word] += 1 tex...
53c1ca380af737aabe9ce0e265b18011a3e290a2
jabedude/python-class
/chapter9/ex4.py
655
4.3125
4
#!/usr/bin/env python3 ''' Code for exercise 4 chapter 9 ''' import sys def main(): ''' Function asks user for two file names and copies the first to the second ''' if len(sys.argv) == 3: in_name = sys.argv[1] out_name = sys.argv[2] else: in_name = input("Enter the name of ...
3cb7470e40d147e81250cc35de89851c0dc453e6
jabedude/python-class
/chapter9/ex7.py
597
3.875
4
#!/usr/bin/env python3 ''' Code for exercise 7 chapter 9 ''' import sys def main(): ''' Docstring ''' in_one = sys.argv[1] in_two = sys.argv[2] set_one = set() set_two = set() with open(in_one, "r") as file_one, open(in_two, "r") as file_two: while True: line_one = file_on...
c722a49a7f8b4b80ed4238b53759e922299957e2
jabedude/python-class
/chapter7/restaurant.py
1,686
4.21875
4
#!/usr/bin/env python3 class Category(): ''' Class represents Category objects. Only has a name ''' def __init__(self, name): self.name = name @property def name(self): return self._name @name.setter def name(self, name): self._name = name def __str__(self): ...
3de09ed4a2e79290073962087fccd9a10ebcc245
UlisesND/CYPUlisesND
/libro/problemas_resueltos/capitulo2/problema2_10.py
706
3.953125
4
A = int(input("introduce un numero entero")) B = int(input("introduce un otro numero entero positivo")) C = int(input("introduce un otro numero entero positivo")) if A > B: if A > C: print (f"{A} es el mayor") elif A == C: print(f"{A} y {C} son iguales, y son los mayores") else: prin...
9e3dac800bd632b85beb9c905687e1141547732c
UlisesND/CYPUlisesND
/listas2.py
1,361
4.40625
4
# arreglos #lectura #escritura/ asignacion #actualizacion: insercion, eliminacion, modificacion #busqueda #escritura frutas = ["Zapote", "Manzana" , "Pera", "Aguaquate", "Durazno", "uva", "sandia"] #lectura, el selector [indice] print (frutas[2]) # Lectura con for #for opcion 1 for indice in range (0,7,1): print ...
a7408410098390dad499a6b0663f680d9a6950a7
UlisesND/CYPUlisesND
/libro/problemas_resueltos/capitulo2/problema2_8.py
476
3.859375
4
COMPRA = float (input("Ingresa tu monto de compra: ")) if COMPRA < 500 : PAGAR = COMPRA else: if COMPRA <= 1000 : PAGAR = COMPRA - (COMPRA +0.05) else: if COMPRA <= 7000 : PAGAR = COMPRA - (COMPRA * 0.11) else: if COMPRA <= 15000 : PAGAR = COMP...
13af2fef7cc8e5fb279625a5ad6fd38a8044f25a
UlisesND/CYPUlisesND
/libro/problemas_resueltos/capitulo1/problema1_2.py
196
3.734375
4
BASE = float(input("Base del Triangulo:")) ALTU = float(input("Altura del Triangulo:")) SUP = (BASE * ALTU)/2 print(f" El area del triangulo con base {BASE} U.y altura {ALTU} U. es: {SUP} U^2.")
edf5c6a444671cfd511730b7e49695cb954f7dca
obhutara/Python
/untitled1.py
2,086
3.640625
4
import sys import os.path import nltk import io import itertools import operator import string import re import collections from nltk.corpus import stopwords stop_words=stopwords.words('english') def readfile(): try: filename=sys.argv[1] if not os.path.isfile(filename): print("This file does not exist") wit...
bbdbdc8af0280e882f2a87b9ce0d4238db261c72
rkporwal/MachineLearning
/Feature_selection.py
1,406
3.515625
4
import pandas as pd import numpy as np from sklearn.feature_selection import SelectKBest from sklearn.feature_selection import chi2 data=pd.read_csv("CellPhone.csv") X = data.iloc[:,0:20] #independent columns y = data.iloc[:,-1] #target column i.e price range #univariate selection #apply SelectKBest class to ex...
ed544f53a3a328aff0bdd1246a7a1db33867589c
Dulal-12/Python-basic-300
/50+/Test6.py
202
4.15625
4
#Find BMI height = float(input("Enter height ft(foot) : ")) weight = float(input("Enter weight Kg : ")) height = (height*12*2.54)/100 BMI = round(weight/height**2) print(f'Your BMI is {BMI} KGM^2')
e43935bb36fceca09cca540c9a9049a56b469b36
abigdream84/PythonStudy
/.metadata/.plugins/org.eclipse.core.resources/.history/a0/d0854a1af9db001612a6e4ac6047d554
178
3.78125
4
#!/usr/bin/env python class Car: def __init__(self, brand, colour): self.Brand = brand self.Colour = colour car1 = Car('BMW', 'Red') print car1.Brand
46571f9cb4192020003720aa3515a5e08b76ef57
YeahHuang/Leetcode
/572_subTreeofAnotherTree.py
1,728
3.671875
4
class Solution(object): def isSubtree(self, s, t): """ :type s: TreeNode :type t: TreeNode :rtype: bool """ def convert(p): return "^" + str(p.val) + "#" + convert(p.left) + convert(p.right) if p else "$" return convert(t) in convert(s) ...
c17191f6336a29b888d7a6c2aec14adf69965107
YeahHuang/Leetcode
/37_sudokuSolver.py
1,865
3.625
4
class Solution: def solveSudoku(self, board: List[List[str]]) -> None: def dfs(x, y, board, row, col, squa) -> bool: if y==9: if x == 8: return True else: x, y = x+1, 0 while (board[x][y]!='.'): ...
3293518a918fbcaea2bcaffd73aa4513ef6b2651
YeahHuang/Leetcode
/1110_deleteNodesandReturnForest.py
2,281
3.625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def __init__(self): self.to_delete = set() self.forests = {} def delNodes(self, root: TreeNode, to_delete: L...
b5d423922c0c5881695d626f154222caad1778fc
YeahHuang/Leetcode
/289_game_of_life.py
2,345
3.546875
4
class Solution: def gameOfLife(self, board: List[List[int]]) -> None: """ Do not return anything, modify board in-place instead. """ def checkNeighbor(board, x, y): #一开始单独写了8个if 还是不够有统一性吖 return 0<=x<len(board) and 0<=y<len(board[0]) and abs(board[x][...
fe27afe34b5f85623fd8896b55e1deccf6f89bee
YeahHuang/Leetcode
/70_climingStairs.py
262
3.5625
4
class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int """ f = [0] * (n+3) f[1] = 1 f[2] = 2 for i in range(3,n+1): f[i] = f[i-1] + f[i-2] return f[n]
92ad4e42c960dde8f6a0849af5ba6a02f6be47a0
YeahHuang/Leetcode
/211_wordDictionary.py
2,292
3.859375
4
class WordNode: def __init__(self): self.children = collections.defaultdict(WordNode) self.end = False class WordDictionary: def __init__(self): """ Initialize your data structure here. """ self.root = WordNode() def addWord(self, word: str) -> None: ...
d0c7e8a295b6f731d9f1f1872906b4109a12c006
YeahHuang/Leetcode
/987_verticalOrderTraversalofBT.py
2,560
3.734375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: #52ms def __init__(self): self.opt = [] self.neg = [] def verticalTraversal(self, root: TreeNode): self.my...
6d5cc6d478d38a395e12f2b779dd3c5a1180bac9
YeahHuang/Leetcode
/151_reverseWordsInaStr.py
365
3.640625
4
class Solution: def reverseWords(self, s: str) -> str: return ' '.join(reversed(s.split())) #一开始的时候写的是s.split(' ')反而不ok 学到了吖 #C++ Sol ''' void reverseWords(string &s) { istringstream is(s); string tmp; is >> s; while(is >> tmp) s = tmp + " " + s; if(s[0] == ' ') ...
b08d7f3e7ed2da87c0cd2f8a33436edfbab5379d
YeahHuang/Leetcode
/79_wordSearch.py
4,479
3.671875
4
import copy class Record: def __init__(self, x, y, step, visited): self.x = x self.y = y self.step = step self.visited = visited class Solution: #Sol1 BFS 因为deepcopy太耗时 会TLE def exist(self, board, word: str) -> bool: def equals(x,y,target): ''' ...
a434f76eef766c481a8eaafcff76bcc4249a3d3a
crq-13/pythonIntermedio
/data_filter.py
579
3.71875
4
from data import DATA def main(): all_python_devs = [worker["name"] for worker in DATA if worker["language"] == "python"] all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"] adults = list(filter(lambda worker: worker["age"] > 18, DATA)) adults = list(map(lamb...
e76b8b90216b3c35efcc269ed7f90f6c75b6d4ce
CandyTt20/Notes
/algorithm/findmid.py
483
3.703125
4
class Node: def __init__(self, value, next=None): self.value = value self.next = next def find_mid(head): slow, fast = head, head while fast.next is not None and fast.next.next is not None: slow = slow.next fast=fast.next.next return slow head = Node(1) head.next = Nod...
3e3db51329518b0432112f9f3546bca7b5599cae
CandyTt20/Notes
/archives/levelOrder.py
790
3.921875
4
class Tree(object): def __init__(self, value, left=None, right=None): self._value = value self._left = left self._right = right def levelOrder(self): #! 宽度遍历 queue = [self] while queue: cur = queue.pop(0) print(cur._value,end=' ') ...
486990d19beead733bf3f655002e6afa663934f4
CandyTt20/Notes
/algorithm/merge intervals.py
698
3.5625
4
class Solution(object): def merge(self, intervals): """ :type intervals: List[List[int]] :rtype: List[List[int]] """ if intervals == []: return [] merged = [] intervals.sort(key=lambda x: x[0]) start = intervals[0][0] end = interval...
c3fb2a61eeeb3b89f54a91c1b31b5bdd66d298be
rhlvora/Random
/piglatin.py
897
3.71875
4
import numpy as np def ScorePigLatin(beforeword, afterword): if(afterword[-2:] != "ay"): return False transposed = beforeword[1:] + beforeword[0] if(transposed != afterword[:-2]): return False return True def ConvertWord(word): x = 0 while(True): x = x + 1 ...
c615ce093bfdbca79195b264796ff6eb6c2fe3e1
nmschorr/twint
/nulspy-twitter/python-twitter/more/examples/get_all_user_tweets.py
1,554
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Downloads all tweets from a given user. Uses twitter.Api.GetUserTimeline to retreive the last 3,200 tweets from a user. Twitter doesn't allow retreiving more tweets than this through the API, so we get as many as possible. t.py should contain the imported variables....
0c1b5407359d307f58772c628130e7242840a60c
Sophyarach/programming
/hw9/hw9.py
983
3.6875
4
import re def askfilename(): print("Введите название файла") name=input() try: file=open(name) except FileNotFoundError: print("Такого файла нет или введена пустая строка вместо названия") name=-1 return name def find_find(text): verb_forms=r'(?:найти|найд(?:у|(?:ё|е)(?...
56c1af79612f1dabcf35babeab54a2c6b42f45c3
Sophyarach/programming
/caesar.py
342
3.5625
4
c=input() alpha='абвгдеёжзийклмнопрстуфхцчшщъыьэюя' res="" for x in c: if x=='ю': res+='a' continue if x=='я': res+='б' continue if x==' ': res+=' ' b=alpha.find(x) if b==-1: continue res+=alpha[b+2] print(res)
954a5bccd15db2537a100d04249d217a260e30d5
Sophyarach/programming
/leap.py
91
3.8125
4
x=int(input()) if not x%4 and x%100 or not x%400: print ("YES") else: print ("No")
d1fd301d72b085399ae5f9aba618d4f381b54bd3
chenhuidong/MyGit
/MyScript/Python/generator.py
255
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- g = (x * x for x in range(10)) g.next() for n in g: print n def fib(max): n, a, b = 0, 0, 1 while n < max: yield b a, b = b, a + b n = n + 1 g = fib(6) for n in g: print n
e727fa70e3507d8ff3033ea9f0a890a53a1fb79d
chenhuidong/MyGit
/MyScript/Python/if.py
124
4.25
4
age = input('please enter your age: ') if age >= 18: print 'adult' elif age >= 6: print 'teenager' else: print 'kid'
32b3098c57406045b2e30e8ae1ed1c8b8d2cc5cd
VincentPauley/python_reference
/03_indentation.py
314
3.515625
4
#!/usr/bin/python # comments in python start with '#' character # rather than using braces to denote code blocks as in C or javascript, python using indenting. This is rigidly enforeced, and all statements must be indented to the same amount if True: print( 'Today was a good day' ) else: print( 'Bad day' )
c8dfc1abb5893d5bf47ce29b761973a40467683d
VincentPauley/python_reference
/17_substrings_and_slices.py
239
3.578125
4
#!/usr/bin/python # python uses some very slick syntax to create substrings team_name = "BlackHawks" print( team_name[0] ) # 'B' print( team_name[1:5] ) # 'lack' -> character 1 until 5 print( team_name[5:] ) # 'Hawks' -> character 5 on
02d93cbd77bd7932d09deb5c0f1a258882ab4efa
jofre44/EIP
/scripts/string_concatenated.py
458
4.09375
4
print("Actividad 1. Programacion Avanzada en Python") print("Alumno: Jose Sepulveda \n") # Lectura de string por pantalla string_1 = input("Introducir primer string: \n") string_2 = input("Introducir segundo string: \n") # Tamaño de los string introducidos len_str_1 = len(string_1) len_str_2 = len(string_2) # Result...
c9ba48d06cb3b6c4b51d327ced1547d86183205f
jofre44/EIP
/scripts/working_with_ddbb.py
8,607
3.90625
4
import sqlite3 from sqlite3 import Error print("Actividad 7. Programacion Avanzada en Python") print("Alumno: Jose Sepulveda \n") def create_connection(db_file): """ Funcion para crear conexion con la base de datos param: df_file: nombre de la base de datos output: conn: ...
7864a41a75d755453c19572e19eed4e6503842a2
hbhargava7/biophysical-data-aggregator
/bda/PDB.py
4,930
3.71875
4
"""This script will enable the user to extract all structural information avaiable for a given protein search.""" import urllib.request as urllib import requests import numpy as np import pandas as pd def getPDBIDs(input): """This function takes in a protein name, finds all related PDB IDs, and exports that as a...
df3e76f8e666c1169ff376f6ff82d6d54e04912b
swiftlysingh/Learning_Python
/date.py
173
3.5625
4
from datetime import datetime,timedelta current_date = datetime.now() print(current_date) one_day = timedelta(days=2) print(current_date-one_day) print(current_date.day)
46ebc2660769d28c223db26a9ca88b79466fb027
Cheesepuffed/2-Rooms-and-a-Boom-Randomizer
/main.py
3,240
4.09375
4
# This is a sample Python script. from Role import Role import random # makes the member list with commas separating each member def make_memberlist(): longlist = str(input("Please paste everyone's names ensuring each name is separated by a comma (,)\n")) return longlist.split(",") # creates finallist in main...
d3aca3e126466efe777f55bbcee9aa3007417a3b
luxiaolei930/python3_book
/第三章/3.8 利用nltk工具包进行分句和分词.py
1,247
4.0625
4
# 利用nltk工具包进行分句和分词 # 导入nltk import nltk # 待分句、分词文本,使用\符号隔开目的是方便阅读。 text = "He was an old man who fished alone in a skiff in the Gulf Stream and he had gone eighty-four days now without taking a fish. In the first forty days a boy had been with him." \ " But after forty days without a fish the boy’s parents had t...
cd32b23e5fd521b3db28dcfbeafc427774d9d071
luxiaolei930/python3_book
/第一章/1.12 翻页获取语料代码.py
1,319
3.59375
4
#引入 requests 库 import requests #引入BeautifulSoup4 解析库 import bs4 #查看网址链接,发现top250的电影名称总共有10页,每页所列的电影数目为25。使用for循环实现翻页,设置代表页码的i变量,取值为0-9之间。(range的取值范围为左闭右开区间。即大于等于第一个参数,小于第二个参数。) for i in range(0,10): #查看网址链接,发现翻页的时候变化的是start参数,网页每页所列的电影数目为25,start参数每页增加25。 用i*25表示参数的变化,将其命名为start_,i的取值范围为(0,10) start_=i*25 ...
8dc98b7f9d8b64771ec4eb95a2e3817daef79ec9
Nitro2000/Speak_Bot
/BOT.py
4,826
3.578125
4
import pyttsx3 # Text to speak import speech_recognition as sr # Speak to string(text) from datetime import datetime # For correct time and date import wikipedia # For search import webbrowser # For opening sites import os # For opnening inbuild platforms import smtplib # For mail (stands for simple mail tr...
4bfff67203f0ab60a696bdb49cbc00de7db79767
govindak-umd/Data_Structures_Practice
/LinkedLists/singly_linked_list.py
2,864
4.46875
4
""" The code demonstrates how to write a code for defining a singly linked list """ # Creating a Node Class class Node: # Initialize every node in the LinkedList with a data def __init__(self, data): # Each of the data will be stored as self.data = data # This is very important becaus...
1b79159fe3e599737ba1c9e6c34c7783726578ee
jiangjiane/Python
/pythonpy/test16_6.py
917
4.0625
4
def func(): x=4 action=(lambda n:x**n) return action x=func() print(x(2)) print(x(3)) print('\n') def func(): x=4 action=(lambda n,x=x:x**n) return action x=func() print(x(2)) print(x(3)) print('\n') #变量在嵌套的函数被调用时才进行查找,所以结果是同样的值 def makeActions(): acts=[] for i in range(5): a...
c762ee9649cca79d79ff7970f00fb51d2d7bdf14
jiangjiane/Python
/pythonpy/class1.py
756
3.65625
4
#! /usr/bin/python3 # -*- coding: utf8 -*- #例1 class MixedNames: data='spam' def __init__(self,value): self.data=value def display(self): print(self.data,MixedNames.data) print('-----例1-----') x=MixedNames(1) y=MixedNames(2) x.display() y.display() #例2 class NextClass: def printer(se...
13cb81770a801836a42d4f35d81c40c7cc78ded2
jiangjiane/Python
/pythonpy/primes.py
463
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): for n in primes(): if n<1000: print(n) else: break def _odd_iter(): n=1 while True: n=n+2 yield n def _notdivisible(n): return lambda x:x%n>0 def primes(): yield 2 it=_odd_iter(...
8520011404a3e7fd9ca5205dd68348acf9dd0cc5
jiangjiane/Python
/pythonpy/attr.py
681
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class Myobject(object): def __init__(self): self.x=9 def power(self): return self.x*self.x obj=Myobject() print('hasattr(obj,\'x\')=',hasattr(obj,'x'))#是否有属性'x' print('hasattr(obj,\'y\')=',hasattr(obj,'y'))#是否有属性'y' setattr(obj,'y',19)# 设置属性'y' ...
ff97ced37ea41e57879dfb013924eb7b89750856
jiangjiane/Python
/pythonpy/part4_5.py
201
3.8125
4
#第四部分习题 #xiti5 字典复制 def copyDict(old): new={} for key in old.keys(): new[key]=old[key] return new d={1:1,2:2} e=copyDict(d) d[2]='?' print('d=',d) print('e=',e)
f72adcb023e20f58c1c28a6789e718aced2fe7a3
jiangjiane/Python
/pythonpy/xiti3_4.py
938
3.765625
4
#第三部分 语句和语法 #第四题 #a print('第三部分第四题 ') print('a小题\n') L=[1,2,4,8,16,32,64] X=5 i=0 while i<len(L): if 2**X==L[i]: print('at index',i) break i+=1 else: print(X,'not found') print('\n') #b print('b小题\n') L=[1,2,4,8,16,32,64] X=5 for p in L: if(2**X)==p: print((2**X),'was found at...
edc0087b0906acb96fa8f6ec77d3923b472fc47e
jiangjiane/Python
/pythonpy/part4_3.py
608
3.984375
4
#第四部分习题 #xiti3 def adder1(*args): print('adder1',end=' ') if type(args[0])==type(0): #手动测试类型,看是否为整数 sum=0 #若为整数,sum初始值为0 else: sum=args[0][:0] #若不是整数,第一个参数的空分片为初始值 for arg in args: sum+=arg return sum def adder2(*args): print('adder2',end=' ') sum=args[0] for n...
6a7c42b6a4d4e0297a1a9df574fbe23c219ae864
wjlei1990/finance101
/src/stock.py
2,070
3.734375
4
#!/usr/bin/env python3.6 # -*- coding: utf-8 -*- """ Stock price implementation :copyright: Wenjie Lei (wjlei1990@gmail.com), 2017 :license: UNDERTERMINED YET """ from __future__ import print_function, division, absolute_import import numpy as np import matplotlib.pyplot as plt TRADING_DAYS = 250 class Da...
9a81df8d915013d0daf4213736d65ae211c81e58
igauravsehrawat/Utility-scripts
/python-utility/graphics_in_python.py
202
3.703125
4
import turtle def draw_square(): window = turtle.Screen() window.bgcolor("green") brad = turtle.Pen() for i in (1,5): brad.forward(100) brad.left(90) window.exitonclick() draw_square()
70da10ed10a452e43ad55f9313b3f71e8ebd8f35
jspencersharp/Portfolio
/Python/Stars/stars.py
452
3.515625
4
#part 1 # def draw_stars(): # x = [4,6,1,3,5,7,25] # for i in range(0,len(x)): # temp = x[i] # print("*" * temp) # draw_stars() #part 2 import string def star2(arr): for i in arr: if isinstance(i, int): print "*" * i elif isinstance(i, str): length...
03d392f60a994c3ac4e6a6d78f1269625aae1695
jspencersharp/Portfolio
/Python/names/names.py
1,631
3.5
4
#part 1 # students = [ # {'first_name': 'Michael', 'last_name' : 'Jordan'}, # {'first_name' : 'John', 'last_name' : 'Rosales'}, # {'first_name' : 'Mark', 'last_name' : 'Guillen'}, # {'first_name' : 'KB', 'last_name' : 'Tonel'} # ] # for data in students: # print data['first_name'], data['last...
627a7b8809a91183e6779fab590942f9ec4ca039
jspencersharp/Portfolio
/Python/deckOfCards/deck.py
1,092
3.625
4
from random import shuffle import copy class Deck(object): def __init__(self): self.cardList = ["SA", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", "S10" ,"SJ", "SQ", "SK", "HA", "H2", "H3", "H4", "H5", "H6", "H7", "H8", "H9", "H10" ,"HJ", "HQ", "HK", "DA", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9...
ea14b178d782fe155888caf2987a29f851d9a096
vintagefuture/passwordGenerator
/generate-pwd.py
1,416
3.8125
4
from tkinter import * def createPassword(): import secrets import string import datetime x = datetime.datetime.now() piece1 = '' piece2 = '' piece3 = '' t = 'ioqxnmzvdbIOQXNMZVDB' # letters to exclude becuase difficult to pronounce and understand for x in range(0, 3): pie...
d0a89ddf61233ac6b283a46abf49479dd5a34afc
liran2208/AT1
/SM_brute.py
620
3.703125
4
from collections import deque # small world problem def d_two_nodes_graph(g, num1, num2): count = 0 q = deque() q.append(g[num1-1]) current = 0 while count < len(g): count += 1 current = q.popleft() if (num2 in current): return count else: f...
a02a807bfc1189201fd0b64aa24a1be136b00a67
XandraMcC/LabSheet3.2
/DBOperations.py
6,257
3.515625
4
import sqlite3 import pandas as pd import constants as constants from Employee import Employee class DBOperations: def __init__(self): self.get_connection() def get_connection(self): self.conn = sqlite3.connect("mydb") self.cur = self.conn.cursor() # Drop table EmployeeUoB def drop_table(self):...
90806ae210ebcd37d5e930f3f353122b7518177f
chrisguest75/py-wordament-helper
/py_wordament_helper/dictionary_abc.py
369
3.9375
4
from abc import ABC, abstractmethod from typing import Text class dictionary_abc(ABC): @abstractmethod def is_word(self, word: Text) -> bool: """Is the word in the dictionary Arguments: word {Text} -- Word to check for in dictionary Returns: bool -- True if d...
8d919c8ff5fff1d5d87a98ca5d5143ed25320812
Abdul-Rehman1/Python-Assignment1
/pattern.py
552
3.671875
4
# -*- coding: utf-8 -*- """ Created on Sat Jul 20 13:19:18 2019 @author: Abdul Rehman """ ''' for i in range(0,20): print(" "*(20-i),end="") print("* "*i,end="") print() # print(" *"*i) for i in range(20,-1,-1): print(" "*(20-i),end="") print("* "*i,end="") # print(" *"*i) ...
6efd365cc80b1c343b38f8881e174c41aa2f7efb
Rauf-Totakhil/BoringBookTools
/ReadXlsxFile.py
221
3.546875
4
from openpyxl import Workbook from openpyxl import load_workbook import pandas as pd import os def readXlsxFile(): df = pd.read_excel (input("Enter Name of the file with Xlsx : ")) print (df) readXlsxFile()
bab18545791bf6e8b510c64caf9713e8a0e5e104
MageCraft/pyfreecell
/funds/t.py
2,724
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- (align_left, align_right, align_middle) = range(3) #header must have following format: #(text, length, align, data_align) class PrintTable: def __init__(self, headers=None, rows=None): self.headers = headers if rows is None: se...
dc8e36cdd048bcff0c3bfaa69c71923fd53ec7bc
pgrandhi/pythoncode
/Assignment2/2.VolumeOfCylinder.py
367
4.15625
4
#Prompt the use to enter radius and length radius,length = map(float, input("Enter the radius and length of a cylinder:").split(",")) #constant PI = 3.1417 def volumeOfCylinder(radius,length): area = PI * (radius ** 2) volume = area * length print("The area is ", round(area,4), " The volume is ", round(vo...
b3e4b7f3b30bc917e1feb007aa3eb289fb9aa479
pgrandhi/pythoncode
/Triangle.py
689
4.09375
4
import turtle turtle.pensize(2) def drawShapeUsingForwardLeft(color): turtle.forward(100) turtle.left(120) turtle.forward(100) turtle.left(120) turtle.forward(100) def drawShape(color, start, points): turtle.pencolor(color) turtle.penup() turtle.goto(start) turtle.pendown() t...
1bf9ae4f947b407009b3a1423dae4a0bd6df2cb8
pgrandhi/pythoncode
/Class/OlympicSymbol_Functions.py
324
4.0625
4
import turtle turtle.pensize(5) def drawCircle(color, x, y, radius=45): turtle.color(color) turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.circle(radius) drawCircle("blue",-110,-25) drawCircle("black",0,-25) drawCircle("red",110,-25) drawCircle("yellow",-55,-75) drawCircle("green",55,-7...
224678df235e2466ec4df9f5ab19c251d44b040b
pgrandhi/pythoncode
/Assignment4/TestStock.py
295
3.796875
4
from Stock import Stock stock1 = Stock("INTC","Intel Corporation",20.50,20.35) print("Stock name:",stock1.getName(),"Symbol:",stock1.getSymbol(), "previous closing price",stock1.getPreviousClosingPrice(),"current price:",stock1.getCurrentPrice(),"change Percent:",stock1.getChangePercent())
670e2caa200e7b81c4c67abe0e8db28c9d3bce5d
pgrandhi/pythoncode
/Class/BMICalculator.py
584
4.3125
4
#Prompt the user for weight in lbs weight = eval(input("Enter weight in pounds:")) #Prompt the user for height in in height = eval(input("Enter height in inches:")) KILOGRAMS_PER_POUND = 0.45359237 METERS_PER_INCH = 0.0254 weightInKg = KILOGRAMS_PER_POUND * weight heightInMeters = METERS_PER_INCH * height #Compute ...
d9dc45bda82b080bd87db396165a659430f7aee2
pgrandhi/pythoncode
/Assignment2/8.CalculateEnergy.py
497
3.953125
4
#Prompt the use to enter the input to calculate energy weightInKgs = eval(input("Enter the amount of water in kilograms:")) initialTemp = eval(input("Enter the initial temperature:")) finalTemp = eval(input("Enter the final temperature:")) #constants ENERGY_CONST = 4184 def calculateEnergy(weightInKgs, initialTemp, f...
8c544140e9567a5de4b2bf10e08989d793b8d2e2
pgrandhi/pythoncode
/Assignment4/TestTime.py
320
3.921875
4
from Time import Time t = Time() print("Time class created") print ("Current time :", t.getHour(),":",t.getMinute(),":",t.getSecond()) elapseTime = eval(input("Enter the elapsed time:")) t.setTime(elapseTime) print ("The hour:minute:second for the elapsed time is :", t.getHour(),":",t.getMinute(),":",t.getSecond())
040517aec84c454143f6fc41ee34cbcfb12928a6
16GordonA/Essay-Writer
/paragraphs.py
3,211
3.96875
4
''' Takes paragraph as text string, parses for quotes, searches internet to find full quote and verifies with citation Several different types of paragraphs which will be formed using the inputted quotes ''' from fileparse import * qmarks = ['"'] #quotation marks since... there are several for some reason #sample pa...
82d8385e9f60546bc89fb5faed44fe627279970f
doseboy/CSCI-4830
/project1/vigenere.py
6,063
3.671875
4
#!/usr/bin/python3 #Author: William Anderson #Identikey: wian8678 #Assignment: Project 1 #Class: ECEN 4113 import sys from collections import Counter #taken from Wikipedia letter_freqs = { 'A': 0.08167, 'B': 0.01492, 'C': 0.02782, 'D': 0.04253, 'E': 0.12702, 'F': 0.02228, 'G': 0.02015, ...
10adfe46188ab41c061efdba5d694e966a479f6b
LucianErick/URI
/estruturas_e_bibliotecas/pares_e_impares.py
793
4.0625
4
numberList = [] pairList = [] oddList = [] ## functions def bubbleSort(vector): for i in range(len(vector) - 1): for j in range(len(vector) - 1): if(vector[j+1] < vector[j]): vector[j], vector[j + 1] = vector[j + 1], vector[j] def reverseBubbleSort(vector): for i in range(l...
dc4eb7f06aebe59bbbbdf90dc4bca68b97630d40
BenPoole2005/Practice
/guessingGame.py
376
4.0625
4
print("guess a number between 1 and 20") import random number = random.randint(1,22) guess = 0 while guess != number: guess = raw_input() if guess == "q": break else: guess = int(guess) if number == 21: print("NO") elif guess > 20: print("Idiot") elif guess == number: print("You win!!") elif guess ...
491d43e6905758402b2aaa59e65efb65e4e2ea61
nguyenhuudat123/lesson5
/bt3.py
403
3.609375
4
def is_perfect(n): # kiểm tra xem số tự nhiên n có phải là số hoàn hảo hay ko, sum = 0 if n <= 0: return 0 elif n == 1: return 1 else: for i in range(1, int(n/2)+1): if n % i == 0: sum += i if sum == n: return 1 else: retur...
ca2840732d5629eb14bbfc80d607b3674ba2b72e
MosesSymeonidis/aggregation_builder
/aggregation_builder/operators/arithmetic.py
5,352
3.75
4
def ABS(expression): """ Returns the absolute value of a number. See https://docs.mongodb.com/manual/reference/operator/aggregation/abs/ for more details :param expression: The number or field of number :return: Aggregation operator """ return {'$abs': expression} def ADD(*expressions)...
3596417999170bb42042659bdf7864ece1d8fa16
Puthiaraj1/Comprehensions
/timtit_challenge.py
482
3.78125
4
import timeit def fact(n): result = 1 if n > 1: for f in range(2, n + 1): result *= f return result def factorial(n): # n! can also be defined as n * (n-1)! if n <= 1: return 1 else: return n * factorial(n-1) if __name__ == '__main__': print(timeit.tim...
6325c9d7e3c9d68cb5e82f4c86d7db8c48c915aa
aviik/pirple_py_Is_easy
/homework1.py
613
3.546875
4
""" Program to enlist some of the important attributes that could describe a song """ #Attribute variables song = " I'll Play The Blues For You" artist = "Daniel Castro" albumn = "No Surrender" year = 1999 genre = "Blues" sub_genre = "Blues-Contemporary" track_number = 8 song_duration = 7.42 #Attri...
338461346f5813f79e5fc25eaab7e5caaf6eba6e
tarados2/prueba1
/paroimpar.py
155
3.90625
4
### Introducir un numero por teclado y decir si es par o impar num = int(input('Introduzca un numero: ')) ifnum % 2 == 0: print('Par') else: print('Impar')
4fc02d640d9387001833cb7376581298d53c5547
zioan/list_comprehensions
/only_nymbers.py
567
3.84375
4
temps = [221, 234, 340, -9999, 230] #-9999 means no data new_temps = [temp / 10 for temp in temps if temp != -9999] print(new_temps) #[22.1, 23.4, 34.0, 23.0] #-9999 is excluded from the loop/execution #will display only numbers, no strings def foo(lst): new_lst = [] for i in lst: if isinstance(i,...
2efd04f806a3108cc5a6856a1a3a12807d9fe5ba
Antoine07/Data-01
/Exercices_chap1_introduction/moyenne.py
530
3.671875
4
#! /usr/bin/env python """ Calculateur de moyenne ====================== Ce programme admet un nombre arbitraire d'arguments. Il affiche la moyenne de toutes les valeurs. """ from argparse import ArgumentParser from statistics import mean parser = ArgumentParser() parser.add_argument(dest="nombres",...
92ce6a908d91d420ea44e404f659fa4d428b71f2
PaulG17/python-project-lvl1
/brain_games/games/gcd.py
553
3.671875
4
from random import randint DESCRIPTION = "Find the greatest common divisor of given numbers." def prepare_round(): one = randint(1, 100) two = randint(1, 100) question = f"{one} {two}" right_answer = gcd(one, two) return question, str(right_answer) def gcd(one, two): if one == two: ...
e17f5a02da071dcc1dae864460babf1d2690bb7b
VladimirKozlov466/QAP_module_16
/testCat.py
835
3.75
4
from cat import Cat Baron = Cat("Барон", "мальчик", 2) Sam = Cat("Сэм", "мальчик", 2) # --------- Вывод из этого файла print(f'Имя питомца: {Baron.getName()}, Пол питомца: {Baron.getGender()}, Возраст: {Baron.getAge()} года') print(f'Имя питомца: {Sam.getName()}, Пол питомца: {Sam.getGender()}, Возраст: {Sam.getAge(...
8f672d109a35cd8647a5e16f217323301d202cca
gustavo-moura/SCC5900-algorithm-design
/04-backtracking-queens-chess/backtracking.py
2,108
4.03125
4
# -*- coding: utf-8 -*- """ # Backtracking ## SCC5900 - Algorithm Design ### Lecture 4 #### v1 """ import sys def printBoard(board): for l in range(8): for c in range(8): print(f"{board[l][c]:2}", end=" ") print('') def zeroes(l): return [False for _ in range(l)] def conditio...
fe80ce91e178bb8da556ab141e00de1133de9c41
edwinnab/code_python
/strings.py
158
3.59375
4
name ="john is {} a boy" print(name.format("very clean")) print(name.count("[0:]")) num = "John" num1 = "Edwinn" num2 = "Bikeri" print(num[0],num1[0],num2[0])
3c77545df683b67b1c16cf7f478a325ba5af5bb4
edwinnab/code_python
/datatypes.py
3,605
4.53125
5
""" #integers print(34) #assign to a variable num = 34 print(num) #perform mathematical operations #addition num = 34 num2 = 45 #sum is a keyword to perform addition uses the operator + sum = (num + num2) print(sum) #subtraction print(num - num2) #multiplication print(num * num2) #division integer division print(num/nu...
99c1967188396b40b668b043f3de75235b39b62f
samrooj/Prisoners-Dilemma-in-Trees
/player.py
2,081
3.625
4
"""CSC111 Winter 2021 Final Project Module Description ================== This module handles Player, which represents any decision-maker in a game of Prisoner's Dilemma. Copyright and Usage Information =============================== This file is provided solely for the personal and private use of TAs and instruct...
a726d85e43863c9bb2182a2c18c5b60c6863d120
ZicanGong/exercise
/ex7.py
1,822
3.515625
4
class Solution(object): def exist(self, board, word): """ :type board: List[List[str]] :type word: str :rtype: bool """ m = len(board) n = len(board[0]) if board[0][0] == word: return True def dfs(a,b,s,history): ...
35e884947ad00e548f06347fc3c5bf2316e11299
parduman/lovebabbar450
/tree/leftViewOfTree.py
1,235
3.875
4
class Node: def __init__(self, data) -> None: self.data = data self.left = None self.right = None def leftViewOfTree(node, height, maxheight): if not node: return if(height>maxheight[0]): print(node.data) maxheight[0] += 1 if node.left: leftViewOfTree(node.left,...
3066f03eb90bb1175b303f818865db2aa69d731f
laxmankusuma/practice_notebook
/Approaching_Almost_Any_Machine_Learning_Problem_1.py
3,297
4.09375
4
#!/usr/bin/env python # coding: utf-8 # # by Abhishek Thakur # # Supervised vs unsupervised learning # • **Supervised data:** always has one or multiple targets associated with it. # <br> # • **Unsupervised data:** does not have any target variable. # If the target is categorical, the problem becomes a classificati...
5177016ebf88ce8b363829b422b6399d36e26caa
eimearfoley/MosaicMake
/api/backups/get_photo_ids.py
1,688
3.53125
4
""" A simple example script to get all photos on a user's timeline. Originally created by Mitchell Stewart. <https://gist.github.com/mylsb/10294040> """ import facebook import requests from PIL import Image from io import BytesIO def some_action(photo, p, i): #saves the photo in the folder 'photos' eg photos/0_0....
e8ed6b7ea00018d8190062643bfafb3c8770bd38
AntoData/Hate_Crimes_Spain_2014_2017
/Instantiators/LinearRegression.py
5,607
3.921875
4
''' Created on 27 oct. 2019 @author: ingov ''' #We import pandas to manage our data through dataframes import pandas as pd #We import this modules to handle linear regression tasks from sklearn import datasets, linear_model #We import this modules to handle r square calculations from sklearn.metrics import mean_square...
5ec70d0a90702a14fb71c2b2b523632df1096448
AntoData/Hate_Crimes_Spain_2014_2017
/API/GifGenerator.py
3,959
3.75
4
''' Created on 8 sept. 2019 @author: ingov ''' #selenium to display the html files in a browser and get screenshots from selenium import webdriver #time to set a delay between the opening of the browser and the screenshot import time #os to manage folders and path for the html, png and gif files import os #imageio to ...
82e13fb04e0254eb0812abf6f971d70a4a8e1cef
918spyderporsche/movie-recommender-system
/insertToMongo.py
1,518
3.78125
4
import sqlite3 def get_all_movies(db_file): """ create a database connection to a SQLite database """ movies = [] conn = None try: conn = sqlite3.connect(db_file) cur = conn.cursor() for row in cur.execute("SELECT * FROM Movies"): print(row) movies.appen...
af39c2e32e439c19ed098067f37e467d3fa467ae
antonyshen/sbc-lte-ap
/rootfs/usr/local/bin/shutdown.py
1,349
3.8125
4
#!/usr/bin/python3 # Simple script for shutting down the raspberry Pi at the press of a button. # by Inderpreet Singh import RPi.GPIO as GPIO import time import os # Use the Broadcom SOC Pin numbers SHUTDOWN_PIN = 24 # Setup the Pin with Internal pullups enabled and PIN in reading mode. GPIO.setmode(GPIO.BCM) GPIO.se...
abd18b8111328000caf08d5078065b85b79449c5
WyattOchoa/Data_Sorter
/main.py
4,308
3.75
4
import tkinter as tk import pandas as pd def browse(): global user_file #Global variable for use in functions 1-6 from tkinter.filedialog import askopenfilename user_file = askopenfilename() #asks tkinter to open a file that is defined as user_file browselabel.config(text=user_file) ...