blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f1fecf9edb3ea8f1224cd9f4fdca3fb263c0c9ff
maurovasconcelos/Ola-Mundo
/Python/aula21.py
431
4.1875
4
#----------------------------------------------------------------------------------------------------------------------- def somar(a=0,b=0,c=0): """ -> faz a soma de 3 valores e mostra o resultado :param a: primeiro valor :param b: segundo valor :param c: terceiro valor """ s = a + b + c...
f3269e6fa845a3cc679d0d5a4eb06a8cd850d6a7
AshokDon/Data-structures
/stack.py
649
3.671875
4
''' stack data structure books-->A B C D stack representation D-->Top C B A stack contains push and pop operations ''' class Stack(): def __init__(self): self.items=[] def push(self,item): return self.items.append(item) def pop(self): return self.items.pop() def ...
763f01c3f6e41bed8c88d72977b213482becda8c
harverywxu/algorithm_python
/01_string/02longest_substr/1044.最长重复子串.py
3,917
3.953125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 1044. Longest Duplicate Substring Given a string S, consider all duplicated substrings: (contiguous) substrings of S that occur 2 or more times. (The occurrences may overlap.) Return any duplicated substring that has the longest possible length. (If S does not have...
4552871c851a571c2b1bd68b5703c7e8d726c2ea
Vedsted/Internet_of_Things
/other/led.py
855
3.71875
4
import pycom pycom.heartbeat(False) def turn_on_led(color): pycom.rgbled(color) def turn_off_led(): pycom.rgbled(0x0) # 0x0 equals to black or turned off def rgbToInt(red, green, blue): red = int(bin(red) + "0000000000000000", 2) green = int(bin(green)+"00000000", 2) return red + green + blue ...
19eb2cc0920918884b25ebdf8c82612eaa547e01
qqmadeinchina/myhomeocde
/homework_zero_class/lesson5/homework/水仙花数.py
2,560
3.875
4
#!D:\Program Files\Anaconda3 # -*- coding: utf-8 -*- # @Time : 2020/7/11 21:32 # @Author : 老萝卜 # @File : 水仙花数.py # @Software: PyCharm Community Edition print("1000以内的水仙花数如下:") i = 0 while i < 1000 - 1: i += 1 if i < 10: mi = 1 elif i < 100: mi = 2 else: mi = 3 num1 = i % 10...
5ab53c441f10cad3bd36534248157e899fc1a9b8
kakakaya/boppy
/boppy/plugin/xmas.py
526
3.5625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author: kakakaya, Date: Mon Oct 24 13:25:35 2016 # from pprint import pprint as p import datetime import re def check_xmas(): now = datetime.datetime.now() if (now.month, now.day) == (12, 25): return True else: return False def is_xmas(robot...
f65c329afc211aedc385468a30b2d48d554fe133
Wjun0/python-
/day07/03-读取文件中的数据-r模式.py
741
3.515625
4
# r模式:以字符串的方式读取文件中的数据 # 第一步:打开文件, 默认是在当前工程目录里面去找对应的文件 # 1. 要打开的文件 # 2. 文件的操作模式,默认是r模式 file = open("test.txt", "r", encoding="utf-8") # 查看打开文件后的编码格式 # cp936其实就是GBK编码格式 print(file.encoding) # 第二步:读取数据 content = file.read() # 表示一次性读取文件中的所有数据 print(content, type(content)) # 第三步: 关闭文件 file.close() # r模式的注意点: # 1. 操作的文件必...
443ea8946cb00ba53bcb1655d26e5bc0d9e2cf09
VladRusakov/Deck
/card.py
954
3.734375
4
suits = ["пик", "червей", "бубен", "треф"] values = ["6", "7", "8", "9", "10", "Валет", "Дама", "Король", "Туз"] class Card: def __init__(self, value: "int or str", suit: str): if(not(isinstance(value, int) or isinstance(value, str)) or not(isinstance(suit, str))): raise TypeE...
e3abfd486b1c083eeaa05aba71f3d59dddcb6dc8
mayassheeb/maya-sheeb
/lessons/recorjion.py
954
4.03125
4
import turtle turtle.shape ("turtle") # def tree(branchLen,t): # if branchLen > 5: # t.forward(branchLen) # t.right(20) # tree(branchLen-15,t) # t.left(40) # tree(branchLen-15,t) # t.right(20) # t.backward(branchLen) # def main(): # t = turtle.Turtle() ...
bd8aea338be2e123a6796ef8bd3070ccc574f725
lloydamiller/automation-hps
/samples/intro-to-python.py
2,251
4.34375
4
# This is a comment """ This is a multi-line comment """ # import statements always go at the top of your file import random # use the randint method to generate a random number between 0.0 and 1.0 and assign to the variable rf rf = random.random() # use the randint method to generate a random integer between 0-10 ...
32fc3118d0454eef6bebbb167e9051d55765434e
Xfan0225/python-BasicPrograming
/OJ自行练习/冰雹游戏.py
305
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 27 22:58:00 2019 @author: xie """ x =int(input()) if x == 1: print('1') while x != 1: while x %2 == 1: x = 3*x +1 print(int(x)) while x %2 == 0: x = x/2 print(int(x))
10c2db56ae40ec380e150eb1e89a8c07515b9cfe
GintarasGaucys/TicTacToe
/functions.py
1,335
3.75
4
enterboard = {(1, 1): 0, (1, 2): 1, (1, 3):2, (2, 1): 3, (2, 2):4, (2, 3):5, (3, 1):6, (3, 2):7, (3, 3):8} board = [" ", " ", " ", " ", " ", " ", " ", " ", " "] #Checks for win of sym and returns True or False def checkWin(sym, theboard=board): if theboard[4] == sym: if theboa...
bd14094ed38a789401a71418c8221721e2ea5068
charapod/noregr-and-ic
/regret.py
663
3.515625
4
# Module computing the regret for a sequence of actions. import numpy as np def regret(loss_lst, num_experts, algo_loss, T): loss_per_expert = [] for i in range(num_experts): s = 0 for t in range(T + 1): s += loss_lst[t][i] loss_per_expert.append(s) tot_algo_loss = sum(...
e5aae9e0916bdb4c89b1d2ba3c582870f7844785
Adnan-Aziz/PythonPractice
/grade.py
604
3.5625
4
def getGrades(fname): try : gradeFile = open(fname,'r') except IOError : raise ValueError("getGrades could not open {0}".format(fname)) grades = [] for line in gradeFile: try: grades.append(float(line)) except ValueError: raise ValueError("Unable t...
1337ee4a616e33554bd8f8bcec01b3308da3009b
jocogum10/organize-files-using-python
/organizeDocument.py
2,255
3.8125
4
#! python3 # organizes your PDf documents base on whether the filename has a keyword you are looking for # usage: run command - python3 organizeDocument.py '{filetype}' '{keyword}' '{working directory}' '{destination folder}' import shutil, os, sys # 1. store the keywords, working directory, and destination director...
3afca43aa59bfe64c0a5e075d9cdcbbc522e00c0
hagemajr/exercism
/acronym/acronym.py
354
3.6875
4
def abbreviate(phrase): return ''.join([x for x in phrase.title() if x.upper() == x and x.isalpha()]) #print(abbreviate('Portable Network Graphics')) #print(abbreviate('Ruby on Rails')) #print(abbreviate('First In, First Out')) #print(abbreviate('GNU Image Manipulation Program')) #print(abbreviate('Complementa...
ab0e1c2df7eb4fed35dc71224bf1811f3e36a75d
awong05/epi
/count-the-number-of-moves-to-climb-stairs.py
1,198
4.09375
4
""" You are climbing stairs. You can advance 1 to k steps at a time. Your destination is exactly n steps up. Write a program which takes as inputs n and k and returns the number of ways in which you can get to your destination. For example, if n = 4 and k = 2, there are five ways in which to get to the destination: - ...
c04975ea7370a755acfe37a34b6536b3f727929a
juanmadlg/Policy-Iteration
/policy_iteration/Utils.py
793
3.625
4
def print_v(v, n: int): """ Print Grid ----------- v : np_array Array that stores the function value for each state. n : int Size of the Grid World """ grid = "" for i, v in enumerate(v): grid = grid + f"{v:.2f}" + (f'\n' if (i + 1) % n == 0 else '\t') print(grid) ...
0b101d341773f95e687eca7afeff6ab6ea822b49
gabriellaec/desoft-analise-exercicios
/backup/user_058/ch61_2019_11_08_21_05_37_606864.py
241
3.859375
4
def eh_palindromo(string): fraseinvertida=[] index = len(string) while index > 0: fraseinvertida += string[ index - 1 ] index = index - 1 if fraseinvertida == string: return True else: return False
cf1303f276f7ffecf63e30af823e1313893266bc
vyshor/LeetCode
/Remove Duplicates from Sorted Array.py
614
3.53125
4
class Solution: def removeDuplicates(self, nums: List[int]) -> int: unique_pt = 0 checker = 1 while checker < len(nums): if nums[checker] != nums[unique_pt]: nums[unique_pt+1], nums[checker] = nums[checker], nums[unique_pt+1] unique_pt += 1 ...
5bf65ab649048d65fd054c98972603f6ed841e47
lhzaccarelli/thm-scripts
/psychobreak/script.py
928
3.859375
4
import os # Wordlist filename WL_FILENAME = "random.dic" #Program name P_FILENAME = "program" #Main function def main(): print("Starting...") #Call function to read the lines of the file lines = read_file(WL_FILENAME) #Read line by line for line in lines: ret = execute_program(line) #Check if the output ...
390fbb9198883d4e2524f6d4943b242dac1d0597
fnatanoy/toxic_comments_classification
/plotting_utils/plot_words_cdf.py
1,002
3.53125
4
import matplotlib.pyplot import numpy class WordsCdfPlotter: def plot( self, word_count_obj, ): word_count = [ item[1] for item in word_count_obj.items() ] word_count = numpy.asarray(word_count) word_count[::-1].sort() n_words = n...
b6d132be7f3138c136e3f8728f6ec7167e45d94f
kernowal/projecteuler
/38.py
890
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: alexogilvie Project Euler Problem 38: Pandigital multiples What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , n) where n > 1? """ import time timer = time.time() def isPandigit...
902e9e693a19d332fdc19b1ffebaf027fdb5a3a1
chat-code/leetcode-everyday
/past/20191229_457/duangduang.py
1,177
3.703125
4
from typing import List class Solution: def circularArrayLoop(self, nums: List[int]) -> bool: cur = left = 0 right = len(nums) - 1 visited = set() cur_visited = set() def step(x): r = (nums[x] + x) % len(nums) return r def check_single(sta...
d88aea5e836c5131b94f2ed4b325098fb0d2c718
jaquinocode/my-algorithms-python
/binary_search_tree_algoexpert.py
3,157
3.671875
4
from collections import deque class BST: def __init__(self, value, parent=None): self.value = value self.left = None self.right = None self.parent = parent def get_child(self, direction): if direction == 'left': return self.left elif direction == 'right': return se...
fcc3b82faebb50c2af161725dee7b8c1ab2be7e8
ryanbhayward/games-puzzles-algorithms
/nim/fib-iterative.py
180
3.65625
4
''' iterative fibonacci, with remembering ''' def fib(n): F = [0,1] for j in range(2,n+1): F.append(F[j-1] + F[j-2]) return F[n] for j in range(41): print(j, fib(j))
67471597b6d1602c0e85abb64a2af4da09045e92
rising-entropy/Assignment-Archives
/DAA/Assignment 1/Q1.py
745
4.0625
4
# You are given two sorted array, A and B, where A has a large enough buffer at the end to hold B. # Write a method to merge B into A in sorted order. emptySpace = None A = [1, 2, 3, 9, emptySpace, emptySpace, emptySpace, emptySpace, emptySpace] B = [4, 5, 6, 7, 8] elementsA = 4 elementsB = 5 def mergeBintoA(A, B, ...
09802766fd19912b90bdb47a970009b5bf453039
kcmao/leetcode_exercise
/jianzhioffer2/39_数组中出现次数超过一半的数字.py
655
3.9375
4
def more_than_half_num(numbers): if numbers is None or len(numbers) == 0: return 0 result = numbers[0] count = 1 for i in range(1, len(numbers)): if result == numbers[i]: count += 1 else: count -= 1 if count == 0: result = numbers[i] ...
35b37d5465c38600d74e45072cd537cafeb65e58
ohentony/Aprendendo-python
/Coleções em python/Listas em python/ex007.py
1,164
3.90625
4
# Faça um programa que leia nome e peso de várias pessoas, guardando tudo em uma lista. No final, # mostre: # A) Quantas pessoas foram cadastradas. # B) Uma listagem com as pessoas mais pesadas. # C) Uma listagem com as pessoas mais leves. pessoas = list() dados = list() # Lista utilizada para auxiliar na obtenção dos...
98f2cfecd424a20488aec0d63f08dff32c14034a
Vonewman/python_app
/classes/employee/employee.py
1,663
3.578125
4
class Employee: raise_amt = 1.04 def __init__(self, first, last): self.first = first self.last = last @property def email(self): return '{}.{}@email.com'.format(self.first, self.last) @property def fullname(self): return '{} {}'.format(self.first, self.last) ...
efb069a11ddab08de8691e009607591d9a27962c
WannaBeAGameDeveloper/PyLearner
/My-100-Days/Day002/E002-03.py
213
3.828125
4
#判断输入的年份是不是闰年 y = eval(input('请输入年份:')) if y % 4 == 0 and y % 100 != 0 or y % 400 == 0: print('{}年是闰年!'.format(y)) else: print('{}年不是闰年!'.format(y))
5a41bf1e5bb15773e83786e55fdeff2638d162d5
SlawekMaciejewski/Python_exercises
/structures/heap.py
361
3.71875
4
import random from heapq import heappush, heappop def heapsort(iterable): heap = [] for value in iterable: heappush(heap, value) return [heappop(heap) for i in range(len(heap))] if __name__ == '__main__': random_list = random.sample(range(100), 10) print(random_list) sorted_list = heap...
3355b746a3796d55470c6a36b29eb73dac3ee27b
Rahul-Thakur7/python-small-projects
/pythontkinter programms/DataStoring.py
981
3.984375
4
from tkinter import * import sqlite3 root = Tk() root.configure(bg='sky blue') root.geometry("400x400") root.title("Login page") a=StringVar() b=StringVar() def login(): db=sqlite3.connect('MUKUND.db') cr=db.cursor() cr.execute("insert into login values('"+a.get()+"', '"+b.get()+"...
b33cc3ae746f05ad9ae2d000b1b58e9f3ef310a3
hermitbaby/leetcode
/leetcode/Gray Code.py
994
3.921875
4
# The gray code is a binary numeral system where two successive values differ in only one bit. # # Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. # # For example, given n = 2, return [0,1,3,2]. Its gray code sequ...
7865959df78b0ca3194eb6396c00ba5d73076123
abuelgheit/problem_solving
/time_convert.py
203
3.890625
4
def TimeConvert(num): num = int(num) hours = int(num/60) mint = num%60 time = "%d:%d" % (hours, mint) return time # keep this function call here print(TimeConvert(input()))
5e3446e5c11c36d8aa11c5bff87af123fc54ad39
ycyoes/pypractise
/com/turing/foundation/chapter5/custom_func.py
265
3.890625
4
def fibs(num): result = [0, 1] for i in range(num - 2): result.append(result[-2] + result[-1]) return result print(fibs(10)) def square(x): 'Calculates the square of the number x.' return x * x print(square.__doc__) print(help(square))
7d6f1f7be6dc70a5760bcb53b9610388b8df431d
satooltama/PycharmProjects
/week3.1/list.py
706
3.703125
4
myList = [] print('TYPE = {}'.format(type(myList))) myList += ['AAA','BBB','CCC'] print(myList) myList.append('DDD') print(myList) print(myList[0]) myList[0] = 'EEE' print(myList) ok = 'ddd' in myList # True , False if 'ddd' in myList: print(myList.index('ddd')) print('*'*30) for i in range(len(myList)): print(...
904b058a8dea590c6c53d2c93440d2fb570572a3
d3cr1pt0r/AdventOfCode2016
/day_1.py
1,602
3.703125
4
import math def has_visited(x, y): for i in range(len(visited_x)): vx = visited_x[i] vy = visited_y[i] if vx == x and vy == y: return True return False def distance(x, y): return abs(x) + abs(y) input = "L2, L3, L3, L4, R1, R2, L3, R3, R3, L1, L3, R2, R3, L3, R4, R3, R...
93a0ff6b261a089704eae16426f95a07ce9ca162
snailQQ/lxf_python
/9_2CustomClass.py
2,536
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 看到类似__slots__这种形如__xxx__的变量或者函数名就要注意,这些在Python中是有特殊用途的。 # __slots__我们已经知道怎么用了,__len__()方法我们也知道是为了能让class作用于len()函数。 # 除此之外,Python的class中还有许多这样有特殊用途的函数,可以帮助我们定制类。 # __str__ class Student(object): def __init__(self, name): self.name = name #adding bel...
34818d81cb9cdc59a9d169ecaeb53d6bc0a34a96
srodriguez1357/algoritmos
/DiegoSofi1.py
774
3.859375
4
input("Buenos días chicos, este es un juego para ver qué tan bien aprendieron los tipos de datos") print("Dberán de escribir int, char, str o float, según el tipo de valor que aparezca en pantalla") input("Presiona enter para continuar") Score=0 op1 = input("A: ") if op1 == "char": Score = Score+1 op2 = input("1:...
c411a59570d185ea003db337a6d207a25ee56c57
chuanyedadiao/Python-Practice
/course/10/10-11.py
506
4.03125
4
import json def read_in(): number = input("Please enter you favorite number:") try: with open("number.txt","w") as num: json.dump(number,num) except FileNotFoundError: print("number.txt is not found") def read_out(): try: with open("number.txt") as num: ...
8210db655df8afb21f808b884eac62ef88c5c203
okurerenalp/ass-nment-10
/Assignment 10#1.py
562
3.765625
4
import pyAesCrypt def encrypt(filename,password): pyAesCrypt.encryptFile(filename, (filename + ".enc"), password) def decryp(filename,password): f = filename[:-4] pyAesCrypt.decryptFile(filename, f, password) command = input("Press 'e' to encrypt and 'd' for decrypt: ") filename = input("Enter...
91d0f395325177bec50568895e2432d8e2b8132e
amat17mir/coding-in-chem
/electron_configuration_generate.py
872
3.890625
4
elem = input(“What is the atomic number?“) elem = int(elem) electronconfig = “” orbital = [“1s”, “2s,” “2p”, “3s”, “3p”, “4s”, “3d”, “4p”, “5s”, “4d”, “5p”, “6s”, “4f”, “5d”, “6p”, “7s”, “5f”, “6d”, “7p”] # break down the electrons into valence shells s, p, d, and f def valence (v): global valence if v[1] == “s” ...
06cb18d0eb935c95a79c3a49c4f4e090ca8be39d
wrroberts/Rosalind
/057_DBRU.py
1,334
3.640625
4
#!/usr/bin/env python ''' A solution to a ROSALIND bioinformatics problem. Problem Title: Constructing a De Bruijn Graph Rosalind ID: DBRU Rosalind #: 057 URL: http://rosalind.info/problems/dbru/ ''' from string import maketrans def ReverseComplementDNA(dna): '''Returns the reverse complement of a given DNA strand....
c0118e6bacc1fab5bc44432180bdf739d123882b
fxw97/SDU-GIG-course
/Data analysis/2.huairou.py
901
3.53125
4
import pandas as pd # 读取数据 data = pd.read_csv('1.huairou.csv') # print(data) # 更改时间分辨率之前,需要把时间列更改为pandas可以识别的时间格式,并设置为索引 data['time'] = pd.to_datetime(data['time']) data.set_index('time',inplace=True) # print(data) # 更改数据的时间分辨率为6小时,并保存 data_6h = data.resample('6H').mean() # print(data_6h) data_6h.to_csv('2.huairou_6...
a59154e0e16f713633fd32fac60ff7a4551825bf
Fleschier/Python
/My Python Programs/CH5/.idea/1627405072_E027.py
209
3.8125
4
s=input('请输入一个字符串:') if len(s)<=2: #讨论字符串长度小于2的情况 print('') else: print('{}{}'.format(s[0:2],s[-2:])) #输出新字符串
4dcc3e1fc68b20bb85849ac05c6d372463637026
u101022119/NTHU10220PHYS290000
/student/100011247/HW2/mandelbrot.py
371
3.59375
4
import math import numpy as np from matplotlib.pylab import * Nx=[] Ny=[] def iterate(x,y): a=0 b=0 for i in range(100): A=a**2-b**2+x B=2*a*b+y a=round(A,5) b=round(B,5) z=a**2+b**2 if z>2: Nx.append(x) Ny.append(y) break return i for i in np.arange(-2,3,0.05): for j in np.arange(-2,3,0....
e086ce89fa3a2aab719dad07cdd61654f0b8d69a
aloktripathy/keywords-collect
/src/regex/grouping.py
378
3.640625
4
import re ''' Pattern to match HTML tags ''' pattern = re.compile(r''' (?: <(?P<tag>\w+)> #starting tag (?P<content>(?![\d]+).*) #content </(?P=tag)> #ending tag ) +? ''', re.X | re.DOTALL | re.I) pattern2 = re.compile(r'\W+') while True: string = str(input("Enter a st...
e219f371b902e238d7f26a90a7d76e6b93e3b3a9
Rushi21-kesh/30DayOfPython
/Day-17/Day_17_Mohit.py
555
4.15625
4
# Implement a Queue in Python. Also perform Enqueue and Dequeue Operations. lst = [] i = int(input("Enter the lenth of the Queue : ")) def fun(i, lst): k = input("enter your choice to do operation Enqueue or Dequeue : ") for n in range(0, i+1): if (k == "enqueue"): ele = int(input("Elemen...
039a3d009d9ea9f3fc597bb45779156528625d76
jubayera/python_code
/most_frequent.py
676
4.0625
4
# Implement most frequent item in a list def most_frequent(given_list): max_count = -1 max_item = None count = {} # dictionary, at ith key of count assign value for i in given_list: if i not in count: count[i] = 1 else: count[i] += 1 if count[i] > ma...
c3f730e805cf088cd28899d4c75516ba5a5c8963
sisodiyajayrajsinh1702/Python_Exercise
/ConsultADD - Task 1.py
2,420
4.28125
4
# 1.) Create 3 Variables in a single line. a, b, c = 1, 2.01, 'string' print(a, b, c) # 2.) Create a variable of type complex and swap it with another variable of type integer. d = 1 + 2j d = 5 print(d) # 3.) Swap two numbers using a third variable and do the same task without using any third variable. # Using 3rd v...
6e5c5dc2c298aa30a268a1f7c61aeadf3ea6c866
alessandrofd/PythonCookbook
/chapter02/Recipe2_19.py
14,563
3.96875
4
__author__ = 'Alessandro' # In this problem, we're focused on the problem of parsing text according to a particular grammar. In order to do this, # you should probably start by having a formal specification of the grammar in the form of a BNF or EBNF. For example, # a grammar fo simple arithmetic expressions might loo...
8d263d426fcc8a3b7e2111f7491f7c2dac836028
jcshott/interview_prep
/interview_cake/love_rect.py
3,084
4.15625
4
def find_x_overlap(rect1, rect2): """find horizontal overlap""" # if our second rectangle bottom corner starts to the right of first if rect2['left_x'] > rect1['left_x']: # find bottom_right, which is bottom right of rect1 bottom_right_x = rect1['left_x'] + rect1['width'] # 11 # if t...
77d07623ed3aac8a5eafe3d4f7fff7e55a5a5795
boulund/adventofcode
/2021/Day_02_Dive/02.py
1,752
4.125
4
#!/usr/bin/env python """AdventOfCode Day 2: Dive!""" __author__ = "Fredrik Boulund" __date__ = "2021-12-02" from sys import argv, exit import argparse def parse_args(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("problem_input") if len(argv) < 2: parser.print_help(...
1776c4dfb3f3feca9b7514809c6d123e94cf2e8d
agatanow/pmds
/lab3_docker/lab3.py
4,730
3.515625
4
import sqlite3 as sql from datetime import datetime as dt # PARTICULAR SQL STATEMENTS USED IN THIS FILE # Creates table for songs CREATE_SONG_TABLE = ( 'CREATE TABLE SONG (' 'perform_id VARCHAR(18) NOT NULL, ' 'id VARCHAR(18) NOT NULL, ' 'artist VARCHAR(256) NOT NULL, ' 'title VARC...
b06005fcbdbace975183f6d49b702a7ba79b7453
josbel/uip-iiig2016-prog3
/laboratorio/laboratorio_3/laboratorio_3.py
268
4.15625
4
while True: preg = input ("preguntale a juan: ") if preg.endswhith('?'): print("ofi") elif preg >= 'A' and preg <= 'Z': print ("chilea") elif (len(preg)==0): print ("Mmm") else: print ("me da igual")
8992c76426f4585bf9138166c7023526bb20b095
zsoltkebel/university-code
/python/CS1028/practicals/lec2/example1.py
313
4
4
salary = float(input("Please enter salary: ")) age = int(input("Please enter age: ")) name = input("Please enter your name: ") letter = input("Please enter your favourite letter: ") print("The salary is ", salary) print("Your age is ", age) print("Your name is ", name) print("Your favourite letter is", letter)
06d58e35fb146dba3f6f14a2bbaeab3ea062e709
GreatSoulSam/PythonlibPublic
/Algorythms/binary heap.py
1,436
3.953125
4
# Если в куче изменяется один из элементов, то она может перестать # удовлетворять свойству упорядоченности. Для восстановления этого свойства # служат процедуры siftDown (просеивание вниз) и siftUp (просеивание вверх). # Если значение измененного элемента увеличивается, # то свойства кучи восстанавливаются функцией...
c643ea72d2221c9fc1005c6215b571698094b7b9
mmore500/hstrat
/hstrat/_auxiliary_lib/_anytree_has_sibling.py
442
3.921875
4
import anytree def anytree_has_sibling(node: anytree.node) -> bool: """Check whether the given node has at least one sibling in the Anytree tree. Parameters ---------- node : anytree.node The node to check for siblings. Returns ------- bool True if the node has at lea...
4066d0389766a67c7873d6e5e14a64cb3ccd3559
DrillND/ML_DL_git
/mldl/practice.py
106
3.59375
4
import numpy as np test_array = np.array([1, 2, 3, 4]) print(test_array) print(test_array.reshape(-1, 1))
14164c4e10196845da8bca8aade954d5aa722376
Amrithnath/46-python-excercises
/ex32-palindromev2.py
842
3.640625
4
#!/usr/bin/python import sys import os import time def fileinp(): mydata=[] if(len(sys.argv)>1): filein=sys.argv[1] else: filein=input("please enter the file name with extension") ifile=open(filein,'r') for line in ifile: mydata.append(line) return mydata def is_palindrome(data): data=(data.strip()).l...
b559b4d541f10dcf6fe955cf50d1daa771bb526d
brinascode/gradle-hello-spring
/py-library/PY native/file_work.py
1,132
4.4375
4
# Reading from a file def reading(file): with open(file, "r") as my_file: contents = my_file.readlines() # Returns the file contents in an array with each line as an item contents2 = my_file.read() # Returns the file contents as a string #print(contents) print(contents2) ...
6e70450fdb79795978ffdafd72f792402c4d90d6
vishipayyallore/LearningPython_2019
/Intermediate/Day4/1VEnvAndPipInstallDemos/source/writeexcelfile.py
377
3.609375
4
import openpyxl as excel filepath = '../Data/students.xlsx' workbook = excel.load_workbook(filepath) currentsheet = workbook['Mar2019'] for row in range( 2, currentsheet.max_row+1): sum = 0 for col in range(3, 6): sum += int(currentsheet.cell(row, col).value) total = currentsheet.cell(row...
badb04c082a32d8ae4ef779e28bb0f841d05bd3a
HyunSung-Na/TIL-algorism
/알고리즘/주사위게임.py
684
3.5
4
from itertools import product def list_move(S): stack = [] for num in range(1, S+1): stack.append(num) return stack def solution(monster, S1, S2, S3): range_move = S1 + S2 + S3 + 2 place = set([(m - 1) for m in monster if m <= range_move]) result = 0 first_move = list_move(S1) ...
00b9fd3f5cb061d6824dcb87c70f80082264d313
koshelev-dmitry/Elements_of_codding_interviews_in_python
/chap_5_arrays/5.3_multiply_arb.py
566
3.8125
4
def multiply_two_nums(num1, num2): sign = -1 if (num1[0] < 0) ^ (num2[0] < 0) else 1 num1[0] = abs(num1[0]) num2[0] = abs(num2[0]) result = [0]*(len(num1) + len(num2)) for i in reversed(range(len(num1))): for j in reversed(range(len(num2))): result[i+j+1] += num1[i] * num2[j] ...
a1d5113c89ea8da5f5d5e279660de25c10c7e13d
JoshWidrick/python-ai-notes
/nltk-notes/stop-words-2.py
463
4
4
from nltk.corpus import stopwords from nltk.tokenize import word_tokenize example_text = 'This is an example showing off stop word filtration.' stop_words = set(stopwords.words('english')) # print(stop_words words = word_tokenize(example_text) # filtered_text = [] # for w in words: # if w not in stop_words: #...
7dce44a24260e9b8e159211f8ab1aa085ea45a03
therealdandong/DojoAssigments
/Python/pythonfundamental/list to dictionary.py
745
3.90625
4
name = ["Anna", "Eli", "Pariece", "Brendan", "Amy", "Shane", "Oscar"] favorite_animal = ["horse", "cat", "spider", "giraffe", "ticks", "dolphins", "llamas", "apple", "banana"] def make_dict(list1, list2): new_dict = {} for i in range(len(name)): new_dict[list1[i]] = list2[i] return new_dict ...
b2f00d2e543f1922a4c35967038b5d9d4064c6ed
jhayer/Bioinfo
/RevComp.py
994
3.9375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ##### Written by Hadrien Gourlé. Feel free to use and modify ##### Description="Script that gives you the reverse complement of a sequence." import argparse parser=argparse.ArgumentParser(description=Description) parser.add_argument("filetype",choices=["s","f"], help="Fil...
f162da780c965361272fe1d10ec932fb26bd4681
Matheus-Pontes/Curso-Python-3
/aula_9/ex26.py
468
4.25
4
# VERIFICANDO QUANDO APARECE Á LETRA 'A' nome = str(input("Digite seu nome: ")).strip().upper() # Quantidade de vezes print("A letra A aparece {} vezes.".format(nome.count("A"))) # count = contar # posição print("A letra A aparece na posição {}.".format(nome.find("A"))) # procura e informa a primeira posição...
507cd1e57aedaba705c21a91c02080b0a76e9250
adrielk/ConnectX
/Connect4Game.py
2,118
3.640625
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 26 19:55:03 2020 Connect 4 - Text Version Exact same implementation as TicTacToe but with game baord's gravity enabled! @author: Adriel Kim """ from GameBoardClass import GameGrid as grid #Dependancy that deals with managing player turns and round set up for games impo...
742743c89aebea8baf74f092ff274521b08f009a
rabiatuylek/Python
/for-while.py
1,168
3.921875
4
#while(True): # print("sad") # yukarıdaki dongu cesidi , sonsuz bir dongudur. Kosul true oldugu sürece dönmeye devam edecektir. #index = 0 #while index<100: # print("ındex degeri :",index) # index = index + 10 # 1 ile 1000 arasında yer alan cift sayıları yazdır #sayi = 2 #while sayi<=1000: # print("sa...
5d3eae3d58c14eceb6de8efe34abb595704f69f3
marco8111/python
/exercicio2.4.py
472
3.953125
4
A = int(input("Insira tamanho de lado A:")) B = int(input("Insira tamanho de lado B:")) C = int(input("Insira tamanho de lado c:")) if (A <= B + C) and (B <= A + C) and (C <= A + B) : print("Estes Valores formam um triangulo") else : print("estes valores nao formam um triangulo") if A == B and B == C : pr...
c2e7d56cb1ca78b15ed522d80731a38490123a0f
triptii01/pythonprograms
/str25.py
121
3.734375
4
#select any element randomly from the list and will give its index value l = [2,4,5,3] print(l) x = l.index(5) print(x)
163adc6112eed3c68d414030f82b2186cc69bb1c
peterhsprenger/VuRProjects
/TrainingResources/03workingsnippets/index.cgi
205
3.859375
4
#!/Python26/python print('Content-type: text/html\r\n\r') hrs = raw_input("Enter Hours:") h = float(hrs) if h <= 40: salary = h*10.5 else: salary = 40*10.5 + (h-40)*(10.5*1.5) print(salary)
7fcfac1de91677310c820910c40e0c750b1b60db
sendurr/spring-grading
/submission - Homework3/set2/TRET C BURDETTE_11074_assignsubmission_file_Homework 3/Homework 3/P1.py
242
3.53125
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 26 16:54:54 2016 @author: Tret Burdette """ from math import* def area(x1,y1,x2,y2,x3,y3): A=0.5*abs(x2*y3 - x3*y2 - x1*y3 + x3*y1 + x1*y2 - x2*y1) return A print "area=", area (0,0,1,0,0,2)
e86cf248a0d260cd018151717c332acb989303b2
sgo101/code-trainning
/DataSci/calc.py
498
3.703125
4
def bmi(height, weight): return round(weight / height ** 2, 2) def meter(inch): return round(inch / 39.37, 2) def kg(pound): return round(pound / 2.205, 2) def bmi_status(bmi): if bmi <= 18.5: return 'Underweight' elif bmi > 18.5 and bmi < 24.9: return 'Normal' else: return 'Overweight' def count(n,...
3f4991d99131c8f88045da869780464be92ad0ac
jayeeta1987/TicTacToe
/drawframe.py
4,495
4.1875
4
from tkinter import * import human, computer # This function used to open a window in center postion of system def center(toplevel): toplevel.update_idletasks() w = toplevel.winfo_screenwidth() h = toplevel.winfo_screenheight() size = tuple(int(_) for _ in toplevel.geometry().split('+')[0].split('x')) ...
2a01ced3f87abacdb6532a8cb333f87551865344
TyDunn/hackerrank-python
/GfG/Doubly Linked List/dll_delete.py
1,408
3.796875
4
#!/bin/python3 class Node: def __init__(self, data): self.data = data self.next = None self.prev = None class DoublyLinkedList: def __init__(self): self.head = None def push(self, new_data): new_node = Node(new_data) new_node.next = self.head if self.head: self.head.prev = new_node self.head ...
ae795b2bf8ab3dbe3bd305fac1b4079c2cd3d52c
rafaelperazzo/programacao-web
/moodledata/vpl_data/59/usersdata/195/48877/submittedfiles/testes.py
138
3.78125
4
# -*- coding: utf-8 -*- i=int(input('digite i:')) if i<18 and i>=60: print('facultativo') if i>=18 and i<60: print('obrigatório')
d11cd7f65bf651cb618c1063b8a6c51bed6f59b2
shilpasayura/algohack
/code-basic/class.py
393
3.671875
4
class Car(object): wheels = 4 def __init__(self, make, model): self.make = make self.model = model def start(self): print("..brroom", self.make, self.model, "started") myCar = Car("Suzuki", "Swift") yourCar = Car("Ford", "Mastang") print (myCar.make, "Wheels", myCar.wheels) myCa...
40157f1a23f9346d0f1b49563f86475ac8896459
Azurekuz/SuperMinimax354
/old_agents/eugenek_players.py
5,509
3.578125
4
# adapted by Toby Dragon from original source code by Al Sweigart, available with creative commons license: https://inventwithpython.com/#donate #Eugene Kuznetsov import random import copy from collections import deque class HumanPlayer: def __init__(self, symbol): self.symbol = symbol def get_move(...
a13c91eddc5bd0aef45bd06625ec644cac9218d4
eyetpn/crypto
/caesar.py
890
3.84375
4
from helpers import alphabet_position, rotate_character new_text = str(input("Type a message:")) rotate = int(input("Please enter rotation:")) return_text = "" #enter_text = x.upper dictionary = 'abcdefghijklmnopqrstuvwxyz' #dictionary = ['a','b','c','d','e','f','g','h','i','j','k','l','m', #'n','o','p','q','r','s','t'...
112c1ccd854cd955b1d6c09c4b54efa38eddeacf
shaidazmin/MissionPaython
/LogicalOperator.py
362
4.21875
4
# logical and = and # logical or = or # let's see ..... user = input("Enter Your Names first Latter : ") user2 = input("Enter Your Love Names first Latter : ") if user == 'n' and user2 == 'z': print(user +" love lot of you " + user2) if user == 'n' or user2 == 'z': print("She loves you but don't Marry You") ...
ab24a845ce9d945af6ec9476346e283c396e9cf4
kevinjyee/PythonExcercises
/Excercise02_13.py
385
4.125
4
'''(Split digits) Write a program that prompts the user to enter a four-digit integer and displays the number in reverse order. Here is a sample run:''' def main(): integertoPrint =str(eval(input("Enter an integer: "))); integertoPrint[::-1]; num = int(integertoPrint) while(num > 0): print(...
d79a540230590b7ed6af950029b8dcdfdca708d2
tobias-fyi/vela
/cs/lambda_cs/03_data_structures/binary_search_tree/binary_search_tree.py
5,535
4.125
4
""" Data Structures :: Binary search tree """ import sys sys.path.append("../queue_and_stack") from dll_queue import Queue from dll_stack import Stack class BinarySearchTree: def __init__(self, value): """Implementation of a binary search tree. Each node can be considered a leaf and a complete ...
04036b1b4c81ae9af7496deedd0546e485c28a4f
gistnoor/python-experiment
/module/asyncio/thread/08-thread-subclass.py
488
3.546875
4
# At start-up, a Thread does some basic initialization and then calls its run() method, which calls the target function passed to the constructor. To create a subclass of Thread, override run() to do whatever is necessary. import threading, logging class MyThread(threading.Thread): def run(self): logging.d...
1c777319df5b73bdcec8c22dc4bbf46ada7f71ff
Hamza-Muhammad/assignment3
/florida.py
1,902
3.53125
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('florida.csv') X = dataset.iloc[:, 0:1].values y = dataset.iloc[:, 4].values # Fitting Linear Regression to the dataset from sklearn.linear_model import LinearRegression lin_reg = LinearRegr...
260a96b7e6293f9deb51c3cb8ea05a169ed6f30d
tkoz0/problems-online-judge
/vol_001/p117.py
1,732
3.515625
4
def dijkstra(g,a,b): inf = 1+sum(sum(g[v1][v2] for v2 in g[v1]) for v1 in g) # infinity dist = dict() for v in g: dist[v] = inf dist[a] = 0 queue = [s for s in g] while len(queue) > 0: u = queue[0] queuei = 0 for i in range(1,len(queue)): # pop min if dist[qu...
a51124a22102aee2d993ad22a4cb3095658bf93f
suhanree/network-recommender
/code/using_friends.py
9,496
4.5
4
# Classes that usese friends for recommendations. # Filename: using_friends.py # by Suhan Ree # last edited on 06-21-2015 import numpy as np import itertools class Using_Friends(): """ Class that uses friends or friends of friends for recommendation. It uses information of friends from the given network...
6d461920561ea93645ac7d996908f9d3bd307d9c
agustinaguero97/Sudoku-finale
/Sudoku/antiguo-no-mirar/test_sudoku4.py
7,199
3.765625
4
import unittest from sudoku import Sudoku4 class Test_Sudoku4(unittest.TestCase): def test_board_set(self): game = Sudoku4() game.set_board([ ["", 3, 4, ""], [4, "", "", 2], [1, "", "", 3], ["", 2, 1, ""] ]) print(game.board) ...
2f2248d5d818afd216553a39fa98aa0c51cf2853
MoonByul-E/Games-Search-Web-V1
/test.py
230
3.75
4
test = { 1: {"name": "가", "score": 100}, 2: {"name": "나", "score": 10} } for key, value in test.items(): for key1, value1 in value.items(): print(f"{key}: {key1} - {value1}") print("=================")
c07db2799c1ce46a10905f4d9e5d58c7a3c9e8f3
JamesNowak/Chapter-7-Practice
/7.8.py
393
4.28125
4
# TODO 7.8 Two-Dimensional Lists # Create a two dimensional list that has the months of the year and the days in each month during a non leap year # print the contents of the list months = list([["Jan", 31], ["Feb", 28], ["Mar", 31], ["Apr", 30], ["May", 31], ["June", 30], ["July", 31], ["Aug", 31], ["Sept", 30], ...
c9444b1915cf36093b7ad24a80fa855ea0d7aa2e
aditigupta96/Slide-Puzzle
/work1.py
2,024
3.515625
4
#Slide Puzzle #By project 3 of LNMIIT-CSI Branch #Code begins here #Note : These are the first five functions def terminate(): pygame.quit() sys.exit() def checkForQuit(): for event in pygame.event.get(QUIT): # get all the QUIT events terminate() # terminate if any QUIT events are present for...
2bb7dc3d10bc7142cb46e1738a49864e127f62a9
rodrigosilvanew/pythonexercicios-guanabara
/ex010.py
206
3.828125
4
r = float(input('Quantos reais você tem na carteira? ')) d = r / 3.27 print('Você tem o equivalente a {:.2f} dólares na carteira!'.format(d)) #:.2f = determina que só devem existir duas casas decimais
47b3afec5455e49d9d9314ef34234e29d048b2c5
stacykutyepov/python-cp-cheatsheet
/leet/trees/delnodes.py
874
3.703125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right """ time: n space: n """ class Solution: def delNodes(self, root: TreeNode, to_delete: List[int]) -> List[TreeNode]: ...
a326f714fbb95f48217bcf7a556a9c574f9034db
RakValery/exadel-python-course-2021
/tasks/task02/Area_of_a_triangle.py
2,466
4.40625
4
# main menu import math print("\nWelcome to the triangle area calculation tool.") while True: print("\nMenu:","1. Calculate triangle area by base and height","2. Calculate triangle area by 2 sides and angle between them","3. Exit", sep = "\n") mitem = input("Enter menu item number: ") if mitem == "1": ...
62589ae1468219aa3992876a0a112ae1a8550797
maidougit/python-test
/com/maimai/python/20171103/ListCaseTwo.py
187
3.8125
4
#-*-coding=utf-8-*- # 定义元祖 name =(1, 2, 3, 4, 5, 6) # 元祖叠加输出 print name + name print name * 3 names = list(name) names[1]='我是谁' name = tuple(names) print name
bd6c0c28e1c7ede6be1b8c24fe4de8be5587ecb9
TGlove/AlgorithmLearning
/pyHundredTraining/11-20/T015.py
431
3.859375
4
#-*- coding: UTF-8 -*- # 利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。 # (a>b)?a:b这是条件运算符的基本例子。 score = int(raw_input('please input your mark:')) if score>=90: print 'A' elif score<90 and score>=60: print 'B' elif score<60 and score>=0: print 'C' else: print 'invalid input!'
4c640c54805c478179cb5c462932f55a2aa379ae
Techwrekfix/Starting-out-with-python
/chapter-8/Morse_code_converter.py
3,417
4.84375
5
#This program converts a user string into morse code #ALGORITHM in pseudocode #The main function: # 1.get a string from the user # 2.morse code converter function accepts # string an argurment #The morse code converter function(string): # 1.converts all alphabetic letters in string # to uppercase # 2....
33b2031f6d5b6765bea3f69fe1132358415ef85d
yuxueCode/Python-from-the-very-beginning
/01-Python-basics/03-Python-control-statement/chapter03/branch/sample6.py
539
3.890625
4
high = input("请输入您测量的高压值:") low = input("请输入您测量的低压值:") high = int(high) low = int(low) if (low > 60 and low < 90) and (high > 90 and high < 140): print("您的血压正常,请继续保持健康的生活习惯") else: if low <= 60: print("您的低压过低,请注意补充营养。") elif high <= 90: print("您的高压过低,请加强锻炼,提高心肺功能") else: ...