blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
88b776ce62e4f4a0c6aec9dfd349fc99929ecb07
krishnatiruveedula/ktrepository
/if_else.py
136
4.21875
4
num = int(input("Enter the number: ")) mod =num % 2 if mod > 0 : print("This is ODD numuber") else: print("This is EVEN number.")
d46c887b9ab5f7bb73d9d9741f4c44c5b9e5d8b1
yakshitgupta310/Patterns
/pattern-14(reverse-diamond).py
645
3.90625
4
n = 13 for i in range(n): if i <= (n // 2): for j in range((n // 2) - i + 1): print("*", end="\t") for k in range(i + 1): print("", end="\t") for l in range(i): print("", end="\t") for m in range((n // 2) + 1 - i): print("*"...
95fbf27f30a05e613a017e17d12e88a4900892f3
DaHuO/Supergraph
/codes/CodeJamCrawler/CJ_16_1/16_1_1_Hamukichi_r1aa.py
438
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def compute_last_word(s): answer = s[0] for c in s[1:]: if answer[0] <= c: answer = c + answer else: answer += c return answer def main(): t = int(input()) for i in range(1, t + 1): s ...
2f828f4c61fe447df40adebbc493897a653aeaec
songzi00/python
/Pro/基础/02数据类型/运算符与表达式续集.py
1,395
4.1875
4
""" 位运算符:按位运算符是把数字看做二进制来进行计算 """ # % 按位与运算符 #相应的二进制个位数都为1 ,则该位的结果为1,否则为0 print(5 % 7) """ 5 = 101 7 = 111 101 """ # \ 按位或运算符 #两个二进制位有一个为1时,结果为1 print(5 | 7) """ 5 = 101 7 = 111 111 """ #按位异或运算符 #二进制的两位相异时,结果为1 print(5 ^ 7) """ 101 111 010 """ # ~ 按位取反运算符 #每个二进制数据位取反,1变0,0变1 print(~5) # ...
f91af3d3ae12fbadce8ebebf99b3ebc44d6b9c31
amirfarhat/utilities
/types-and-algorithms/python/priorityqueue.py
4,360
3.59375
4
import random from collections import deque from heap import MaxHeap, MinHeap # ------------------------------------------ QUEUES class PriortyQueueABC: def __init__(self, heap_constructor): self.heap = heap_constructor() # inited by subclasses def __len__(self): return len(self.heap) def insert(self, elemen...
c1a599ba1603559e781182fd9b26b8559204c9aa
AngheloAlf/CIAC-Conglomerado-de-ejercicios
/ejercicios/03 condiciones y ciclos/07 - diferencias entre strings/Code/p2.py
276
3.625
4
A=raw_input('Ingrese A: ') B=raw_input('Ingrese B: ') cont=0 interseccion='' diferencia='' while cont<len(A): if A[cont] in B: interseccion+=A[cont] else: diferencia+=A[cont] cont+=1 print 'interseccion:',interseccion print 'diferencia:',diferencia
1edd0394957f216c7abf8a3dd0b41521f26a44e0
samineup0710/geneses_pythonassignment3rd
/harmonicseries.py
310
4.09375
4
inp =int(input("Enter the number of terms: ")) """set counter to store sum""" s = 0 for i in range(1,inp+1): s =s+(1/i) if i!=0: """to print harmonic series""" print("1/{} + ".format(i), end = " ") """ to print harmonic series sum""" print("\nThe sum of series is",round(s,3))
3af00d208849f6cfb92b1d2c4ffe3a895ababa03
Harris-Logic/Main_Arithmetic_Classifier
/code/Neural_Network_MLPClassifier.py
824
3.5
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 20 19:29:11 2018 @author: yan MLPClassifier¶ """ import pandas as pd import numpy as np import matplotlib.pyplot as plt work_dir = "new.csv" bankdata = pd.read_csv(work_dir) droplist = ['class'] X = bankdata.drop(droplist, axis=1) y = bankdata['class'] from sklearn....
fc41b26a6bc1b0b28d1ced7151e92a64b9048463
NUS-Projects-Amir/CS3243-Project-1
/manhattan_Final.py
7,102
3.875
4
## CS3243 Introduction to Artificial Intelligence # Project 1: k-Puzzle import os import sys import math from collections import deque from Queue import PriorityQueue import time #Class used for Priority Queue class PriorityEntry(object): def __init__(self, priority, data): self.data = data self....
c15b7a0751ace59db58187f070dde7c763148c21
frkngny/sorting_algorithms
/merge_sort.py
1,026
3.78125
4
import random import math index = int(input("index: ")) lower = int(input("lower bound: ")) upper = int(input("upper bound: ")) random.seed(1) A = list() for ind in range(index): value = random.randint(lower, upper) A.append(value) org_list = A.copy() print('original list: ', org_list) r...
0cb49bd7d4f56804062db55acfe826f31a41398b
CnrLwlss/ScientificPython
/Resources/mtDNA.py
1,568
3.875
4
# string package is for analysing text # urllib is for downloading data from the web import string, urllib # Text file derived from http://www.mitomap.org/MITOMAP/HumanMitoSeq URL="http://www.staff.ncl.ac.uk/conor.lawless/ScientificPython/Resources/mtDNA.txt" textfile=urllib.urlopen(URL) lines=textfile.readlines() tex...
b493065983c05d742c2261d9c298cb4956e1d987
Julienpir/sb7-pgz
/sweeper/sweeper.py
5,002
3.765625
4
# To run this game type the command pgzrun mines.py into the terminal whilst in this directory import random import math # Create the top tiles COVER = Actor('cover') FLAG = Actor('flag') # Create a dictionary that stores all the possible bottom tile types TILES = {0: Actor('blank'), 1: Actor('one'), ...
a71f489e041a547da81de9ef63eedce9588e7903
zouxiaohang/PythonicCodeSnippets
/PythonicCodeSnippets/PythonicCodeSnippets.py
425
3.671875
4
# -*- coding:utf-8 -*- #(1)获得正负无穷的float值 '''当涉及 > 和 < 运算时, 所有数都比-inf大, 所有数都比+inf小''' maxFloat = float('inf') minFloat = float('-inf') #(2)交换两个变量值 a, b = b, a #(3)字符串列表的连接 strList = ["Python", "is", "good"] res = ' '.join(strList) #Python is good res = ''.join(strList) #Pythonisgood if __name__ == "__main__"...
90028b87b0375e67eefdb56ba0dfa07c647e044a
lucas-jsvd/python_crash_course_2nd
/python_work/salvar_nun_predileto.py
242
3.75
4
import json filename = "num_predileto.txt" try: numero = int(input("Qual o seu numero predileto? ")) except ValueError: print("Você digitou um valor incorreto.") else: with open(filename, "w") as f: json.dump(numero, f)
da23bd49d98c131157ca0fc520434e87c131e103
pulse-net/sockx
/sockx/receiver/tcp_message_receiver.py
1,181
3.5625
4
""" Server receiver of the file """ import socket from ..constants import * class TCPMessageReceiver: def __init__(self, port=PORT): self.__port = port def receive_message(self): # Create the server socket # TCP socket s = socket.socket(family=socket.AF_INET, type=socket.SOCK...
7149a80bc074b3af8c7bbe524bc02f7ddd6a976f
Joel-Quintyn/Python-Learning
/Name Counter Loop.py
346
3.796875
4
""" SYNOPSIS: This Program Was Rewritten From C On My Learning Journey Of Python, It Is A Name Counter Using While Loop. """ i = 0 while True: name = str(input("Enter A Name: ")) i = i + 1 x = int(input("\nPress 1 To Enter Another Name\nPress 0 To Finish\n")) if x == 0: break print("You Ent...
5572433bd8203c2f11b1b73c680261c53254ed75
hsrambo07/AES_pyaes
/AES.py
3,346
4.03125
4
################################## """AES algorithm using python AES package""" ################################## #before running this file run install the requirements import ast from Crypto.Cipher import AES from Crypto.Random import get_random_bytes #encryption function def encrypt(key, msg): iv = get_rand...
7df5ea92150bce1fe70015d86d30c3f6e7135e33
Hammad214508/Quarantine-Coding
/30-Day-LeetCoding-Challenge/April/Week3/21-LeftColWithAOne.py
2,465
4.21875
4
""" (This problem is an interactive problem.) A binary matrix means that all elements are 0 or 1. For each individual row of the matrix, this row is sorted in non-decreasing order. Given a row-sorted binary matrix binaryMatrix, return leftmost column index(0-indexed) with at least a 1 in it. If such index doesn't exi...
cece3fe8d0a63e9809dec27d423b33292e8750ae
Caqtus/pythonSelfExercise
/oddoreven.py
335
4.1875
4
def oddoreven(): myNumber = int(input('enter number and I will tel you if its odd or even')) if (myNumber % 2 == 0): print('Your number is even') print(f'{myNumber} % 2 - remainder is {myNumber % 2}') else: print('Your number is odd') print(f'{myNumber} % 2 - remainder is {m...
3475914f56b952907a1acd5447a8966c855bae13
EugenenZhou/leetcode
/nowcoder/jzoffer/IsPopOrder.py
1,160
3.859375
4
# 栈的压入弹出顺序 # 输入两个整数序列,第一个序列表示栈的压入顺序, # 请判断第二个序列是否可能为该栈的弹出顺序。 # 假设压入栈的所有数字均不相等。 # 例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列, # 但4,3,5,1,2就不可能是该压栈序列的弹出序列。 # (注意:这两个序列的长度是相等的) ###################################################################### # -*- coding:utf-8 -*- class Solution: def IsPopOrder(self, pus...
0c7983a45eb1887b13a33a2b0f6c79db96e48f9c
haru-256/ExpertPython3_Source
/chapter4/vector_as_dataclass.py
520
3.875
4
from dataclasses import dataclass @dataclass class Vector: x: int y: int def __add__(self, other): """+演算子を使ったベクトルの足し算""" return Vector( self.x + other.x, self.y + other.y, ) def __sub__(self, other): """-演算子を使ったベクトルの引き算""" return Vecto...
087c3b3497da3d3098b97baa625dc4680e879609
arjun1321/BasicPython
/PythonModules/TurtleModule.py
428
3.6875
4
import turtle import time # Square # t = turtle.Pen() # t.forward(50) # t.left(90) # t.forward(50) # t.left(90) # t.forward(50) # t.left(90) # t.forward(50) # Octagon # t = turtle.Pen() # for i in range(0,8): # t.forward(50) # t.left(45) # Star # t = turtle.Pen() # for i in range(1,38): # t.forward(100) ...
3bc96eed0104c3d501baa7fb7ef0a76f049461d1
daanjderuiter/oop_TN
/templates/solarsystem.py
1,793
3.734375
4
from math import sqrt import matplotlib.pyplot as plt from scipy.constants import G, au from vector import Vector class Universe: def __init__(self, dt=60*60*24): """Initialises an empty universe with default time steps of a day""" pass def add_body(self, planet): """Add a body to the...
fbb782563da941f0321d1101a2265e1c01404909
cristianlepore/python_exercises
/Lesson3/decimalToBinary.py
422
3.578125
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 8 12:09:59 2016 @author: ericgrimson """ num = 19 startingNum = num if num < 0: isNeg = True num = abs(num) else: isNeg = False result = '' if num == 0: result = '0' while num > 0: result = str(num % 2) + result num = num // 2 if isNeg: res...
01549c2259aab221243a87c2b86a34d62f943a57
LArchCS/Handwritten-Equation-Recognition-Tensorflow
/processImage/testEqual.py
756
3.65625
4
import os import cv2 from PIL import Image ''' This class is used to seperate single symbol with equation according to its file name length ''' # This class is used to seperate single and equation from the annotated data class TestEqual: def getEqual(self): dataroot = os.getcwd() + "/data/annotated_train/"...
ce3a509e547ece177ed7686ba38d574bac03f622
kolyaskink/python
/search_in_text/search_in_text.py
3,249
3.765625
4
import argparse import re class MyException(Exception): pass def get_config(): """ Parse config file and save data as a dictionary""" try: with open('config.txt') as f: settings = {} for line in f: line = line.strip() settings[(line.split(...
ab0c189a14358c9a7e009b57402bc3ed30bcaf42
ganeshgirase/expression_parser
/lib/base_formatter.py
630
3.53125
4
#! /usr/bin/python # # Base class for all formatter. # class Formatter(object): # Base class for all formatter def __init__(self): # Initialization method # This method can be overriden to set up the value of # output and output_attributes instance variable pass @property def output(self): ...
a91721403c89dd28c110f88925b82278a4cb9ba2
LeiShi/Synthetic-Diagnostics-Platform
/src/python3/sdp/math/interpolation.py
8,629
4.3125
4
"""This module contains some useful interpolation methods """ import numpy as np from scipy.interpolate import BarycentricInterpolator class InterpolationError(Exception): def __init__(self,value): self.value = value def __str__(self): return repr(self.value) class OutofBoundError(Interpolati...
4ff22f39ef7273ec95649cf2036c31f48cdb2f5e
danvb112/introducaoPython
/revisãoDeTudo/exercicio 3.12.py
315
3.8125
4
print("Saiba quanto tempo sua viagem de carro irá durar!!") distancia = int(input(" Digite a distancia em Km que você irá percorrer: ")) velocidadeMedia = int(input("Digite a que velocidade média em Km/h que você irá percorrer: ")) tempo = distancia / velocidadeMedia print ("Seu tempo em horas é: " , tempo)
d6396e1980649d9fcfbe3e5a50f3fb6f37016731
aditya-sengupta/misc
/ProjectEuler/Q19.py
1,067
4.21875
4
"""You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occurs o...
bc8cf4f3f0c6d2a65eb8534c6b26e9c7d1196826
pkrucz00/ASD
/Gotowce/slowniki/spantree.py
2,768
3.53125
4
from math import inf class Node: def __init__(self, val, span): self.val = val self.span = span #(a,b) - przedzial, za ktory odpowiada dany wezel self.intervals = [] #przedzialy zawarte w wezle self.left = None self.right = None def spanTreeInit(data): def spanTr...
7d610474f8178f1b3fee7e004c07c2707f9eb328
MrSyee/algorithm_practice
/math/can_you_eat_your_favorite_candy_on_your_favorite_day.py
4,500
3.90625
4
""" 1744. Can You Eat Your Favorite Candy on Your Favorite Day? (Medium) https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/ You are given a (0-indexed) array of positive integers candiesCount where candiesCount[i] represents the number of candies of the ith type you have. You are also ...
97020f981f868efceb8004a0f470bb1bf72e0b60
santhoshkumar22101999/santhoshkumar
/factorial.py
82
3.671875
4
n=int(input("enter a number")) i=1 while(n>0): i=i*n n=n-1 print(i)
4aa227bf657f4b9d9befcca7558e26bf128e55c8
leogtzr/python_crash_course_book_code_snippets
/default_values1.py
540
3.78125
4
def describe_pet(pet_name, animal_type='dog'): """Display information about a pet.""" print(f"\nI have a {animal_type}.") print(f"My {animal_type}'s name is {pet_name.title()}.") def myf(name='Leo'): print(f"Hello, {name.title()}") describe_pet(pet_name='Willie') myf('Leonardo') myf() # NOTE # Wh...
22be17f5faf23cf6e1c8ef64d3e2f02e76719e82
chinmay232000/learning-python
/sallysshipping.py
1,028
3.84375
4
def cost_of_ground_shipping(weight): if weight>10: print((weight * 4.75 ) + 20) elif weight > 6: print((weight * 4.00 ) + 20) elif weight > 2: print((weight * 3.00 ) + 20) elif weight<=2: print((weight * 1.50 ) + 20) cost_of_premium_ground_shipping = 125 def cost_of_drone_shipping(weight): if ...
eb03dbf82808d2861f2b629bad1e3d45fe676fe0
shiwanibiradar/10days_python
/day2/while/average.py
251
4.40625
4
#Take 10 integers from keyboard using loop #and print their average value on the screen. print("Enter the 10 numbers for addition") i=10 add =0 while i > 0: a=float(input("")) add = add+a i = i-1 print('addition of your 10 numbers are',add/10)
d3234f95398e6e9582e7a2b0ceb320d8f0f62fe9
srikii/git_repocommits
/hw4a.py
1,269
3.53125
4
"""program to read the number od repositories in a given username and also the number of commits for each repository author: srikanth""" import urllib.request import urllib.parse import urllib.error import json import requests import ssl def git_repocommits(n): git_name=n git_url= "https...
ea78927c476246b086cc17e642fa3e0f61819964
isw4/IntroSoftwareEng08_GoogleCalPart2
/meetings/timeslot.py
9,384
3.890625
4
""" Class to represent timeslots and perform some calculations """ import arrow, calc ASCENDING = 1 DESCENDING = -1 class TimeSlot: def __init__(self, contains, begin_datetime, end_datetime): """ TimeSlot object, used to represent time slots. Contains the following fields: contains: a list...
238f2949524b02f984ffc52fcb33a99a1442241d
Jeltorotik/snake-ai
/snake.py
3,506
3.65625
4
import pygame from collections import deque import random def draw_a_block(screen, x, y, type_of_block, color, size): #Scaling shell = size // 25 x *= size y *= size h, w = size, size if type_of_block == "horizontal": y += shell w -= shell*2 elif type_of_block == "vertical": x += shell h -= shell*2 e...
276db976128910aec53f1e27a09209936302b345
baieric/hackerRank
/algorithms/dynamicProgramming/candies.py
1,211
3.59375
4
# Solution to https://www.hackerrank.com/challenges/candies # Test Cases: # [1, 2, 3, 4] -> 10 # [4, 3, 2, 1] -> 10 # [1, 1, 1, 1] -> 4 # [1, 2, 3, 3, 3, 2, 1, 2] -> 15 # [1, 3, 2, 1] -> 7 n = int(input()) a = [] floor = None; for _ in range(n): i = int(input()) a.append(i) candies = 1 rating = a[0] total ...
b19e020a980763759dc51fdadb8dd36cacedb167
Hush14/Homeworks
/Pack4/4.3.py
5,247
3.625
4
import random from random import randint class animal(): pass class fish(animal): def __init__(self): self.t = 2 def __str__(self): return 'FISH' class bear(animal): def __init__(self): self.food = 0 self.t = 1 def __str__(self): return 'BEAR' class no...
dfc30e3fa0e11552f0c638ed26f1e1258ce8a05d
nascarsayan/lintcode
/428.py
572
3.640625
4
class Solution: def recurse(self, x, n, pows): if n == 0: pows[n] = 1 return pows[n] if n == 1: pows[n] = x return pows[n] if n == -1: pows[n] = 1 / x return pows[n] if n in pows: return pows[n] pows[n] = self.recurse(x, n // 2, pows) * self.recurse(x, n ...
dea2b61150dc56131e1a64e18d2ce4b0fe1bdbd4
Khushboo-09/DataStructureWithPython
/Doubly Linked List/RemoveAtEnd.py
2,775
3.515625
4
class _Node: __slots__= '_element','_next','_prev' def __init__(self,element,next,prev): self._element = element self._next = next self._prev = prev class DoublyLinkedList: def __init__(self): self._head = None self._tail = None self._size = 0 def __len_...
c7a586240101a69c7ef72ff30b1b0cb3187c26b3
gracemetzgar/New-Repo
/HW4.py
1,073
4.46875
4
# Author: Grace Metzgar # Date: 20210917 # Python for Data Analysis 101 ## Homework ### Instructor: Evelyn J. Boettcher, DiDacTex, LLC ### Week 1: Lecture 4 # Write a function that takes a single argument, prints the value of the argument, and returns the argument as a string. def str_function(x): print(x) r...
103c5395839ec916f3e00f8ad041e727baa2bc31
DanMeloso/python
/Exercicios/ex061.py
421
3.9375
4
#Exercício Python 061: Refaça o DESAFIO 051, lendo o primeiro termo e a razão de uma PA, #mostrando os 10 primeiros termos da progressão usando a estrutura while. termo = int(input('Informe o primeiro termo: ')) razao = int(input('Informe a Razão')) numero = 0 c = 0 while c < 10: if c == 0: numero = termo ...
89667726789ecba9ec269f9fbb177e20ec331679
jufecabrera/jf.cabreraMC
/csemana1/ex3.py
342
3.734375
4
a= 27 b= 83 #a es impar? if (a%2==0): print "%d es par" % (a) else: print "%d es impar" % (a) #divisres de a print "los dividores de a son:" for i in range(1,a+1): if (a%i == 0): print i #max comun divisor max_d=0 for j in range(1,a+1): if (a%j == 0 and b%j == 0): max_d=j print "El maximo comun divisor entre a ...
57160abed2c7701c35cc58bcb0cdd87cf00c92f6
shantanudwvd/PythonHackerrank
/CollectionsDeque.py
652
3.671875
4
from collections import deque deq = deque() digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", " "] queries = int(input()) for i in range(queries): my_string = input() string = "" number = "" for j in my_string: if j not in digits: string += j else: ...
78caa65847184ff5b184514ac88c478f451c3312
kjjeong104/MD_kjjeong
/py_development/data_process/math/NRsol.py
760
4.09375
4
#!/home/kjeong23/softwares/bin/python3.4 import math import numpy # Newton-Raphson method practice #Variables section thres=0.00001 #threshold target=0 #target value for the function guess=0 #initial guess clue for x dx=0.05 #increment of x to measure slope of f(x). search for both direction damp=1 #dam...
94e5caf4a11ccf9bd35a57f27d557ea32173ac7d
jessieharada6/Mini-Python-Projects
/Day-46-Create-a-Spotify-Playlist-using-the-Musical-Time-Machine/main.py
1,383
3.53125
4
from bs4 import BeautifulSoup import requests # import spotipy # from spotipy.oauth2 import SpotifyOAuth date = input("which year do you want to travel to? Type the date in this format YYYY-MM-DD \n") response = requests.get("https://www.billboard.com/charts/hot-100/2000-08-12") web_page_songs = response.text soup =...
bd5e76f700a52d1e050d104f117615c8838b178b
chengbo/leetcode
/leetcode/binary_search_tree/convert_sorted_array_to_binary_search_tree.py
337
3.640625
4
from leetcode.binary_tree.tree_node import TreeNode def sorted_array_to_bst(nums): nums_len = len(nums) if nums_len == 0: return None middle = nums_len // 2 root = TreeNode(nums[middle]) root.left = sorted_array_to_bst(nums[:middle]) root.right = sorted_array_to_bst(nums[middle+1:])...
1c71f72a950253f9c3c7d11f84abaa83d15c38de
ca-sousa/py-guanabara
/exercicio/ex039.py
354
4.125
4
from datetime import date ano = int(input('Digite o ano de nascimento: ')) idade = date.today().year - ano if idade == 18: print('Esta na hora de se alistar') elif idade < 18: print('Ainda faltam {} anos para o seu alistamento'.format(18 - idade)) elif idade > 18: print('O prazo para alistamento passou j...
15730d8ea44a3075ce3927cbffd66e5be53e76e1
christaggart/openblock
/ebpub/ebpub/streets/name_utils.py
3,545
3.578125
4
""" Utility functions for munging address/block/street names. """ import re from ebpub.utils.text import smart_title, slugify def make_street_pretty_name(street, suffix): street_name = smart_title(street) if suffix: street_name += u' %s.' % smart_title(suffix) return street_name def make_block_nu...
b591b8fb098356b108500ba450080b2b13c6a1ce
huanglun1994/learn
/python编程从入门到实践/第五章/5-10.py
363
3.859375
4
# -*- coding: utf-8 -*- current_users = ['admin', 'huanglun', 'wangdi', 'xiaoming', 'xiaohong'] new_users = ['Huanglun', 'Wangdi', 'ranming', 'yandong', 'maning'] for new_user in new_users: if new_user.lower() in current_users: print('Sorry, you must choose another name again.') else: print("Thi...
6a4be92b8cb4ee4f12b04a2204fc70a71dcf7295
Josh-Cruz/python-strings-and-list-prac
/multiple_sum_average_algos.py
787
4.5
4
# Multiples # Part I - Write code that prints all the odd numbers from 1 to 1000. # Use the for loop and don't use a list to do this exercise. # for x in range(1,1000): # if x % 2 != 0: # print x # Part II - Create another program that prints # all the multiples of 5 from 5 to 1,000,000. # for x in ran...
518cfae73e9e13d83dea1ee0a538496a72364bb7
Sampreet/numerical-techniques
/python/modules/root_finding/NewtonRaphson.py
4,452
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Authors: Sampreet Kalita # Created: 2019-03-26 # Updated: 2020-01-12 """Module to find roots of a function using Newton-Raphson Method.""" # dependencies import numpy as np def find_root_uni(fn, df, xi, et=1e-6, imax=1e6): """ Find the (approximate) root o...
32d8acb3c65622a65ab0e7c6b2cffd1e01313ed9
dinaramairambaeva/PP2_2021
/week 6/14.py
215
3.703125
4
# def panagram(a): # for i in range (97,123):if a.find(chr(i))==False:break # return True # print(panagram(input().lower())) a = input().lower() print(sum([i in a for i in 'abcdefghijklmnopqrstuvwxyz'])==26)
7fd8578347f284fa99f71fb9f4eff927a6484895
xieziwei99/py100days
/day01_15/multi/multiprocessDemo1.py
1,060
3.59375
4
""" Created on 2019/6/18 完成1~100000000求和的计算密集型任务 @author: xieziwei99 """ from multiprocessing import Queue, Process from time import time def main(): total = 0 number_list = [x for x in range(1, 10000001)] start = time() for number in number_list: total += number print(total) end = time() print('Execute time...
ff1e263a8b941e42d90e0a104e40942bf9ac0db3
avidekar/python-assignments
/group_anagrams.py
645
4.3125
4
# Given an array of strings, group anagrams together. # # Example: # # Input: ["eat", "tea", "tan", "ate", "nat", "bat"], # Output: # [ # ["ate","eat","tea"], # ["nat","tan"], # ["bat"] # ] def group_anagrams(strs): result = [] grouped_dict = {} for word in strs: sorted_word = "".join(sorted(...
cc3e0fda5f4ea7f1b09c21f08e82dffc865ca0da
eduardorasgado/AlgorithmsX
/introduction/selection_sort.py
1,050
4.125
4
#!/usr/bin/env python3 def selection_sort(A, increasing=True): # clonning A B = A[:] # for 1 ... j-1 for j in range(len(B)-1): max_min_e = B[j+1] # to compare actual vs smallest(at the moment i) max_min_index = j+1 if increasing: # finding the smallest number in uppe...
80c64c279c159e823befc5d576a46ebd509eb28b
soedjais/dodysw-hg
/ProjectEuler/Problem22.py
828
3.953125
4
""" Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For example...
fc5715c5e64d15e98079e050418b325e28e7ebe5
JavaRod/SP_Python220B_2019
/students/ramkumar_rajanbabu/lesson_09/assignment/test_database.py
2,321
3.578125
4
"""Module for testing database""" import unittest from unittest import TestCase import database as db class TestDatabase(TestCase): """Test Database""" def test_import_data(self): """Testing import data""" db.clear_database() actual = db.import_data("csv_files", "products.csv", "custo...
fd4348a9770e79af8f1e93d1a313cc15280597b2
nltk/nltk
/nltk/lm/preprocessing.py
1,640
3.609375
4
# Natural Language Toolkit: Language Model Unit Tests # # Copyright (C) 2001-2023 NLTK Project # Author: Ilia Kurenkov <ilia.kurenkov@gmail.com> # URL: <https://www.nltk.org/> # For license information, see LICENSE.TXT from functools import partial from itertools import chain from nltk.util import everygrams, pad_sequ...
f52df76c041ebf79251391ed771e72bd88d231d2
Hellofafar/Leetcode
/Medium/427.py
2,469
4.125
4
# ------------------------------ # 427. Construct Quad Tree # # Description: # We want to use quad trees to store an N x N boolean grid. Each cell in the grid can only # be true or false. The root node represents the whole grid. For each node, it will be # subdivided into four children nodes until the values in the ...
7f40dfbac1224a4e52599c3aabd14813d2c2a093
mohsindalvi87/bearsnacks
/computer-vision/anaglyphs/test.py
2,847
3.515625
4
#!/usr/bin/env python3 # https://en.wikipedia.org/wiki/Anaglyph_3D # https://github.com/miguelgrinberg/anaglyph.py/blob/master/anaglyph.py import numpy as np import cv2 # declare various color blending algorithms to mix te pixels # from different perspectives so that red/blue lens glasses # make the image look 3D mix...
08a9c7da4f6a2c8cc1fb77f8fc539a10efcc3bfd
OlehPalka/First_semester_labs
/Lab work 8/numberssum.py
1,160
3.84375
4
""" This module counts to different lists and appends multiplication of i elements from both lists """ def narayana(number): """ This function returns list of numbers. A(i) = A(i-1) + A(i-3), де A(0) = A(1) = A(2) = 1 >>> narayana(12) [1, 1, 1, 2, 3, 4, 6, 9, 13, 19, 28, 41] """ result = [...
c1bb060af581f07d8c10127cb9a9e7027bdf08cc
loganyang/Logviewer
/Components/EncryptionDecryption/WriteArchive/Test/Hexshow.py
389
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # R.Wobst, @(#) Aug 02 2011, 19:13:36 # output file contents in hex form, at most 64 chars per line import sys, binascii sz = open(sys.argv[1]).read() hexout = binascii.b2a_hex(sz) if len(hexout) < 64: print '"%s"\n' % hexout print "crypt length:", len(sz) print w...
35c9fe22dc529a3f8e5cdc91f491b387158fb9c2
cslarsen/project-euler
/e089/e89.py
3,305
3.765625
4
# -*- encoding: utf-8 -*- """ProjectEuler.net problem 89 Read and convert roman numerals. --> Slow but sure solution. By Christian Stigen Larsen, http://csl.sublevel3.org Public domain, 2012 The only rule you need to know: ***Numerals must be arranged in descending order of size.*** The law: Only I, X, and C can be...
b1365138baae837056bd89bb165a1240179f8aaa
jacobbieker/NUR
/two_e.py
4,495
4
4
import numpy as np import matplotlib.pyplot as plt def two_e(rand_gen, A, a, b, c): def sat_equation(r, A, num_satallites=100): return A * num_satallites * (r / b) ** (a - 3) * np.exp(-(r / b) ** c) # Since we are integrating the sat_equation in 3D spherical integral, but only a dependence on r, inte...
e0c85d445a0dafc70b7b31f961ccee0e3556797e
ruozhizhang/leetcode
/problems/sliding_window/Constrained_Subset_Sum.py
1,443
3.78125
4
''' https://leetcode.com/problems/constrained-subset-sum/ Given an integer array nums and an integer k, return the maximum sum of a non-empty subset of that array such that for every two consecutive integers in the subset, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied. A subset of an array i...
835b83e6aae42ed5a4e0175fe37686557325bee4
pvvishnu557/sum-of-the-digits-in-the-number
/sum of digits.py
127
3.9375
4
k=int(input("enter the number:")) sum=0 while(k>0): sum=sum+k%10 k=k//10 print("sum of the digits=",sum)
a44349e2fb7f0f29e05d6dffed3145503684e486
matthewelwell/adventofcode2020
/15.py
583
3.765625
4
import typing from utils.day15.game import Game def part1(data: str) -> typing.Union[str, int]: starting_numbers = list(int(number) for number in data.split(",")) game = Game(starting_numbers) results = game.play(to=2020) return list(results)[-1] def part2(data: str) -> typing.Union[str, int]: ...
cfb0cac2a3acc2caa3b1a63670b7f1e67ae03043
asen-krasimirov/Python-OOP-Course
/Graphic Timer/main.py
580
3.671875
4
from time import sleep from timer import Timer import os import pyfiglet # time format = hh.mm.ss/mm time = input('Enter time (in format hh.mm.ss or in mm): ') if time.count('.') == 0: timer = Timer.from_minutes(int(time)) else: timer = Timer.from_string(time) clear = os.system('cls') while True: if ti...
d4d6fc20e95b50201e85ab2ffd39eebcdeadcb43
dburger4/PythonProgrammingExercises
/Homework 1/poundSignPrint.py
549
4.09375
4
################ # Author: Daniel Burger # Date: 2/23/2019 # This program draws a patter of pairs of pound signs that have # more spaces inbetween them the further down you go ################# NUM_LINES = 9 # number of lines the code will print for i in range(NUM_LINES): print('#', end='') #prints the first poun...
6ccc88651f97f4db0aace1f18ebf1462a2b4c637
mitem9106/Algorithm-Practice
/linearSearch.py
421
3.953125
4
def linearSearch(array, x): for i in range(len(array)): if int(array[i]) == int(x): return i return -1 def main(): array = [88, 40, 10, 150, 34, 55, 20, 111] print("Search for: ") x = int(input()) result = linearSearch(array, x) if result == -1: print("Element ...
540cfcf034daafcf70d03bdd974282e19e7a7d61
bysr/untitled
/Project/function/recursionFun.py
585
3.84375
4
# 递归函数,比如阶乘算法 import sys sys.setrecursionlimit(1500) # set the maximum depth as 1500 def fact(n): if n == 1: return 1 else: return n*fact(n-1) print(fact(1000)) def fact(n): return fact_item(n, 1) def fact_item(num, produce): if num == 1: return produce return fact_i...
6af543ba08666861778bbf747b6e71d0bed132eb
johnklee/algprac
/hackerrank/implementation/medium/bigger-is-greater.py
1,629
3.5625
4
#!/usr/bin/env python3 import math import os import random import re import sys def swap(w, i, j): w[i], w[j] = w[j], w[i] # Complete the biggerIsGreater function below. def biggerIsGreater(w): #print('w={}'.format(w)) wi = list(map(lambda e: ord(e), w)) wi_len = len(wi) for i in range(1, wi_...
87fedbdd9642ba5bce5eadbec2cfef8c73000eb4
Andrew1707/Group-Adventure
/run.py
341
3.640625
4
from player import player from room import room from initialize import * tandrew = player("Tandrew", "Noob") caleb = player("Caleeb", "boss") kitchen.enter(caleb) def run(): resp = input("Where do you want to go? ") for room in caleb.location.adjacent: if resp == room.name: room.enter(cal...
4172681fe102671deceed0f096e803668f49cf41
ash2osh/Algorithmic-Toolbox
/week2_algorithmic_warmup/6_last_digit_of_the_sum_of_fibonacci_numbers/fibonacci_sum_last_digit.py
1,212
3.875
4
# Uses python3 import sys def fibonacci_sum_naive(n): if n <= 1: return n previous = 0 current = 1 sum = 1 for _ in range(n - 1): previous, current = current, previous + current sum += current return sum % 10 def test_fibonacci_sum(n): for i in range(1, n + 1):...
cb9d147e0988a3684bd3b12f9ff92736a8bdaeee
wz1990911/w
/11day/01-for循环插入数.py
80
3.546875
4
list1 = [] for i in range(0,101): if i% 2 != 0: list1.append(i) print(list1)
e5fab826d23740f7c3d80f64de9a358cfa904662
Chidalu567/networking
/reverseshell/server.py
5,444
3.78125
4
import socket import sys import threading import queue '''First i need to create a thread that can preform two actions(listen&acceptingconnections,sending commands)''' number_of_jobs=2; #the number of actions i want to carry out job_to_do=[1,2]; #(1) is for listen and accept while (2) is for sending commands que...
0f0c6b6f55233d0bed91142fadd87f965dc30633
code-harvey/MicroEarthQuake
/phasepapy/associator/func1D.py
1,464
3.515625
4
from .tt_stations_1D import * def tt_km(session, d_km): """ tt_km(session,d_km) Look up travel time from tt_table for the closest distance to entered value stored in the tt_table database. km_difference is the distance difference between the stored value returned in the lookup and the distance requested. ...
d5e427fed5e731a562c70f2ca6b348e3a55c51a9
vaskocs/project
/2.py
398
3.65625
4
def convert(list,b1,b2): number=0 helyiertek=1 for i in range(len(list)-1,-1,-1): if list[i]>=b1: print("Nem jó szám") return None number+=list[i]*helyiertek helyiertek*=b1 list2=[] while number!=0: list2.append(number%b2) n...
e6209333c52a7830a10af07278980cf39af72bae
apri-me/python_class00
/Session6/assignment2.py
556
3.984375
4
import prettytable n = int ( input("Number of employees: ") ) employees = [] for i in range(n): emp = input("Emplyee number {}: ".format(i + 1)) employees.append(emp) hours = [] for i in range(n): h = float ( input("Work hours of Employee {}: ".format(i + 1))) hours.append(h) salary_per_hour = int ...
d41eb4ec0708076a61561be19175d13bfd46d352
julia-neme/project-euler
/problem_5.py
1,195
3.65625
4
""" 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? """ def is_prime(N): i = 2 ans = True while i*i <= N: if N % i == 0: ans = False break ...
e94c423add2747b54775629dfa3b5032dcd964b3
fabnonsoo/Matplotlib
/Analyzing_CSV_Data/csv_analysis1.py
804
3.671875
4
# Analyzing Data Loaded from CSV File: Using an 'import csv' module # NB: 'from collections import Counter' is used when a data is too large to loop through.... import csv import numpy as np from collections import Counter from matplotlib import pyplot as plt plt.style.use('fivethirtyeight') # Using csv: with open('...
6c52aba1745a56128980a30f3d8871386e654193
blackhumdinger/LPTHW
/LPTHW_EXER/13.py
1,368
3.59375
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 22 08:35:03 2019 @author: Pranav """ # EXERCISE 13 (PARAMETERS, UNPACKING AND VARIABLES #from sys import argv #script, first, second, third = argv #the line above unpacks the variables assigned rather than hoding the argumrnts #it gets assigned to four vari...
5bc7cf74faa7c270117104fa2196b5fa8595b2ee
spudtrooper/photostitcher
/photostitcher.py
1,831
3.515625
4
"""Stitches a directory of images together into one image.""" import argparse import os import logging import math import sys from PIL import Image def Stitch(image_dir='images', output_image='output.jpg', images_per_row=6): images = [Image.open(os.path.join(image_dir, img)) for img in os.listdir(image_d...
5751ee6acd98c6cddb3d5217c9719e62f6c8dc15
qaswedf/test
/c_to_f.py
126
3.609375
4
c = input ("請輸入換算的溫度為攝式:") c = int(c) f = c * 9 / 5 + 32 print('你轉換出來的溫度為華式', f)
8b3006b08674d70cb7466fec085d4ff7b7e7b67a
jakehoare/leetcode
/python_1_to_1000/724_Find_Pivot_Index.py
1,163
4.03125
4
_author_ = 'jake' _project_ = 'leetcode' # https://leetcode.com/problems/find-pivot-index/ # Given an array of integers nums, write a method that returns the "pivot" index of this array. # We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of # the numbers ...
1ca3c5bf9a9ee216c43d58ffaa52f4f5b1817442
masontmorrow/Data-Structures
/heap/heap.py
2,670
3.8125
4
from math import floor class Heap: def __init__(self): # storage starts with an unused 0 to make # integer division simpler later on self.storage = [0] self.size = 0 def insert(self, value): self.size += 1 self.storage.append(value) self._bubble_up(self.size) def delete(self): ...
b5c012032e037a35df29a9eec250cc5074b12b14
hrusikeshnandy/python
/if.py
231
4.09375
4
num1 = int(input("Enter the first number: ")) num2 = int(input("Enter teh second number: ")) if num1 > num2: print("number 1 is greater") elif num1==num2: print("numbers are equal") else: print("number 2 is greater")
66a33a1abcd607531b5461358db0d45f491d40f6
ageraldo1/Python-bootcamp
/regular_expressions/sample_re.py
1,337
3.875
4
import re print (re.search('ORA-', 'this is a sunny day')) patterns = ['term1', 'term2'] text = 'This is a string with term1, but not with the other term' for pattern in patterns: print (f"Searching for {pattern} in: \n {text}") # check for match if re.search(pattern, text): print ("\nMatch foun...
1a77ebcb3f67a9d0500d799e6e1112c2be5426ac
shanekang/pre-education
/quiz/pre_python_18.py
491
3.6875
4
"""18. 확장자가 포함된 파일 이름이 담긴 리스트에서 확장자를 제거하고 파일 이름만 추가 리스트에 저장하시오. file = ['exit.py',hi.py','playdata.hwp',intro.jpg'] 결과: file = ['exit',hi','playdata',intro'] 예시 <입력> print(new_list) <출력> ['exit', 'hi', 'playdata', 'intro'] """ file = ['exit.py','hi.py','playdata.hwp','intro.jpg'] new_list = file...
2ec5a6540e18f23f5e44c37c777e2a4c306f492b
tariksetia/Algx-Practice
/tree/node.py
456
3.5
4
from queue import Queue class Node: def __init__(self, data=None, left=None, right=None): self.data, self.left, self.right = data, left, right def __repr__(self): return str(self.data) def __str__(self): return str(self.data) def __bool__(self): return True i...
1c173a869c41bded6297c7287320283d605f695b
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/series/77379993a1cf4730a1d5b70daa8fa818.py
220
3.53125
4
def slices(numbers, length): if length == 0 or length > len(numbers): raise ValueError numbers = [int(number) for number in numbers] return [numbers[i:i+length] for i in range(len(numbers)-length+1)]
6028b5ba85e7261b0946051c1b10272886d8fd43
Macedo3/Curso-IME-USP-parte-1
/curso/quadrado.py
121
3.546875
4
l = int((input)('Qual é a medida do quadrado? ')) x = l * 4 y = l**2 print("perímetro: {} - área: {}".format(x, y))
1f5bb7f75412341343588bbaf215e56a6e430190
AdamZhouSE/pythonHomework
/Code/CodeRecords/2628/47937/306970.py
384
3.671875
4
a=input() b=input() c=input() d=input() #print(a) #print(b) #print(c) #print(d) if(a=="2" and b=="0 1" and c=="0 5" and d=="5 1"): print(6) print(1129) elif(a=="2" and b=="0 1" and c=="0 5" and d=="5 0"): print(6) print(1129) elif(a=="2" and b=="0 0" and c=="0 5" and d=="5 0"): print(6) print(...
1798e12359a6d675f6735e92af0f13f40312bcb0
spartantri/wafme
/tail.py
2,539
4.15625
4
#!/usr/bin/env python ''' Python-Tail - Unix tail follow implementation in Python. python-tail can be used to monitor changes to a file. Example: import tail # Create a tail instance t = tail.Tail('file-to-be-followed') # Register a callback function to be called when a new line is found in the fol...
c19df0ce66369694ad43ba00806ebf24bf788189
ruohoruotsi/pyACA
/pyACA/ToolBlockAudio.py
888
3.59375
4
""" helper function: Creates blocks from given array. This method creates a block only if there is enough input data to fill the block. This means if there isn't enough data to fill the last block then that lst chunk of input data will be discarded. To avoid losing data, you should pad the input with zeros of at least ...
3a6169bc13ec9a1619030133df4a6a1a833b4562
alanxing1122/workspaceU
/random_1225.py
450
4.09375
4
import random def jdstb_game(): computer = random.randint(1,3) player = input("1.剪刀、2.石头、3.布\t请输入对应的数字:") player = int(player) if(player not in [1,2,3]): print("请输入1、2、3") elif(computer == player): print("平局") elif((computer == 1 and player == 3)or(computer == 2 and player == 1)or(computer==3 and player=...