blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3653242be14e617fde7dc136fa1351214cd30697
infotraining-team/py-bs-2020-11-30
/hello_world.py
499
3.96875
4
# Welcome :) print("Hello world") a = 1 print(a + 10) if a > 3: print("tada") else: print("something") alist = [1, 2, 3] another_list = [1, "Leszek", 3.14] another_list.append(123) print("List length", len(another_list)) for x in alist: print(x) x = x + 2 ## to nic nie zmienia ## ...
c825ea1b91f7920436bfc0a1fa1661be1a83fb2b
imgeekabhi/HackerRank
/algorithms/repeat-k-sums.py
1,576
3.53125
4
#!/usr/bin/env python3 from itertools import combinations_with_replacement arr = [] def generate(arr, k): for el in combinations_with_replacement(arr, k): print(el, end=' ') print() for el in combinations_with_replacement(arr, k): print(sum(el), end=' ') def delete_...
081327774260b2cf6537624b88cd8e8a214fa1ca
nikuthapa/Python-Assignment
/Functions/Question16.py
334
4.34375
4
list3 = [1, 2, 4, 6, 7, -3, -5, -9] square_numbers = list(map(lambda a : a ** 2, list3)) cube_numbers = list(map(lambda a : a ** 3, list3)) print("Actual list: ", list3) print("\nList after squaring every number element in actual list:", square_numbers) print("\nList after cube of every number element in actual list:",...
dbff229df7b0cb4e7042ac805abd806db897c8e1
wangjs/Lintcode
/(174)删除链表中倒数第n个节点.py
1,461
4
4
''' 给定一个链表,删除链表中倒数第n个节点,返回链表的头节点。 思路:若没有时间的要求,可以先对链表遍历一遍获得链表长度,在第二次遍历时获得倒数第n个元素;若要求只遍历一遍时,可以采用一个额外的计数指针temp,先让temp向前移动n-1,然后另一个指针从头节点开始,两个指针一起向后移动直至计数指针到达链表末尾,另一指针所指的节点即为倒数第n个节点,然后对这个节点进行删除操作即可(链表操作可以再查资料了解)。 ''' """ Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self...
550c4980627a59e4427126aec59b33062801a38c
Rezenter/AU-Python
/syntax_tree.py
3,092
3.53125
4
__author__ = 'rezenter' import tree class ASTNode(tree.Node): def execute(self): raise Exception("nope") class IntLiteralNode(ASTNode): def execute(self): return self.getValue() class UnaryOpNode(ASTNode): def getArg(self): return self.getLeft().getValue() def getMnemonic(...
649e8a7c9d4134921a7cb2f2dcbb47a939bcbc7d
zavedenski/Git-Training-Folder
/additionalFile.py
2,604
3.53125
4
from time import gmtime, strftime class Worker: def __init__(self): self.fullName = "Vladyslav Zavedenski" self.nationality = "Poland" self.sex = "Male" self.age = 20 self.degree = "Bachelor of computer science" self.experience = 1.5 self.skills = ['Python', ...
1b9e8e7775fb17c80a4a99796d93a1cc9d82cb0d
jsolano28/Data_Scientist_with_Python_Career_Track
/C13_Interactive_Data_Visualization_with_Bokeh/Ch3_Ex01_Using_the_current_document.py
1,629
3.734375
4
# EXERCISE: # Using the current document # Let's get started with building an interactive Bokeh app. This typically begins with importing the curdoc, or # "current document", function from bokeh.io. This current document will eventually hold all the plots, controls, and # layouts that you create. Your job in this exe...
9da6c9e6cc9dd5304a3970365c4064d239c6f115
miguelcaste/cursoPython
/Cap15/ejer15_03.py
1,091
3.65625
4
# -*- coding: utf-8 -*- """ Código fuente de ejemplos y ejercicios del libro "Curso de Programación Python" (C) Ediciones Anaya Multimedia 2019 Autores: Arturo Montejo Ráez y Salud María Jiménez Zafra """ def nuevo_pedido(producto, precio, descuento=0): print('Pedido de', producto, 'por va...
98c39d39be1b4188a783e14c0b2367298a45e400
adenhaus/Collection-of-Small-Python-Programs
/rock_paper_scissors.py
1,690
4.125
4
import random print("Type rock, paper, or scissors to make your move, or type stop to exit.") while True: move = random.choice(['rock', 'paper', 'scissors']) choice = input() choice = choice.lower() if choice.lower() == "rock" and move == "scissors": print("Your choice: " + choice + "\nThe co...
1d1b049543fa532ad016931575f92bc42a35096e
filipe-gomes/encryption_exercise
/encryption_exercise.py
958
4.28125
4
"""In this program we will encrypt and decrypt messages entered by the user""" def get_mode(): mode = input('Do you wish to encrypt or decrypt a message?\n') answers = ['encrypt', 'decrypt', 'e', 'd'] if mode in answers: return mode else: print('Please enter one of the following...
aeb760c282690dbae0f7e427c6a72ef4c166902b
xxxsssyyy/offer-Goal
/26二叉搜索树与双向链表.py
1,486
3.515625
4
# coding:utf-8 class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None """ 验证是否为二叉搜索树 """ class Solution1: def Convert(self, pRootOfTree): # write code here self.res = [] if pRootOfTree is None: return True def df...
63169a0887e23b7a6aeadc2ecfc8ec2d33fb4798
davixcky/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/1-search_replace.py
172
3.90625
4
#!/usr/bin/python3 def search_replace(my_list, search, replace): new_list = [] new_list[:] = [replace if search == x else x for x in my_list] return new_list
c4a4d9bcff6239b9b1b795a239cb845da92365b0
wdtch/My-Account-Book
/bookDB.py
4,875
3.8125
4
# -*- coding: utf-8 -*- import sqlite3 class BookDBManager(object): def __init__(self): self.dbcon = sqlite3.connect("db/book.db") self.dbcur = self.dbcon.cursor() def get_daily_balance_week1(self, year, month): # 年をまたぐときはイレギュラーな処理が必要 if month == 12: # 1週目の残高合計 ...
d9ccf3ee251b2ffb7d8bb2dc97b890a324018df8
GayaThamel/github-demo
/math.py
333
3.75
4
# Add implementation def add(x,y): return x + y # Substract implementation def subtract(x,y): if y>x : return Negative_Value_ERROR else: return x-y # Multiply implementation def multiply(x,y): return x*y # Divide implementation def divide(x,y): ...
b82a7e1f43302afca9f8b9289287305a112e48b4
fazarafi/text-pos-tagger
/ConditionalProbabilityExpression.py
1,211
3.546875
4
class ConditionalProbabilityExpression: first = 0 second = 0 third = 0; #Define probability as P(first|second) def set_two_param(self, one, two): self.first = str(one); self.second = str(two); #Define probability as P(first\second,third) def set_three_param(self, one, two,...
b21d95a23d718192e0d855cfac48a25949f67b30
thu4nvd/yen-baitap
/test.py
265
3.78125
4
import datetime from datetime import date, timedelta year = 1980 start_date = date(year, 1, 1) end_date = date(year, 12, 31) # delta = timedelta(days=1) while start_date <= end_date: print (start_date.strftime("%Y-%m-%d")) start_date += timedelta(days=1)
50fd32da7bbc44325070f8e304c8b14ce9198f73
Kerono4ka/modified-genetic-algorithm-for-calculating-the-chromatic-number-of-a-graph
/graph/graph.py
706
3.734375
4
class Graph: # переменные должны быть инкапсулированны через getter\setter no_points = 0 def __init__(self, points, edges): Graph.no_points = len(points) self.points = points # а тут присваиваются массивы self.edges = edges def __str__(self): """ [перечень всех вершин] ...
eb25ae29dcdfd313c90fca05cf267458e821b510
kyleclo/practice
/sorting/counting-sort.py
936
3.671875
4
""" Counting sort """ import numpy as np def counting_sort(x): n = len(x) max_value = max(x) counts = [0] * (max_value + 1) for i in range(n): counts[x[i]] += 1 for i in range(1, max_value + 1): counts[i] += counts[i-1] out = [None] * n for i in range(n-1, -1, -1): ...
08b595a4e287695c3f9f6e6531da201cc2608ed9
coldmax88/PyGUI
/Tests/07-radiogroup.py
1,038
3.890625
4
from GUI import Window, Button, RadioButton, RadioGroup, application from testing import say labels = ["Banana", "Chocolate", "Strawberry"] def report(): value = grp.value try: say(labels[value], "selected") except (TypeError, IndexError): say("Value =", value) def set_to_chocolate(): grp.value = 1 win = Wi...
92893c7d0cbd15fbb4f43f9461ebcbd5cd56f0c6
DiegoBMP/aprendiendo-python
/datatype.py
489
3.5625
4
# Strings print("hola") print('sdsdas') print('''que pasa puta''') print("""queres que te la ponga""") print(type("hello wolrd")) # Numbers # Integer print(30) #int # Float print(30.5) #float # Boolean True #bool False # List [10, 20, 30, 55] ['hola', 'bye','queres', 'ahre'] [10, "hello", True, 1...
d5f7db254e061d9abf654305eb6d96263e7083b7
emilyengle/advent-of-code
/2019/dec-1/fuel.py
546
3.78125
4
import math # Part 1 def get_fuel_requirement(mass): fuel = math.floor(mass / 3) - 2 return fuel if fuel > 0 else 0 # Part 2 def get_total_fuel_requirement(mass): fuel = get_fuel_requirement(mass) if fuel is 0: return 0 return fuel + get_total_fuel_requirement(fuel) def main(): fi...
275392922beeeb4502011cd0e8264c2e9fcb0387
mlovell82/python
/webserver.py
1,776
3.875
4
# this code written by Dr. Jong Hoon Kim from socket import * serverPort = 12000 # an int variable representing a port ServerSocket = socket(AF_INET, SOCK_STREAM) # list with 2 strings (SOCK_STREAM is for TCP, AF_INET defines web based instead of packet based serverSocket.bind(('',serverPort)) #...
e76d778e37b0341dfcf8d9780e82ea7d9115ce3f
Coliverfelt/Desafios_Python
/Desafio060_c.py
445
4.1875
4
# Exercício Python 060: Faça um programa que leia um número qualquer e mostre o seu fatorial. # Ex: 5! = 5 x 4 x 3 x 2 x 1 = 120 from math import factorial numero = int(input('Digite um número: ')) fatorial = factorial(numero) print('{}! = '.format(numero), end='') while numero >= 1: if numero != 1: print...
d51a64233f0ef1a36a461e460d0262baf936f59f
DoubleIA/Algorithms
/python/n_bst.py
399
3.515625
4
def count_bst(n): if n <= 1: return n b = [0] * (n + 1) print b b[0] = 1 b[1] = 1 for i in range(2, n+1): for j in range(i): print i, j, i - 1 - j b[i] += b[j] * b[i - 1 - j] return b[n] if __name__ == "__main__": print count_bst(0) print cou...
b20b8e500023fbb77ec1528c24a6a31f355d7e71
qwerty1092/Coursera
/week1/synth/solution.py
246
3.765625
4
import sys digits = sys.argv[1] digits=str(digits) i, j = 0, 0 for letter in digits: if not letter.isdigit(): print(f"Please correct input: {letter}") j=1 break i+=int(letter) if j==0: print(i)
5a95cfae84b276a50e8bf3a66cbba36bba9c9bfb
julianhasse/Python_course
/29_sorting_lists.py
366
3.984375
4
# numbers = [1, 5, 21, 123, 0, 2] # numbers.sort() # # or # numbers.sort(reverse=True) # print(numbers) # print(sorted(numbers)) # print(numbers) # Sorting using Lambda Functions items = [ ("Product1", 10), ("Product2", 9), ("Product3", 12) ] # lambda function syntax: lambda parameter(s):expresion item...
16b8a1c2fa411a1bc786d6554c749ee4c86534e0
yang-collect/data_struct
/树/114. 二叉树展开为链表.py
921
4.0625
4
# 给你二叉树的根结点 root ,请你将它展开为一个单链表: # 展开后的单链表应该同样使用 TreeNode ,其中 right 子指针指向链表中下一个结点,而左子指针始终为 null 。 # 展开后的单链表应该与二叉树 先序遍历 顺序相同。 # 来源:力扣(LeetCode) # 链接:https://leetcode-cn.com/problems/flatten-binary-tree-to-linked-list # 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 def flatten(root): if not root: return # ...
0e355c5d2a1673725ac4e6ca55f6c2ed2addf0e8
way2arun/datastructures_algorithms
/src/arrays/subset_array.py
796
4.28125
4
""" This is to find an array is a subset of an another array. """ def isArraySubset(array1, array2, m, n): i = 0 j = 0 for i in range(n): for j in range(m): if array2[i] == array1[j]: break # If the above inner loop was # not broken at all then array2[i]...
3e3b41ca071dd64a487f0c49a51deb7eaef90701
hhoangphuoc/data-structures-and-algorithms
/data-structure-questions/binary_tree/level_order_traversal.py
1,285
4.5
4
# -*- coding: UTF-8 -*- # Level order tree traversal ''' Level order traversal of a tree is also called breadth first traversal of the tree. METHOD 1: (Use function to print a given level) Time complexity: O(n*n) ''' import binary_tree def level_order_traversal_helper(root, level): '''Print the node if the le...
a6aecc76304a09192888c1e05e411eb39336258e
malcolmcalhoun/Network-App
/IP_reachability_checker.py
983
3.546875
4
import sys import subprocess def ip_reachability(list): #define a function to determine if the ip addresses in the list are reachable(turned on and connected) for ip in list: #for every ip address in the list ip = ip.rstrip("\n") #strip the ip address of newline characters ...
c973365bdb18bce00c8080b339621358fb39ceb8
Satily/leetcode_python_solution
/solutions/solution101.py
837
4.03125
4
from data_structure import TreeNode, build_binary_tree class Solution: def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ def check_symmetric(r0, r1): if r0 is None and r1 is None: return True elif r0 is None or r1...
a8b0b918bf60a8478192f06790be0007e551870b
m-sousa/curso-em-video-python
/Exercicios/MOD02/ex067.py
501
4.125
4
# Exercício Python 067: Faça um programa que mostre a tabuada de vários números, # um de cada vez, para cada valor digitado pelo usuário. O # programa será interrompido quando o número solicitado # for negativo. while True: n = int(input('Digite um ...
29e1bd062d8767cade8deeed835fa2654eddab2c
tyasuda-github/gyogan
/argv.py
661
3.5625
4
# # -*- coding: utf-8 -*- # $Date: 2021/10/08 00:17:54 $ # import sys print('sys.argv : ', sys.argv) print('type(sys.argv) : ', type(sys.argv)) print() print('sys.argv[0]) : ', sys.argv[0]) print('type(sys.argv[0]) : ', type(sys.argv[0])) print() print('len(sys.argv) : ', len(sy...
be7ad308b7d76e1fa4580a23fe32845a08cfe501
Ming-H/leetcode
/605.can-place-flowers.py
578
3.84375
4
# # @lc app=leetcode id=605 lang=python3 # # [605] Can Place Flowers # # @lc code=start class Solution: def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool: """ Time complexity : O(n) Space complexity : O(1) """ i = 0 count = 0 while i<len(flowerb...
b95aad590a76ad0533c0fd2a5066d704666f12a3
benlbroussard/project-euler
/04_largest_palindrome_product.py
1,422
4.09375
4
text = """Largest palindrome product Problem 4 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. Find the largest palindrome made from the product of two 3-digit numbers. """ print(text) import time import math # helper: build a pa...
ffbb6316d88908266c830f11ba51ad28fee691c0
anklav24/Python-Education
/A-Byte-of-Python/9_3_for.py
153
4
4
for i in range(1, 5): print(i) else: print('Loop \'for\' finish') for i in range(1, 10, 2): print(i) else: print('Loop \'for\' finish')
ccb0672b3aaec6901a2c786e09a5546151257665
infestonn/practicepython
/draw_a_game_board.py
304
4.125
4
def draw_board(row=3, col=3): for i in range(0, row): print(" ---"*col) print("| "*(col + 1)) print(" ---"*col) if __name__ == "__main__": row = int(raw_input("Input number of rows: ")) col = int(raw_input("Input number of columns: ")) draw_board(row=row, col=col)
cb56d6e59567c3713f2b9fff7efea89ed5d29c77
atbohara/basic-ds-algo
/linkedlist/rearrange_pairs.py
1,420
4.25
4
"""Rearrange node-pairs in a given linked list. Demonstration of 'runner' technique. """ from linked_list import Node from linked_list import LinkedList def rearrange_pairs(orig_list): """Modifies the input list in-place. O(N). """ slow_ptr = orig_list.head fast_ptr = orig_list.head while fas...
93722e170363906b79e5b27980751e8bd4a0b994
JDavidStevens/python_intro_workshop
/practice.py
2,079
4.25
4
# # declare a variable # x = 42 # print(f"x={x}") # # numbers # x = int(4) # y = int('5') # z = float(5) # print(f"x = {x}, y={y}, & z={z}") # # boolean types # # True = 1 & False = 0 # x = True + False # print(f"x={x}") # # add number and string # x = 3 # print(str(x)+" Three") # # or # y = 'three' # print(int(x)+3...
246a4a281f7f474817d3716056eee875cfc19da7
scan3ls/holbertonschool-higher_level_programming
/0x03-python-data_structures/9-max_integer.py
252
3.609375
4
#!/usr/bin/python3 def max_integer(my_list=[]): length = len(my_list) biggest = -10000 if length == 0: return (None) for i in range(length): if my_list[i] > biggest: biggest = my_list[i] return (biggest)
e124e135bf9751217f4205478a36d18bcedbfc5a
tokuD/atcoder
/abc/B/216.py
120
3.546875
4
N = int(input()) ST = [input() for _ in range(N)] st = set(ST) if len(st) == N: print('No') else: print('Yes')
3f9bc1a880b919a6335fb100dbd9d26bfacdac7f
Aiden-Jeon/Algorithm
/src/acmicpc/2021/17299.py
631
3.609375
4
""" title: 오등큰수 date: 2021-04-04 - problem number: 17299 - link: https://www.acmicpc.net/problem/17299 --- ## Define input, output - Input: - Output: ## 설명 """ import sys from collections import Counter N = int(sys.stdin.readline()) array = list(map(int, sys.stdin.readline().strip().split(" "))) cnt = Counter(a...
764bb209c8ec096e310b7c49bc958d05c3b4e14b
cosmologist10/Algorithms
/hackerrank/array/reverse_list.py
437
4.28125
4
import time def reverse_list(): """ Take a list of numbers from user and print the reverse order as a single line of space-seperated integers. """ x = [] while True: try: y = int(input("enter a number:")) x.append(y) print(x) except: ...
48f577b476e132160ff343c4f5ec34b6013bbb5f
DavideTimo/hello-world
/Esercizio_05.py
684
3.734375
4
""" Questa è la doc_string del modulo. Questa descrizione è richiamabile con nomemodulo.__doc. Max tra Tre Numeri Scrivi una funzione che prende stavolta tre numeri come parametro e restituisce il più grande tra loro! """ def soluzione5(a,b,c): if a >= b and a >= c: max = a elif b >= a...
261fb6a6da856d710b70b9f25a44efbb79876fbb
Narcissus7/LeetCode
/2020.01.07-494.py
3,639
3.640625
4
""" 494. 目标和 https://leetcode-cn.com/problems/target-sum/ 给定一个非负整数数组,a1, a2, ..., an, 和一个目标数,S。现在你有两个符号 + 和 -。对于数组中的任意一个整数, 你都可以从 + 或 -中选择一个符号添加在前面。 返回可以使最终数组和为目标数 S 的所有添加符号的方法数。 示例 1: 输入: nums: [1, 1, 1, 1, 1], S: 3 输出: 5 解释: -1+1+1+1+1 = 3 +1-1+1+1+1 = 3 +1+1-1+1+1 = 3 +1+1+1-1+1 = 3 +1+1+1+1-1 = 3 一共有5种方法让最终目标和为3...
a8147d1a156328a2dd4574a61add9676240013a9
RibRibble/python_april_2017
/Cody_Williams/OOP/cardGame.py
1,384
3.859375
4
import random class Card(object): def __init__(self, suit, value): self.suit = suit self.value = value class Deck(object): def __init__(self): #build the deck of card objects self.deck = [] self.reset() self.shuffle() def reset(self): self.deck = [] suits = ['Clubs', 'Spades', 'Diamonds', 'Hearts'...
1ee2b500d269abcad80740535a7824c5766d06b2
fstoltz/schoolwork
/Datastructures and algorithms/DSALibrary_fredriks/InsertionSort.py
766
3.9375
4
from random import randint from time import time def insertionSort(li): for index in range(1, len(li)): currentVal = li[index] position = index while position > 0 and li[position-1] > currentVal: li[position] = li[position-1] position = position-1 li[position] = currentVal #myList = [87,33,105,3...
c3dbc22aa22e25b0dad3fcde21f929954defc243
AlyMetwaly/python-scripts
/miscellaous/list.py
273
3.671875
4
fruits = ['Apples', 'Oranges', 'Bananas'] quantities = [5, 3, 4] prices = [1.50, 2.25, 0.89] i = 0 output = [] for fruit in fruits: temp_qty = quantities[i] temp_price = prices[i] output.append((fruit, temp_qty, temp_price)) i += 1 print(output)
6c3d122dfefcfadd8a5f7666a585680110359989
aespyro/CSE7-Classes
/CSE7 Classes.py
3,721
4.0625
4
#Inheritance: for Dummies #30 Classes #Every class must have its own method #Every class must have a constructor moves = 0 global(score) = 0 class Character(object): def __init__(self, name, hp, defense, attack): self.name = name self.hp = hp self.defense = defense self.attack = atta...
3fad415c2af8f63fbcd4ce70aed52017cd642353
Chairmichael/ProjectEuler
/Python/Complete/0003b - Largest prime factor.py
1,063
4
4
#/usr/bin/env # 0003b - Largest prime factor.py ''' The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? ''' def is_prime(n): if n == 2 or n == 3: return True if n < 2 or not n % 2: return False if n < 9: return True if not n % 3: return False ...
612f3f59a7bc1d87418fa665e010ca955854f6ad
adonisbodea02/Fundamentals-of-Programming
/Achi/Domain.py
9,919
3.75
4
from texttable import Texttable import unittest from unittest import TestCase class Board: def __init__(self): self.data = [[" "," "," "],[" "," "," "],[" "," "," "]] def readFromFile(self, fname): with open(fname, 'r') as f: lines = f.readlines() i = 0 for...
1d3ffa3b1c5ee727ea54d048864f8c120b18d708
Shweta1312/Currency-demonition
/currency_denomination.py
1,712
3.703125
4
till_amount = int(input("Amount required in till(In INR): ")) d={} count=1 currency=[1,2,5,10,20,50,100,200,500,2000] while count>0: tot=0 n= int(input("\nHow many types of denomination do you want:")) m=n print("\nEnter the no. of notes with their denominations\n[FORMAT: 4 50 ...(4 notes of Rs.50)]"...
6912e9049c82aad8a6145bae1b92e8b74db02e1f
schemaorg/schemaorg
/software/util/textutils.py
1,106
3.5625
4
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- import re def StripHtmlTags(source): """Strip all HTML tags from source.""" if source and len(source) > 0: return re.sub('<[^<]+?>', '', source) return '' def ShortenOnSentence(source, lengthHint=250): """Shorten source at a sentence boundary. Args: s...
064edc7cbd55c1e8e0510d049c28ce00c2c458b2
jordan-hamilton/325-Homework-1
/insertsort.py
1,313
4.15625
4
#!/usr/bin/env python3 # Open the file with the passed name as read only, using the readlines method to insert each line into a list, then # return the created list. def openFile(fileName): with open(fileName, 'r') as file: contents = file.readlines() return contents # Append each element in the pas...
2c94ba4103b54be1917ebb27c415950238501898
AnantMishra123/GCI2018_anantmishra_1
/MyFirstTask.py
660
4.34375
4
<<<<<<< HEAD for i in range(0,10): print("GCI is great") # Python code to reverse a string # using loop def reverse(s): str = "" for i in s: str = i + str return str name=input("what is your name? ") print ("Hello",name,"pleased to meet you!") ======= for i in range(0,10): print("GCI is g...
b62617c17c79ccac2d0f2a132c80370a5214de36
ilegorreta/test_ilegorreta
/detecting_change.py
533
3.6875
4
# -*- coding: utf-8 -*- import pandas as pd def main(): df = pd.read_csv('datasets/weather.csv') flag = None bad_weather = [] for row in df.iterrows(): if row[1][1] == True and flag == False: bad_weather.append([row[1][0], row[1][1]]) flag = True elif row[1][1] ...
c024e6123004fb08aa765f2e1a443d5d05738c8f
fingerman/python_fundamentals
/python-fundamentals/6.9.regex_FishStatistics.py
2,359
3.84375
4
''' Problem 09. Fish Statistics You are a marine biologist tasked with researching various types of fish. You will receive a single line on the console as input. From this line, you must extract all the fish you find and print statistics about each one. Fish are categorized by three criteria: tail length, body length a...
fd5d741900603e9a0e7c7d40410352551be7048d
ClodaghMurphy/pandsproject2019
/15analysis.py
699
3.75
4
#05042019 Investigate the DataSet #Data Visualisation with pands and matplotlib functions #Code adapted from # Basic Analysis of the Iris Data set Using Python by Oluwasogo Oluwafemi Ogundowole #https://medium.com/codebagng/basic-analysis-of-the-iris-data-set-using-python-2995618a6342 #Import pandas and matplotlib modu...
f7a8d06be8d3560afe8fd461efe871630f4f1489
tillyoswellwheeler/module-02_python-learning
/ch02_operations-strings-variables/ch02_tilly.py
1,182
4.03125
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 29 13:51:06 2018 @author: 612383362 """ #--------------------------------------------------------------------------------------- # CHAPTER TWO - Introduction to calculations, printing variables and string munipulation. #---------------------------------------------------...
a8b87e432b778a9f02b7409055b8431382ce1395
mauza/kata
/2020/May/MothersDay/run.py
1,769
3.515625
4
import time import utils as u me = '8018217046@msg.fi.google.com' lori = '8013108931@vtext.com' HOUR = 3600 MINUTE = 60 def main(): time.sleep(5*MINUTE) u.send_text('It has started', [me]) print('It has started') # Initial message u.send_text('Incoming messages! for security they will be obfuscat...
8bf90528c6d7c1464f4af0884767f0c881e0d2e6
SS-Runen/Code-Wars-Scripts
/Code Wars Moving Zeros To The End 2.py
508
3.53125
4
def move_zeroes(array): new_array = [] for number in array: if number != 0 or (isinstance(number, bool)): new_array.append(number) diff = len(array) - len(new_array) for i in range(diff): new_array.append(0) return new_array second_test = [ Fal...
e7201cf6ba47976566a398ddbf20952c4fcd36a1
HelixAngler/Univ-Assignment-Bank-
/bank.py
3,382
3.984375
4
#Customer Class class Customer(object): def __init__(self,listing): self.categories = listing self.check="" while True: try: self.first=input("First").upper() self.last=input("Last").upper() self.check=self.first+"_"+self.last ...
cf539a16a00d115d807a506aed7d875f13bbd958
PiKaChu-R/code-learn
/program/sort_search/Hash_search.py
1,547
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @File : Hash_search.py @Time : 2019/06/24 15:12:45 @Author : R. @Version : 1.0 @Contact : 827710637@qq.com @Desc : 哈希查找 ''' ''' 算法流程: 1.用给定的哈希函数构造哈希表; 2.根据选择的冲突处理方法解决地址冲突; 3.在哈希表的基础上执行哈希查找 复杂度:对于无冲突的hash表而言,查找复...
958574c12ba5db4f4b4998883960cd7e78a56dbf
liuyonggg/youngcoders
/prime.py
751
4
4
def is_prime(n): for i in range(2, n-1): if n % i == 0: return False return True def test_prime(): assert (is_prime(3)) assert (not is_prime(4)) assert (is_prime(13)) assert (not is_prime(15)) def get_nth_prime(nth): p = 2 number_of_prime = 0 while True: ...
a444b3125335589cba6386e8626edac560d5b868
jameswmccarty/AdventOfCode2018
/day14.py
5,459
3.96875
4
#!/usr/bin/python """ --- Day 14: Chocolate Charts --- You finally have a chance to look at all of the produce moving around. Chocolate, cinnamon, mint, chili peppers, nutmeg, vanilla... the Elves must be growing these plants to make hot chocolate! As you realize this, you hear a conversation in the distance. Wh...
3a58eaa2632d8dee22ac935ccf409d4478ccad41
MilanMolnar/Codecool_SI_week1
/Set A/SetA_2.py
2,621
3.640625
4
import time import sys def sprint(str): for c in str + '\n': sys.stdout.write(c) sys.stdout.flush() time.sleep(0.8 / 1) def exitu(exit_parameter): while True: e = input(exit_parameter) if e == "exit": exit() elif e == "start": ...
8c284981d22aef08d11549c7f3041db49f17f610
evgenblaghodir/pyproject
/funct.py
181
4
4
def cube(number): print(number*number*number) def by_three(number): if(number%3 == 0): print(cube(number)) else: print("False") number=6 cube(number) by_three(number)
4248e16335d67f6e81e20d38fc286c8700eabe8b
khf0008/BIOL-3001
/ssDNA to dsDNA calculator.py
2,315
4.15625
4
#this python program will calculate the percent of nucleotides in a single-stranded DNA. It will also give the percent of cytosine if the ssDNA was double stranded print("This program will help you grade lab 8 exercise 2 in BIOL 30001 lab.") Startup = "y" #initializes while loop so user can grade for as long as the...
a6031ecbca29d5e3160fafab799c703ba25f09e0
nfbarrett/CCIS-1505-02
/Session08/Session8 InClass/inClass5.py
494
4.09375
4
def GetNames(): """This function collects names from keyboard and returns a list of names""" lstNames = [] blnDone = False while blnDone == False: strName = input("Enter a name or press ENTER when done: ") if len(strName) > 0: #Did user enter a name lstNames.append(strName.t...
70eca8b89fc5fec7c4d62af9c72392f664ffc3aa
kaiwensun/leetcode
/2501-3000/2614.Prime In Diagonal.py
547
3.625
4
IS_PRIME = [True] * (4 * 10 ** 6 + 1) IS_PRIME[0] = IS_PRIME[1] = False sqrt = len(IS_PRIME) // 2 + 1 for base in range(2, sqrt): if not IS_PRIME[base]: continue for num in range(base * 2, sqrt, base): IS_PRIME[num] = False class Solution: def diagonalPrime(self, nums: List[List[int]]) -> i...
21ea15622dcd12dce79459f3c7ffbaae9e96c6d2
ltzp/LeetCode
/DFS/回溯/LeetCode60_star.py
914
3.53125
4
class Solution(object): res = [] def getPermutation(self, n, k): """ :type n: int :type k: int :rtype: str """ self.target = k used = [False] * (n+1) self.dfs(n, used,[]) result = "" for i in self.res: result += str(i) ...
9720e98ce765be23d5a80388e0a0c2f1aa3350af
onestarshang/leetcode
/reverse-integer.py
330
4.03125
4
""" http://oj.leetcode.com/problems/reverse-integer/ Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 """ class Solution: # @return an integer def reverse(self, x): if x == 0: return 0 sign = x / abs(x) return sign * int(str(abs(x...
535e0219527ea99e1063adbca19c791ce55da1c7
QinlangQC/NLP
/hw2/CKY.py
4,711
3.625
4
""" Implement CKY algorithm to parse sentences """ from math import * import json, sys class Parameters: "Store the parameters need" def __init__(self): self.xyz = {} self.xw = {} self.nonterminal = {} self.unary_rule = {} self.binary_rule = {} ...
d656259a1304356f10bbccb7e3df52fa735d5f7b
PrairieSchool/Python_Challenge
/PyBank/main_Bank.py
1,297
3.796875
4
import os import csv BudgetData = open("budget_data.csv") # print(BudgetData.read()) print("Financial Analysis") print("-------------------") # Count number of months reader = csv.reader(BudgetData,delimiter = ",") months = list(reader) MoCount = len(months) - 1 print("Total number of Months:", MoCount) with open(...
ae2475b0c3f28d584c7616467f23be08aa5ad6f4
ZGRochelleDev/coding-challenges
/assignment1/Recursive functions/extra-numsSmallerThanCurrent.py
2,223
4.125
4
#Leetcode problem 1365 #How Many Numbers Are Smaller Than the Current Number #Example of using a frequency array class Solution: def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: #sorting # nums = [8,1,2,2,3] # index: [0,1,2,3,4] # nums: [1,2,2,3,8] # outpu...
14e2e023a2716a499dc89c4c8ac4cfbb23da48ca
avedensky/quick-python-code-snapshots
/files_remove/remove_files_by_time.py
1,423
3.828125
4
#!/usr/bin/python3.3 # -*- coding: utf-8 -*- import os import os.path import datetime """ Script remove files in the selected directory by last modification time argument 1: workdir argument 2: file exctension (format example:.txt or * for all argument 3: time of life file """ def removeTemporyFiles (wo...
68508bd4f3b8b79b1de021f609e402b2a62b6dde
ChawinTan/algorithms-and-data-structures
/Trees/pre_order_traversal.py
891
3.640625
4
''' iterative ''' class Solution(object): def preorderTraversal(self, root): """ :type root: TreeNode :rtype: List[int] """ if not root: return [] stack, res = [root], [] while stack: temp = stack.pop() res.append(t...
98a247c67a7143cbebfbd7fd8f5be681b99f01aa
ajay-panchal-099/Project
/Some Small Opencv Projects/dummy.py
168
3.71875
4
from datetime import datetime import time val1 = datetime.now() time.sleep(1) val2 = datetime.now() difference = val2 - val1 print(difference.total_seconds())
b8c8ee6223975e4a80856954121c9cb8a36d9090
Aasthaengg/IBMdataset
/Python_codes/p02536/s868024277.py
2,479
4.5
4
""" Union Find 木クラス 参考URL:https://note.nkmk.me/python-union-find/ parents 各要素の親要素の番号を格納するリスト 要素が根(ルート)の場合は-(そのグループの要素数)を格納する 例: parents[2] = 0 → 要素2の親は0 parents[0] = -3 → 要素0は根であり、そのグループの要素数は3個 """ class UnionFind(): # 初期化(初期状態は全要素が根) def __init__(self, n): self.n = n self.parents = [-1...
5775d2cc6efa51b911f4444505af2ef1b6f8a7c9
sravyaysk/chatbot-for-booking-cabs-restaurants
/chatbot v2/Intents.py
1,425
3.515625
4
from abc import ABCMeta, abstractmethod class Intent(object): def __init__(self, name, params, action): self.InputContexts = [] self.OutputContexts = [] self.name = name self.action = action self.params = [] for param in params: # print param['required'] self.params += [Parameter(para...
a46ecd608765bfcd5e2e25258f5e4ce221ab7c1b
anoirtrabelsi/TicTacToe
/TicTacToe.py
5,665
3.6875
4
import pygame pygame.init() class Grid: def __init__(self): #empty board self.board = [['','',''], ['','',''], ['','','']] w, h = pygame.display.get_surface().get_size() self.s = w // 3 def draw (self, window): #draw grid lines: s = self.s pygame.draw.l...
d141dc259743bc5e5146a82f64ead2ca9921f245
Taneristique/taneristique_mathmodules_tests
/modules/definite.py
2,571
4.09375
4
from sympy import Matrix, symbols from sympy.plotting import plot3d def sounds_definite(B): """takes a matrix than returns if it is positive definite,negative definite,semi definite or not definite than ask user if they would want to draw it as 3d if user responds 'no' returns ok see you! if user says yes it s...
f7dda63fd50a43ee24861ea76cf10ce9131e7b8f
geokhoury/htu-ictc6-python-webapp-development
/W6/S1/exception_handling/exception_basics.py
1,205
4.28125
4
# import module sys to get the type of exception import sys # > How to use a try...except block to catch exceptions? numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # numbers = [1, 2, 3, 4, 5, 'a', 0, 8, 9, 10] for number in numbers: try: print(f"n = {number} and 1/n = {1/number}\n") except Exception as e: ...
4d6ded565c66040d6e069bc48253be3c54418b24
DriveMyScream/Python
/11_inheritance/01_inheritance.py
551
3.578125
4
class Employee: company = "Microsoft" def companyName(self): print(f"The Name of Company is {self.company}") class Progremmer1(Employee): language = "Python" def WorkingOn(self): print(f"Working on a Youtube with language {self.language}") class Progremmer2(Employee): la...
d261ab9bb11ff0da9c9bff08565a5f363264f0b8
VaijanathSawrate/PYCHARM
/mymain.py
225
3.9375
4
import numberword print("__name__value for this file: ", __name__) print("__name__ value for numberword: ", numberword.__name__) userInput = input("Enter any number:") numberword.printNumberToWords((int(userInput)))
8cbc44d2bb5d9010d3d0724a23e7a2668f0d3018
tvtheanh/waitercaller
/user.py
606
3.640625
4
"""We need to create a User class that can work with flask_login. We will have some methods that look redundant. """ class User: def __init__(self, email): self.email = email def get_id(self): '''This method is required. And returns a unique identifier. ''' return self.email ...
1d812e93beaab31738d45fbaeee2b68a683ab20f
isabella232/supertagging
/util.py
390
4.125
4
def blockwise(f): """ Reads from a file-like object and splits its contents into "blocks" separated by empty lines. Yields each block as a list of rstripped lines. """ block = [] for line in f: line = line.rstrip() if line: block.append(line) else: ...
bb41512ce68dd449e2c99ea5a393934eda9db41c
wchen02/python-leetcode
/Questions/69-SqrtX.py
635
3.890625
4
from typing import List # See details here https://wenshengchen.com/2020/01/14/69-sqrt-x.html class Solution: def mySqrt(self, x: int) -> int: lo, hi = 0, x while lo <= hi: mid = lo + (hi-lo)//2 square = mid**2 if square == x: return mid ...
13c4680cfdf33e26dd9d58adbbf99a495a3ac3eb
lovehhf/LeetCode
/剑指offer/面试题14- I. 剪绳子.py
1,290
3.78125
4
# -*- coding:utf-8 -*- """ 给你一根长度为 n 的绳子,请把绳子剪成整数长度的 m 段(m、n都是整数,n>1并且m>1),每段绳子的长度记为 k[0],k[1]...k[m] 。请问 k[0]*k[1]*...*k[m] 可能的最大乘积是多少? 例如,当绳子的长度是8时,我们把它剪成长度分别为2、3、3的三段,此时得到的最大乘积是18。 示例 1: 输入: 2 输出: 1 解释: 2 = 1 + 1, 1 × 1 = 1 示例 2: 输入: 10 输出: 36 解释: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36 来源:力扣(LeetCode) 链接:https://leetco...
d5d5c4097bb5db62e0620bd5e0b4e330d9f7d116
willcgoulart/algoritmos_programacao2
/Algoritmos II/Exercicio01/pessoa.py
116
3.640625
4
nome=input('Qual o seu nome') idade=input('Qual a sua idade') peso=input('Qual seu peso') print(nome, idade, peso)
477e25c0a6a5e9795b2061c7fac32dcd15dfa99c
Gijoe614/Madlibs_remade
/mad_libs revised.py
1,112
3.78125
4
# Variables person = raw_input("please enter a persons name:") pet = raw_input("a type of pet:") color = raw_input("a color:") example = raw_input("example of that color:") place = raw_input("a place:") group = raw_input("a group:") person2 = raw_input("another person:") adverb = raw_input("an adverb:") action = raw_in...
b14bcb156da44b39fc135d3ad5c6706a257f9a7e
ericfp87/day-15---coffee_machine
/main.py
4,927
3.921875
4
from coffee import MENU from coffee import resources quarters = 0.25 dime = 0.10 nickel = 0.05 penny = 0.01 def machine(): escolha = input("O que você gostaria? (espresso, latte, cappuccino): ") def coins(): q1 = quarters * float(input("Quantos quarters? ($0,25 cada): ")) d1 = dime * float(i...
c9be4e77981df1319aca5e584a4fcea57057c604
bezdomniy/unsw
/COMP9021/Assignment_3/ring.py
5,753
3.65625
4
from collections import Iterable class Ring(list): def __init__(self,_data=[]): if isinstance(_data,set): raise TypeError("'set' object is not subscriptable") elif isinstance(_data,int): raise TypeError("'int' object is not subscriptable") elif isinstance(_da...
65ea869d81938dfe8ea9923dbc04f79b8ec51aa2
eric-do/technical-prompts
/system_design/golden_ticket/solution.py
1,967
3.71875
4
class Solution: def exchange_money_for_chocolate(self, ppc, wpc, wallet) -> int: if ppc <= 0: return 0 wrappers = self.exchange_currency_for_chocolate(ppc, wallet) total = wrappers while wrappers >= wpc: exchanged_chocolates = self.exchange_currency_for_choco...
94004cbb7e82e70e73d3593da753ecc9ffff0919
ahparikh/euler
/001/main.py
474
3.78125
4
def sum_divisble_by(number, maxval): n = maxval / number return number * (((n+1) * n) / 2) def solution_sexy(): print (sum_divisble_by(3, 999) + sum_divisble_by(5, 999) - sum_divisble_by(15, 999)) def solution_brute(): tot = 0 x = 3 while x < 1000: tot += x x += 3 x = 5 while x...
d8e60bd3e794cbc575a6e9febbd5435fd2bd06d1
valeriacavalcanti/ALP-2020-R
/Bimestre_02_Aula_03/atividade_individual/questao03.py
277
3.921875
4
antes = float(input("Informe o valor antes: ")) durante = float(input("Informe o valor durante: ")) if (antes > durante): reducao = ((antes - durante) / antes) * 100 print(f'-{reducao}%') else: aumento = ((durante - antes) / antes) * 100 print(f'+{aumento}%')
07a6fe44bcbc4f646eb5b4bfc091dae026250fa0
786440445/scrapy_demo
/src/match.py
708
3.625
4
import re # 匹配网址 def match_url(): pattern = "[a-zA-Z]+://[^\s]*[.com|.cn]" string = "<a href = 'http://www.baidu.com'>百度首页</a>" result = re.search(pattern, string) print(result) # 匹配电话号码 def match_mobile_num(): pattern = "\d{4}-\d{7}|\d{3}-\d{8}" string = "021-645627782343523424" result = r...
4d89aa0b7e62d8e0fdd67b7da3bf379b62a9a047
Khaledherzi/feats
/feats/feats_utils.py
1,272
3.59375
4
import numpy as np from sklearn.preprocessing import normalize # Function to normalize the features of X def FeatureNormalize(sc, norm): """ Computes and stores the normalized gene expression data stored in SingleCell object. Parameters ---------- sc : SingleCell The SingleCell ob...
1149f0d92fd3d8144c8341a5992f9459144ec521
witherellt21/Lab12
/modules/math/infinity.py
416
3.875
4
INFINITY = "-" def addWithInfinity(a, b): """Adds a and b, with the possibility that either might be infinity.""" return 0 def minWithInfinity(a, b): """Finds the minimum of a and b, with the possibility that either might be infinity.""" return 0 def lessThanWithInfinity(a, b): ...
269a68a22ac50a4e03f8609a58718d48356737db
StavrGeek/Lesson_1
/Task_6.py
459
3.703125
4
first_day_res = int(input("Введите результат пробежки за первый день в км: ")) wish_res = int(input("Введите желаемый результат в км: ")) result_day = 1 result = first_day_res while result <= wish_res: result += result * 0.1 result_day += 1 print(f"На {result_day:d}-й день спортсмен достиг результата не менее ...