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
eae5c9ee2bdbfe18049a16834d7b1a1062e98526
lennikorhonen/penTest-ict4tn027-3005
/h6/hashbreak.py
684
3.78125
4
import hashlib def main(): break_hash() def break_hash(): hash_to_crack = input('Give hash: ') with open('./common.txt') as passwords: pswd_list = passwords.read().split('\n') print(pswd_list) i = 0 # Go through the list while i <= len(pswd_list): # Ha...
0b26b8a028665415e151658d3f4613b7efa8c9bc
redgatling/text_games
/scrabble.py
5,490
3.984375
4
import random VOWELS = 'aeiou' CONSONANTS = 'bcdfghjklmnpqrstvwxyz' HAND_SIZE = 7 SCRABBLE_LETTER_VALUES = {'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, ...
7503f35fc05ff859152c576a700f3f7876454831
emilypng/python-exercises
/Packt/ex38.py
95
3.90625
4
list = [4, 2, 7, 3] max = 0 for num in list: if num > max: max = num print(max)
d4bb5a83bf83ed0f3b9b427a45c77dbdd2cf733a
emilypng/python-exercises
/Packt/act11.py
253
4.28125
4
def fib_recursive(n): if n<2: return n else: return fib_recursive(n-2)+fib_recursive(n-1) user_input = eval(input("Enter a number to take the factorial of: ")) input_factorial = fib_recursive(user_input) print(input_factorial)
5edb72d11a232492600d3d532891911c159d7e6e
indrahrp/NetCheck
/test3.py
1,163
4.09375
4
class Pizza(object): @classmethod def produce(cls,k,l): print "in class method produce " return cls(k,l) @staticmethod def mix_ingredients(x, y): print 'x ' + str(x) + ' and ' + str(y) return x + y def __init__(self,cheese,vegetables): self.cheese=cheese self.vegeta...
326da70531ea51b8a6b74fdf23a497895de0e7ad
StanGuinel/resident-advisor-graph
/resident-advisor-graph/grapheFromAdjacencyMatrix.py
2,706
3.515625
4
import scipy.optimize as opt import numpy as np import random import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages def dijkstras(M, n): #return a list with list[i]=length of shortest path from n to i N=len(M) list=[] dis=np.zeros(N) for i in range(N): dis[i]=...
a1889e8016f351441095c96221ef49e7f25ea725
vildeka/CompGen
/Practical_5/rndseq.py
694
3.625
4
#! /usr/bin/env python "prints first argument aa sequences of length second argument to screen" import random import sys seq_dict = {} number=int(sys.argv[1]) length=int(sys.argv[2]) inputfile= sys.argv[3] outfile=sys.argv[4] aas="ARNDCEQGHILKMFPSTWYV" def r20(): return random.randrange(20) for i in range(number): ...
1c3c562c93535fd28c6384ef0e85486ddbdc0dce
akrolsmir/streamlit-reddit
/streamlit_app.py
962
3.5
4
import streamlit as st import json from google.oauth2 import service_account from google.cloud import firestore # Load the Firestore key from Streamlit secrets key_dict = json.loads(st.secrets["textkey"]) creds = service_account.Credentials.from_service_account_info(key_dict) db = firestore.Client(credentials=creds, p...
a3bb77b037823b51b81bc3301b133444740b73a5
honyacho/atcoder_excercise
/abc114/c.py
371
3.5
4
arr=[3,5,7] global res res = 0 ma = int(input()) def gen(num = 0): global res # print(num) if ma < num: return else: st = str(num) if st.count('3') and st.count('5') and st.count('7'): res += 1 for i in arr: if num == 0: gen(num+i) e...
6838063f8ec42773b5618099b8b7fd0f32ba6170
pitpalac36/AI
/examen_3/file_utils.py
711
3.59375
4
import csv def read_from_csv(fileName): data = [] with open(fileName) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') line_count = 0 for row in csv_reader: if line_count == 0: dataNames = row else: data.a...
5f43499880c6a606c7bf215e29cfef49fba73280
Lagyu/python_tutorial_2
/day2_exercise1.py
8,318
3.59375
4
from abc import ABCMeta, abstractmethod from datetime import date from typing import Union if __name__ == "__main__": # 1 temp_c = 100 temp_f = temp_c * 9 / 5 + 32 print(temp_f) # 2 def cels_to_fahr(cels: float): return cels * 9 / 5 + 32 print(cels_to_fahr(0)) # 3 whi...
9e21397b233a53ee4eeff75f84542922781c8de2
scoutiii/PYTHON-primeNumberCode
/test.py
3,347
3.53125
4
import primefac import math def f(x, slope, intercept): return int(slope * x + intercept) def G(x, y): return int((x+y)*(x+y+1)/2 + x) def F(x, slope, intercept): return int(G(x, f(x, slope, intercept))) # This works for lines of slope 1 and positive y intercept primeRate = 10**3 slope = 1/5. interc...
fd3f61d317a9a3ac4a8b962152ba7fb21a2a4141
sunrain0707/python_exercise_100
/ex20.py
342
3.578125
4
#20.一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米? # 第10次反弹多高? def hight(n): if n == 0: return 100 return hight(n-1)/2 sum = 100 for i in range(0,11): sum +=hight(i) print(hight(10)) print(sum)
5d704ce0b6ab4651bd88ccfa974db9fd6aea8979
sunrain0707/python_exercise_100
/ex22.py
457
3.796875
4
#22.两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。 # 已抽签决定比赛名单。有人向队员打听比赛的名单。a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单。 n = ['a','b','c'] m = [] for i in range(3): if(n[i]!='a' and n[i]!='c'): m.insert(i,'x') elif n[i]!='c': m.insert(i,'z') else: m.insert(i,'y') print(m)
23d8518bad7e9ad65368390031150c6ba6ea8e04
sunrain0707/python_exercise_100
/ex55.py
336
3.71875
4
#55.学习使用按位取反~。 a = 7 b = ~a c = -7 d = ~c print ('变量 a 取反结果为: %d' % b) print('【二进制】a:',bin(a),'b:',bin(b)) print ('变量 c 取反结果为: %d' % d) print('【二进制】c:',bin(a),'b:',bin(d)) print('2进制',bin(22)) print('16进制',hex(22)) print('8进制',oct(22))
d5b2c4adbf5a743c96ceea89803e9e305c3cd50c
sunrain0707/python_exercise_100
/ex80.py
727
3.625
4
#80.海滩上有一堆桃子,五只猴子来分。 # 第一只猴子把这堆桃子平均分为五份,多了一个,这只猴子把多的一个扔入海中,拿走了一份。 # 第二只猴子把剩下的桃子又平均分成五份,又多了一个,它同样把多的一个扔入海中,拿走了一份, # 第三、第四、第五只猴子都是这样做的,问海滩上原来最少有多少个桃子? i = 0 j = 1 x = 0 while (i < 5): x = 4 * j for i in range(0, 5): if (x % 4 != 0): break else: i += 1 ...
d849765e14eabc3f1ac3b5c6d0bb7cc73ac9b4f3
sunrain0707/python_exercise_100
/ex95.py
396
3.921875
4
#95.字符串日期转换为易读的日期格式 import time start = time.time() for i in range(3000): print(i) end = time.time() print(end - start) print(time.ctime(time.time())) print(time.asctime(time.localtime(time.time()))) print(time.asctime(time.gmtime(time.time()))) import datetime print(datetime.date.today()) pri...
581a0edbb1d621d8d72a86c07e7956de67e7eac1
sunrain0707/python_exercise_100
/ex38.py
142
3.640625
4
#38.求一个3*3矩阵主对角线元素之和。 a=[[1,2,3,],[4,5,6],[7,8,9]] sum=0 for i in range(0,3): sum+=a[i][i] print(sum)
fcd6f202979ef112b68034e4a5bf9d8320f54b85
JaydenAssignment/2020-Jayden-AE401
/Homework4.py
567
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Apr 2 10:46:53 2020 @author: jaydenjian """ #召喚模組 import turtle #創造一個畫布 C=turtle.Screen() #設定畫布視窗名稱 C.title("my window") #設定背景顏色 C.bgcolor("black") #生成烏龜 a=turtle.Turtle() #設定烏龜(畫筆)樣式 a.color("yellow") a.shape("turtle") j=0.1 #加入for迴圈 for i in ra...
fda8fce78ec25b467a25f8f7fab7ea6972efb753
actuarial-tools/PythonStuff
/Old Stuff/nqueenspy.py
378
3.90625
4
#numqueens=int(input("How many queens? ")) numqueens=2 board=[] for x in range(0,numqueens*numqueens): board.append(0) length=len(board) #empty board created for x in range(0,numqueens): board[x]=1 #starting queens def generateall(board): #print(board) temp=board[length-1] for x in range(0,length-1)...
6a33d79064c098e34df1c80e424b565f45d2b75b
actuarial-tools/PythonStuff
/Old Stuff/oopython.py
306
3.78125
4
class square: sideLength=0 def __init__(self,sides): self.sideLength=sides def getLength(self): return self.sideLength def setLength(self,sides): self.sideLength=sides mySquare=square(5) print(mySquare.getLength()) mySquare.setLength(10) print(mySquare.getLength())
0b59f906346a3977aec0b17db3aaaf2d8f56f498
actuarial-tools/PythonStuff
/Old Stuff/growingdictionary.py
417
3.8125
4
exec(""" words=["apple"] definitions=["red fruit"] while 1: found=False length=len(words) currentword=input("Enter a word: ") for x in range (0,length): if currentword==words[x]: print(definitions[x]) x=length found=True if found==False: words.append(currentword) currentdefinition=input("Enter the ...
08d0a7740c407a413298a1a645bcdf0f50a14833
amrgharib/my_leetcode_challenges_solutions
/Python/969_pancake_sorting.py
1,631
3.5
4
# leetcode solution class Solution: def pancakeSort(self, A: List[int]) -> List[int]: """ sort like bubble-sort sink the largest number to the bottom at each round """ def flip(sublist, k): i = 0 while i < k / 2: sublist[i], sublist[k-i-1] ...
08bfc6964db27c4d8f8fd9d5a62af3c587d1c713
kirbym/CSCI-421
/P01/caesar-encrypt.py
458
3.90625
4
import sys import library as c if len(sys.argv) <= 1: print "I need a key!" sys.exit(1) key = int(sys.argv[1]) text = "" if len(sys.argv) == 2: #only key, get input from 'cin' text = sys.stdin.read() else: #file = open(sys.argv[2]) #text = file.read('R') #file.close() with open(sys.ar...
10876f040233829ddd019f6d6d98b448cbd6a775
MichaelBamba/day-6
/vehicleclass.py
361
4.0625
4
class Vehicle: def __init__ (self, make, model, year): self.make = make self.model = model self.year = year def print_info(self): return "the car is a {} {} from {}".format (self.make, self.model, self.year) car = Vehicle("nissan ", "leaf ", "2015 ") # print (car.make, car.m...
435a92084bf31a0cf48b7a923297c49d746f1d3a
ananddtyagi/Glossary_Evaluation
/topic_approx/alt_page_options.py
886
3.515625
4
from didyoumean import didyoumean import pickle spell = input('enter the subclass\n') pages = [] with open('../wiki-cats.list.pickle', 'rb') as handle: pages = pickle.load(handle) correctSpell = didyoumean.didYouMean(spell, pages) print(correctSpell) while (input('would you like to search for a page?\n') == '...
adf3ce3aa6dec2aba7e7ed21293be3a25ceddc34
becdot/sockets_irc
/test_server.py
2,125
3.65625
4
# Things to worry about eventually ### 1. How to implement usernames ### 2. How to deal with messages bigger than 1024 bytes? ### 3. How does select.select actually work? ### 4. Why do we have to check whether a message exists -- shouldn't it exist by default? ### 5. Implement checking whether a socket is writeable bef...
757bcded1d57ff6b032187d651847c3ff6bd68cb
kitakou0313/crackingCodingInterview2nd
/chap17/6.py
665
3.828125
4
import unittest from unittest.case import TestCase def countNumberOf2(N:int) -> int: """ Nまでの自然数で文字列表記したときの2の個数 """ numberOf2 = 0 for n in range(1, N+1): while n > 0: if n % 10 == 2: numberOf2 += 1 n = int(n / 10) return numberOf2 class Test(Te...
bcfad2c83821e6985b455f395bf753da2fd3bc60
kitakou0313/crackingCodingInterview2nd
/libs/tree.py
860
3.78125
4
class TreeNode(object): """ Int型を要素に持つ木のNode """ def __init__(self, val:int) -> None: super().__init__() self.__val:int = val self.__left:TreeNode = None self.__right:TreeNode = None def getVal(self) -> int: """ Val返却 """ return self._...
c104c5be60c1e5a6b573a5333fa6d5e28af53bd4
kitakou0313/crackingCodingInterview2nd
/chap8/8_8.py
1,378
3.640625
4
from typing import Dict, Set, List import unittest import itertools def generatePermutationsWithoutDup(inputStr:str, memo:Dict[str, Set[str]]) -> Set[str]: if len(inputStr) == 1: memo[inputStr] = set([inputStr]) return set([inputStr]) res:Set[str] = set() chars:List[str] = list(inputStr) ...
3e635d9d0e6688ff16cf738e192396f4f11423af
Alexis374/LeetCode
/2 add two numbers.py
1,508
3.828125
4
''' You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8 ''' class ListNode: def __init__(self, x):...
b707ea3a159c8992cfe6b22ce64fcd8ccc849b7f
Wajahat-Ahmed-NED/WajahatAhmed
/1st sem practice.py
5,250
3.6875
4
from math import * import datetime import random y=[] for i in range(1,10): if i==1: x=str(random.randint(0,4)) y.append(x) else: x = str(random.randint(0,9)) y.append(x) country=input("Kindly tell us your country name").casefold() if country=="pakistan": a = "+9...
1ba4897ba6a98d4cbace7314f1952421bc245ec5
Wajahat-Ahmed-NED/WajahatAhmed
/newinstanceandclassvari.py
549
4
4
class Employee: no_of_employees=0 def __init__(self,fname,lname,salary): self.fname=fname self.lname=lname self.salary=salary Employee.no_of_employees+=1 increment=1.5 def increase(self): self.salary=int(self.salary*self.increment) print(Employee.no_of_e...
30ed215f931ffdcde9dc2e8853f15a00a66b6e00
Wajahat-Ahmed-NED/WajahatAhmed
/harry diction quiz.py
253
4.1875
4
dict1={"set":"It is a collection of well defined objects", "fetch":"To bring something", "frail":"weak", "mutable":"changeable thing"} ans=input("Enter any word to find its meaning") print("The meaning of ",ans,"is",dict1[ans])
e2a9ed8d8002251d6a91009f1f4fe271972e03ab
Wajahat-Ahmed-NED/WajahatAhmed
/scratch_26.py
442
4.03125
4
grade=int(input("enter your grade")) salary=int(input("enter your salary")) if(grade>=1 and grade<=16): inc=salary+20/100*salary print("your present salary is",inc) elif(grade>=17 and grade<=19): inc=salary+10/100*salary print("your present salary is",inc) elif(grade>=20 and grade<=22): inc=salary+5...
e24a6058422b321d4720809f7261963142ea2fb4
Wajahat-Ahmed-NED/WajahatAhmed
/enumeratefunc.py
216
3.578125
4
lis1=["bhindi","aloo","piyaz","timatar"] # i=0 # for item in lis1: # if i%2 == 0: # print(item) # i+=1 for index,item in enumerate(lis1): if index % 2==0: print(item)
25d01364f28b2caa786dc2eb79fb8e0d0df367ae
Wajahat-Ahmed-NED/WajahatAhmed
/dogs.py
12,978
4.09375
4
# class Dog(): # """A simple attempt to model a dog""" # def __init__(self,name,age): # #initialize name and attributes # self.name=name # self.age=age # # def sit(self): # """Stimulate a dog sitting in response to a command""" # print(self.name.title()+"is n...
7b514c98cf895cde2cc7d455bf5c29d4a3f813d3
huwenbo920529/otherLibraryStudy
/pandasStudy/test2.py
3,831
4.0625
4
# -*- coding:utf-8 -*- # 数据帧(DataFrame)是二维数据结构,即数据以行和列的表格方式排列。 # 数据帧(DataFrame)的功能特点: # 潜在的列是不同的类型 # 大小可变 # 标记轴(行和列) # 可以对行和列执行算术运算 # pandas.DataFrame # pandas中的DataFrame可以使用以下构造函数创建 - # pandas.DataFrame( data, index, columns, dtype, copy) # 编号 参数 描述 # 1 data 数据采取各种形式,如:ndarray,series,map,lists,dic...
f8a8c20c0ce089cc4cc0032f6ca28887dc584437
Reena-Kumari20/Dictionary
/saral9.py
474
3.90625
4
#Iterate through all keys:- states_capitals = { 'Gujarat' : 'Gandhinagar', 'Maharashtra' : 'Mumbai', 'Rajasthan' : 'Jaipur', 'Bihar' : 'Patna' } #for state in states_capitals: # print(state) #for state in states_capitals: # print(state,states_capitals[state]) for state in states_capitals.keys(): ...
fd38fc531606f37eb343d17e9ddf100667ea508c
Reena-Kumari20/Dictionary
/w3schoolaccessing_items.py
870
4.28125
4
#creating a dictionary thisdict={ "brand":"ford", "model":"mustang", "year":1964 } print(thisdict["brand"]) print(thisdict.get("brand")) #dictionary_length #to determine how many items a dictinary has,use the len()function. print(len(thisdict)) #dictionary items-data types thisdict={ "brand":"ford", "ele...
690c805ceffe227f5b4cdd282b8d8180f05b79fa
wldmr/notedown
/parsing/util.py
5,549
4.0625
4
import re class Parser: r"""This is what a ``§Phrase definition `` looks like. A phrase is started after the regular expression defined by ``Parser.start`` matches:: >>> p = Parser() >>> p.start == r'§(?!\s)' True and ends before the "phrase ending" regular expression, defi...
671d7b3112a422dca1574a452da6a3236cb2bfbc
Francesinezmaria/hda_msc_tutorials
/4_SVM_and_likelihood/Python/svm_questions_FCR.py
7,494
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: Mariana Clare mc4117@ic.ac.uk """ import numpy as np import matplotlib.pyplot as plt # use seaborn plotting defaults import seaborn as sns; sns.set() from sklearn.datasets.samples_generator import make_blobs # consider two classes of points which are well...
49ea247ab0a73050ec593e86390668aeb72406b3
PIPIDADA/guess_number
/guess_number.py
411
3.65625
4
import random start = input('請輸入開始值:') end = input('請輸入結束值:') start = int(start) end =int(end) x = random.randint(start, end) k = 0 while True: y = input('請於',start,'及',end,'中猜一個數:') y = int(y) k = k + 1 if x > y: print('比答案小!') elif x < y: print('比答案大!') else: print('終於猜對了') print('你猜了',k,'次喔!!') bre...
a6041ce5ffc2a73253c3939ecb9605e8956e64ed
suhanyujie/simple_fractal
/index.py
673
3.890625
4
# -*- coding: utf-8 -*- ' a $ module ' __author__ = 'Samuel' import turtle import time length = 5 angle = 90 def main(): path = 'F-F-F-F' turtle.speed(0) path = apply_rule(path) path = apply_rule(path) path = apply_rule(path) draw_path(path=path) turtle.exitonclick() pass def app...
add3967b6f4efdaf93a0c32abd811911d31b415e
caiprozect/Bioinformatics
/neighbors.py
681
3.546875
4
def hammingDist(sPtnA, sPtnB): nHammingDist = 0 assert(len(sPtnA) == len(sPtnB)), "Two patterns must have the same length" for i in range(len(sPtnA)): if sPtnA[i] != sPtnB[i]: nHammingDist += 1 return nHammingDist def neighbors(sPtn, nD): lNucls = ['A', 'C', 'G', 'T'] if nD == 0: return sPtn if len(sPtn...
0351e4ad96213cce10f56440486f9ba65dac0e6b
Diptendra/Algorithms-for-Data-Analytics-IE-531
/Week2/dbagchi2_hw2/dbagchi2_Deterministic_Select.py
5,439
3.59375
4
#!/usr/bin/env python3 # coding: utf-8 import sys import argparse import random import numpy as np import time import math import matplotlib import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages sys.setrecursionlimit(3000) # This is given by the Professor (I just modified the code) def...
ff6f7c387ee332af8b00b5a819a8572c86750790
tanglan2009/mit6.00
/FinalExam/P6.py
1,336
4.34375
4
class Frob(object): def __init__(self, name): self.name = name self.before = None self.after = None def setBefore(self, before): # example: a.setBefore(b) sets b before a self.before = before def setAfter(self, after): # example: a.setAfter(b) sets b after a ...
213f3aeb437efa95a64676fbd1dc37e73ee046fe
tanglan2009/mit6.00
/LecturePractice/P6.py
781
4.0625
4
# def swapSort(L): # # """L is a list on integers.""" # print "Original L: ", L # for i in range(len(L)): # for j in range(i+1, len(L)): # if L[j] < L[i]: # # the next line is a short # # form for swap L[i] and L[j] # L[j], L[i] = L[i], L[j...
08128522a894c6497ed3f0eb1cd82ddb79978e5b
tanglan2009/mit6.00
/demo.py
375
3.703125
4
__author__ = 'tanglan' class Person(object): def __init__(self, name, birthday, race): self.name = name self.birthday = birthday self.race = race def getName(self): return self.name def getAge(self): return now() - self.birthday me = Person("zhihong", 30, "eas...
0d3ec4c759440573513f493dcbeb4951842a4b86
tanglan2009/mit6.00
/LecturePractice/L7P8.py
1,320
3.921875
4
# # def f(n): # # """ # # n: integer, n >= 0. # # # # """ # # if n == 0: # # return 1 # # # elif n == 1: # # # return 1 # # else: # # return n * f(n-1) # # # # print f(3) # # # def FancyDivide(numbers,index): # # try: # # denom = numbers[index] # # # # ...
c9de82205295f3f9345bc54480ca86973dc5d95e
tanglan2009/mit6.00
/LecturePractice/5_ListComprehension.py
113
3.609375
4
L = [x**2 for x in range(1,7)] print L mixed = [1, 2,'a', 3, 4.0] print [x**2 for x in mixed if type(x) == int]
f951608c3e56a091048bf71621bc8ca43cb31029
HarshPonia/Python_Programs
/function/doubt.py
1,399
3.78125
4
# def display(*x, sep=' ', end='\n'): # x = 3, y = 6 # st_lst = list(map(str, x)) # f = sep.join(st_lst) # print(f, end=end) # display(2, 4, 6, 7, 'amir', sep='\n', end='') # display('hello') # def student_info(name, section, roll_number, subject): # # logic # info = f''' # Name : {...
5a25b02053ae3bd15704e9bad350fff249962ac0
HarshPonia/Python_Programs
/File_handling/File_handling_Question/Q8_longest_word.py
188
3.96875
4
# Write a python program to find the longest words. f = open('addition.txt','r') words = f.read().split() mx = len(max(words,key=len)) print([word for word in words if len(word) == mx])
8e7c7025dd9e8a0a87b760d78a4a68e791484e25
HarshPonia/Python_Programs
/Q11.py
345
4
4
age = int(input("Enter age\n")) sex = input("Enter sex m of f\n") ms = input("Enter the marital satus yes(Y) or no(N)") if(sex == 'f'): print("she will work only urban areas.\n") elif(sex == 'm' and age>20 and age<40): print("He may work anywhere\n") elif(sex=='m' and age>40 and age<60): print("He will wor...
cb7d94e628573bc3549f3cda969335c3d39ccd96
HarshPonia/Python_Programs
/list/list3.py
175
4.40625
4
#Creating List In Python Lst = [1,2,3,4,5,6,7,8,9] print(Lst) lst = ['Hello','Hii','who are you'] print(lst) #Nested list lst = [1,['hello'],2,'hii',['great']] print(lst)
50dd82e6795ef4d215f1da9025bba21609bdedbd
HarshPonia/Python_Programs
/Numbers.py
782
4.4375
4
# In python We have Three numbers # 1. int # 2. float # 3. Complex # Ex 1:- a= 25 print(type(a)) #int b = -30 print(type(b)) #int # Ex 2:- c = 1.0 print(type(c)) #float d = -20.25 print((type(d))) # float # Ex 3:- e = 2j print(type(e)) # complex f = -4+5j print(type(f)) # complex # Convert Numb...
790354fe9432f1cf7a4a6aa7d9db3f68ed2b41b0
HarshPonia/Python_Programs
/Pattern/Apattern.py
261
4.15625
4
n = 8 for i in range(0,n): if i == 0: print(" ",end = "") print("@",end = "") print("\r") for i in range(0,n//2): print("@ @") for i in range(0,n+2): print("@",end = "") print("\r") for i in range(0,n//2): print("@ @")
1ec85df6674a05cbdea719cfab69a389f931cc96
prasunroy/pytorch-bootcamp
/nn_torch_v3.py
2,875
3.78125
4
# -*- coding: utf-8 -*- """ Implementation of a neural network using PyTorch with custom Autograd function. Created on Wed Mar 27 14:00:00 2019 Author: Prasun Roy | CVPRU-ISICAL (http://www.isical.ac.in/~cvpr) GitHub: https://github.com/prasunroy/pytorch-bootcamp References: [1] https://pytorch.org/tutorials/beginner/...
834b5a53360ccc5637f4770aee7d0b0c52d61c37
yangxuan1031/test
/venv/001(数字组合).py
476
3.671875
4
# 有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少? # 1解: # total=0 # for i in range(1,5): # for j in range(1,5): # for k in range(1,5): # if((i!=j)and (i!=k) and (j!=k)): # print(i,j,k) # total+=1 # print(total) # 2解:itertools迭代器 import itertools sum2=0 a=[1,2,3,4] for i...
159422be06426af0e40e17fce2372de93e0c4774
masknugget/somethings
/font/lit/assembly/plain_text/plains.py
1,811
3.625
4
import streamlit as st import pandas as pd import altair as alt import numpy as np st.title('Uber pickups in NYC') st.text('this is text api') st.subheader('Raw data') st.write('data or text !!! ') if st.checkbox("show raw data"): st.subheader('raw data') st.write('this is data') # 通过requests 获取一个markdown的文...
4f9aab2c40c2bfd8ccae05264fc3243efd3da3f4
KrShivanshu/264136_Python_Daily
/ProgramsForSubmission/ListIntoNestedDict.py
221
4.125
4
""" Write a Python program to convert a list into a nested dictionary of keys """ my_list = ['a','b','c','d','e'] my_dict = current = {} for ele in my_list: current[ele] = {} current = current[ele] print(my_dict)
7c1731dd1a6513e7a2104a107d0a6d53500de1c3
KrShivanshu/264136_Python_Daily
/Print_Function.py
144
3.65625
4
if __name__ == '__main__': n = int(input()) def seq(x): s='1' for i in range(2,x+1): s=s+str(i) return s print(seq(n))
95a0479c00a08064eb4c7a18fbbc74899b053563
KrShivanshu/264136_Python_Daily
/ProgramsForSubmission/next_day.py
562
4
4
# Write a Python program to get next d of a given date using if-elif-else d = int(input("Enter d: ")) m = int(input("Enter m: ")) y = int(input("Enter y: ")) leap_year = False if y%4==0 or y%100!=0 and y%4==0: leap_year = True if m in (4,6,9,11): month_size = 30 elif m == 2: if leap_year: month_si...
644883c1f70bb00513a4bb2cdf9d256a16c4664a
KrShivanshu/264136_Python_Daily
/break_SecretWord.py
187
4.3125
4
word = input("Enter a word: ") while word!="chupacabra": word = input("Enter a word: ") if word == "chupacabra": print("You've successfully left the loop.") break
3044aa9396d2a3481d652a64f99db78253d88d71
KrShivanshu/264136_Python_Daily
/Collatz'sHypothesis.py
420
4.125
4
""" Write a program which reads one natural number and executes the above steps as long as c0 remains different from 1. We also want you to count the steps needed to achieve the goal. Your code should output all the intermediate values of c0, too. """ c0 = int(input("Enter a number: ")) step = 0 while c0!=1: if ...
1190cece82a30e1d9d8478089de2972df3556396
brendonwanderlust/digital_crafts_git_demo
/topThree.py
334
3.78125
4
def word_histogram(sentence): tally = {} wordsList = sentence.split() for word in wordsList: if tally.get(word): tally[word] += 1 else: tally[word] = 1 def print tally def top_three(tally): = sorted() word_histogram('Brendon, it is ...
9f37b47fa88c99e4502b74bc459f4c53a81d6d0e
danielmohansahu/self-triggered-control
/control/controller.py
1,544
3.609375
4
""" A simple periodic controller that executes a given controller on a given plant periodically. """ import numpy as np class Controller: def __init__(self, model, control): # the plant model to execute self.model = model # the control law to apply self.control = control def e...
0f46661eb4208c064f2badee1a0322bae583b6fa
johnsogg/play
/py/tree.py
1,997
4.34375
4
class Tree: """A basic binary tree""" def __init__(self): self.root = None def insert(self, node): if (self.root == None): self.root = node else: self.root.insert(node) def bulk_insert(self, numbers): for i in numbers: n = Node(i...
41ca8d2037941e4d4fab101b88b739fa19be0df5
wei91101/X-Village-2018-Exercise
/lesson06_Common_built_in_Function&Module/ex2.py
271
3.84375
4
def caesar_cipher(a,b): for i in range (len(a)): #print(a[i]) x = ord(a[i]) + b #print(x) if(97 <= x <= 122): print(chr(x), end = '') else: print(chr(x-26), end='') caesar_cipher('xvillage',3)
1ca0493338282e4e425a1191e64ef508af538e11
me-piyush/Python-Turtle
/mini_project.py
328
3.828125
4
import turtle list1=["red","blue","Khaki","purple","grey"] def fig(): window = turtle.Screen() window.bgcolor("Black") t=turtle.Turtle() for i in range(1,364): t.forward(100+i) t.right(90) t.speed(0) t.color(list1[i%5]) t.right(1) window.exitonclick(...
f60c786a6bd6d10e3a2cc0fefed4adf500ffc43c
Dibarium/Prologin
/Prologin 2020/Regional/Lost in space.py
789
3.75
4
def state(d, m, n, positions): """ :param d: distance entre les deux planètes :type d: int :param m: distance à laquelle Joseph s'est téléporté :type m: int :param n: nombre de trous noirs :type n: int :param positions: liste des positions des trous noirs :type positions: li...
f7f44c0f5f0bd8ea51e11cd386b9e847bd23aac8
alyssapyros/code_stuff
/euler/homework20.py
224
3.71875
4
def find_factorial(n): number = 1 while n >= 1: number = number * n n = n - 1 return number factorial=str(find_factorial(100)) total=[] for i in factorial: total.append(int(i)) print sum(total)
86caa55e75f57a386105002c2073ebfe5e070487
alyssapyros/code_stuff
/euler/homework10.py
1,064
3.90625
4
import numpy def get_all_primes(x): a = range(2,x) i = 0 while i < len(a): # grab next prime out of list current_prime = a[i] multiple = 2 while current_prime * multiple <= a[-1]: # find a multiple of your prime not_prime = multiple * current_prime # remove it if it's in the list if no...
151391461398593b15593037a47117483325dfe0
alyssapyros/code_stuff
/euler/homework7.py
413
4
4
def is_prime (number): i=2 while i<=number: if number%i==0 and i!=number: return 'False' if number%i!=0: i+=1 if i==number: return 'True' number=1 count=0 while count<10001: number+=1 if is_prime(number)=='True': count+=1 print number # add counter and when counter gets to 1000 then print # chec...
2526f3901b1b930ad216ca5a377863617811ea6e
alyssapyros/code_stuff
/euler/homework15.py
1,061
3.671875
4
import turtle import random alyssa = turtle.Turtle() alyssa.shape('turtle') alyssa.speed(10) alyssa.color('purple') # def grid (t): # t.penup() # t.setposition(0,20) # t.pendown() # path=[] # new_path=[] # count=0 # while t.ycor()>0: # t.setheading(0) # a=[0,90] # t.right(random.choice(a)) # t.forward...
41d93034feae4db4cd027433bd60db1bdbaded63
1178615156/leetcode
/python/Trie.py
1,417
4.09375
4
from typing import Dict class Trie: def __init__(self): self.node: Dict[str, Trie] = {} self.word_end = False def insert(self, word: str) -> None: if not word: self.word_end = True return head = word[0] if head not in self.node: sel...
4fb7bf8ff0068a78e5cdef5749544eeba8488908
HunterProgram22/Football_game_project
/Football_game_project/firstdown.py
1,094
3.53125
4
# coding: utf-8 class team(object): # Class with attribute of a team on a yardline def __init__(self, yardline = 20): self.yardline = yardline def yardchange(self, yardchange): self.yardline = self.yardline + yardchange def printyard(self): print(self.yardline) class series(team): # a series is an sub...
317665fcb62340d8755ca2506cd29eb4b903ac31
magic7454/A-Technoligies_Assignment
/MAGIC.py
3,207
3.890625
4
opt=True; ar=[]; while opt: print("1)ARIHMETIC CALCULATOR\n2)BITWISE CALCULATOR\n3)HISTORY\nPRESS ENTER TO EXIT"); opt=input("ENTER YOUR CHOICE : "); if opt=="1": opt1=True; while opt1: print("1)SUM\n2)SUBTRACT\n3)MUNTIPLY\n4)DIVIDE\nPRESS ENTER FOR GOING BACK TO MAIN MENU"); ...
ffcb28fd554d602a775ffd81e22af51b655476c3
Mystery-College-of-The-Adapts/artificial-intelligence
/projects/TSP/GA/tsp_ga.py
2,584
3.796875
4
import random import time import statistics import itertools import functools import matplotlib.pyplot as plt import matplotlib matplotlib.style.use('seaborn') import numpy as np #------------------- Representing Cities--------------------------# class Point(complex): """Cities are represented as Points, wh...
7e09ead742664f9cdfa95bf460ddf62fd9d82d0c
raad1masum/Competitive-Programming
/LeetCode/102. Binary Tree Level Order Traversal.py
1,242
3.890625
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def levelOrder(self, root): """ :type root: TreeNode :rtype: List[Li...
d17e698060437ba7e76aab4da6429709c015a4f9
raad1masum/Competitive-Programming
/LeetCode/Convert_Binary_Number_in_a_Linked_List_to_Integer.py
377
3.53125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def getDecimalValue(self, head: ListNode) -> int: if head == None: return 0 helper = lambda head,num : num if head == None else helper(he...
1e11e21d9483e2c635d2ef23c79b5967315f38b7
eliasheinzen/project-euler
/python/problem6.py
759
3.96875
4
# Sum square difference # The sum of the squares of the first ten natural numbers is, # 1^2 + 2^2 + ... + 10^2 = 385 # The square of the sum of the first ten natural numbers is, # # (1 + 2 + ... + 10)^2 = 55^2 = 3025 # Hence the difference between the sum of the squares of the first ten natural numbers and # the square...
74f8bbce00a323dda4ae783310e0bdc9fb9dac1a
nishimehta/Sobel-Image-Filter
/sobel.py
2,380
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Sep 17 19:22:42 2018 @author: nishimehta """ import cv2 import numpy # performs convolution between matrix m and k def convolution(m,k): product=0 n=len(m)-1 for i in range(len(m)): for j in range(len(m)): product+=(m[...
64c82df208c8db0f90a000cbb08afcb51ad3fb3d
navneettomar11/learn-py
/geeksforgeeks/sort/StalinSort.py
386
3.734375
4
from typing import List class StalinSort: def sort(self, nums: List[int]): j = 0 n = len(nums) while True : moved = 0 for i in range(n-1-j): if nums[i] > nums[i + 1]: nums.insert(moved, nums.pop(i+1)) moved+=1 ...
38df807e8b39f3401b85f1ee7e531bcca8af79cc
navneettomar11/learn-py
/hackerrank/FindingPercentage.py
548
3.78125
4
def findPercentageOfStudent(students, studentName): if studentName not in students: return 0 marks = students[studentName] totalMarks = 0 for mark in marks: totalMarks+=mark return "{:.2f}".format(totalMarks/3) if __name__ == '__main__': n = int(input()) student_marks = ...
c9b6c0753da269f381a00d56044c038816be6b1f
navneettomar11/learn-py
/leetcode/problems/clock_angle_problem.py
289
3.53125
4
def clock_angle_problem(hr: int, min: int) -> float: delta = abs(.5 * (60 * hr - 11 * min)) return 360 - delta if delta > 180 else delta if __name__ == "__main__": print(clock_angle_problem(2,20)) print(clock_angle_problem(10,16)) print(clock_angle_problem(5,45))
dfd19c46147494a33a50e89061e5400cfc7930a3
navneettomar11/learn-py
/leetcode/RemoveDuplicates.py
1,101
3.765625
4
from typing import List class RemoveDuplicates: def removeDuplicatesOld(self, nums: List[int]) -> int: n = len(nums) if n == 0: return 0 prev = nums[0] count = 1 for i in range(1,n): if prev == nums[i]: nums[i] = None el...
7fdef78e14f679577a96d80945d5e731d998f776
navneettomar11/learn-py
/leetcode/Arrays.py
577
3.75
4
from typing import List class Arrays: def __init__(self): def findDisappearedNumbers(self, nums: List[int]) -> List[int]: ret = [] for num in nums: idx = abs(num) - 1 if nums[idx] > 0: nums[idx]*=-1 print(nums) for i in range(0,len(num...
53b033db25faa95074a34e44b1fc095a5abd7824
ltoshea/py-puzzles
/lowestprod.py
805
4.1875
4
"""Create a function that returns the lowest product of 4 consecutive numbers in a given string of numbers This should only work is the number has 4 digits of more. If not, return "Number is too small". lowest_product("123456789")--> 24 (1x2x3x4) lowest_product("35") --> "Number is too small" lowest_product("1234111")-...
262640e837f437569612a0de2f2377f82d40c82d
ricardasgecas/apbteam
/host/simu/model/table_eurobot2012.py
3,875
3.609375
4
# simu - Robot simulation. {{{ # # Copyright (C) 2011 Nicolas Schodet # # APBTeam: # Web: http://apbteam.org/ # Email: team AT apbteam DOT org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software F...
1079696fc4321a3a1e2585dac004c9a0877b5d90
MarcoASCruz/LearningPython
/counting.py
102
3.78125
4
count = 1 while count <= 10: print(count); count += 1; if count == 11: print('Counting complete');
625b5c1642c07a17d591b3af07c99cb65ab2070c
DipanshKhandelwal/Unique-Python
/PythonTurtle/turtle_circle/turtle_circle.py
1,053
4.3125
4
import turtle ''' this moves turtle to make a square even tells us how to configure our turtle like changing its speed ,color shape etc''' def turtle_circle(): window = turtle.Screen() window.bgcolor("red") brad = turtle.Turtle() brad.shape("turtle") ''' Inputs be like : turtle...
22b69f77c2baa55bd31c339bd21ee987d98505df
DipanshKhandelwal/Unique-Python
/PythonInheritance/inheritance.py
820
4.0625
4
class Parent(): def __init__(self, last_name, eye_color): print("Parent constructor called") self.last_name = last_name self.eye_color = eye_color def show_info(self): print("Last Name - "+self.last_name) print("Eye Color - "+self.eye_color) class Child(Parent): def...
c466860b7264fa5a1dd1bff5166846cba568676f
victorhugocb87/Ejercicios-de-programacion-III-python
/notas.txt.py
1,369
3.640625
4
CREAR UNA CLASE EN PYTHON ** *ESTUDIANTE {NOMBRE, APELLIDO, CARRERA, MATERIA} FUNCION PARA MOSTRAR LA CARRERA QUE ESTA CURSANDO FUNCION SALUDAR ** *PREGUNTAS EN VIVO ** ** ** ** ** ** * ** ** ** ** ** ** ** ** ** *0 9 - 06 - 2020 ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** * HERENCIA EN PROGRAMACION CLA...
1042dde871f306dbc1f5a64d1c84e98ceb74fab1
victorzn/python_test
/sort.py
5,673
3.9375
4
def swap(arr,i,j): arr[i],arr[j] = arr[j],arr[i] #################### 冒泡排序 ############################## def bubble(arr): if len(arr)<2: return arr for i in range(1,len(arr)): for j in range(len(arr)-i): if arr[j]>arr[j+1]: swap(arr,j,j+1) return arr a = [1,3...
aa26300aab299e40f29c9f78c6f7dd1f1b160ea2
riders994/ml-from-movie-reviews
/code/scrape_reviews.py
10,912
3.5
4
from bs4 import BeautifulSoup import requests from pymongo import MongoClient def init_mongo_client(): ''' Start the Pymongo client, access the movie_reviews database, access the movies collection, and return pointer. (later, we will access the reviews collection) ''' client = MongoClient() db...
f3c5e6772f6f965aff48964510bbe10e87dd9760
rams1996/DP-3
/DeleteAndEarn_FinalSolution.py
953
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 4 17:28:22 2020 @author: WELCOME """ """ Time Complexity = O(N) where N is max(nums) Space Complexity = O(M) where M is number of unique elements in nums """ class Solution: def deleteAndEarn(self, nums): if nums==None or len(nums)==0: return 0 ...
481e8ef62e242c90df3387700f4dd85ebae682a9
vamshi9390/myAI
/Assignment2.py
453
3.71875
4
# -*- coding: utf-8 -*- """ Created on Sat Jun 1 10:01:26 2019 @author: Vamshi Krishna """ game_answer=[9] guess_answer=[6] if (game_answer>guess_answer): print('The answer is too low') else: (print('The answer is too high')) for i in range(1,10): multiply=5*i if(multiply<=30): print(multiply) ...
6d811d874c49e9c07b5069d805be9871b56e6950
devrajkanti/PythonSelenium
/10_DropDown.py
777
3.59375
4
#Select One Option #Capture the options are seen #Count the no of options from selenium import webdriver from selenium.webdriver.support.ui import Select import time driver = webdriver.Chrome("D:\Stuffs\Python\LearnPython\PythonSelenium\Drivers\chromedriver_win32\chromedriver.exe") driver.get("https://fs2.fo...
199465955aec869f443560b91d6f5f50fe1d4340
gabrieldelisle/Euler-project
/euler65.py
830
3.65625
4
def pgcd(a,b): while a!=0 and b!=0 : if a>b : a=a%b else : b=b%a return a+b class Frac: """docstring for Frac""" def __init__(self, num, den=1): self.num = num self.den = den def inverse(self) : self.num, self.den = self.den, self.num def simplifie(self) : ...