blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
52967e893653a28cab3e646c3870444eb0b08239
peterpeng1993/learngit
/script/python/12-1列表操作.py
556
4
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 19 19:40:44 2018 @author: asus """ namelist=[] print('Enter 5 names(press the Enter key after each name):') for i in range(5): name=input() namelist.append(name) print('The names are',namelist) new_namelist=namelist[:] new_namelist.sort() print('Th...
cdeffbf6c2d7599a7e24ded1d2f5ee8f2d65358f
UniBus/Server
/data_management/modules/gtfs/server/routes.py
3,860
3.703125
4
#! /usr/bin/python ## This module import routes.txt to table 'routes' in a mySQL database # # It take two parameters, as # import_routes $dbName $cvsFilePath # # Thus, it imports $cvsFilePath/routes.txt to $dbName.routes. # if $dbName.routes exists, it deletes the table first. # # $dbName.routes table st...
af37e074c6ddf250f37d8887bc24400a5f48a31b
abhinai96/Python_Practise_Programs
/14 find the occurance of char in given string.py
242
3.6875
4
#ABBACBA #A3 B3 C1 a="abbacba" """b=a.count("a") print(b)""" l=[] for i in a: if i not in l: l.append(i) print(l) for i in sorted(l): print("{} occurs {}times".format(i,a.count(i)))
acb9e3ecaa4094c40ebfa7434aa0e718eb9c6120
LfqGithub/LfqGithub.github.io
/docs/python/oldButImportant/note/iterator.py
928
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from collections import Iterable #可以用for便历元素的数据类型, 一类是集合数据类,如list,tuple,dict,set, str等,一类是genetrator,包括生成器和带yield的 generator function,这些可以直接作用于for,成为iterable print(isinstance({},Iterable)) print(isinstance([],Iterable)) print(isinstance('abc',Iterable)) print(isinstance((x...
c388a2bf9cd4e316ad16bab715620ef4f6c68a1c
sprksh/quest
/binary_search/first_greater.py
300
3.796875
4
def first_greater(arr, target): lo, hi = 0, len(arr) while lo < hi: mid = lo + (hi-lo)//2 if arr[mid] <= target: lo = mid+1 else: hi = mid return hi if hi<len(arr) else -1 if __name__ == "__main__": arr = [0,1,5,7,8,10,12,15] print(first_greater(arr, 2))
e47a8ba0c048d75e657b8025b24bd17c8604d48f
phankanp/Secret-Messages
/secret_messages.py
4,506
3.9375
4
from affine import Affine from atbash import Atbash from caesar import Caesar from key_word import Keyword import sys ALL_CIPHERS = {"1": Affine, "2": Atbash, "3": Caesar, "4": Keyword} def main(): """ 1. Shows welcome message 2. Gets users cipher choice, message, and keyword if necessary 3. Determi...
59da193c528634b8f753ed89243ca9483911d3c8
oleg31947/QA_Algorithmes
/Algorithm/Class_1.py
3,913
4.1875
4
""" 12. Ask for the total price of the bill, then ask how many diners there are. Divide the total bill by the number of diners and show how much each person must pay """ i = int(input("What's price of the bill? ")) j = int(input("How many diners there are? ")) each_price = i / j print("Each diners is owes this amout...
980130d9e6aa18866dc6f06a18e4df231fccf022
sankumsek/assorted-python
/Queue Assignment.py
1,109
3.8125
4
class Queue1: def __init__(self): self.q = [] def add(self, item): self.q.append(item) def remove(self): return self.q.pop(0) def isEmpty(self): return len(self.q) == 0 #more efficient Queue2 with an updated remove class Queue2: def __init__(self, lst = []): ...
387d43229fccadce56876ae1118ae71c2abbcec6
kxtarrao/Graph
/main.py
1,958
3.765625
4
# Dictionary Format: {Node:data} class Node: def __init__(self, data): self.neighbors = {} def __repr__(self): return f"NODE" class Graph: def __init__(self): self.nodes = {} def add_node(self, data): self.nodes[Node(data)] = data # Gets node for given value ...
ef7fd2af0ee6bc57071b1b7c02a187efb1339e9b
fdmxfarhan/ikiu_python
/test-11 angle changer (exercise-07 - page 23).py
98
4.0625
4
angle = int(input('Your angle: ')) if angle >= 0: print(angle) else: print(angle + 360)
78b8e251e1226060f2c675ba3e9c8932570e692c
realbakari/python-arrays
/array_remove.py
234
3.5625
4
import array as arr numbers = arr.array('i', [10, 11, 12, 12, 13]) numbers.remove(12) print(numbers) # Output: array('i', [10, 11, 12, 13]) print(numbers.pop(2)) # Output: 12 print(numbers) # Output: array('i', [10, 11, 13])
6f4dbd6701a57ca71cbf1556006e026d4fddff41
sangzzz/Leetcode
/0075_Color_Sort.py
754
3.546875
4
class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ nums.sort() # or class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instea...
7ce9ced1fd7c94c13869fb68228568b35d1227ce
Consecratio/503-binary-search-tree
/main.py
511
3.734375
4
from BinaryTree import Node from BinaryTree import BinaryTree my_node = Node('hello') # print(my_node) my_BST = BinaryTree() my_BST.insert(7) my_BST.insert(3) my_BST.insert(11) my_BST.insert(1) my_BST.insert(5) my_BST.insert(4) my_BST.insert(6) my_BST.insert(11) my_BST.insert(9) my_BST.insert(13) my_BST.insert(8) my...
04ab65f5d842a5339a258fba32956ccc69e29aea
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/vlsjus001/question1.py
377
4.3125
4
#question1 #author:justin valsecchi #2014/05/08 #creating a base case def reverse(p): if len(p) == 1: return p else: return p[-1] + reverse(p[:-1]) #use of return funtion, istead of iteration loops #continuing through the other parts string = input("Enter a string:\n") if reverse(string) == st...
261f1b93761fe088ebbbf3cb13655ad7b3b9b6b0
robin-norwood/TIY-SAT-Python-Aug-2016
/week2/02.args_and_kwargs.py
1,146
4.15625
4
def concat_three(first, second, third): return first + second + third # Error: #print(concat_three("one", "two")) def concat_all(*args): print("TYPE: " + str(type(args))) return ' '.join(args) print(concat_all("Jimminy", "Cricket", "Steve")) def concat_with(sep, *strings): return sep.join(s...
f589c545f8653208493ded600326dd73efc8980f
manityagi/Option_pricing
/scripts/finite_difference_method.py
522
3.96875
4
def finite_difference(f, e, second_order = False): ''' inputs: ========== f: function (lambda function) e: error second_order: order of finite difference method returns: ========= if second_order is False, then it returns first-order finite difference...
653a93e009de2d53c5cf20e24256dfac6b13d8dd
MaxTechniche/dcp
/DCP_033 Median of a Stream.py
719
4.09375
4
""" Good morning! Here's your coding interview problem for today. This problem was asked by Microsoft. Compute the running median of a sequence of numbers. That is, given a stream of numbers, print out the median of the list so far on each new element. Recall that the median of an even-numbered list is the av...
533bf274dc3632ec4b9ead4e1c2d803c1fccedb9
lymanreed/Currency_Converter
/Topics/Math functions/Octahedron/main.py
114
3.6875
4
import math a = int(input()) print(round(2 * math.sqrt(3) * a ** 2, 2), round(1 / 3 * math.sqrt(2) * a ** 3, 2))
267a03b9fce3b6650512055034446a032647cd63
HyACT-AI/MLP
/Common/robotics.py
3,074
3.875
4
# Python 3.7.0 # 제목 : Robotics Package v1.0 # 날짜 : 2020.12.24 # 내용 : 다른 프로젝트와 코드 통합 import math class Kinematics(): # default # link1 = 64 # link2 = 44 # link3 = 210 def __init__(self, link1=64, link2=44, link3=210): self.link1 = link1 self.link2 = link2 ...
1ea8923892d0e1b72ab4ebd9e04ad1aa515aadc2
LasseTretten/INF-1400
/Assignment1/Src/breakout.py
9,440
3.875
4
import pygame pygame.init() from spriteloader import SpriteMe, SpriteSheet import random import math class Platform(SpriteMe): """ platform object can move horizontally acording to user input. Platforms are not allowed to move outside of the screen. Parameters ---------- surface --> A pygame.Surface ob...
9f54f332a5ccddca006df429e0a93e097c987ee4
gomanish/Python
/array/two.py
148
3.546875
4
# Leaders in an array arr=[55,3,20,15,8,25,3] l=len(arr) max=0 for x in range(0,len(arr)): if max<arr[l-1]: max=arr[l-1] print max, l=l-1
e5f5b9d6ecaaaa8d3c1105d56dcdb2bc6b291f41
middlebury/HPC
/array-job-example/factor_list.py
2,918
4.25
4
#!/usr/bin/env python3 # factor_list.py # # Get the prime factors of a list of integers supplied in an input file import numpy as np import argparse import math ############################################ # Returns a list of the prime factors of n ############################################ def primeFactors(n): ...
33a43b2be0cd60929e038742428d28a8e72b7106
chulkx/ejercicios_python_new
/Clase04/busqueda_en_listas.py
1,306
3.6875
4
# -*- coding: utf-8 -*- """ Created on Thu Aug 26 12:34:49 2021 @author: Gustavo @mail: gustavogodoy85@gmail.com """ #%% Ejercicio 4.3 Busqueda de un elemento def buscar_u_elemento(lista, elem): i = len(lista)-1 for i in range(len(lista)-1, -1, -1): #asi recorro la lista desde el final hasta el inicio ...
becb7a7523b6c73dfa1ccc093a65852e933616fe
GabrielRStella/SquarePuzzle
/solver.py
2,561
3.625
4
import board, copy, queue Board = board.Board Queue = queue.Queue class Solver: def __init__(self, board, depth): self.board = board self.depth = depth self.reset() pass #clears the cache of decided moves #eg, if the user has changed the board's state def reset(self): ...
eec22981e0ac13edfe46414233bff234debea3b3
j16949/Programming-in-Python-princeton
/2.3/factorial_r.py
115
3.640625
4
import sys def factorial(n): if n == 1: return 1 return n * factorial(n-1) print(factorial(eval(sys.argv[1])))
a484a1f4cae35291bf28e0fd3b5d3d0a71c0fea7
jacksonx9/BlackjackMachineLearning
/play_game_ml_version/blackjack/deck/deck.py
825
3.71875
4
import random import copy from ..card.card import Card, RANK class Deck(): '''Represents deck of 52 cards to be dealt to the player and dealer.''' def __init__(self, num_decks=1): self._cards = [Card(rank) for rank in RANK] * 4 * num_decks def __len__(self): return len(self...
e44d884b44464ffbd64af012b79a6c7b62caeff4
delltross/Exercise
/cashRegister.py
2,817
3.859375
4
""" File: cashRegister.py Author: Ken Greenberg Date: 09/30/2019 Section: 01 Email: kgreen7@umbc.edu Description: This file contains a class called CashRegister. This class has an three attributes: total, bills, and locked. Bills is a list of 4 integer values that correspond to 4 denominations of dollars. Lock...
6905083fbfc4baf3b4a2cd206d66c2077b577c54
PesDavyd/vkChatBot
/vk_bot/db.py
379
3.59375
4
import sqlite3 db = sqlite3.connect('users.db') cursor = db.cursor() cursor.execute(''' CREATE TABLE IF NOT EXISTS users( user_id VARCHAR(50) PRIMARY KEY, status INTEGER, have INTEGER ); ''') db.commit() array = cursor.execute(""" SELECT * FROM users """).fetchal...
02faf56f84bfaaababbfb150252e492bbf121e79
Sanlook/guvi
/task/looping/prime.py
373
4
4
n= int(input("start range: ")) m=int(input("end range: ")) sum = 0 for num in range(n, m + 1): i = 0 for i in range(2, num): if (int(num % i) == 0): i = num break; #If the number is prime then add it. if i is not num: sum += num print("Su...
39f070b56c82b4f2f66607ca5a206219cbfe5473
AntonTrainer/practice
/rw_practice.py
2,089
4.125
4
# molecular motion from random import choice import matplotlib.pyplot as plt # ------------------------ Create a class that will fill define the walk points --------------------------------------------------------- # create a call to create random walks class RandomWalk(): def __init__(self, num_poi...
2fe999cc46d35776ab58972212ae96b25a808733
zyhsna/Leetcode_practice
/problems/decrypt-string-from-alphabet-to-integer-mapping.py
525
3.625
4
# _*_ coding:UTF-8 _*_ # 开发人员:zyh # 开发时间:2020/8/17 18:16 # 文件名:decrypt-string-from-alphabet-to-integer-mapping.py # 开发工具:PyCharm def freqAlphabets(self, s:str): """ :type s: str :rtype: str """ def get(string): return chr(int(string) + 96) i, ans = 0, "" while i < len(s): if...
685d76c3f704cecde436eb2d82a6b522ddc54a64
codeSmith12/PCAP-Training
/timer.py
1,001
3.6875
4
class Timer: def __init__(self, hrs=0, mins=0, secs=0): self.hrs = hrs self.mins = mins self.secs = secs def __str__(self): myStr = "{:d}:".format(self.hrs) myStr += "{:d}:".format(self.mins) myStr += "{:d}".format(self.secs) return "".join(myStr) de...
03c238e3bd5aee1c412ac688bc17ea72ff9c37ca
Tthkrisztian/lotto
/lotto.py
194
3.609375
4
import random lottoszamok = [] while len(lottoszamok)<5: kihuzott = random.randrange(1,91) if kihuzott not in lottoszamok: lottoszamok.append(kihuzott) print(lottoszamok)# lotto
9e1580073cfd9d78f1359c757f67bd8bba106bbf
Hu-Wenchao/leetcode
/prob191_numberof1bits.py
495
4.25
4
""" Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11' has binary representation 00000000000000000000000000001011, so the function should return 3. """ class Solution(object): def hammingWeight(self...
0c80dac2b0682b7ba8274b87cc9396c000907645
mauney/Graphs
/projects/social/islands.py
2,062
3.59375
4
def island_counter(islands): matrix = [[cell for cell in row] for row in islands] components = 0 for y in range(len(matrix)): for x in range(len(matrix[y])): if matrix[y][x] == 0: continue elif matrix[y][x] == 1: components += 1 ...
4df67947e8f08923c8f5d9ba22ea5af8a3c64299
bayramcicek/algoritma-analizi
/002-a-ussu-b.py
355
3.515625
4
#!/usr/bin/python3.6 # created by cicek on Mar 03, 2020 21:00 # a^b 'yi bulan fonksiyon karmaşıklığı counter = 0 def fun1(a, b): global counter s = 1 for i in range(b): s = s * a counter += 1 return s a, b = 2, 16 result = fun1(a, b) # print(result) print(counter) # b ne ise o ...
edfef284e23142a772c867012cb112e1f9e57e5c
rakeshnambiar/tech_tasks
/Solution.py
4,584
3.671875
4
import sys import os import operator from itertools import chain import re from statistics import mean, median, mode def main(): file_path = "" try: file_path = sys.argv[1] list_of_words = read_file(file_path) evaluate(list_of_words) except Exception as fnf: print( ...
f0306eaed42a29d1e36d11e176d785fd9a0453fb
Sem31/PythonBasics
/37 operator-overloading.py
293
4
4
#operator overloading class A: def __init__(self,a,b): self.a = a self.b = b def __str__(self): return('A is (%d,%d)'%(self.a,self.b)) def __add__(self,other): return (A(self.a + other.a,self.b + other.b)) a1 = A(12,8) a2 = A(9,7) print(a1+a2)
69defc5c5b10de88c9be67b9b49127603e69c851
borisbutenko/leetcode
/easy/intersect_of_two_arrays.py
676
4.0625
4
from typing import List def intersect(nums1: List[int], nums2: List[int]) -> List[int]: """Given two arrays of integers, write a function to compute their intersection. From `leetcode <https://leetcode.com/problems/intersection-of-two-arrays-ii/>` Note: - Each element in the result...
bfdc6ee0bf7200debb05e7380ebb3003f426c0a5
anthepro/Advent-of-Code-2018
/day2.py
567
3.703125
4
# Who needs more code from functools import reduce def part1(input): return reduce(lambda x, y: x * y, (sum(any(x.count(c) == y for c in x) for x in input) for y in (2, 3))) def part2(input): # sum(1 for ... if cond) rather than sum(cond for ...) because it's much faster in this case return next(''.join...
7d217f4898eef3c1be8fccbae41347ed31ae91a5
Raikhen/numberception
/continuum-hypothesis/main.py
2,244
3.5
4
import time from os import system from random import randint from pynput import keyboard from datetime import datetime # Constants N = 50 LETTERS = ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'ñ'] # Variables i = 0 num = 0 time = 0 listening = True # Open data file f = open('data.txt', 'a') # Se...
0cb6e6ae39b92a935931901d68c5e1e9f09079c9
oklinux/LRWiki
/lib/tools/payload_generator.py
588
3.5625
4
import string import random CHARS = ( string.ascii_uppercase + string.ascii_lowercase + string.digits ) def random_string(length=10, chars=CHARS): """ Generate a random alphanumeric string of the specified length. """ return str(''.join(random.choice(chars) for _ in range(length))) def generate...
5be3a0a39081e4f98609bedde31911544971a2a1
LiaoTingChun/python_advanced
/ch3_pass_var.py
194
3.8125
4
# pass by value # pass by reference # python: pass by object reference def f(y): y.append(1) x = [0] f(x) print(x) # [0] or [0, 1] ? def ff(y): y += 1 x = 0 ff(x) print(x) # 0 or 1 ?
ec9d0acb3c122cee6654df2f6332655690667222
Wizmann/ACM-ICPC
/HackerRank/Python/Strings/sWAP cASE.py
191
4.0625
4
def swap_case(s): return ''.join(map(lambda x: x.lower() if x.isupper() else x.upper(), s)) if __name__ == '__main__': s = raw_input() result = swap_case(s) print result
7fa87d6e956c0c3b6a7962e87a0a19778330089b
milenatteixeira/cc1612-exercicios
/exercicios/aula11.2.py
2,681
3.671875
4
from tkinter import * from tkinter import messagebox from tkinter import Menu from tkinter import scrolledtext tarefas = [] seg = 59 minu_fixo = 25 minu = 24 controle = 0 def mensagem(): res = messagebox.showinfo("Aviso!","Tarefa realizada e inserida no banco.") def pagListar(): janelaListar =...
786fced09a2f705505b7bedb601795e99a0b94b2
Yuhjiang/LeetCode_Jyh
/problems/midium/47-permutations-ii.py
955
3.53125
4
from typing import List class Solution: def permuteUnique(self, nums: List[int]) -> List[List[int]]: length = len(nums) nums_set = set(range(length)) nums.sort() visited = set() ans = [] def dfs(pos, output): if pos == length: ans.appen...
165890b8d3a16cb542fabde4f7c0e1b65f73f973
rodeyfeld/sorry-game
/player.py
453
3.609375
4
from typing import Dict, List class Player(object): def __str__(self): return "Player: " + self.name def __init__(self, name, team): self.name = name self.team = team self.cards: List = [] def display_cards(self): return [card.card_text for card in self.cards] ...
5805c0e243ff9875c27aa6ec03fb4599f671403b
SurajGutti/CodingChallenges
/removeInvalidParanthesis.py
1,855
3.828125
4
''' Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may contain letters other than the parentheses ( and ). Example 1: Input: "()())()" Output: ["()()()", "(())()"] Example 2: Input: "(a)())()" Output: ["(a)()()", "(a())()...
d23da468c9e61c476177978448f9e555867d7b29
zneu/printbox
/printbox.py
810
3.671875
4
import os def clear(): os.system('cls' if os.name == 'nt' else 'clear') clear() class Box: def setup_box(self): S = ["+ ", "- ", "+", "| ", " ", "|" ] self.top = ((S[0] + S[1] * self.x)) + S[2] self.side = ((S[3] + S[4] * self.x)) + S[5] self.bottom = ((...
4d7b99980b630c0b649b9286ed32b77856193e19
andrewsonin/4sem2
/C_dynprog1.py
284
3.765625
4
def recursion(n): if n <= 2: return 0 f_list, g_list = [0, 0], [0, 0] for i in range(2, n): f_list.append(f_list[-1] + 2 * g_list[-2] + 1) g_list.append(f_list[-3] + 2 * g_list[-1] - 1) return f_list[-1] print(recursion(int(input())))
9fc2ccaac0109d3a3ce2501dce1882a1697a7175
elevenfofiv/PY4E
/week5_Q3.py
1,713
4
4
import random def guess_numbers(): numbers = [] for i in range(3): number = random.randint(0, 100) numbers.append(number) numbers.sort() game = 0 success = 0 my_numbers = [] print(numbers) while 1: game += 1 print(f'{game}차 시도') my_number = int(...
73db5e4ce878162a4ddd87634878af14a8b266af
anmolpanwar/python-practice
/Practice/temp2.py
82
3.53125
4
ls = [1,2,4,4] ls1 = [4,1,2,4] ls1.sort() print ls1 if ls==ls1: print "yes"
3f8f6432fe6b19f41899f2af3dbfde727c27a1ef
derivadiv/advent2020
/day24/day24.py
5,679
4
4
""" Coordinate systems - let's try odd-r horizontal layout https://www.redblobgames.com/grids/hexagons/#coordinates-offset - if row is even: (x,y) for y%2 = 0: - NE = (x, y+1) ; NW = (x-1, y+1) - E = (x+1, y) ; W = (x-1, y) - SE = (x, y-1) ; SW = (x-1, y-1) - if row is odd: (x,y) for y%2 = 1: - NE = ...
cf8f5f5e146b5f46ef6e4e71cfc93e56b9b95c20
yyash01/20-days-python
/Day-2.py
2,938
4.1875
4
#starting the second day....... #i=1 #while (i<=6): # if(i==5): # continue # else: # if(i==4): # break # print(i) # i = i+1 ################################################# #FILE HANDLING IN .PYTHON. #The key function for working with files in Python is the open() function. #The open() function takes two para...
fcc62535862006bb4f3ad8f0d130b29c035daf76
GrishamNathan/Statistical-Analysis-for-Mental-Health
/sample.py
728
3.875
4
import numpy as np import pandas as pd N = 100 df = pd.DataFrame({ 'A': pd.date_range(start='2016-01-01',periods=N,freq='D'), 'x': np.linspace(0,stop=N-1,num=N), 'y': np.random.rand(N), 'C': np.random.choice(['Low','Medium','High'],N).tolist(), 'D': np.random.normal(10...
e79e619da461a1bb8b7e1e211ce2e7ad7e1c2725
paudirac/Bb
/parser.py
2,708
3.625
4
""" Parser modules. >>> list(parse("a b")) ['a', 'b'] >>> list(parse("1 2")) [1, 2] """ from collections import defaultdict # : + ( x y -- x ) x y opplus def make_binary(op, binary): def bb_binary(op, blast, last): return binary(blast, last) def bb_op(op, stack): last = stack.pop() ...
26d106d12bb89a8619a62ce19ec12f2cc0fdb8f1
M0use7/python
/python基础语法/day7-字典和集合/05-集合.py
1,689
4.1875
4
"""__author__ = 余婷""" # 集合(set) # 集合是python中一种容器类型; 无序的,可变的, 值唯一 # 和数学中的集合差不多 # 除了可变的类型,其他的基本都行,数字、布尔和字符串是可以的(和字典的key的要求一样) # 1.声明一个集合 set1 = {1, 'abc', 100, 100} print(set1, type(set1)) # 将其他的序列转换成集合,自带一个去重的功能 set2 = set('name name') print(set2) set3 = {10, 4.14, True, 'abc'} print(set3) # 2.查(获取集合中元素) # 集合是不能单独获...
afc6024d3a14564ed21fbd7a36514aa8882525d6
akshitgupta29/Competitive_Programming
/LeetCode & GFG & IB/Immediate Smaller Element.py
751
3.78125
4
'''https://practice.geeksforgeeks.org/problems/immediate-smaller-element1142/1''' #User function Template for python3 class Solution: def immediateSmaller(self,arr,n): temp = [] for i in range(0, n): if arr[i+1] > arr[i]: temp.append(-1) else: tem...
14015002e75771e5c954f97e617d08d1648a834b
TheNameIsGav/Bioinformatics
/BreakpointsPermutations/breakpoints.py
773
3.671875
4
def readFile(file_name): with open(file_name, 'r') as file: line = file.readline().strip().split() length = len(line) #removes the silly parenthesis that rosalind includes line[0] = line[0].replace("(", "") line[-1] = line[-1].replace(")", "") print(line) #convert a...
a44d0adcb06808d7ee5eb9583f906b3b4ad2e8d9
thekrutarth/AutomatedEssayGradingSystem
/temp.py
272
3.78125
4
import nltk string = 'He said,"something!" and ran away' m = nltk.wordpunct_tokenize(string) print m r=[] punctList = [".",",",":",";","/","?","[","]","{","}","!","@","#","$","%","^","*","(",")",',"','?"','."','"'] r =[w for w in m if w.lower() not in punctList]
f314e57e4b0fcaf9bf8ee2cb5d084fc06930bc5d
sarkarChanchal105/Coding
/Leetcode/python/Medium/binary-tree-zigzag-level-order-traversal.py
3,625
4.125
4
""" Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its zigzag level order traversal as: [ ...
e738de61bec3428700dd6b6a4c4e7a26e7f35e3a
wackernagel/master-project
/gui_classes/safety_circuit_frame.py
6,196
3.671875
4
import tkinter as tk from parameters import Parameters class SafetyCircuitFrame: """ This class implements the gui widget for the saftey circuit section. Methods --------- auto_update_labels() Starts to periodically update the gui state labels (safety circuit frame) """ def __init__(self,...
5f35adbba88a7c48280088e785cd9f057d1c6c95
KattaVishnuTeja-01/first-factorial-coderbyte
/code.py
216
3.796875
4
def FirstFactorial(num): fact = 1 # code goes here for i in range(1, num + 1): fact = fact * i return fact # keep this function call here num = raw_input() print FirstFactorial(num)
223a519713e3da4badbfcabea887ffb0c32d1087
robinsxdgi/Kaggle_1
/CustomerRevenueExp.py
8,660
3.59375
4
# coding: utf-8 # # This program is used for exploring the data structures of Google customer revenue training data file # # ## 1. Import the necessary library import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import json from pandas.io.json import json_nor...
da410a22340b816ea80cbb06ee3772950d5024e5
UG-SEP/Data-Structure-and-Algorithms
/Leetcode/Number of Islands/Number of Islands.py
1,543
3.96875
4
""" A python program to implement Number of Islands Given an m x n 2d grid map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. ""...
cf24a3f91b0bf985e00101cb5603b83cd55a32b0
tbabej/uadt
/uadt/automation/markov.py
4,257
3.625
4
from numpy.random import choice class Node(object): """ A node in a markov chain. """ def __init__(self, name): self.name = name self.transitions = [] def add_transition(self, transition): self.transitions.append(transition) # If the transition has zero probabili...
b4a4ce3f7a02c9e6d6c7b65eea5ed42d7b422d4b
gabriellaec/desoft-analise-exercicios
/backup/user_078/ch16_2020_03_30_23_48_08_058323.py
121
3.828125
4
valor_conta=float(input('Insira o valor da conta: ')) print ('Valor da conta com 10%: R${0:2f}'.format(valor_conta*0.10)
864e69a6366dd73e44c0be44fce5f06a6e457a2a
Florian-Moreau/maison
/In_out/external_boards/relay/Relay.py
801
3.53125
4
from enum import Enum from threading import Lock class STATE(Enum): ON = 1 OFF = 0 class Relay: """ This is a simple relay """ def __init__(self): self.state = STATE.OFF self.nb_objects = 0 self.mutex = Lock() def set(self, state): self.mutex.acquire() ...
071571e8864e919aa9ee383b9de9f71a4b2fd3b3
kamaihamaiha/Tutorial
/python_tutorial/com/python/chapter9/car.py
3,445
4.09375
4
class Car(): def __init__(self, make, model, year, power): self.make = make self.model = model self.year = year self.power = power """给汽车初始化里程值""" self.odometer = 0 def describe(self): """返回描述汽车的一条信息""" des_info = '一辆 ' + str(self.year) + ' 的 ' + ...
e6aa9cf5848dc1ace43363d67a9fd018e4a4c54f
SiTh08/naan-project-2
/naan_functions.py
556
3.734375
4
def make_dough(ingredient1, ingredient2): if (ingredient1 == 'wheat' or 'water') and (ingredient2 == 'water' or 'wheat'): return 'dough' else: return 'not dough' def wood_oven(ingredient3): if ingredient3 == 'dough': return 'Naan bread' else: return 'not Naan bread' def...
e45307e6ead61a39afbbdfcb6e4ccf3a047315ac
ChrisAcosta15/Finished_Kattis
/Quad.py
141
3.796875
4
x = input() y = input() x = int(x) y = int(y) if x > 0: if y > 0: print(1) else: print(4) else: if y > 0: print(2) else: print(3)
fdf127d011f96fc5ac1b4139ada2655d6a09a57e
mgovilla/CodingProblems
/DailyCodingProblems/dcp_27.py
357
3.859375
4
""" Given a string of round, curly, and square open and closing brackets, return whether the brackets are balanced (well-formed). """ """ Idea 1: """ def main(): string = "([])[]" print(wellFormed(string)) def wellFormed(brackets): if(len(brackets) % 2 == 1): return False print(brackets) ...
19e11c58fd43d8aa06f1a4cc2fe850addf133d65
vivek84527/ML_TRAINING
/MLPractical11.py
236
3.671875
4
import numpy as np n4 = np.array([10, -1, 0, 90, 300, 3, -6, 2]) print("Before : ", n4) print(sorted(n4)) # External Sorting print("After : ", n4) n4.sort() # In-place sorting or Internal Sorting print("After n4.sort() = ", n4)
22247671c3739951448c84f33a1b469191f1b95c
danielforero19/taller-30-de-abril
/ejercicio 22.py
166
4
4
a = float(input("ingrese el numero: ")) if a > 0: print("el numero es positivo") elif a == 0: print("el numero es 0") else: print("el numero es negativo")
beebbd61c754eb3dc196f447dd0ab6b906da35cc
tara0017/Advent-of-Code
/2015/day11.py
1,317
3.890625
4
# day11 def increment_password(): global password, letters i = len(password) - 1 # find right most non-z letter while password[i] == 'z': #change password[i] to 'a' password = password[:i] + 'a' + password[i+1:] i -= 1 current_letter = password[i] ind_of_next...
d59ddbe54f532579cd4a43ff59fc1296014be0b9
iman-sedgh/pythonHomeWork
/PrintStars/printingStarts.py
398
4.15625
4
Number = int (raw_input("Enter A Number: " )) star =1 space = Number/2 originalNumber = Number while Number > originalNumber/2 : print ' '*space + '*'*star # print '*'*star star +=2 space -= 1 Number -=1 # OK , Hala BarAx -----> star = originalNumber space = 0 while Number > 0 : Number -=1 ...
87e5cd6398ccaccb84d5afeaa40bfec5ced31503
Pradhapmaja/Pradhap
/oddeven.py
105
3.828125
4
n,m = input().split() n = int(n) m= int(m) sum = n+m if (sum % 2==0): print("even") else: print("odd")
1cdd502de6f8625c4e2c591ada3f5d5f7ee96685
bithu30/myRepo
/Notebooks/Threading.py
673
3.65625
4
import threading import time exitFlg = 0 class myThread(threading.Thread): def __init__(self,thrID,name,counter): threading.Thread.__init__(self) self.thrID = thrID self.name=name self.counter = counter def run(self): print "Starting --"+self.name print_time(self.name,self.counter,5) print "Exiting...
fb4594ba79485dcaf5881ef34d5b15cf8625a634
kalaiselvikandasamy/python
/copystring.py
116
3.984375
4
def string(str,n): result=" " for i in range(n): result=result+str return result print(string("abc",3)
f72f38b288302710ce471adbaca5086fc1836ab8
cjhayne/life-expectancy-per-county
/health.py
5,654
3.875
4
import csv import matplotlib.pyplot as plt def worst_county(year, path): counties = info #list of counties information that correspond to the state provided in the parameter county_year_lst = [] #iterates thorugh the list for county in counties: #checks to see if the key "Years" is equeal t...
670b82c3ab92217b38dd8b69f691ba3f73687f5c
szymonczaplak/self-driving-car-project
/geometry.py
462
3.6875
4
import numpy as np def line(p1, p2): A = (p1[1] - p2[1]) B = (p2[0] - p1[0]) C = (p1[0] * p2[1] - p2[0] * p1[1]) return A, B, -C def line_intersection(L1, L2): D = L1[0] * L2[1] - L1[1] * L2[0] Dx = L1[2] * L2[1] - L1[1] * L2[2] Dy = L1[0] * L2[2] - L1[2] * L2[0] # print(f"D = {D} f...
a1a10bf7293b4cb1b63b9583d48ae03eeef615a5
rubiyadav18/list_questions
/binary_to decimal.py
152
3.59375
4
num=[1, 0, 0, 1, 1, 0, 1, 1,] index=len(num)-1 decimal=0 c=1 while index>=0: decimal=decimal+num[index]*c c=c*2 index=index-1 print(decimal)
026d2ba39013cc11fe15c1ea94a38322bb7669f7
FabianoBill/Estudos-em-Python
/Curso-em-video/115-exerciciospython/d063_Fibonacci.py
785
4.15625
4
# Exercício Python 63: Escreva um programa que leia um número N inteiro qualquer e mostre na tela os N primeiros elementos de uma Sequência de Fibonacci. Exemplo: 0 – 1 – 1 – 2 – 3 – 5 – 8 # N = int(input("Escolha a quantidade de termos > 1 da sequência de Fibonacci que você quer exibir: ")) # an = 0 # aN = 1 # c = 2 ...
98568288d74b6232ed5c2137895143bf99215c63
yang0011102/Python_learning
/pycode_pycharm/test_dictionary.py
404
3.84375
4
a_list=[1,2,3,4,5,6,7]#这是一个列表 b_dic={'apple':1, 'pear':2, 'orange':[52,8,1], 'banna':{1:3,3:'a'}}#这是一个字典 c_dic={1:'a', 2:'b'}#这也是一个字典 # print(b_dic['apple']) # print(c_dic[1]) # print(a_list[2]) # del b_dic['orange']#删除 # print(b_dic) # c_dic[3]='c' #无序添加 # print(c_dic) # pr...
bbb785a2f73ce2dda06670bb9d8665a2413e534c
aliciathoe/TicTacToe
/game.py
1,371
3.53125
4
#Discard this. More like a rough draft. The actual game is on VideoGame.py from tkinter import * TTT = Tk() def Winner(event): print("You Win!") def Loser(event): print("Wrong button :( Try again.") b1 = Button(TTT, bg = "yellow", height = 2, width = 4, text = "1") b1.bind("<Button-1>", Winner) b1.grid(row ...
fd00ec6ea569522fc12c40003d61beb67edad235
mayankkushal/python_sdp
/day_two/star_triangle.py
200
4.09375
4
n = int(input("Enter the number of stars: ")) for i in range(0, n): for j in range(0, i+1): # printing stars print("* ",end="") # ending line after each row print("\r")
fe872c9a5beb230e7f7e03fa3ca88677f1463af0
2018hsridhar/Leetcode_Solutions
/leetcode_2490.py
924
3.796875
4
''' 2490. Circular Sentence URL = https://leetcode.com/problems/circular-sentence/ Complexity Let N := len(sentence) := #-tokens in sentence Time = O(N) Space = O(1) (EXP & IMP ) ''' class Solution: def isCircularSentence(self, sentence: str) -> bool: isMySentenceCircular = True # delimeter = "\\s...
40be5d70d680ab5a490776b7ad743305169f8d38
daniel-reich/ubiquitous-fiesta
/dFz2PDjQkXZ9FhEaz_16.py
334
3.90625
4
def letter_check(lst): for i in range (len(lst)): if i==1: STRING2 = lst[1] STRING1 = lst[0] for elem in STRING2: if elem not in STRING1 and elem not in STRING1.lower(): print('NO') return False print("YES") ...
472441fe2899c57bb97525eadd9e24a0209a37ce
jamilemerlin/exercicios_python
/CursoemVideo/e003.py
175
3.90625
4
numero1 = int(input('Primeiro número:')) numero2 = int(input('Segundo número:')) soma = numero1 + numero2 print('A soma entre:{} e {} é:{}'.format(numero1, numero2, soma))
83f79e5059d3775da22fd77f21e1505fd259a618
laohou/Leetcode
/Populating Next Right Pointers in Each Node.py
704
3.578125
4
class TreeNode: def __init__(self,x): self.val = x self.left = None self.right = None self.next = None class Solution: def connect(self,root): if root == None: return None curlvl = root prelvl = None while curlvl: curN...
0a89150535c205379fef54583651f8c0bae808ab
RogerMCL/PythonExercises
/Ex099.py
408
3.8125
4
# EXERCÍCIO 099: from time import sleep def maior(*n): m = 0 q = 0 print('Lista de números:', end=' ') for c in n: print(f'{c}', end=' ') sleep(0.5) if c > m: m = c q += 1 print(f'\nForam informados {q} números e o maior deles é {m}!') ...
dfb7f05a22501d0e691e5c12f10a03096c7c79a3
Jovamih/PythonProyectos
/Pandas/Data Sciensist/pivot-tables.py
1,074
3.734375
4
#/usr/bin/env python3 import numpy as np import pandas as pd from seaborn import load_dataset import matplotlib.pyplot as plt def pivot(): #podemo usar pivot para mostrar una mejor vista #pibot usala funcion de agregado mean() por defecto en aggfunc='mean' data=load_dataset('titanic') a=data.pivot_tab...
079fa92e12b01b1263a631272bca09fa3012df58
Abhi848/python-basic-programs
/p44.py
218
4.03125
4
n= int(input("enter any number")) sum=0 temp=n while temp>0: a=temp%10 sum=sum+(a**3) temp=temp//10 if n==sum: print("it is armstrong number") else: print("it is not a armstrong number")
54fac5c6fd494f14d57f764855aebec7ab39a2d0
alexisapcs/ProjectEuler
/prob5_smolMult.py
160
3.53125
4
def divs(num): for x in range(1, 21): if num%x != 0: return False return True i = 2500 while divs(i) != True: i += 20 print(i)
395b920a332f37c34206e742efba4dd95af5b1e7
RodrigoFigueroaM/competitivePrograming
/intersection.py
402
3.859375
4
def intersection(nums1, nums2): if not nums1 and not nums2 : return [] minRange = len(nums1) if len(nums1) < len(nums2) else len(nums2) for i in range(0, minRange - 1): if nums1[i] == nums2[i]: return nums1[i] if __name__ == '__main__': # print( intersection(5)) print( intersection([1, 2, 2, 1], ...
7d6adc32cf209b635e959401839d602f61efe004
popey456963/blarg-bash
/collatz.py
476
3.765625
4
#Collatz def collatzlen(y): length = 0 while(True): if y == 1: return length + 1 elif y % 2 == 0: #number is even y = y / 2 length = length + 1 else: #number is odd y = 3 * y + 1 length = length + 1 array...
8f8c526592a354c90144e6c6a3fef5daeafb81cb
halfendt/Codewars
/6_kyu/10_min_walk.py
551
3.8125
4
def is_valid_walk(walk): """ Take a Ten Minute Walk Kata https://www.codewars.com/kata/54da539698b8a2ad76000228 """ if len(walk) != 10: return False num_n = 0 num_s = 0 num_e = 0 num_w = 0 for trip in walk: if trip == 'n': num_n += 1 elif ...
7de5d22b1824f718492fca58f9cd4d6b880e8654
Berchon/trybe-exercises
/modulo4/bloco37/dia3/exercises/ex2.py
437
3.875
4
def longer_no_repeating_substring_len(string): biggest = 0 for index, _ in enumerate(string): substr = set() for letter in string[index:]: if letter in substr: break substr.add(letter) if len(substr) > biggest: biggest = len(substr) ...
9e375f0dd15ea7b06fecc34ab6e1048ce7005286
sidsharma1990/Data-Structure
/if, else and elif statement.py
874
4.21875
4
if 5 > 3: print("Yup, that's true. This will be printed!") if 6 > 10: print("Nope, that is FALSE. That will not be printed!") if "Sandeep" == "Sandeep": print("Great name!") if "sharma" == "Sharma": print("Awesome name") if "sharma" == "Sharma": print("Haha, got you to print") print("Great s...
907684b89f02c5376a7db17492f01865f6483dfa
ArunBE6/arun
/player_set1_6.py
146
3.515625
4
arr,buy=input().split() for i in arr: cod=arr.count(i) for j in buy: dot=buy.count(j) if cod==dot: print("yes") else: print("NO")