blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
8db500414203b1a1da1f3641c9d24b45fb95ee09
sweta-chauhan/Simulation
/plotter.py
1,233
3.5625
4
import matplotlib.pyplot as plt import sys as s import reader as r def plot_it(x,size): y = x[1:]+[x[-1]] plt.scatter(x,y,marker='p') plt.show() return True def calc_frequency_table(ls,interval_size): max1,min1 = max(ls),min(ls) prev1 = min1 x = [] step= (max1-min1)/interval_size m...
f6ccc6983dc26acd00b2d2fcddd48de22e9d03fd
sweta-chauhan/Simulation
/weibull_distribution.py
2,253
3.515625
4
''' It is normally used to predict time to failure for machine or electronic components. alpha scale parameter beeta shape parameter { f(x) = { { { F(x)= { 1-exp(-(x/alpha)^beeta) { let X be random variate then X = alpha*(-ln(Ui))^(1/beeta) Note :- if X is weibull ...
0f5b747e54aad064293a13fc8ba3fdd814499222
BlackCode7/Projetos_Python
/LoopForPython.py
267
3.890625
4
volwes = ['a', 'e', 'i', 'o', 'u'] word = 'Anderson' for leters in word: if leters in word: print(leters) for leters in word: if leters in word: print(leters) for leters in word: if leters in word: print(" Comandos do python")
a92e982df871e169a33577d6ba0e404009a98e6a
emonhossainraihan/exp-python-tutorial
/Application/DB/create.py
365
4.03125
4
import sqlite3 connection = sqlite3.connect('movies.db') cursor = connection.cursor() cursor.execute('''CREATE TABLE IF NOT EXISTS Movies (Title TEXT, Director TEXT, Year INT)''') cursor.execute("INSERT INTO Movies VALUES ('Taxi Driver', 'Unknown', 1990)") cursor.execute("SELECT * FROM Movies") print(cursor.fetcha...
ca4cc6cbb80f10cc7209ad1d1ce055f420790538
bruxeiro/AulasPython
/app_py/aula6.py
225
3.75
4
conjunto = {1, 2, 3, 4} conjunto2 = {4, 5, 6, 7} conjunto_uniao = conjunto.union(conjunto2) print('União: {} '.format(conjunto_uniao)) # conjunto = {1, 2, 3, 4} # # conjunto.add(5) # conjunto.discard(1) # print(conjunto)
4e630b1beba7ebcc60203ddce1ba624d893d03ea
nyagajr/password-locker
/run.py
3,008
4.4375
4
#!/usr/bin/env python3.6 from credentials import Credentials from user_details import User def create_credentials(fname,lname,uname,phone,email,password): ''' Function to create a new credentials ''' new_credentials = Credentials(fname,lname,uname,phone,email,password) return new_credentials def ...
73000a7cbc05bc572ba79ab8baab763df0b45017
codywsy/PythonCode
/Project1/util.py
577
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # lines产生一个生成器generator对象,作用在文件file参数的最后追加一个空行'\n' def lines(file): for line in file: yield line yield '\n' # def blocks(file): block = [] for line in lines(file): if line.strip(): # strip()是为了去除文本内容开头和结尾中多余的空格 block.append(line) #加入列表对象block中 elif block: #如果此时...
500a0e7fefbe931bb987afb5fe2b9777ff56a2fc
ZhifeiCheng/TCSS-Final-Project
/Dungeon.py
8,663
3.75
4
import math import random from RoomFactory import RoomFactory class Dungeon: """ This class randomly generates a maze of rooms given the desired dimensions which players can pass through to play the Dungeon Adventure game. """ def __init__(self, column_count, row_count): """ Given ...
df3c0636f2994c4fdb3828e3220665960f75cfbe
jnash10/Ration-delivery-post-disaster-IISC-Hackathon-
/dist_matrix.py
470
3.640625
4
import numpy as np def dist(a, b): return int(((a[0]-b[0])**2+(a[1]-b[1])**2)**(1/2)) def matrix(cities): dist_matrix = [] for city in cities: city_dist = [] for i in range(0,len(cities)): city_dist.append(dist(city,cities[i])) #print(type(city_dist), city_dist) ...
ede71eaf8f409a526b48ecbe81898c13826be3c0
ali-almousa/CS50-AI-Project0-degrees
/util.py
1,617
4.09375
4
class Node: def __init__(self, state, parent, action): # the state attribute is a coordinate for the node in the maze self.state = state # the parent attribute is an object (node) of Node class self.parent = parent # the action attribute is a string (up, down, left, right) ...
973f74c535a6a6eb0505a92ae35cdf09581f46cc
jpallavi23/Smart-Interviews
/07_SI_Primary-Hackerrank/01_Print Hollow Diamond Pattern.py
587
3.734375
4
# For question to go # https://www.hackerrank.com/contests/smart-interviews/challenges/si-print-hollow-diamond-pattern no_of_test_cases = int(input()) iter = 1 while iter <= no_of_test_cases: size_n = int(input()) count = size_n - 1 count = count / 2 print("Case #{}:".format(iter)) for itr in rang...
147a8d125d9289c6b7bd0dc4ca7f5b7d8096f029
jpallavi23/Smart-Interviews
/01_B_Algorithms-Hackerrank/22_Drawing Book.py
292
3.5625
4
# For question go to: # https://www.hackerrank.com/challenges/drawing-book/problem no_of_pages = int(input()) page_reqd = int(input()) min_no_of_turns = (no_of_pages // 2) - (page_reqd // 2) if min_no_of_turns > (page_reqd // 2): min_no_of_turns = page_reqd // 2 print(min_no_of_turns)
bb0e1fe19f80ab08f9d338483c1c88b3b253b1f1
jpallavi23/Smart-Interviews
/01_B_Algorithms-Hackerrank/10_Time Conversion.py
247
3.78125
4
# For question go to: # https://www.hackerrank.com/challenges/time-conversion/problem time = input().upper().split(":") time[0] = int(time[0])%12 if "PM" in time[-1] and [0]: time[0]+=12 time[0] = '%02d' % time[0] print(":".join(time)[:-2])
da7c6439c4344639aadbf4f3ce7f97fa6ceba643
jpallavi23/Smart-Interviews
/01_A_Data Structures-Hackerrank/01_Array - DS.py
185
3.578125
4
# For question go to: # https://www.hackerrank.com/challenges/arrays-ds/problem array_size = int(input()) array_elements = list(map(int, input().split())) print(*array_elements[::-1])
b22864e5fc16f9a52eec5dbc3ae9d570fcef1b4f
jpallavi23/Smart-Interviews
/03_Code_Forces/22_Beautiful Matrix.py
1,565
4.0625
4
''' You've got a 5 × 5 matrix, consisting of 24 zeroes and a single number one. Let's index the matrix rows by numbers from 1 to 5 from top to bottom, let's index the matrix columns by numbers from 1 to 5 from left to right. In one move, you are allowed to apply one of the two following transformations to the matrix: ...
4ba77e1ec6d8665a964f988cba5286746e8c60f3
jpallavi23/Smart-Interviews
/07_SI_Primary-Hackerrank/02_Print Right Angled Triangle Pattern.py
606
3.796875
4
# For question go to: # https://www.hackerrank.com/contests/smart-interviews/challenges/si-print-right-angled-triangle-pattern # Input: # 2 # 1 # 4 # Ouput: # Case #1: # * # Case #2: # * # ** # *** # **** no_of_test_cases = int(input()) iter = 1 while iter <= no_of_test_cases: size = int(input()) i = ...
dd23412ee46c88333b88c07b3d8a270143a6cdc3
jpallavi23/Smart-Interviews
/01_B_Algorithms-Hackerrank/02_Simple Array Sum.py
328
3.75
4
# For question go to: # https://www.hackerrank.com/challenges/simple-array-sum/problem def simpleArraySum(ar): sum = 0 for obj in ar: sum = sum + obj return sum if __name__ == '__main__': ar_count = int(input()) ar = list(map(int, input().split())) result = simpleArraySum(ar) print...
97a312f66353fb5fd0a5c918f54f557e2479559d
jpallavi23/Smart-Interviews
/03_Code_Forces/29_Petya and Strings.py
1,301
3.859375
4
''' Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The letters' case does not matter, that is an uppercase letter is considered equivalent to the ...
dbbbb52829963fe9ea2b1015d3cdaa17ffc9cc3d
jpallavi23/Smart-Interviews
/07_SI_Primary-Hackerrank/14_Finding Missing Number.py
526
3.703125
4
# For question go to: # https://www.hackerrank.com/contests/smart-interviews/challenges/si-finding-missing-number def findMissingNum(length_of_num_list, list_nums): total_sum = (length_of_num_list + 1) * (length_of_num_list + 2) / 2 print(int(total_sum - sum(list_nums))) if __name__ == '__main__': no_of_t...
fe297a22342a92f9b3617b827367e60cb7b68f20
jpallavi23/Smart-Interviews
/03_Code_Forces/08_cAPS lOCK.py
1,119
4.125
4
''' wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage. Let's consider that a word has been typed with the Caps lock key accident...
4344f818cad8fd3759bab9e914dafb31171782f8
jpallavi23/Smart-Interviews
/06_SI_Basic-Hackerrank/40_Hollow rectangle pattern.py
628
4.21875
4
''' Print hollow rectangle pattern using '*'. See example for more details. Input Format Input contains two integers W and L. W - width of the rectangle, L - length of the rectangle. Constraints 2 <= W <= 50 2 <= L <= 50 Output Format For the given integers W and L, print the hollow rectangle pattern. Sample Input ...
510827c32bcef49a1c3216fe969b687d5e904027
jpallavi23/Smart-Interviews
/Filtering_Contest/04_Anagrams Easy.py
358
3.84375
4
# For question go to: # https://www.hackerrank.com/contests/smart-interviews-gcet-2021-a/challenges/si-check-anagrams no_of_test_cases = int(input()) iter = 1 while iter <= no_of_test_cases: string1, string2 = list(map(str, input().split())) if sorted(string1) == sorted(string2): print("True") else...
a200d058612bb4a449731837d3cb3578b6f8a24d
jpallavi23/Smart-Interviews
/01_B_Algorithms-Hackerrank/07_Staircase.py
305
3.921875
4
# For question go to: # https://www.hackerrank.com/challenges/staircase/problem size = int(input()) i = j = 1 count = 2 * size - 2 while i < size+1: for j in range(i, size): print(end=" ") count = count - 2 for j in range(1, i + 1): print("#", end="") i += 1 print("")
bfb85080d765702f7c45dddf6c2b9301af95ddce
jpallavi23/Smart-Interviews
/01_B_Algorithms-Hackerrank/28_Climbing the Leaderboard.py
445
3.5
4
# For question go to: # https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem no_of_players = int(input()) leaderBoard_Scores = sorted(set(list(map(int, input().split()))), reverse = True) no_of_games = int(input()) gameScores = list(map(int, input().split())) length = len(leaderBoard_Scores) for itr...
56efa98ef892acdad26a8a53fe38b1616cb4b143
jpallavi23/Smart-Interviews
/06_SI_Basic-Hackerrank/10_Natural Numbers Sum.py
325
4
4
''' Given positive integer - N, print the sum of 1st N natural numbers. Input Format Input contains a positive integer - N. Constraints 1 <= N <= 104 Output Format Print the sum of 1st N natural numbers. Sample Input 0 4 Sample Output 0 10 ''' n = int(input()) sum_n = 0 for _ in range(n+1): sum_n += _ print(s...
df06707786077c8da542e958d33b91b9ba2f4e99
Marian4/Classes
/Questão3.py
879
3.78125
4
class retangulo(object): def __init__(self): self.base = 1 self.altura = 2 def MudarValorLados(self,novaBase,novaAltura): self.base = novaBase self.altura = novaAltura def RetornarValorLados(self): return self.base,self.altura def calcularArea(self): return self.base*self.altura def ca...
b70e5919523c5da709d17b4312f368d33e67de01
GorgonEnterprises/HackerRank-Practice
/ProblemSolving/warmup/comparetheTriplets/comparetheTriplets.py3
263
3.640625
4
def compareTriplets(a, b): arr = [0,0] for i in range(0,3): print("i=", i) if(a[i] > b[i]): arr[0]+=1 print("a", a[i]) if(b[i] > a[i]): arr[1]+=1 print("b", b[i]) return arr
9f482988c925e7a83335560e4b5c2c5880a0d3ab
muklah/Kattis
/Problems' Solutions/akcija.py
281
3.5625
4
books = int(input()) prices = [int(input()) for _ in range(books)] prices.sort() total = 0 group = [] for price in range(books): group.append(prices.pop()) if len(group) == 3: total += sum(group) - min(group) group = [] total += sum(group) print(total)
3cb40bd32d698d618bc51c960460955075357217
muklah/Kattis
/Problems' Solutions/everywhere.py
232
3.5
4
t = int(input()) f_result = {} for i in range(t): n = int(input()) result = [] for j in range(n): c = input() result.append(c) f_result[i] = [set(result)] ee = type(f_result[0]) print(ee)
5b6e8deee28ff65889d15ec612f3f778cce1b097
bumiltacaldrin11/datascience
/Bumiltacaldrin.py
1,043
4
4
# COE 003 / CPE22FA1 # Datascience # Programs and Contents a = [] while True: print("MENU") print(" ") print("1.) Add Bookmarks") print("2.) Edit Bookmarks") print("3.) Delete Bookmarks") print("4.) View Bookmarks") print("5.) Exit") print(" ") x = input("What do you wa...
5510d31f40b640c9a702d7580d1d434715469ba9
smzapp/pyexers
/01-hello.py
882
4.46875
4
one = 1 two = 2 three = one + two # print(three) # print(type(three)) # comp = 3.43j # print(type(comp)) #Complex mylist = ['Rhino', 'Grasshopper', 'Flamingo', 'Bongo'] B = len(mylist) # This will return the length of the list which is 3. The index is 0, 1, 2, 3. print(mylist[1]) # This will return the value at...
8189e8d5c7169ba0b1f1e17268d440c03a5874cf
kangminsu1598/TIL
/algorithm/list_algorithm/2nd-list/test.py
458
3.890625
4
# 행 우선순회, i: i행, j: j열 array = [[0,1,2,3] ,[4,5,6,7]] for i in range(len(array)): for j in range(len(array[i])): print(array[i][j], end='') print() # 열 우선순회 for j in range(len(array[0])): for i in range(len(array)): print(array[i][j], end='') print() # 지그재그 for i in range(len(...
6042f3d8fc435e8d33b2ef7e7d04f51f7b85a743
kangminsu1598/TIL
/startcamp/test/string_test.py
671
3.84375
4
# 파이썬 과거 단축 #print('일은 영어로 %s, 이는 영어로 %s' % ('one', 'two')) # pyformat print('{} {}'.format('one', 'two')) #name = '강민수' #e_name = 'Kang' #print('안녕하세요. {}입니다. My name is {}'.format(name, e_name)) #f-string python 3.6 #print(f'안녕하세요.{name}입니다. My name is {e_name}') #오늘의 행운의 번호는 ~~ 입니다, f-string 사용 import random nu...
c2d87e140241f97ab0bb59d363db33133b079c2f
shofi384/CSC.11300
/cube.py
205
4
4
def main(): n= int(input("Please enter an integer.\nI will print the sum of all cubes up to the integer: ")) SumTotal=0 for i in range(n+1): SumTotal+=i*i*i print(SumTotal) main()
51d06bd680e05e77c24e7927219e9d97db5661f2
pool-prateek/Lucia-examples
/Text Input Example/text_input_example.py
862
3.65625
4
#This program demonstrates how to use virtual input in Lucia #The program will prompt the user to type in a message and will print it to the screen before exiting import lucia import sys #Must be called in order for lucia to work properly #Since we are using bass, I will just call init without the open Al parameter. #S...
9a3e48d47cf481867703918e5c959b1be81448a0
Bchass/Algorithms
/Sort/QuickSort/QuickSort.py
367
3.96875
4
def QuickSort(list): if len(list) <= 1: return list else: pivot = list.pop() high = [] low = [] for item in list: if item > pivot: high.append(item) else: low.append(item) return QuickSort(low) + [pivot] + Q...
5da5f3b2063362046288b6370ff541a13552f9c8
adamyajain/PRO-C97
/countingWords.py
279
4.28125
4
introString = input("Enter String") charCount = 0 wordCount = 1 for i in introString: charCount = charCount+1 if(i==' '): wordCount = wordCount+1 print("Number Of Words in a String: ") print(wordCount) print("Number Of Characters in a String: ") print(charCount)
b79c328c307619ebb2896624af769cf418af0694
kaulashish/Edyoda
/Python/Assignment 1/Sequence of travel.py
1,528
4.09375
4
# You will be given an integer number of elements and for next n lines space # separeted key value pairs. make a dict from strings of tickets("to":"from"). # find out the sequence of travel. # Assuming that there will be only one starting point for the journey. # Input Format: # You will be given an integer number of...
9757bf55218b0805da802ced331ce27b2f123cb6
ailenbianchi/Practica-Pandas-y-Matplotlib
/ejfinanzas.py
759
3.609375
4
import pandas as pd import matplotlib.pyplot as plt fin = pd.read_csv(r"C:\Users\LENOVO\PycharmProjects\Practica Pandas - Matplotlib\finanzas.csv") #print(fin) columnas = fin.columns.values print(columnas) #Ver las primeras filas de la categoria comestibles vol = fin[fin.Categoría == "Comestibles"] print(vol.head()) ...
cf241ae2cf67158ceeaff90d474e63468116b6bf
ChenchuSowmyaDhulipalla/Python_Training_Basics
/Assignment_q2_functions.py
1,438
3.84375
4
#!usr/bin/python def lcount(): string=raw_input("Enter Your string") if string: letters={'upper':'isupper()', 'lower':'abcdefghijklmnopqrstuvwxyz', 'digits':'0123456789', 'space':' '} let={'uc':[],'lc':[],'spa':[],'di':[],'spe':[]} count={'u':0,'l':0,'sp':...
3051fe1bd45b615c243a5896f3c28994f6f744a1
platt607/December19
/test.py
1,544
4.03125
4
# Write any code you like in here # Run your code from the 'Run current' menu item above # Open the README.md file for more instructions # Import the modules import sys import random import sys ''' Section 1: Collect customer input ''' ##Collect Customer Data - Part 1 ##1) Request Rental code: #Prompt --> "(B)ud...
a3b8219f6e886f67e10ac77514bc350ef7990ac7
hungnv132/algorithm
/books/python_cookbook_3rd/ch08_classes_and_objects/08_inteface_and_abstract_class.py
814
3.640625
4
def define_interface_and_abstrace_class(): """ - Problem: You want to define a class that serves as an interface or abstract base class from which you can perform type checking and ensure that certain methods are implemented in subclass. - Solution: user the `abc` module. """ from abc impo...
80240cb2d0d6c060e516fd44946fd7c57f1a3b06
hungnv132/algorithm
/recursion/draw_english_ruler.py
1,689
4.5
4
""" + Describe: - Place a tick with a numeric label - The length of the tick designating a whole inch as th 'major tick length' - Between the marks of whole inches, the ruler contains a series of 'minor sticks', placed at intervals of 1/2 inch, 1/4 inch, and so on - As the size of the interval dec...
f02cbda65847efff6b096c0ec3973e7656c1d8aa
hungnv132/algorithm
/recursion/reversing_sequence.py
501
3.921875
4
def _reverse(S, start, stop): if start < stop: S[start], S[stop] = S[stop], S[start] _reverse(S, start+1, stop-1) def reverse(S): _reverse(S, 0, len(S)-1) # using a repetitive structure instead of recurring def reverse_v2(S): start, stop = 0,len(S)-1 while start < stop: S[s...
7240fb816fb1beba9bf76eaf89579a7d87d46d67
hungnv132/algorithm
/books/python_cookbook_3rd/ch01_data_structures_and_algorithms/07_most_frequently_occurring_items.py
1,516
4.28125
4
from collections import Counter def most_frequently_occurring_items(): """ - Problem: You have a sequence of items and you'd like determine the most frequently occurring items in the sequence. - Solution: Use the collections.Counter """ words = [ 'look', 'into', 'my', 'eyes', 'look', ...
d5004f19368c1db3f570771b70d9bd82f94f1a3b
hungnv132/algorithm
/design_patterns/decorator.py
1,029
4.3125
4
def decorator(func): def inner(n): return func(n) + 1 return inner def first(n): return n + 1 first = decorator(first) @decorator def second(n): return n + 1 print(first(1)) # print 3 print(second(1)) # print 3 # =============================================== def wrap_with_prints(fun...
28552575419755dab6accc6f1b71a408dc85f106
hungnv132/algorithm
/basic_python/python_unittest/basic_examples.py
595
3.90625
4
import unittest class TestStringMethod(unittest.TestCase): def test_uppper(self): self.assertEqual('hung'.upper(), 'HUNG') def test_isupper(self): self.assertTrue('HUNG'.isupper()) self.assertFalse('Hung'.isupper()) def test_split(self): s = 'Hello World' self.as...
e99d73ce04dfc38b413d95a316b163913e8f60a1
hungnv132/algorithm
/recursion/power.py
541
4.0625
4
""" + Describe: x^n =? + References: Data structures and Algorithms in Python by Goodrich, Michael T., Tamassia, Roberto, Goldwasser, Michael """ # Performance: O(n) def power_v1(x, n): if n == 0: return 1 else: return x * power_v1(x, n-1) # Performance: O(log(n)) def power_v2(x, n): i...
41fb69abf407da6702944ec82295f3167246a900
anuragrana/2019-Indian-general-election
/election_data_analysis.py
4,064
3.65625
4
import json with open("election_data.json", "r") as f: data = f.read() data = json.loads(data) def candidates_two_constituency(): candidates = dict() for constituency in data: for candidate in constituency["candidates"]: if candidate["party_name"] == "independent": ...
e93d3094a36e01dba4266f745ae941b69f66f896
SIDORESMO/crAssphage
/bin/location_db.py
4,391
4.34375
4
""" Create a location database for our data. This is a SQLite3 database that has a single table with the following attributes: 0. latitude 1. longitude 2. locality: the name of the city, municipality, or province in utf-8 encoding 3. country: the name of the country in utf-8 encoding 4. ascii_loca...
535a354eedfbd2326a5f9b5291625503cff16d67
SIDORESMO/crAssphage
/bin/cophenetic.py
2,213
3.546875
4
""" Read a cophenetic matrix """ import os import sys import argparse import gzip def pairwise_distances(matrixfile): """ Read the matrix file and return a hash of all distances :param treefile: The cophenetic matrix file to read :return: a dict of each entry and its distances """ global verb...
2f3534e15f5a56418438272837b0cbad3c461d9d
SIDORESMO/crAssphage
/bin/count_sequences.py
689
3.6875
4
""" Count the abundance of sequences in a fasta file """ import os import sys import argparse from collections import Counter from roblib import read_fasta if __name__ == '__main__': parser = argparse.ArgumentParser(description="Count the abundance of sequences in a fasta file") parser.add_argument('-f', help...
cb64e41f14386d24d6d928f6b8ce21e4f4bcc5f5
1505069266/python-study
/day7/缺省参数.py
275
3.640625
4
# 调用函数时,缺省的函数如果没有传入,则被认为是默认值,下例会默认打印的age,如果没有age传入 def main(name,age = 18): # 打印任何传入的字符串 print("name=%s"%name) print("age=%d"%age) main("朱晓乐") main("郑璇",24)
fe9b66a099c25bf54d095202059736826b12a219
1505069266/python-study
/day9/面向对象.py
658
3.625
4
# 面向过程容易被初学者接受,其往往用一段长代码来实现制定功能,开发过程的思路是将数据与函数按照执行的逻辑顺序组织在一起,数据与函数分开考虑 # 面向对象:将数据与函数绑定到一起,进行封装,这样能够快速的开发程序,减少了重复代码的重写过程 def 发送邮件(内容): # 发送邮件提醒 连接邮箱服务器 发生邮件 关闭连接 while True: if cpu利用率 > 90%: 发送邮件("CPU报警) if 键盘利用率 > 90%: 发送邮件("键盘报警") if 内容占用 > 90%: 发送邮件("内存报...
f41a55e4ca0d385fa4de53d022888e1961718f55
1505069266/python-study
/day7/名片管理系统函数版.py
1,788
3.9375
4
# 用来储存名片 lists = [] # 1.打印功能提示 def print_menu(): print("="*30) print(" 名片管理系统 V1.0.0") print(" 1. 添加一个新的名片") print(" 2. 删除一个名片") print(" 3. 修改一个名片") print(" 4. 查询一个名片") print(" 5. 退出系统") print("="*30) def add_new_card(): """这是用来增加名片功能的方法""" new_name = input("请输入新的名字:") new_...
b4df6fe80ec75894b86504a9cfd03dc9d54da50b
spconger/CardGamePython
/card.py
2,010
4.09375
4
#Card ''' This class represents a playing care. It has a rank and suit. The rank is a number between 1 and 13, 1 being an ace and 13 being a king. The value is not set because that depends upon the game context, though the getValue() method, if called assigns the usually assumed values. The suit is generally Hearts, cl...
dd9f51c988dfb236495b7e0c296665e333a54e52
yylong711/shixun
/jieba分词/play_pickle.py
203
3.5625
4
import pickle class A: def __init__(self): self.s=3 def add(self): self.s+=2 a=A() a.add() result=pickle.dumps(a) print(result) aa=pickle.loads(result) print(aa.s )
9f75bdbd937e01d95d48c30411170658a939bbf2
renarsuurpere/prog_alused
/2/yl1.py
110
3.59375
4
kord = int(input("Sisestage mitu korda äratada: ")) for k in range(1, kord + 1): print("Tõuse ja sära")
52dae5211d71f556f5794b6e39776235a4f196a8
bluish3101/primeirostestes
/teste_random.py
102
3.609375
4
lista = [] for c in range(0,10): lista.append (int(input('Digite o número: ')) ) print(lista)
fd258b407871d2879cde7a88fcbd60bf419f9136
georgedimitriadis/themeaningofbrain
/ExperimentSpecificCode/_2018_Chronic_Neuroseeker_TouchingLight/Common_functions/csv_manipulation_funcs.py
2,913
3.9375
4
import csv from os import path import pandas as pd import numpy as np def find_number_of_frames_from_video_csv(video_csv_file): """ Get the number of frames the camera collected (including the frames that were dropped from the Video.avi file) using the Video.csv file information :param video_csv_fil...
08bead65e08b3db80c7760dc04e53802932be5b2
matyh/scrabble_cheat
/bin/wordlist_length.py
1,590
3.59375
4
from itertools import permutations with open('../docs/sowpods.txt', 'r') as word_file: word_file = word_file.read().lower() scores = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, "f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3, "l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1, "r": ...
53603c7a810e6e521c1d74e7cf13634e34ed02b8
AuroraBoreas/python_advanced_tricks
/py_ad_04_trick.py
182
3.765625
4
# Python >= 3.7 from dataclass import dataclass @dataclass class Card: rank: str suit: str card1 = Card("Q", "hearts") print(card1 == card1) print(card1.rank) print(card1)
2d1041ac01853c9bd6bd8092c50595db5eb787fd
AuroraBoreas/python_advanced_tricks
/python-06-expert/python_05_gen.py
511
3.640625
4
def g(n): for i in range(n): yield i # result = g(5) # print(next(result)) # print(next(result)) # print(next(result)) # print(next(result)) # print(next(result)) ### generator not only yield result, but yiled 'control' for i in g(10): print(i) def first(): print("first") def sec...
0f4be732d8717e1cc46b09e6b5a6edb98cf61b29
AuroraBoreas/python_advanced_tricks
/python-05-flntPy-Review/fpy_33_operator.py
1,892
3.96875
4
### start functional programming using operator module import operator import itertools fmt = "\n{:-^50}" # some iterable. fractal essences calculation a = range(10, 1, -1) print(fmt.format("simple usage")) # get sum ttl = itertools.accumulate(a, lambda x, y: x + y) print(list(ttl)) # or alternative ttl = it...
166da2f7107c017ec2283b27aeb5b2c924f01e8e
AuroraBoreas/python_advanced_tricks
/python-06-expert/python_04_dec.py
690
3.625
4
### decorator in Python import time def activate(flag=True): # decorator factory def timer(func): # true decoractor def inner(*a, **kw): # decorated function if flag: start = time.perf_counter() result = func(*a, **kw) end = time.perf...
6f59f5ba43ff2a6dfdcfdca44e8f3c13e5fcda0f
rontou2/Sprint-Challenge--Graphs
/graph_social_network/social.py
2,240
3.640625
4
import random names = ["bob","steve","dave","zorg, destroyer of worlds","fred","greg","mark"] class User: def __init__(self, name): self.name = name class SocialGraph: def __init__(self): self.lastID = 0 self.users = {} self.friendships = {} def addFriendship(self, userID, friendID): if user...
a5de25231cef8caf3e2112c8f2168fe179e267a7
smorzhov/adventofcode2017
/02_corruption_checksum.py
1,046
3.53125
4
from os import path PWD = path.dirname(path.realpath(__file__)) FILE_NAME = 'input.txt' def read_input(file_name=path.join(PWD, FILE_NAME)): content = [] with open(file_name) as file: for line in file: content.append(list(map(int, line.split()))) return content def find_checksum(dat...
cc94542945d9391098c4583819ace83a81ed1f02
matchalunatic/honkhonk
/honkhonk
891
3.546875
4
#!/usr/bin/env python3 import sys import re import string GOOSE_EMOJI = '🦢' has_cap = lambda x: x[0] in list(chr(a) for a in range(ord('A'), ord('Z'))) LETTERS = string.ascii_letters UPPERCASE_LETTERS = string.ascii_uppercase def honkhonk(stream): i = 0 for line in stream: prev_is_letter = False ...
edfb520b99ff35f709065255f6ffbfca8e766d5b
paulmburu08/Lockpass
/user_test.py
1,340
3.875
4
import unittest from user import User class UserTest(unittest.TestCase): def setUp(self): ''' Set up method to run before each test cases. ''' self.new_user = User('Paul','Mburu','paulmburu08@gmail.com','python34562') def tearDown(self): ''' tearDown metho...
10bdaba3ac48babdc769cb838e1f7f4cdef66ae9
nikitaagarwala16/-100DaysofCodingInPython
/MonotonicArray.py
705
4.34375
4
''' Write a function that takes in an array of integers and returns a boolean representing whether the array is monotonic. An array is said to be monotonic if its elements, from left to right, are entirely non-increasing or entirely non -decreasing. ''' def monoArray(array): arraylen=len(array) increasing=True ...
be012b97acfa6aff0075c6349da435b4b22f8d12
gaurav-kay/GitHub-Art
/app.py
799
3.5625
4
from os import system # accepted date formats: rfc2822 (Mon, 3 Jul 2006 17:18:43 +0200) and iso8601 (2006-07-03 17:18:43 +0200) def get_commit_hash(op1): return op1.split(' ')[1] def draw(dates): for date in dates: print(date) command = 'echo "commit" >> test.txt' system(...
5335fe276809fcebf1992c1725b3189fb73cb091
AntonChernov/luxsoft_task_poland
/token_validator.py
1,676
4.03125
4
import argparse import itertools def letters(obj): # separate string to letters if isinstance(obj, list): # itertools.chain.from_iterable(obj) --> from ['asd', 'sdf'] to ['asdsdf'] return list(set(itertools.chain.from_iterable(obj))) # from ['asd', 'sdf'] to ['asdsdf'] but the string # co...
4dc1099a08a4bcd40eaeba6643a060338e624638
jjjjooonno/fc_wc
/코드/Week1/b.py
260
3.921875
4
list_ = ['a',3,5] print(list_[0]) list_.append(7) print(list_[3]) dic = {'a' : 1, 'b' : 2} print(dic['a']) dic.update({'c' : 3}) print(dic['c']) for item in list_: print(item) for index, item in enumerate(list_): print(str(index)+'th item is'+str(item))
64816cb5e3c9e27c1773b76d35ef320bddf5949b
putraeka/python
/arkadiusz-wlodarczyk/11-simple-calculator.py
606
4.0625
4
# Membuat calculator berdasarkan input yang dimasukkan oleh user menuOption = input("+ Add - Substract * Multiply / divide : ") first = int (input("Input your first number : ")) second = int (input("Input your second number: ")) if menuOption == '+' : print(first + second) elif menuOption == '-' : print(...
2696cdcf687d654d2ce468327bd39f2a6196a86b
putraeka/python
/arkadiusz-wlodarczyk/19-list-operations-and-functions.py
565
3.96875
4
""" operasi yang ada di list len() - length of list .append - adding on the end of SINGLE element .extend - extending list by another list .insert(index, what) - put in .index(what) - return index of 'what' .sort(reverse=False) -sort ascending .sort(reverse=True) - sort descending .max() .min() .count - how many occu...
1c0951e02ae8e0298db3bd4c6bd91152e51542f7
putraeka/python
/arkadiusz-wlodarczyk/23-nested-types.py
755
3.65625
4
# Nested Types # Digunakan untuk memasukkan data yang banyak dan mirip # Nested Types sendiri adalah LIST didalam LIST # Nested LIST juga bisa memuat tuple """ Misalkan kita punya beberapa orang dengan tamu name = "Arkadiusz" age = 29 sex = "man" name2 = "Jessica" age2 = 23 sex2 = "woman" name3 = "John" age3 = 32 ...
7e68f4da3b81c0adee9db128dc3dc706bc6942f4
rohit-konda/systemcontrol
/systemcontrol/basic_systems.py
8,219
3.65625
4
#!/usr/bin/env python """ Class defintions for creating basic feedback control affine systems """ import numpy as np class System: """general formulation for a continuous system""" def __init__(self, x, dt=.1, params=None, t=0): self.x = x # state self.t = t # time se...
f9f970c1c2d316b760035fb8942de4882d06fdc0
rohit-konda/systemcontrol
/examples/obstacle_avoidance_CBF.py
3,944
3.96875
4
#!/usr/bin/env python """ Tutorial example for using barrier functions for collision avoidance Environment includes a unicycle model of a car, and some obstacles that the car has to avoid """ import numpy as np from systemcontrol.basic_systems import SingleUnicycle from systemcontrol.CBF_systems import Feas...
3a690d3c0bc3b56ac34c5b83025d8fd13a6af716
askariya/seng533_project
/seng533_assign1.py
10,801
3.75
4
import sys import csv from collections import defaultdict def calculateAnswers(csv_file, txt_file): columns = defaultdict(list) # each value in each column is appended to a list file = csv_file reader = csv.DictReader(open(file, newline=""), dialect="excel") for row in reader: for (k,v) in ro...
867ab00937a707e8f1de468f62b501e0c4019d3d
ganesh-santhanam/Spark
/Spark Basics.py
6,558
3.71875
4
#data is just a normal Python list, containing Python tuples objects data[0] len(data) #Length 10000 #Create a dataframe using Sql Context #DataFrames are ultimately represented as RDDs, with additional meta-data. dataDF = sqlContext.createDataFrame(data, ('last_name', 'first_name', 'ssn', 'occupation', 'age')) ...
82dd250d063086764db4e2d70150afbff03079d4
chang02/alg
/hw1/checker.py
534
3.78125
4
import sys def check(arr, nth, value): lower = 0 same = 0 for x in arr: if x < value: lower = lower + 1 if x == value: same = same + 1 if lower < nth <= (lower + same): return True else: return False nth = int(sys.argv[1]) filename = sys.argv[2] value = int(sys.argv[3]) f = open(filename, 'r') li...
583e51f6ed23c94ce3bb92e143f67452c23c76ca
KGeetings/CMSC-115
/Assignments/progNumber13.py
1,595
3.671875
4
#Write a program which will read the dictionary file (words.txt), #and calculate the answer to the question: "What percentage of words have more vowels than consonants?" file = open("words.txt","r") vowelWords = 0 counter = 0 content = file.read() newList = content.split("\n") for line in file: line = line....
a7f8f0101b6b47a71048c2eb19c5b64d530857bf
KGeetings/CMSC-115
/In Class/Year100.py
159
3.734375
4
userAge = int(input("What is your age? ")) yearBorn = 2021 - userAge yearHundred = yearBorn + 100 print("You will be 100 years old in the year", yearHundred)
fa6ab346c0be5b1ed20ef6441f4f6a5f6d404baa
KGeetings/CMSC-115
/In Class/BankAccount.py
1,131
3.703125
4
class BankAccount: def __init__(self, owner, startingBalance): self.owner = owner self.balance = startingBalance self.interestRate = .05 def withdraw(self, amount): if self.balance >= amount: self.balance = self.balance - amount else: print("OVERD...
6e046e3427b8592f75a5ea3702ec14fbc4a30101
KGeetings/CMSC-115
/In Class/turtlePetals.py
601
3.984375
4
import turtle petal_length = 15 petal_angle = 50 num_petals = 360 // petal_angle // 2 for petals in range(num_petals): if petals % 3 == 0: turtle.color("red") elif petals % 3 == 1: turtle.color("pink") else: turtle.color("purple") turtle.begin_fill() for i in range(2): ...
9e56e18be02f567543d7b8467f42a613e7b0df43
KGeetings/CMSC-115
/In Class/ColatzSequence.py
425
3.546875
4
longest_seq = 0 longest_sew_orig = 0 for n in range(2,1000): if n % 1000 == 1: print(n / 100000 * 100, "%") orig = n while n > 1: if n % 2 == 0: n = n//2 else: n = n*3 + 1 if count > longest_seq: longest_seq = count longest_se...
f1e02a8d95ca7d162383ade1c14bab27b45b22ac
KGeetings/CMSC-115
/In Class/Hello_World.py
195
4.25
4
diameter_str = input("What is the diameter of your circle? ") diameter_int = int(diameter_str) radius = diameter_int / 2 area = 3.1415 * radius ** 2 print("The area of your circle is: ", area)
b27ea7f9301fbf02aba5a63a90b9845a5a0b05d0
formazione/python_book
/snippets/lists.py
141
4.1875
4
Lists in Python 1. Insert items in a list Insert an Item at the end ========================== lst.insert(tk.END, entry.get()) v.set("")
f4dfebe98073181b1352701e3246e96603bacb05
mananshah511/Machine_learning
/Simple linear regression/simple_linear_regression.py
1,366
3.984375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed May 20 12:19:27 2020 @author: manan """ #simple linear regression import numpy as np import pandas as pd import matplotlib.pyplot as plt #importing dataset dataset=pd.read_csv('Salary_Data.csv') #creating independent and depenedent matrix X=dataset.il...
440c99c8f7628b5ff1f311a0f9bd0cf35b47cdcd
rmanzano-sps/IS211_Assignment4
/search_compare.py
4,062
3.78125
4
#HOW TO: In terminal type 'python search_compare.py' to run program import timeit import random from timeit import Timer def sequential_search(a_list, item): pos = 0 found = False while pos < len(a_list) and not found: if a_list[pos] == item: found = True else: pos =...
eb05a439ca3e8cb84a9dd47e7476548ed343a980
cizixs/playground
/leetcode/strStr.py
386
3.609375
4
class Solution: # @param haystack, a string # @param needle, a string # @return a string or None def strStr(self, haystack, needle): if len(haystack) < len(needle): return None if needle == "": return haystack result = haystack.find(needle) if resu...
dfb99f0bdecab494bd696ff377a85a4d25272b5e
cizixs/playground
/eulerproject/largestprimefactor.py
353
3.6875
4
# -*- coding: utf-8 -*- from math import ceil, sqrt def largestFactor(n): if n < 3: return n if n <= 0: raise ValueError('can;t handle non-positive number') root = int(ceil(sqrt(n))) for x in range(2, root): if n % x == 0: return largestFactor(n/x) return n p...
32b719757a612498a8de225ae39e9966434a5b78
cizixs/playground
/leetcode/generateParenthesis.py
597
3.65625
4
class Solution: # @param an integer # @return a list of string def generateParenthesis(self, n): result = ["()"] if n == 1: return result while True: import pdb; pdb.set_trace() t = result.pop(0) if len(t) == 2*n: resu...
552e54f97f701a2424f9319fcf6fb6e470c155b5
Tzhong16/python
/logic_operators.py
2,386
3.890625
4
# Comparisons print(True == False) print(-5 * 15 != 75) print('pyscript' == 'PyScript') print(True == 1) x = -3 * 6 print(x >= -10) y = "test" print( 'test' <= y) print(True > False) #array comparison import numpy as np my_house = np.array([18.0, 20.0, 10.75, 9.50]) your_house = np.array([14.0, 24.0, 14.25, 9.0]...
0915b352ed93be7c1fe19f751d021b7b74cafbc2
alexthotse/data_explorer
/Data-Engineering/Part 07_(Elective):Intro_to_Python /Lesson_04.control_flow/control_flow.py
1,798
4.28125
4
# #1. IF Statement # # #2. IF, ELIF, ELSE # #n = str(input("Favourite_number: " )) # n = 25 # if n % 2 == 0: # print("The value of " + str(n) + " is even") # else: # print("The value of " + str(n) + " is odd") # # print(n) # # ######################## # # # season = 'spring' # # season = 'summer' # # season = '...
1641ddf27ade4047141364e400008e5877c8fd33
mungjin/2020-Python-code
/Chapter05/05-10wordsort.py
262
3.84375
4
word = list('삶꿈정') word.extend('복빛') print(word) word.sort() print(word) fruit = ['복숭아', '자두', '골드키위', '귤'] print(fruit) fruit.sort(reverse=True) print(fruit) mix = word + fruit print(sorted(mix)) print(sorted(mix, reverse=True))
9db6dac80ca8a24e68c5e7b08ac5b3e6a3e65696
Pozyvnoy/laboratoranaya
/lab1_6.py
200
3.9375
4
chislo = int(input("Введите целое: ")) mult = 1 while (chislo != 0): mult = mult * (chislo % 10) chislo = chislo // 10 print("Произведение цифр равно: ", mult)
098cd36626e7398e75c3dd56dd85ed21e46bd080
Pozyvnoy/laboratoranaya
/lab1_7.py
98
3.671875
4
x1 = input("Введите число:") x2 = x1 [::-1 ] print("Обратное число:", x2)
3b36b4c4131dc250dd3a079cbe749344c442e9c4
senorpatricio/python-exercizes
/exercise8.py
485
3.53125
4
from time import clock def naive_fib(n): if n == 0 or n == 1: return n else: return naive_fib(n - 1) + naive_fib(n - 2) def fib_helper(n): if n == 0: return 0 else: return fib_improved(n, 0, 1) def fib_improved(n, p0, p1): if n == 1: return p1 else: ...
433ad06ffcf65021a07f380078ddf7be5a14bc0d
senorpatricio/python-exercizes
/warmup4-15.py
1,020
4.46875
4
""" Creating two classes, an employee and a job, where the employee class has-a job class. When printing an instance of the employee object the output should look something like this: My name is Morgan Williams, I am 24 years old and I am a Software Developer. """ class Job(object): def __init__(self, title, sal...