blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
492ea73477b473d6990cd80ae2540e27e167edd7
mxtm/cmps-200-fall-2018
/asst5/flatten.py
333
3.671875
4
# Maxwell Richard Tamer-Mahoney ID #: 201804029 # Flatten multi dimensional lists def flatten(lst): result = [] [result.extend(i) if type(i) is list else result.append(i) for i in lst] if any(isinstance(x, list) for x in result): return flatten(result) else: return result print(flatten...
75af308dfa62404e2ce0e31032163ac287d3512a
mxtm/cmps-200-fall-2018
/exam2/index.py
2,045
3.53125
4
# Maxwell Richard Tamer-Mahoney ID #: 201804029 import sys # The first argument is the file in question myFile = sys.argv[1] # Everything else in the arguments list are the words we are looking for wordsToIndex = sys.argv[2:] # Make a dictionary with each of the words in the wordsToIndex list as keys, # and empty li...
b53767bbdc13a23c0893f1a43aacbdda2e8f9d31
nkyllonen/GWC-SIP-2019
/week3/tweets/histogram_sample.py
959
4.09375
4
''' sample code for plotting a histogram original code: https://github.com/GirlsFirst/SIP-2018-starter/blob/master/U2-Applications/U2.1-Data/histogram_sample.py ''' import matplotlib.pyplot as plt ''' plot_histogram: data(list) : list of data values data_bins(list) : list of bin values (x-axis) a...
5502643e5f7dacc18538f0fe4d492e083ff031cb
nkyllonen/GWC-SIP-2019
/week2/summation.py
210
3.78125
4
import math def summation(start, stop): sum = 0 for x in range(start, stop): sum += x return sum if __name__ == '__main__': output = summation(0,10) print("Summation = " , output)
8a8c6b0ea27891f9c94af9abf1ed30ec5ede1c55
Lathas0123/pythoncodes_B38
/python_day2_batch38.py
468
4.03125
4
""" x=3 y=4 z=x+y print(z) print(type(x)) name="latha" print(name) print(type(name)) last_name="suma" print(last_name) name1='giri' print(name1) name2="swamy" print(name2) name3="""rishik""" print(name3) #this is comment. if 5>3: print("5 is greater than 3") x1 = 1 y1 = 35656222554887711 z1 = 35.9 print(ty...
f9b667bd48f6c3fec28020e6668bfa5f59315d96
kailinshi1989/leetcode_lintcode
/863. All Nodes Distance K in Binary Tree.py
1,563
3.65625
4
""" 题意是让我们在一颗二叉树中,给定节点 Target, 寻找和target节点距离 为 K的所有节点, 我们可以把这颗树看成一个无向图, 没有顺序就意味着,二叉树的旁边的指节也是可以算距离的。 我们可以先把二叉树转化为无向图,再在图中进行 BFS 搜索应该就可以得到答案。 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None fro...
ef983ec9493a36d3e98c6064839a20b26a343bec
kailinshi1989/leetcode_lintcode
/113. Path Sum II.py
863
3.734375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def pathSum(self, root, sum): """ :type root: TreeNode :type sum: int :rtype: List[List[i...
ce4279854864b964c83f77f19db347803d9b948d
kailinshi1989/leetcode_lintcode
/889. Construct Binary Tree from Preorder and Postorder Traversal.py
860
3.875
4
""" 所以pre[0]是根节点,也就是post[-1]; post[-2]时候右子树的根节点,因此在前序遍历中找到post[-2]的位置idx就能分开两棵子树。 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def constructFromPrePost(self, pre, ...
8ace94e3c35c7f0a1e19890094d87f1b8ccd3ea7
kailinshi1989/leetcode_lintcode
/307. Range Sum Query - Mutable.py
2,100
3.65625
4
""" 超时做法 """ class NumArray_1(object): def __init__(self, nums): lenN = len(nums) self.n = nums self.l = [None] * lenN if lenN != 0: self.l[0] = nums[0] for i in xrange(1, lenN): self.l[i] = self.l[i - 1] + nums[i] def update(self, i, v...
4c51b1aad3ab2e6659075832b32a959e913db951
kailinshi1989/leetcode_lintcode
/295. Find Median from Data Stream.py
1,839
3.921875
4
""" 把比 median 小的放在 maxheap 里,把比 median 大的放在 minheap 里。median 单独放在一个变量里。 每次新增一个数的时候,先根据比当前的 median 大还是小丢到对应的 heap 里。 丢完以后,再处理左右两边的平衡性: 如果左边太少了,就把 median 丢到左边,从右边拿一个最小的出来作为 median。 如果右边太少了,就把 median 丢到右边,从左边拿一个最大的出来作为新的 median。 maxHeap里面的是负数,minHeap里面的是正数 """ from heapq import * class MedianFinder(object): def __...
6368dabb9ba7db2a372441fc598e5f398008cf36
kailinshi1989/leetcode_lintcode
/236. Lowest Common Ancestor of a Binary Tree.py
2,521
4.0625
4
""" Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes v and w as the lowest node in T that has both v and w as descendants (where we allow a node to be a descendant of itse...
d66412a3ca16cc6c19e77f3c8d5abdf28d580775
kailinshi1989/leetcode_lintcode
/200. Number of Islands.py
2,281
3.5
4
class Solution_1(object): def numIslands(self, grid): if not grid or len(grid) == 0 or len(grid[0]) == 0: return 0 m = len(grid) n = len(grid[0]) visited = [[False for i in xrange(n)] for i in xrange(m)] result = 0 for i in xrange(m): for j ...
7444be87c58e2dc0781da42318e6ed24b62ad1bd
Keith-Njagi/python_intro
/variables.py
476
3.78125
4
# Strings - alphanumeric/special characters firstname = "Keith" secondname = "Njagi" print(firstname + " " + secondname) print(firstname.title(), secondname) print(type(firstname)) print(len(secondname)) print(secondname.__len__()) myname = "Keith Njagi".split(' ') print(myname) li = [0,1,2,3,4,5] lis = list(secondna...
a0ada395e4947ed51088c92810ccd1d46186693b
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/Python Codes by NIYATI SINHA/app5.py
448
4.03125
4
birth_year=input("enter the year of your birth: ") present_year=input("enter present year: ") print(int(present_year)-int(birth_year)) #everything entered using the input function is treated as a string thus we need to convert this string to integer #int(): to convert string to integer #float(): to convert string to fl...
fd118451afbc6c9a8848ec3ee885b41fa480cff3
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/Python Codes by NIYATI SINHA/app27.py
340
3.84375
4
#guess the secret number within 3 turns secret_number=9 guess_count=0 guess_limit=3 flag=0 while guess_count<guess_limit: guess=int(input('Guess: ')) if guess==secret_number: print("You Win") flag=1 else: print("You lost") guess_count+=1 #guess_count++ will give error if flag...
98735348c7809704b46a2686810489ce540c14ea
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/Python Codes by NIYATI SINHA/app24.py
235
4.09375
4
#weight converter weight=int(input("Weight: ")) unit=input("(L)bs or (K)bs:") if unit.upper()=='K': print(f"You are {weight/.45} Pound") elif unit.upper()=="L": print(f" You are {weight*.45} Kgs") else: print("wring input")
b1c7612815be019c31e398c59d8fbf8c16fe79c4
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/Python Codes by NIYATI SINHA/app38(1).py
196
3.953125
4
#the way this program would have been implemented in anyother language numbers=[5,2,5,2,2] for item in numbers: output="" for iterator in range(item): output+="X" print(output)
0c3db0ea32fe1453ab68c7795dca281645185ed0
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/TNT LAB/Lab4/Lab4_p1(way2).py
360
4.15625
4
def secondLargest(T): sort_T=sorted(T) print(f'sorted tuple {sort_T}') return sort_T[-2] a=[] #defining empty list n=int(input("enter no. of elements to enter in tuple")) for i in range(n): a.append(int(input(f'Enter element {i+1} :'))) print(a) #all elements are added in list print(type(a)) ...
0b4aeb62026d2ea3f18d652d86a3a4654eca4e24
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/Python Codes by NIYATI SINHA/app53.py
615
4.1875
4
#functions #when we use : at the end of line , we are telling Python that we are defining a block of code #function calling is done after function defination as PYTHON uses a Interpreter i.e. one statement after other is executed def greet_user():#defining a function named greet_user #write the name of function in...
016ec35dede6c7f58001f1a079cc2fd798e7760d
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/Python Codes by NIYATI SINHA/app48.py
436
4.15625
4
#unpacking # can be applied to list and tuples both coordinates=(1,2,3) #coordinates[0]*coordinates[1]*coordinates[2] #x=coordinates[0] #y=coordinates[1] #z=coordinates[2] x,y,z=coordinates # PYTHON INTERPRETER ASSIGNS THE FIRST VARIABLE IN THE TUPLE TO X THEN SECOND TO Y AND SO ON. #A,B=coordinates # this gives error ...
2dbfd502126cfa32407b9c7b3aa98789d6ad2bb9
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/Python Codes by NIYATI SINHA/app8.py
807
4.375
4
#using indexes in string #index 0123456789... course='Python for beginners' #reverse index ...-3 -2 -1 ; -1 for s, -2 for r, ... print(course[0]) print(course[-1]) print(course[-2]) print(course[0:3]) #all the character starting from index 0 to 2 as the upper limit is not inclusive print(course[1:3]) print(cours...
abb63e26c6adad723444a6f2c140580d52eaefd0
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/TNT LAB/Lab5/Lab5_p5.py
397
4.09375
4
def input_to_dict(key,value): dict[key]=value def sort(): sort_dict = sorted(dict, key=dict.get, reverse=True) # descening order print(sort_dict) dict={} n=int(input("Input no. of items you students you want to add to dictionary")) for count in range(n): name=input(f'Input name {count} : ')...
fb9320e5a5044e743ddccede156d07d6c90897c0
NiyatiSinha-yb/PYTHON-Codes-By-Niyati-Sinha
/TNT LAB/Lab4/Lab4_p1.py
522
4.28125
4
a=[] #defining empty list n=int(input("enter no. of elements to enter in tuple")) for i in range(n): a.append(int(input(f'Enter element {i+1} :'))) print(a) #all elements are added in list print(type(a)) #finding second largest element in list a=sorted(a) #ascending order # a=sorted(a,reverse=True) #...
5531ba251ea6a76cd2aa0474071c2380bee368d7
joaqFarias/fundamentos-python
/00-ejercicio1.py
524
3.765625
4
# Crea una función que tome una lista y devuelva el primer y el último # valor de la lista. Si la longitud de la lista es menor que 2, # haga que devuelva False. def ejercicio(lista=[]): if len(lista) < 2: return False, False else: primer = lista[0] #ultimo = lista[-1] ultimo = ...
5a8f910e9405a4e863acc3e48b40a2bccf3c3c2a
vf201516754/LingProg
/Exercicio03.py
17,525
4.34375
4
# coding: utf-8 # 1 - Faça um Programa que peça dois números e imprima o maior deles. # In[9]: numero1 = input ("Insira o primeiro número?") numero2 = input ("Insira o segundo número?") if numero1 > numero2: print ("O maior número é " + numero1 + "!") elif numero1 == numero2: print ("Os dois numero são ig...
ac5513945a7e21378d42fc7e5353da69a82c786d
minhhngu/TLG
/challenge2.py
544
3.984375
4
#!/usr/bin/env python3 # NDE CHALLENGE #2 - LISTS #Take the following list dogs = ["1 dalmation", 5, "3 huskies", ["spot", "toto", "kujo", "dex", "fred"], "1 St. Bernard"] #Print out the following sentences. The {} show you where the variables should go. #I have {5} dogs. My {3 huskies} are {spot}, {kujo}, and {dex...
d8c01443ca7d7b9ce9935390ab9547683bdd1666
DRMF/DRMF-Seeding-Project
/macro_replacement/src/function.py
5,003
3.78125
4
__author__ = "Cherry Zou" __status__ = "Development" import re class Function(object): """This class represents a mathematical function or polynomial. It provides methods to search for the function and replace it using a given replace function""" # create the function object with the given name, abbreviatio...
81ed0703a545bc8798a0d84106e90cd63767cfd5
shsimeonova/SoftUni-Svetlina-IT-Labs-PB-Python
/Simple Operations and Calculations/Solutions/Demo.py
117
3.90625
4
square_side = float(input('a:')) square_area = square_side * square_side # int(square_area) print('%d' % square_area)
8eb66edcf44a82ba396bbd7036f852e64a66ba32
shsimeonova/SoftUni-Svetlina-IT-Labs-PB-Python
/Simple Operations and Calculations/Solutions/full_greeting.py
253
3.984375
4
first_name = input() last_name = input() age = int(input()) town = input() # You are <firstName> <lastName>, a <age>-years old person from <town> # float() int() str() %d print(f'You are {first_name} {last_name}, a {age}-years old person from {town}.')
bf3c83cd5f933483a66e4aaa14dbf1a21bb8ae2d
Larionov0/DimaKindruk_Lessons
/OOP/Start/2.py
1,394
3.59375
4
class Cup: seria = 'AWCF23' v = 4 color = 'blue' liquids = {} def count_v_of_liquids(self): sum_ = 0 for liquid in self.liquids: sum_ += self.liquids[liquid] return sum_ def add_liquid(self, liquid, v): count = self.count_v_of_liquids() if co...
2bcbf89d03f3136d3c6dd59817ec4f2864f6bbc2
Larionov0/DimaKindruk_Lessons
/Web/API/old/homework/1.py
903
3.8125
4
import requests def get_exchange_rate(date, currency_name): response = requests.get( f'https://api.privatbank.ua/p24api/exchange_rates?json&date={date}' ) # Делаем запрос на API Приватбанка и получаем Response - ответ, кладем его в переменную response dct = response.json() currencies = dct['e...
6a8362c2e11c8126f74e40ac2f116a1be2793681
Larionov0/DimaKindruk_Lessons
/OOP/__magic__methods/main.py
3,793
3.625
4
from random import choices, choice from json import loads import random class Human: names = None def __init__(self, sex, name, age=0, money=0): self.sex = sex # "Ч"/"Ж" self.name = name self.age = age self.money = money # print('Нова людина народжена: ' + self.name) ...
c14c6edbdd15522c9130f8503c07fca6be9c0dff
shyamg90/MLreferance_02
/MultipleLinearRegressionHomework.py
2,046
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 27 21:24:44 2019 Multiple Linear Regression @author: Anand """ import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('50_Startups.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:...
d08cba571dca61a1274fa28ec35cc14f2b347e28
apollo-music/apollo-compiler
/resources/ply_example/testcalc.py
459
3.5625
4
import calclex import unittest # Test it out data = ''' 3 + 4 * 10 + -20 *2 ''' tokens = ['3', '+', '4', '*', '10', '+', "-", '20', '*', '2'] class CalcTest(unittest.TestCase): def test_calc(self): # Give the lexer some input calclex.lexer.input(data) # Tokenize for t in tokens:...
2192c549decdd7bee184ccfeb314573d9a97378d
Sandeep-pk/guvi
/py.py
142
3.921875
4
def main(): a=raw_input("Enter the string:") print(a) v = a.split() b= " ".join(reversed(v)) print(b) main()
4cb9fca3f23cbbc969e9e91ce7cc2120b9d12c1b
CaralDesail/MPU6050V3
/test/rot_ex.py
1,935
3.5
4
import pygame pygame.init() BACKGROUND_COLOR = (0, 0, 0) class Player(pygame.sprite.Sprite): def __init__(self, position=(0, 0)): super(Player, self).__init__() self.original_image = pygame.Surface((32, 32)) pygame.draw.lines(self.original_image, (255, 255, 255), True, [(16, 0), (0, 31),...
0f2904e38ca93378de94c975e73ca36e249f09ba
MATOBAD/NLP
/chapter6/rnn_gradient_graph.py
812
3.796875
4
#!/usr/bin/env python import numpy as np import matplotlib.pyplot as plt def main(): N = 2 # ミニバッチサイズ H = 3 # 隠れ状態ベクトルの次元数 T = 20 # 時系列データの長さ dh = np.ones((N, H)) np.random.seed(3) # 再現性のため乱数のシードを固定 # befor # Wh = np.random.randn(H, H) # after Wh = np.random.randn(H, H) * 0.5 ...
d045c824a3b109b9278a12a71d65082643a76307
Aliazhari/web-dev-python
/lesson3/mysql/lesson2/app0.py
570
3.671875
4
# Author: Ali Azhari # insert a record and print the number of records inserted. In this case there is only one record import mysql.connector mydb = mysql.connector.connect( host="localhost", user="ali", passwd="ali", database="chat_db" ) mycursor = mydb.cursor() sql = "INSERT INTO agents (lastname, firstn...
64ca2d80d2e219a48e71e625fca32ebed8f17f82
Sanyastiy/pyfiles
/theory files/hello_path_module.py
2,391
3.9375
4
''' Some documentation: This file import a system module to make a good path for files then defining TWO or more functions First, now, opening file and writing there usually Second analogical First, but using WITH construction Third is writing to list what file contains Fourth is creating a .csv file Fifth is reading ....
7d7f8f8d143b0f13beb648516db79b7b81074271
thuchimney292/thutran-fundamental-lesson2-c4ep35
/test.py
649
3.625
4
# text = 'hello' # t = len(text) == 5 # print(t) # n = int (input("nhap so n: ")) # year=int(input("nhap nam sinh: ")) # age=2019-year # if age>=18: # print("adult") # elif age<=12: # print('baby') # else: # print("teenager") #i=1 # import time # for i in range(10): # for j in range(10): # for k...
8d4afc0dde0bc61ee86d172dec778d9354e2d698
devblocs/python-learnings
/005_control_structures/001_conditions/001_greater_than.py
373
4.0625
4
first_number = int(input("Enter the first number: ")) second_number = int(input("Enter the second number: ")) if first_number < second_number: print(f"Number '{first_number}' is less than '{second_number}'") elif first_number == 0 and second_number == 0: print("Both the numbers are 0") else: print(f"Number...
07dc26a7bd21739869dfe234dc2364f3b06a5159
devblocs/python-learnings
/005_control_structures/002_loops/004_persons.py
128
3.796875
4
persons = ["Venkatesh", "Hari", "Albert", "Amey"] for index in range(len(persons)): print(f"{index + 1}) {persons[index]}")
d6103a0fa34780f11cd1cd8e1b6b834731235c5e
SamehDorgham/Python_Practice_Projects
/Game With three main Choices.py
2,601
4.21875
4
class AllInOne_project1: def __init__(self): print('Welcome to My Game ^__^ ') print('choose your Game from the list : ') print(' [1] Even-Odd Game ') print(' [2] Sum-Average Game ') print(' [3] Multiplication Game ') self.User_Choice() def User...
3f8fc357fc51f2769baa2acfdac61878dcef1ba8
neerajkesav/PythonML_Examples
/com/neeraj/sklearn_ml/data_explorer.py
1,106
3.765625
4
# -*- coding: utf-8 -*- """ DatasetExplorer. @author: neeraj """ import matplotlib.pyplot as plot from pandas.tools.plotting import scatter_matrix class DataExplorer: """Class DataExplorer. To understand data with descriptive statistics and visualization. DatasetExplorer have the following properties: ...
df4722408cce47a49769abed4ddd60c822ea5be4
alfagama/INstagramINfluencers
/show_results/questionnaire_results.py
5,180
3.921875
4
import pandas as pd import show_results.plot_results from dataset_creation import read_data import os.path # Options for pandas ----- pd.set_option('display.max_columns', None) pd.set_option('display.max_rows', None) def read_questionnaire(): # reads data/category_columns_dataset.csv dataset = pd.read_csv("fi...
c13f4dcd5102ba5e3d3d666d60c3e7a97eabdabf
earl-gadel/LC101-Sandbox
/evensteven.py
120
3.625
4
number = 1 for number in range (1, 101): if number % 2 == 0: print("Steven") else: print(number)
cbd5af9e5ca16f421b152e9328b8b2490720dab1
Shinpei2/python_source
/automation/chapter15/stopwatch.py
958
3.9375
4
#! python # stopwatch.py - the simple stop watch program import time # print the description of the program print('------------ストップウォッチ------------') print('Enterを押すと開始します。') print('その後、Enterを押すと経過時間を表示します。') print('Ctrl+Cで強制終了します。') print('----------------------------------------') input() print('スタート') start_time...
409c2418472f118ac71b88b42e002dd7ac39e9aa
Shinpei2/python_source
/automation/chapter15/sleep.py
329
3.6875
4
import time # 注意点:time.sleepは途中で強制終了が出来ない # 時間指定する場合は、for文で回すようにする # for i in range(3): # print('Tick') # time.sleep(1) # print('Tock') # time.sleep(1) now = time.time() print(now) print(round(now,2)) print(round(now,4)) print(round(now))
6f7acd7384580ff75c38f98ca082e1b2723ba86a
Shinpei2/python_source
/sukkiri_python/chapter4/q4-2.py
417
3.75
4
count = 1 print("カレーを召し上がれ") while True: print(f"{count}皿のカレーを食べました。") while True: key = input("おかわりはいかがですか?(y/n)>>") if key in ["y","n"]: break else: print("yかnを入力して下さい。") if key == 'y': count += 1 else: break print("ごちそうさまでした。")
f85fc3317d206bc1162cd5e9af0e6cc242c655a4
VelampudiRohit/292119_miniproject
/Project/Student_Record_Management_System.py
5,728
3.703125
4
import pickle import os class student(object): def __int__(s): s.roll=0 s.name="" s.per=0 def add_rec(s): while(True): roll=input("Enter roll no: ") if(roll.isnumeric()==True): s.roll=int(roll) break else: ...
ff69cf824cee9d9a9ad59576f58b443a1376e45c
jamqd/MITx
/ProblemSet1/set1p1.py
308
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 8 12:04:31 2018 @author: jd """ s = 'azcbobobegghakl' count = 0 for letter in s: if letter == 'a' or letter == 'e' or letter == 'i' or letter == 'o' or letter == 'u': count += 1 print('Number of vowels: ' + str(count))
8ee5f1036cf16b116f71c6a40fd1ca9eb1227729
cocoaaa/WebDev
/Lec2/hello_world/hello_world.py
3,078
3.65625
4
import webapp2 import cgi form=""" <form method="post"> What is your birthday? <br> <label> Month <input type="text" name="month" value="%(month)s"> </label> <label> Day <input type="text" name="day" value="%(day)s"> </label> <label> Year ...
e17733d18e0b1d8b0d7232158bc958dd379910aa
himsangseung/Python-Algorithm-Projects
/Recursion/Recursion.py
4,989
3.984375
4
""" PROJECT 2 - Recursion Name:Sang-Seung Jay Lee """ class LinkedNode: # DO NOT MODIFY THIS CLASS # __slots__ = 'value', 'next_node' def __init__(self, value, next_node = None): """ DO NOT EDIT Initialize a node :param value: value of the node :param next_node: poi...
1d3232f95030f0e32919163f92164160d2402e65
shireen-01/nunam_test
/1_combine.py
981
3.765625
4
import pandas as pd import os from pathlib import Path # returns csv name according to the sheet name eg: detail.csv def get_csv_with_sheet_name(sheet_name): if 'Detail_67_' in sheet_name: return 'detail.csv' elif 'DetailVol_67_' in sheet_name: return 'detailVol.csv' else: return '...
871113fc4ad91884a1bd2e50b298d78eb2f7400e
Schwartz210/427-Bot-Farm
/logger_thingy.py
463
3.609375
4
from functools import wraps def to_console(indentations, message): """For clean console output""" text = '' for i in range(indentations): text += ' ' text += message print(text) def logger(func): """Decorator that prints out function name before function call""" @wraps(func) ...
3fb88ecdc2e698c1c1e82080092774de025877dd
woofwoof4everyonefoundation/coursera_exercises
/c3e12.6.py
1,586
4.09375
4
#Scraping Numbers from HTML using BeautifulSoup In this assignment you will write a Python program similar to http://www.py4e.com/code3/urllink2.py. The program will use urllib to read the HTML from the data files below, and parse the data, extracting numbers and compute the sum of the numbers in the file. #We provide...
e88703a4040e98bb7155166dc592b7fdd0b44af6
Abhyudaya100/my-projects-2
/listcomprehension3.py
125
3.953125
4
list1 = [1,2,3,4,5,6] evalist = [element ** 2 if element% 2 ==1 else element ** 3 for element in list1] print(*evalist)
629bb5d767287f6da54c069b071e120fb8ec1eed
Abhyudaya100/my-projects-2
/reverse_a_number.py
114
3.890625
4
n = int(input("Enter a number :")) while n!= 0: remainder = n%10 print(remainder, end="") n//=10
15d1dfe1a52b249a4a01b92bc1f42392d2e44dfa
Abhyudaya100/my-projects-2
/stringpatternsquare.py
702
3.8125
4
''' Enter a string :abhyudaya abhyudayaabhyudaya abhyuday abhyuday abhyuda abhyuda abhyud abhyud abhyu abhyu abhy abhy abh abh ab ab a a a a ab ab abh abh abhy abhy abhyu abhyu abhyud ...
07096adef94cb915c6a934980419f5315919bbaa
Abhyudaya100/my-projects-2
/probem 2.py
1,003
3.90625
4
''' Problem 2: FACTORS OF X One day a teacher gave an assignment to the student to find the factors of a number. The student is not interested to do the given task and he was searching for the shortcuts. So, please help him by writing a program Input Format First line contains an integer T denoting the no.of tes...
38e4a094c2c02cc09017a854bcef5c3f2e3eef2d
Abhyudaya100/my-projects-2
/sumofcubeoffirstNnumbers.py
184
3.65625
4
''' N = int(input()) total = 0 for n in range(1,N + 1,1): total += n*n*n print(total) ''' print(4194303) 25 8.33 30 10 28.33 9.44 33.33 11.11
c99ce971e2660be2d4d1b54aea5af3f3d28b8a8f
LeonardoJosedaSilveira/Curso-de-python
/Mundo 1/Desafio/025.py
127
3.90625
4
nome = str(input('Digite um nome: ')) silva = nome.split() print('O nome contem SILVA? {}'.format(silva.__contains__('SILVA')))
dc14c8fcd9fb987bcc3a4f5002835b4ddfcd0234
LeonardoJosedaSilveira/Curso-de-python
/Mundo 1/Desafio/026.py
356
4
4
frase = str(input('Digite uma frase: ')) #conta quantas veses 'A' aparece na frase print('A frase contem {} letras A'.format(frase.count('A'))) #encontra a primeira letra 'A' print('Contem uma primeira letra A na posição {}'.format(frase.find('A'))) #encontra a ultima letra 'A' print('Contem uma ultima letra A na posiç...
1ffc0c4484aca16160ba9e503fe006e83dd6cfdb
LeonardoJosedaSilveira/Curso-de-python
/Mundo 1/Desafio/010.py
228
3.796875
4
n0 = float(input('Quanto dinheiro em reais você tem sua carteira ')) n1 = 3.27 n2 = n0/n1 print('A cotação esta {}'.format(n1)) print('Você pode comprar {:.2f} dólares'.format(n2)) print('\033[1;36;43mteste de cores\033[m')
ff0d425b9992d678ed82b3ea5708a979fad41989
deltamoose/gwc
/eminemadventure.py
3,996
4.21875
4
playagain = "yes" print("start") while playagain == "yes" or playagain == "Yes": userChoice = input("It is a nice day in LA. You see posters advertising Eminem's new concert and want to go see it with your friends. Buy the expensive tickets online (type 'Fandango') or look for the shady scalper at the venue (ty...
7245066d2b6fbb2c4b1043a16e370d76e9001e13
SzymonKubica/maths-library
/tokeniser.py
686
4.0625
4
from common import is_operator """ Tokeniser module: splits a given string into a list of tokens. """ def delete_whitespace(line): return ''.join(line.split(' ')) def tokenise(line): """ Splits a line into tokens. """ tokens = [] line = delete_whitespace(line) i = 0 while i < len(line): ...
cfe1d4b2dbc8a804d53cff0df6290f6a65bb0b8c
ritik005/Coding-Contest
/Hackerearth/AugustCircuit/subsetSequence.py
246
3.609375
4
for _ in range(int(input())): n=int(input()) A=[] i=0 while i<64 and n>0: if n&1: A.append(3**i) n>>=1 i=i+1 print(len(A)) for i in range(len(A)): print(A[i],end=" ") print()
e935f511ae2372e631b348f80e23dc9f31a3575e
ljungster/everypay-optimization
/optimal_bins.py
5,432
3.515625
4
#! /usr/bin/python3 import csv dictionary = {} def set_up_dictionary(): ## NOTE: MUST CHANGE FILE with open("Sample.csv", mode = "r") as csv_file: csv_reader = csv.DictReader(csv_file) for row in csv_reader: #variables that we import from the sheet amount = int(row["amo...
d653f07cdd2493f474140b3d4b43d0353872126f
putuwaw/tlx-toki-answer
/06. Perulangan/E. Dua Pangkat/e_dua_pangkat.py
92
3.65625
4
N = int(input()) while N % 2 == 0: N = N // 2 print('ya') if N == 1 else print('bukan')
70bdc891d0523fcf0b3cb88e0771dd6a407ffe23
putuwaw/tlx-toki-answer
/07. Perulangan Lanjut/A. Break Continue Exit/a_break_continue_exit.py
164
3.578125
4
N = int(input()) for i in range(1, N+1): if (i % 10 == 0): continue elif (i == 42): print("ERROR") break else: print(i)
7fb8833d823704bf91068a2f151dc68d408bde0e
sandialabs/pvOps
/pvops/text/utils.py
5,000
3.640625
4
import pandas as pd import numpy as np def remap_attributes(om_df, remapping_df, remapping_col_dict, allow_missing_mappings=False, print_info=False): """A utility function which remaps the attributes of om_df using columns within remapping_df. Parameters ---------- om_df :...
ff41f509f1e8c87e2f06208f54998a03829281b1
nieyulin112/python3
/list.py
840
4.1875
4
# list是有序数组 classMates = ['1', '2', '3'] print(len(classMates)) # 插入元素 classMates.insert(1, 'jack') print(classMates) # 要删除list末尾的元素用pop()方法 classMates.pop() print(classMates) # 要删除指定的 classMates.pop(0) print(classMates) # tuple:另一种有序列表叫元组:tuple。tuple和list非常类似,但是tuple一旦初始化就不能修改 tclass = (1,2,3) print(tclass) t = ('a...
b56d8a8b767fb5067312c6a7f0b7534a4bcb66e7
nirgalili/us-states-quiz
/main.py
1,459
3.8125
4
import turtle import pandas from state import State from scoreboard import Scoreboard def run_main(): screen = turtle.Screen() screen.title("U.S States Quiz") image = "blank_states_img.gif" screen.addshape(image) turtle.shape(image) state = State() scoreboard = Scoreboard() scoreboar...
7f1a217753ba8a67f3fc0a9fe4516c2cd9f5f19f
matheuspiana/Trabalho-CG
/compgraf.py
1,559
3.640625
4
from random import choice import string usuarios = [] def cadastro(): listuser = open("user.txt","w") listsenha = open("senha.txt", "w") user = input("Escolha seu ID: ") senha = input("Digite a sua senha: ") #cadastro = ["\n", user,"\n", senha, "\n", "_"*50] listuser.wr...
7c46b4316d73f636b224b9a21cfeb6cc4e190d79
BarYar/Experis
/venv/Basic/Ex1.py
575
4.46875
4
#תוכנה המקבלת יום חוד ושנה ומדפיסה אותו כתאריך day= int (input ("type the day")) #לא מקבל יום עד שהוא תקין. while day < 0 or day>31: day = int(input("type the correct day")) month= int(input("type the month")) #לא מקבל חודש עד שהוא תקין. while month < 1 or month >12: month = int(input("type the correct month")...
6a7fb3886fb65ebd60e067adb41c3ec0968bcdb0
ericmaines/exampleCode
/coding competition/reversedbinary.py
515
3.828125
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 7 15:44:08 2019 @author: ericm """ def decToBin(num): if(num > 1): decToBin(num//2) return num def BinToDec(num): bin(num).replace("0b", "") def reverse(Number): while(Number > 0): Reminder = Number %10 reversedd = (reversed...
27a38c32cf74f8a6082ec794559dbf4b6c2c502c
voltun/AI-Project-B
/Old Scripts/minimax_agent/player.py
8,649
3.84375
4
import utils.functionality as func import minimax_agent.config as config from heuristics.search import nearest_opponent, euclidean, Node class ExamplePlayer: def __init__(self, colour): """ This method is called once at the beginning of the game to initialise your player. You should use thi...
cb7e190c174876236ae5dcf4514a3de381b0e67e
killedman/web_scraping_with_python
/crawl_sitemap.py
1,840
3.734375
4
#! /usr/bin/env python3 # why just import urllib is error # import urllib from urllib.request import Request, urlopen # Python 3 from urllib.error import HTTPError # import urllib.request # why not urllib.error ,just use urllib is error from urllib.error import URLError # resolv question [SSL: CERTIFICATE_VERIFY_FAILE...
237fa8f2997a3d8a319c8ea77f6eadb4e532bd27
pandeyapurvaa/ConvertImage
/first.py
414
3.65625
4
import cv2 #image conveersion project colour image into grayscale path=input("Enter the path and name of the image==") print("Entered Path By You is==",path) #now read the image img1=cv2.imread(path,0) img1=cv2.resize(img1,(500,500))#width,height cv2.imshow("Converted image==",img1) k=cv2.waitKey() if k==ord...
fc7292fd12c2ff20377009b0cff2c5ec04b78cd2
xingyongxu/leetcode
/flatten_nested_list_iterator/flatten_nested_list_iterator.py
1,700
4.09375
4
# """ # This is the interface that allows for creating nested lists. # You should not implement it, or speculate about its implementation # """ #class NestedInteger(object): # def isInteger(self): # """ # @return True if this NestedInteger holds a single integer, rather than a nested list. # :rt...
a92365af86303b96ae3193e6e40e2952f8e53bd5
ishitasinghal/Data-Structures
/remove.py
400
3.84375
4
# Given nums = [3,2,2,3], val = 3, # Your function should return length = 2, with the first two elements of nums being 2. # It doesn't matter what you leave beyond the returned length. # CODE def removeElement(self, nums: List[int], val: int) -> int: N=len(nums)-1 while N >=0: if(nums[N]==va...
e9c561ed684566ca31ce481e2cc02729188405a8
OsmoSystems/cosmobot-process-experiment
/osmo_camera/tiff/save.py
1,484
3.515625
4
import numpy as np import tifffile from ..constants import DNR_TO_TIFF_FACTOR class DataTruncationError(ValueError): pass def _guard_rgb_image_fits_in_padded_range(rgb_image): """ Guard that the values in the rgb image are all within the padding left over after dividing the signed 32-bit range by the D...
61cee7d7347fddcac187ac857a4577cb6a5c0dfe
rootart/python-omgeo
/omgeo/processors/__init__.py
1,213
3.640625
4
class _Processor(): def _init_helper(self, vars_): """Overwrite defaults (if they exist) with arguments passed to constructor""" for k in vars_: if k == 'kwargs': for kwarg in vars_[k]: setattr(self, kwarg, vars_[k][kwarg]) elif k != ...
7ec3a74a22d71d0baaedd3f634a2f37b75f0849b
Lu-Yi-Hsun/home
/docs/數學/線性代數/chap1.py
319
3.609375
4
import numpy as np import matplotlib.pyplot as plt def graph(formula, x_range): x = np.array(x_range) for f in formula: y = eval(f) plt.plot(x, y,2) plt.axhline(y=0, c='black') plt.axvline(x=0, c='black') plt.show() line=["2*x","x/2+3/2"] graph(line, range(-100, 100))
decf6342b0fc75bcf2fa73486341e8c0e8b7be5b
jasmin-guven/labile_HD_exchange
/pdb2DF.py
2,736
3.515625
4
import numpy as np import pandas as pd import csv import os.path def is_path(filepath): is_path = os.path.isdir(filepath) while is_path == False: filepath = input('Invalid directory %s. Please enter again: ' %(filepath)) is_path = os.path.isdir(filepath) return filepath def is_file(filep...
30e4026d1b405a891c4b7dc25654bbddd8c91d7b
ChadVen/Py-Lists
/ArrayLists.py
202
3.90625
4
mylist = [] mylist.append(1) mylist.append(2) mylist.append(4) print(mylist[0]) # prints 1 print(mylist[1]) # prints 2 print(mylist[2]) # prints 4 # prints out 1,2,3 for x in mylist: print(x)
1819cf11e4ec1657bad97df36ed91d21d1000c47
dietrichsimon/jj_recommender-1
/jj_recommender/recommender_module.py
1,659
3.5625
4
"""Module Docstring goes here""" import random class Recommender: """Class for grouping all my related functions (i.e. methods). A paragraph for all my structured sentences. """ def __init__(self, items): self.items = items def recommend_random(self, num:int)->list: """ ...
56d878234ece366bf6e180e09ff2da2dd2bc8654
srikanthpragada/PYTHON_06_APR_2020
/demo/ex/table.py
113
3.921875
4
# Table num = int(input("Enter a number :")) for i in range(1, 11): print(f"{num:2} * {i:2} = {i * num:5}")
3629ea0441db6c08461181ca45737e72390299aa
srikanthpragada/PYTHON_06_APR_2020
/demo/db/add_employee.py
304
3.625
4
import sqlite3 con = sqlite3.connect(r"c:\classroom\apr6\hr.db") cur = con.cursor() name = input("Enter name :") job = input("Enter job :") salary = input ("Enter salary :") cur.execute("insert into employees(fullname,job,salary) values(?,?,?)", (name,job,salary)) con.commit() cur.close() con.close()
c580889fdc2ec0ec1491e8ef6b39320bc5efed55
srikanthpragada/PYTHON_06_APR_2020
/demo/mylib/str_funs.py
225
4.09375
4
def reverse(s): """Reverses the given string Params: s is a string Returns: Returns reversed version of the given string """ return s[::-1] def alpha(s): return list(filter(str.isalpha, s))
71040a93c9ffead7f6e6c0c8b7a06cb8c889f890
srikanthpragada/PYTHON_06_APR_2020
/demo/ex/sum_of_numbers.py
258
4.03125
4
total = 0 while True: try: num = int(input("Enter number [0 top stop] :")) if num == 0: break total += num except ValueError: print("Invalid input. Please enter a valid number!") print("Total : ", total)
c405ae56a44491fa1ff284b7b193f9f467a45bcb
srikanthpragada/PYTHON_06_APR_2020
/demo/ex/avg_length.py
264
4.15625
4
# take strings until end is given and display avg. length of strings total = 0 count = 0 while True: name = input("Enter name [end to stop] :") if name == 'end': break total += len(name) count += 1 print(f"Avg. Length = {total/count}")
dbf39f76eda5ff6e9b3c85d31af31bc9129a3bb0
srikanthpragada/PYTHON_06_APR_2020
/demo/ex/common_chars2.py
130
3.984375
4
# Print common chars between two strings s1 = "ABCXYZPQRAB" s2 = "DEFAHBXA" for c in set(s2): if c in s1: print(c)
6dabd36cbc045f7b4f181ab74ced444e7932026c
Coderash1998/LeetCode
/1022/1022.py
601
3.6875
4
# 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 sumRootToLeaf(self, root: TreeNode) -> int: self.s=0 def dfs(node, n): ...
7959bb9bd26e5393cad7e266bcdc958eee9bbe4f
Tejasree15/Python
/average.py
189
4.15625
4
#lists in for loop total=0; numbers=[10,20,30,40,50,60] for num in numbers: total=total+num; average=total/len(numbers) print ("The average of {} is {}".format(numbers,average))
798db9111175bd227c0b271105034bf2ebd201a8
TODUR/stepik-python
/solutions/week-1/interval.py
108
3.96875
4
x = int(input()) if (-15 < x <= 12) or (14 < x < 17) or x >= 19: print("True") else: print("False")
8e35cceaa9c380351578f27e560a2f0be4a605aa
TODUR/stepik-python
/solutions/week-1/ending.py
542
3.609375
4
n = int(input()) if 0 <= n <= 1000: if n == 0: print(n, "программистов", sep=" ") elif n % 100 >= 10 and n % 100 <= 20: print(n, "программистов", sep=" ") elif n % 10 == 1: print(n, "программист", sep=" ") elif n % 10 >= 2 and n % 10 <= 4: print(n, "программиста", sep=" ...
d6c2a7ccdcc8a961095118006980aaa57ca8f850
TODUR/stepik-python
/solutions/week-1/conditions_1.py
290
4.15625
4
A, B, H = (int(input()) for i in range(3)) if A <= B: if H > B: print("Пересып") elif H >= A and H <= B: print("Это нормально") else: print("Недосып") else: print("Получаемое число A больше чем B!")
82f79d8b6737ead9c0ba4059412b2f257dc85e1a
dhruvarora93/Algorithm-Questions
/Array Problems/serialize-desrialize.py
1,466
3.53125
4
class Node: def __init__(self,key): self.left=None self.right=None self.value=key class Codec: def serialize(self,root,s): if not root: s.append('/ ') return s.append(str(root.value)+' ') self.serialize(root.left,s) self.serial...
f5a1eb866e8bacfd24c9744a892e8991417b87c6
dhruvarora93/Algorithm-Questions
/Graphs and Trees/number_of_islands.py
1,527
3.5
4
def dfs(matrix,row, col, visited,indices,count): if (row in range(len(matrix)) and col in range(len(matrix[row])) and not visited[row][col] and matrix[row][col] == '1'): visited[row][col] = True count[0] += 1 indices.append((row,col)) dfs(row, col - 1, visited, matrix,indices,count) ...