blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
378ec863c4eb6092affd49014282698951b6cf33 | filipeferreira86/python | /.gitignore/lacos/break.py | 531 | 3.890625 | 4 | print('*'*10, 'Este é o while', '*'*10)
i=0
int(i)
while (i<=2):
print('Estou pensando em %d'%(i))
rep = input('Digite S para continuar: ')
i+=1
if(rep!='S' and rep!='s'):
break
else:
print('Terminei de pensar :)')
print('\n\n', '*'*10, 'Este é o for', '*'*10)
for t in range(... |
83259962da156a0c976ba95acd7dbd4433197a22 | frozenmafia/RETN4_server | /test.py | 254 | 3.75 | 4 |
def convert_phone_string_phone(phone_text):
x = phone_text.split(None,1)
return {
'country_code':int(x[0]),
'phone_number':int(x[1].replace(" ",""))
}
print(convert_phone_string_phone("+91 96679 43369"))
print(int("+9"))
|
96049c80f7f62382e854102de5a6e10bebe80277 | morningsky/target-offer | /链表/面试题17-合并链表.py | 931 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 23 14:30:29 2018
@author: sky
"""
'''
输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减 规则
'''
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def Merge(self, pHead1, pHead2):
merged = None
if not p... |
661f8a200151ad59d2909806e19a162e55a414d5 | MoathElHaj/ibridge-ds | /find_postive_neighbors.py | 262 | 3.5 | 4 | l1 = [int(x) for x in input().split()]
def find_pos_neighbors(alist):
result = []
for i in range(1, (len(alist) - 1)):
if alist[i - 1] * alist[i + 1] >= 0:
result.append(alist[i])
return result
print(find_pos_neighbors(l1))
|
24e11e45e84799051f8eaa4dcb3f904f0389469c | Morris-wambua/pyKid | /MainFiles/pythion/4buttonTkinterDemo.py | 1,117 | 3.578125 | 4 | from tkinter import *
TopLevel = Tk()
TopLevel.title("Chem270 Button Demo")
TopLevel.minsize = "600 x 600"
bw = 30
bh = 10
#dummy functions to handle button clicks
def button1_clicked():
print("button 1 clicked")
def button2_clicked():
print("button 2 clicked")
def button3_clicked():
print("button 3 clic... |
e4a52aab167aa8caaf28c9f854e40f8a17682da9 | kaimaruya/cs257-s21-kai | /web/datasource.py | 13,997 | 3.609375 | 4 | import psycopg2
import psqlConfig as config
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
class DataSource:
'''
DataSource executes all of the queries on the database.
It also formats the data to send back to the frontend, typically in a list
or some othe... |
d440e21d15b589fe1a2e80c1388dd1bfa4e9c3d9 | cichutkiii/grouptask | /main.py | 2,174 | 3.515625 | 4 | import file_ops
import stat_var
import data_ops
pick = 0
data_file = ""
while True:
print(stat_var.menuOptions)
try:
pick = int(input(stat_var.yourChoice))
except ValueError:
print("Podana wartość nie jest liczbą")
if pick == 1:
file_ops.download_file()
# 1. Pobierz pli... |
78ea3b07e91ecef63deb2097a26f76c29a8310df | creeperdeking/Sea-battle | /game/scripts/gameHandler.py | 1,842 | 3.734375 | 4 | """
information:
le point(0,0) de la carte est le point en haut a droite
la coordonnée x est la coordonée de largeur
la coordonnée y est la coordonée de longueur
donnée manquente:
"""
import pdb
import scripts.utils as utils
import scripts.unit as unit
class Game:
"""A class designed to handle the behavior of t... |
aeebb08bed9c817dd07f1ca157657b6c99b107ef | zablanc91/pythonFiles | /pythonFiles/insertionSort.py | 300 | 3.859375 | 4 | def insertionSort(to_sort):
i = 1
while i < len(to_sort):
j = i
while j > 0 and to_sort[j] < to_sort[j-1]:
a = to_sort[j]
b = to_sort[j - 1]
to_sort[j] = b
to_sort[j - 1] = a
j -= 1
i += 1
return to_sort
|
97138c90f16fad8f0a04c4e51053dd476537dff7 | zablanc91/pythonFiles | /pythonFiles/editDistance.py | 936 | 4.09375 | 4 | """
This function finds the edit distance between two words. The edit distance is
number of inserts, deletes, and replacements of characters needed to be made
on the first word in order to make it appear as the second word. Dynamic
programming is used build up the edit distance of smaller parts of the words
in order to... |
7969580de228b4d4b621792fb0aa13c5e5b964e5 | pyowa/march-2014-meeting-examples | /decorators.py | 662 | 3.96875 | 4 | python
from functools import wraps
def log(filename):
def logwrapper(func):
@wraps(func)
def wrapper(*args):
with open(filename, 'w') as f:
print >> f, "'{}' called with {}".format(func.__name__, args)
return_value = func(*args)
print ... |
77e3b3172b5a03361713ab1ee6c1432e6e557c5b | NaikMegha/Python | /FileOps.py | 488 | 3.640625 | 4 | import json
book = {}
book['Megha'] = {'name': 'megha',
"phone_number":'678989',
'address':'#143 ,chitrpur'}
book['Vandana'] = {'name': 'Vandana',
"phone_number":'678989',
'address':'#143 ,CK'}
print(book)
json_obj = json.dumps(book)
print(json_obj)
w... |
243879d2d450d094f3a443a288c1f617ed8bd14f | Salgal1975/Zadachi | /raznoe/fibo2.py | 205 | 3.578125 | 4 | def fibo(n):
a = 0
b = 1
print(a, b, end=' ')
for i in range(2, n + 1):
c = a + b
a, b = b, c
print(c, end=' ')
n = 10
fibo(n) # 0 1 1 2 3 5 8 13 21 34 55 |
f503ced4bd587958d4d99c21f1166f6753d02734 | Salgal1975/Zadachi | /raznoe/zadacha_1.py | 741 | 3.875 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import math
def arifmet (a=int(input('Введите чило=')), b=int(input('Введите 2-е чило=')), c=(input('Введите арифметическую операцию(+,-,*,/)='))):
if c=='+':
s=('Сумма: {0} + {1} = {2}'.format(a,b,a+b))
elif c=='-':
s=('Разность:... |
3220b52320662b9432c0f4181d4a2440b63e8f7b | liuminghao1/algorithm_4 | /sort/shell_sort.py | 550 | 3.640625 | 4 | from utils.sort import less, list_exchange
def shell_sort(_list):
length = len(_list)
step = 1
while step < length//3: # 分成N个子数组 起点分别是 1 4 13 40....
step = step * 3 + 1
while step >= 1:
for i in range(step, length): # 从最后一个数组开始
for j in range(i, 0, -step): # 往上一个数比较, ... |
5e46ecce29296fa2b08a9af8d8f292b3e51b4ec4 | balgillo/aoc2019 | /day6_orbitmap/python/day6_orbitmap.py | 666 | 3.6875 | 4 | #!/bin/python
import sys
import io
def count_orbits(satellite, graph):
p = satellite
total = 0
while True:
p = graph.get(p)
if p == None:
return total
else:
total += 1
file_path = sys.argv[1]
graph = {}
with io.open(file_path, "r") as f:
while True:
... |
061bd44c32eabbbeb21fdff465e4b5220011e932 | MatsAndrew/MyPython_Studying | /task_5.py | 660 | 3.75 | 4 | #task_5
def my_func():
sum_res = 0
ex = False
while ex == False:
number = input('Введите ваши числа или нажмите Q для выхода из программы ').split()
res = 0
for el in range(len(number)):
if number[el] == 'q' or number[el] == 'Q':
ex = True
... |
32ca70ec09d14c8d533b89b95ee7af087fd79413 | prantosharma/Python-Basic-Part1- | /bd_division_info.py | 1,385 | 3.53125 | 4 | bd_dividion_info={}
bd_dividion_info['dhaka']={'district':13,'upozila':93,'union':1833}
bd_dividion_info['chattogram']={'district':11,'upozila':97,'union':336}
bd_dividion_info['barisal']={'district':6,'upozila':39,'union':333}
bd_dividion_info['khulna']={'district':10,'upozila':59,'union':270}
bd_dividion_info['mymens... |
e82cc1436d466cdcabd11ffe4abb7bfd13d98103 | nir099/KnowledgeBase | /Algo/LinkedList/reverseWithMiddleElement/reverseMiddleElement.py | 1,134 | 3.90625 | 4 | import math
import os
import random
import re
import sys
class LinkedListNode:
def __init__(self, node_data):
self.data = node_data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
def insert_node(self, node_data):
node = Lin... |
fe4ad4d521197b9ebed2823a477994c0f04ea898 | nir099/KnowledgeBase | /Algo/Sort/Insertion/insertion.py | 266 | 3.546875 | 4 | arr = [ 0, 1, 3 , 2 , 6 , 9 , 4]
def inser(arr):
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
while j >= 0 and key < arr[j]:
arr[j+1] = arr[j]
j -= 1
arr[j+1] = key
return arr
print(inser(arr)) |
ad1692b5e92ca453000781b7abcb7d314dd25744 | benkeanna/pyladies | /Engeto_kurz/bullsandcows.py | 4,284 | 3.9375 | 4 | """
Game bulls and cows in Python 3.
Program generate 4-digit secret number, where digits must be all different.
Player tries to guess the secret number and program gives the number of matches.
If the matching digits are in their right positions, they are "bulls",
if in different positions, they are "cows".
"""
import... |
69380ba35bf4f1bdb5a2c9d2d8bad73374f7b8ba | benkeanna/pyladies | /05/ukol4.py | 1,387 | 4.03125 | 4 | from random import randrange
cislo = randrange (3)
def ano_nebo_ne(otazka):
"Vrátí True nebo False, podle odpovědi uživatele"
while True:
odpoved = input(otazka)
if odpoved == 'ano':
return True
elif odpoved == 'ne':
return False
else:
print('N... |
0bdd361c3a9db3df10b5fddac1d70189dffd98bf | Athandreyal/scheduler | /shunt.py | 3,157 | 3.5 | 4 | #expects and requires spaces between terms and operators
def shunt(s):
ops = []
end = []
precedence = '()[]!/*+-'
for c in precedence:
s = s.replace(c,'_'+c.strip()+'_')
print(s)
left = '()[]*/+-'
right = '!'
s = s.replace('_ _','_').replace('__','_')
s = s.split('_')
prin... |
2d76bfb081e19bf701a8b2c1595d49df94c36780 | orlandi/connectomicsPCV | /nest/small-clustering/BoundedAdaptation.py | 4,037 | 3.71875 | 4 | # Copyright 2012, Olav Stetter
# Copyright 2014, Javier G. Orlandi
# This is a class to run an adaptive iterative process, assuming an underlying
# monotonically rising function f(x).
# Far later: Another, probably clear way to go about this is to find upper and
# lower bounds first, and then use extrapolation from t... |
abe386b5e3323c4922c1e7f545c3d5a4db81c8c2 | koibiki/ai-factory | /feature_engineering/separate_str_num.py | 535 | 3.65625 | 4 | def separate_num_str(df):
str_columns = get_str_columns(df)
num_columns = [column for column in df.columns if column not in str_columns]
return df.loc[:, num_columns], num_to_str(df.loc[:, str_columns])
def get_str_columns(df):
return [column for column in df.columns if column.startswith("T") or colum... |
abb057898acf1ff79d536bb56e3b887f53c4fd10 | albscheng/python-adventure | /Flashcard/sortVocab.py | 394 | 3.640625 | 4 | #!/usr/local/bin/python3
# Read in vocab.txt and store as list
with open('vocab.txt') as vocab_list:
entries = [line.rstrip().split(' ', 1) for line in vocab_list]
entries.sort()
# Write the sorted vocab list to file
with open('sortedVocab.txt', 'w') as output:
for entry in entries:
#output.write('{0}... |
7bfc0518534f80a1d44d34761fba2be67e581920 | ThePhilosopher4097/zummit | /Linear_Regression.py | 958 | 3.53125 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
house_data = pd.read_csv('./house_data.csv')
house_data.head(5)
house_data.describe()
plt.scatter(house_data['sqft_living'], house_data['price'])
y = house_data['price']
x = house_data.drop(['price','id'],axis=1)
# train linear model on the d... |
bda3eab2776b882a6ad5eae43ac8634faa8d6362 | brunocriscuolo/uerj | /fundamentos-computacao/scripts/Lista PP1/#questao11.py | 210 | 3.765625 | 4 | soma=0
n=input("Número de Termos da PA:")
a1=input("Primeiro Termo da PA:")
r=input("Razão da PA:")
an=a1+(n-1)*r
for i in range(a1,an+1,r):
print i," ",
soma+=i
print "\nSoma dos Termos = ", soma
|
02e2cb21e08529039dc99e5d3b66774bb289e505 | brunocriscuolo/uerj | /fundamentos-computacao/scripts/Lista PP2/#questao7.py | 375 | 3.671875 | 4 | def LerVetor(vet):
for i in range(0,5):
vet[i]=int(input("Nmero:"))
return vet
def NovoVetor(vet):
for i in range(0,5):
if i%2==1:
vet[i]=vet[i]*3
if vet[i]%2==0:
vet[i]=vet[i]*2
return vet
A=[0]*5
A=LerVetor(A)
vetor=NovoVetor(A)
print "... |
a5f6ec2f7f8e7a47bb306277fb0f782a09d4f27a | brunocriscuolo/uerj | /fundamentos-computacao/bubble-sort.py | 476 | 3.640625 | 4 |
def BubbleSort(vetor):
for i in range(0,len(vetor)-1):
for j in range(i+1,len(vetor)):
if vetor[i]>vetor[j]:
aux=vetor[i]
vetor[i]=vetor[j]
vetor[j]=aux
return vetor
import random
tam=random.randint(5,10)
vet=[0]*tam
for i in ran... |
cd3c34137cb14e8acfd13576a1e45fd06f7d85c7 | brunocriscuolo/uerj | /fundamentos-computacao/scripts/Lista PP1/#questao13.py | 216 | 3.96875 | 4 | soma=0
cont=0
n=input("Digite um Número:")
if n>=13:
for i in range(13,n+1):
soma+=i
cont+=1
media=float(soma)/cont
print "Média Aritmética= ",media
else:
print "ERRO!"
|
619b23a6d969587d7fe38f03f90e814bb2aa8ce7 | brunocriscuolo/uerj | /fundamentos-computacao/scripts/Lista PP1/#questao10.py | 125 | 3.90625 | 4 | n=input("Digite um número:")
soma=""
if n>0:
for i in range(0,n+1):
soma+=str(i)
print soma
|
7ca5975d76ea37ff1bf078aa694246e5cb66a07e | brunocriscuolo/uerj | /fundamentos-computacao/scripts/Lista 4/#questao15.py | 637 | 3.5625 | 4 | def LerMatriz(mat):
for i in range(0,5):
mat.append(0)
mat[i]=[]
for j in range(0,5):
mat[i].append(input("Nmero:"))
return mat
def BuscaMaiorElem(mat):
vet=[0]*3
maior=10000
for i in range(0,5):
for j in range(0,5):
if mat[i][j]>maior:... |
2f3d4f79c8a8cd8df2afa7d433f05278ab981370 | UlianaZhuravleva/RIP-Lab-2 | /names_emps.py | 497 | 3.546875 | 4 | def names_emps(arr):
names=[]
for i in arr:
for m in i['children']:
if m['age']>=18:
names.append(i['name'])
break
return names
ivan = {
"name":"ivan",
"age":34,
"children":
[{
"name":"vasja",
"age":12,
},
{
"name":"petja",
"age":10,
}],
}
darja={
"name":"... |
186c29e0c133d8052b075c2b8faef63d716ac08d | weiss-d/log-processing-demo | /src/log_processing_demo/log_updater.py | 1,624 | 3.5 | 4 | """
LogUpdater abstract class
"""
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Dict, List, Optional, Tuple, Union
from log_processing_demo.log_item import LogItem
class LogUpdater(ABC):
"""Abstract class for LOG storage operations."""
@abstractmethod
def update(se... |
18a951c6682905866a72f130f156402967878245 | PaoloMura/AlgoVis | /BubbleSort.py | 3,211 | 4.375 | 4 | # Bubble Sort Algorithm
from Algorithm import Algorithm
from Mediator import Mediator
COMPARE = 0
SWAP = 1
INCREMENT = 2
FINISHED = 3
class BubbleSort(Algorithm):
def __init__(self, array, mediator:Mediator):
self.array = list(array)
self.mediator = mediator
self.stage = COMPARE
s... |
4b4ced21513a53554582c3129d660e74a0fa9ae3 | SergioPeterson/dsna | /merge-sort/recursive.py | 936 | 4.09375 | 4 | def msr(items):
"""
It breaks down the list into n sublists, each containing one element. Then,
it repeatdely merges adjacent sublists to produce new sorted sublists
until there's only one sublist remaining.
"""
if len(items) > 1:
mid = int(len(items) / 2)
left_side = items[:mi... |
4a185d87ac7147a55f63ca1886f783ca91a66571 | SergioPeterson/dsna | /queue-list/__init__.py | 867 | 3.984375 | 4 | class Element(object):
def __init__(self, value):
self.value = value
self.next = None
class Queue(object):
def __init__(self, head_value=None):
self.head = Element(head_value)
def get_head(self):
return self.head.value
def get_tail(self):
current = self.head
... |
4763efd971a517266af8f923bcf403f4fdf347fb | SergioPeterson/dsna | /hash-table/__init__.py | 1,448 | 3.796875 | 4 | class HashTable(object):
def __init__(self, size):
self.size = size
self.keys = [None] * self.size
self.values = [None] * self.size
def hash(self, key):
return key % self.size
def rehash(self, hash_value):
return (hash_value + 1) % self.size
def get(self, key):... |
691dc4926bd148766f8807db570aca3170b78325 | lynnzc/pyalgo | /adt/binarysearchtree.py | 6,030 | 4.03125 | 4 | # !/usr/bin/python
# -*- coding: utf-8 -*-
class BinarySearchTree:
def __init__(self):
self.root = None
self.size = 0
# return the height of bst
def height(self):
if self.root is None:
return 0
else:
return self.root.height()
... |
c9894e22468b255ffaeb93b084f4f66ab5308a59 | lynnzc/pyalgo | /adt/queue.py | 542 | 4.03125 | 4 | # !/usr/bin/python
# -*- coding: utf-8 -*-
class Queue:
def __init__(self):
self.nodes = []
# return whether queue is empty or not
def isEmpty(self):
return (self.nodes == [])
# insert a new node to the rear of the queue
def enqueue(self, node):
self.nodes.i... |
85d40b2d4e9732c72e93ce36e58edc108f441c0f | lynnzc/pyalgo | /adt/deque.py | 874 | 4.125 | 4 | # !/usr/bin/pyhon
# -*- coding: utf-8 -*-
class Deque:
# double-ended queue
def __init__(self):
self.nodes = []
# return whether the deque is empty or not
def isEmpty(self):
return (self.nodes == [])
# return the number of nodes in the dequeue
def size(self):
... |
80786ec584c0e7fb61e2ccd6becbe07e31613368 | yastil01/python_tips | /DFS_BFS.py | 1,370 | 4 | 4 | ================
BFS
================
1. be very careful when you add new elements in the queue. for example, O is empty, * is food and X is block.
here below condition will fail
if 0 <= nRow < rows and 0 <= nCol < cols and grid[nRow][nCol] == 'O' and (nRow, nCol) not in visited:
you are only traversing empty cells... |
50d40cc53414a108db71eb5b914de51f496a1b60 | Levon187/ufar-python | /lesson8/generators.py | 810 | 3.828125 | 4 | def g():
print("Start")
x = 42
yield x # return x
x = x + 1
print('middle')
yield x
print("Finish")
yield
gen = g()
print(type(gen))
result = next(gen)
print(result)
result = next(gen)
print(result)
result = next(gen)
print(result)
print(type(result))
# ////////////////////////
l =... |
193e121ca261e945fe733afc83a241be68b18443 | Levon187/ufar-python | /lesson5.py | 1,492 | 4 | 4 | '''
Write a Python program that outputs all possible strings formed by using
the characters c , a , t , d , o , and g exactly once using only 3-letter words
result -> cat cad cao cag .....
'''
from datetime import datetime
LOGIN = 'VAZGEN'
PASSWORD = 'CHANGEME'
# letters.add("r")
# letters.add("c")
# letters |= {"q"... |
bfecba4a8363d0ecd91de321946a86ef155dc454 | Levon187/ufar-python | /Argishti/Argishti-Homework.py | 5,254 | 4.25 | 4 | '''
Write a short Python function, is multiple(n, m), that takes two integer
values and returns True if n is a multiple of m, that is, n = mi for some
integer i, and False otherwise.
'''
def is_multiple(n, m):
if n%m == 0:
return True
else:
return False
'''
Write a short Python function, is eve... |
594c553196f3e8623849ea049a1d746636e3e2c4 | mchensd/connect_four | /Stack.py | 381 | 3.609375 | 4 | class Stack:
def __init__(self):
self.len = 0
self.load = []
def __repr__(self):
tmp = map(str, self.load)
return ", ".join(tmp)
def push(self, item):
self.load.append(item)
self.len += 1
def pop(self):
self.len -= 1
return self.load.pop(... |
19b44244bce6bcd0d2d2c92ce4ba5e0ae61bee59 | GiantSweetroll/Program-Design-Methods-and-ITP | /Assignments/OOP/Circle/circle.py | 714 | 3.796875 | 4 | import math
class Circle():
#Fields
__radius:float
__color:str
#Constructor
def __init__(self, radius:float = 1.0, color:str = "red"):
self.__radius = radius
self.__color = color
return
#Methods
def getRadius(self) -> float:
return self.__radiu... |
e37780788748cc93dfcadc77c2f378e6459ab033 | GiantSweetroll/Program-Design-Methods-and-ITP | /TA_Projects/pygame/button.py | 1,106 | 3.5625 | 4 | import pygame.font
class Button():
#Constructor
def __init__(self, settings, screen, msg):
self.screen = screen
self.screenRect = screen.get_rect()
#Set the dimensions and properties of the button
self.width, self.height = 200, 50
self.buttonColor = (0, 255... |
5a30208ecfcbfdd05eb7b43f1abbc5e33dfe2edb | GiantSweetroll/Program-Design-Methods-and-ITP | /Exercises/Practice Assorted Problems/CharFrequency.py | 347 | 3.59375 | 4 | def char_freq(string)->dict:
freq:dict = {}
for i in range(len(string)):
letter:str = string[i:(i+1)]
letter = letter.casefold()
try:
freq[letter] = int(str(freq[letter])) + 1
except KeyError:
freq[letter] = 1
return freq
prin... |
56f2450334e1ff553987f8d31c19f0df6578ba29 | GiantSweetroll/Program-Design-Methods-and-ITP | /Assignments/Class/account.py | 1,093 | 3.5625 | 4 | class Account():
#Fields
__id:str
__name:str
__balance:int
#Constructor
def __init__(self, accID:str, name:str, balance:int = 0):
self.__id = accID
self.__name = name
self.__balance = balance
#Methods
getID = lambda self: self.__id
getName = lam... |
7ea9b34e3275b119c516c2146e82978fbf3d50dc | GiantSweetroll/Program-Design-Methods-and-ITP | /Exercises/Practice Assorted Problems/LongestWord.py | 434 | 3.921875 | 4 | def find_longest_word(lwords:list)->str:
dictionary:dict = mapLengths(lwords)
max:int = 0
for num in dictionary: #Find highest key
if (num > max):
max = num
return dictionary[max]
def mapLengths(words:list)->dict:
dictionary:dict = {}
for word in words:
di... |
a2c2552854461ce4b47b1acf059349de7799d2bc | ajaypandey2002/Stepik-tasks | /bishop move.py | 615 | 3.9375 | 4 | '''You are given two different cells of the chessboard. Write
a program that determines whether the bishop can get
from the first cell to the second in one move. The program receives as input
four numbers from 1 to 8 each, specifying the column number and line number,
first for the first cell, then for the seco... |
ec6ae27cbfdfb76336895ecb7c7ec3513abbc917 | ajaypandey2002/Stepik-tasks | /divisors-1.py | 397 | 3.65625 | 4 | #Write a program that finds a natural number from the segment [a; b] with the maximum sum of divisors.
max = 0
sum1 = 0
sum2 = 0
a = int(input())
b = int(input())
for i in range(a, b + 1):
for j in range(1, i + 1):
if i % j == 0:
sum2 += j
if sum2 >= sum1:
sum1 = s... |
f195ff309b41880e7b569dddf84344dd63405044 | ajaypandey2002/Stepik-tasks | /calculator of delivery.py | 200 | 3.625 | 4 | #1000$ for first buy and +120 for every item after 1
def get_shipping_cost(quantity):
if quantity == 1:
return 1000
else:
return (quantity - 1)*120 + 1000
print(get_shipping_cost(3))
|
7ab84de52d9142db1b277ed1ee7977fb22a7d174 | mshcheg/Zanne_next-gen_scripts | /AmpliconScreen/count_reads.py | 3,073 | 3.671875 | 4 | from __future__ import print_function
from Phred import Phred33
'''
Script to parse reads and calculate read quality for each barcode/primer.
Primers are parsed by looking for a primer sequence match in the read. This is
a very crude way to identify the corresponding amplicon for a read. Read
quality is calculated ... |
1bf98e4aa9154b8d9b7e9d0d2f307a2ab7a738fc | buttegab/SideScroller | /Scoller Files/scroller_old.py | 7,476 | 3.5 | 4 | """ A Collaboratively-Coded Clone of Flappy Bird """
import pygame
import random
import time
class DrawableSurface():
""" A class that wraps a pygame.Surface and a pygame.Rect """
def __init__(self, surface, rect):
""" Initialize the drawable surface """
self.surface = surface
self.rec... |
09a6dc9c9d83f690fe29e1caaa546f68a4da5b68 | lucas-salles/ed-projeto3 | /insertion_sort.py | 276 | 4.0625 | 4 | def insertionSort(lista):
for i in range(1,len(lista)):
currentvalue = lista[i]
position = i
while position>0 and lista[position-1]>currentvalue:
lista[position]=lista[position-1]
position = position-1
lista[position] = currentvalue |
46a50d9d86ecd5e65469d7042cc581951e232299 | LeandroTeodoroRJ/CursoTkinter | /Tkinter_Aula14_Inserir_uma_Imagem.py | 964 | 3.546875 | 4 | #*************************************************************************************************
# INSERIR UMA IMAGEM NA TELA
#*************************************************************************************************
#INCLUDES
from tkinter import*
from tkinter.ttk import*
#GUI
ja... |
6f5f72bf389d74a8525800585b65000b134952f6 | LeandroTeodoroRJ/CursoTkinter | /Tkinter_Aula13_GRID_mesclagem_de_celulas.py | 1,070 | 3.5 | 4 | #*************************************************************************************************
# GERENCIADOR DE LAYOUT GRID - MESCLAGEM DE CÉLULAS
#*************************************************************************************************
#INCLUDES
from tkinter import*
#CONSTANTES E DE... |
e6a58d276ca6d8184cc7bbad6497ca0b222683a1 | themohitpapneja/Code_Dump | /Python/Basic Programs/Greatestofthree.py | 317 | 4.34375 | 4 | ## Greatest of three numbers using nested if-else.
a=float(input("Enter A : "))
b=float(input("Enter B : "))
c=float(input("Enter C : "))
if a>b:
if a>c:
print("A is largest")
else:
print("C is largest")
else:
if b>c:
print("B is largest")
else:
print("C is largest")
|
4276276ab591da58477aaa54fd9d2803a3b49645 | themohitpapneja/Code_Dump | /Python/Basic Programs/FibonacciUsingWhile.py | 159 | 3.578125 | 4 | x=int(input())
count=0
first=0
second=1
new=0
print(0)
while(count!=x):
count=count+1
new=first+second
print(new)
first=second
second=new
|
a9d5220623a0e0891fa3648b5f867cdf475fa5b1 | themohitpapneja/Code_Dump | /Python/OS Module/Changing_Directories.py | 352 | 3.546875 | 4 | from os import *
print(getcwd())
print(listdir('D:\\Users\\Mohit\\PycharmProjects\\PythonLab\\venv'))
print("Current Directory is: ",getcwd())
k=input("Enter Directory Where you want to jump: ")
print("Changing Directory.......")
chdir(k)
print("Current Directory is: ",getcwd())
print("Listing )the directories in curr... |
f77aa6892d90874bf5c282c3e0b3199536f73071 | themohitpapneja/Code_Dump | /Python/Pandas/Importing.py | 302 | 3.53125 | 4 | import pandas as pd ##pd is used as a short name for the pandas library
df=pd.read_excel("D:/Users/Mohit/Desktop/1.xlsx") ##df is a dataframe
#data frame consists of rows and columns
print(df.head()) ##df.head() is used to analyse the first 5 rows of the file
print(df) ## this prints the whole file
|
b18f21fae469e8acd5dbc365b8117568dd9e15fd | AlexeyKulyasov/Build-RESTful-Api-with-flask_restful-marshmallow | /models.py | 7,526 | 3.953125 | 4 | import sqlite3
from dataclasses import dataclass
from typing import List, Optional, Tuple
ENABLE_FOREIGN_KEY = "PRAGMA foreign_keys = ON;"
DATA = [
{'id': 1, 'title': 'A Byte of Python', 'author': 'Swaroop C. H.'},
{'id': 2, 'title': 'Moby-Dick; or, The Whale', 'author': 'Herman Melville'},
{'id': 3, 'tit... |
88dd3733389b585d37f85ba8034616e55402a7c7 | AmazingPaper/PrjWk2 | /Board/Board.py | 4,968 | 3.53125 | 4 | from Board.Enumerations import *
from Board.TileNode import *
class Corners:
TopLeft = (0, 0)
TopRight = (0, 10)
BottomRight = (10, 10)
BottomLeft = (10, 0)
# board class
# this class is for the tiles that players can move ( outer nodes of pyhsical board )
class Board:
def __init__(self):
# keeps track of bo... |
69aa760ecfe7d87a47c4231bf688247df5e35d9f | mrshridhara/python_trials | /src/project_euler/even_fibonacci_numbers.py | 751 | 3.796875 | 4 | """
Problem: https://projecteuler.net/problem=2
Each new term in the Fibonacci sequence is generated by adding the previous two terms.
By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not ex... |
4990347afd363c72aaf8d59119548696dea932c9 | yaozezhen/project-euler | /problem9.py | 188 | 4 | 4 | def pythagoreanTriplet(n):
for a in range(1, int(n/3)):
for b in range(a+1, int(n/2)):
if (a**2 + b**2 == (n-a-b)**2):
print(a, b, n-a-b)
pythagoreanTriplet(1000)
|
11447188e3b0b8ebf80c70230a1b6d433d6875ac | yaozezhen/project-euler | /problem12.py | 346 | 3.859375 | 4 | def findDivisor(n):
divisor = 0
if (n == 1):
return 1
for i in range(2,int(n/2)+1):
if (n % i == 0):
divisor += 1
return (divisor + 2)
#Highly divisible triangle number
def HDTN(n):
trigNum = 1
count = 2
while findDivisor(trigNum) <= n:
trigNum += count
count += 1
return tri... |
fdd7b4ff897a9b0d821b3a2a557882e23c945539 | ssrosa/dsc-0-10-10-complete-regression-online-ds-pt-100118 | /regression.py | 2,207 | 3.84375 | 4 | import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
import math
#take in an iterable, calculate the mean and subtract the mean value
# from each element , creating and returning a new list.
def mean_normalize(var):
var_arr = np.array(var)
var_normed = var_arr - var_arr.mean()
r... |
e9cad41d2a8b29a98fcab76da84a90af7cf15c3f | bennyk/MyPythonClass | /snippets.py | 828 | 3.515625 | 4 |
class Library:
numOfCell = 0
def __init__(self, name, version):
self.name = name
self.version = version
# init a dict to keep all store entries
self._cell = {}
Library.numOfCell += 1
def __del__(self):
Library.numOfCell -= 1
def hasCell(self, name):
... |
373af3c4d3e291af4adc9f3c173dbe9e8b851c03 | F820914768/Stevens_Bia660 | /HW2/domain_crawler.py | 771 | 3.703125 | 4 | '''
Yubo Feng stevens
HW 2
send requests to wikepedia, then save body of response into a html file locally
'''
import requests
from config import get_headers_from_config, get_url_from_config
if __name__ == '__main__':
'''
send requests to wikepedia, then save body of response into a html file... |
55acfb907dfda0d14e6670fcecb821935b471a66 | shalemrajmeduri/MyBasicPythonLearning | /While_Loop.py | 103 | 3.890625 | 4 | i=1
while i <= 10:
print (i)
i += 1 #you can also write i = i +1
print ("done with the loop")
|
0f9a69d0bdad5292afeb709c218365866290255a | saeed2016/hacker_collection.counter | /shoeShop.py | 785 | 3.625 | 4 | from collections import Counter
shoeSize = list(input("please enter size of shoes:").split(","))
cusCount = int(input("please enter number of Customer"))
orders = []
amount = 0
while cusCount > 0:
size, price = input("please enter shoe size and it's price:").split(",")
orders.append([size, price])
cusCount... |
76967b072a3d8172e4f33b468729002421e2c883 | vanderstel/pop-corpus | /dictionary/build_dict.py | 1,697 | 3.65625 | 4 | """
Parses the CMU dictionary into a usable format.
(Based on work by Adam Waller & Ivan Tan.)
"""
import string
from utils import skip_comment_generator, format_word
CMU_FILENAME = 'dictionary/cmudict.txt'
EXTENSION_FILENAME = 'dictionary/extension.txt'
FUNCTION_WORDS_FILENAME = 'dictionary/function_words.txt'
d... |
87597536a0c872b0b657489f5d4fcbce8e7c65a9 | ashi-27/choice | /players.py | 344 | 3.65625 | 4 | from random import choice
players = ['miley','tom','harry','mike']
teamA=[]
teamB=[]
print(players)
while len(players)>0:
playerA = choice(players)
teamA.append(playerA)
players.remove(playerA)
playerB = choice(players)
teamB.append(playerB)
players.remove(playerB)
print("teamA=",teamA)... |
d899014c4e20fee990dda32f1dd89530a07ff39d | ddd887/python | /支持命令的端口扫描器.py | 1,518 | 3.84375 | 4 | #! /usr/bin/python
# -*- coding: UTF-8 -*-
import socket
import sys
def open(ip,port):
s = socket.socket()
try:
s.connect((ip,port))
return True
except:
return False
def scan(ip,portlist):
for x in portlist:
if open(ip,x):
print("%s host %s p... |
e3ee1aa50b2e45655a08c7bb7a76fd7323b93c35 | ddd887/python | /staticmethod.py | 375 | 3.71875 | 4 | #! /usr/bin/python
# -*- coding: UTF-8 -*-
import time
class a:
def __init__(self,hour,minute,second):
self.hour = hour
self.minute = minute
self.second = second
@staticmethod
def b():
return time.strftime("%H:%M:%S",time.localtime())
def main():
print(a.b()... |
0d18180515ff00c1faa83997d4bfac7b148606f2 | AdarshRaveendran/pythonprogram | /Datepython.py | 250 | 4.09375 | 4 |
a=int(input("Enter day"))#input from the user
b=int(input("enter month"))
c=int(input("enter year"))
if a<=31 and b<=12 and (c<=2021):#days less than 32,month less than 13,years lessthan 2021
print("valid date")
else:
print("Invalid date")
|
305300819b4c20a7234c94353a5f0d03742139ce | PatKayongo/PythonKatas | /PythonKatas/StringCalculator/StringCalculator.py | 1,902 | 3.84375 | 4 | import StringHelper
class StringCalculator(object):
"""String Calculator Kata which can be found here http://osherove.com/tdd-kata-1/"""
def Add(self, numbers):
numberList = self._getNumberListFromString(numbers)
totalCount = 0
negativeNumbers = []
for number in numberList:
... |
30ac1834448ef5d8057246681d39fb7480f952a9 | chrisliatas/py4e_code | /py4e_ex_05_02.py | 625 | 4.09375 | 4 | largest = None
smallest = None
#count = 0
while True :
userinpt = input('Enter a number: ')
if userinpt == 'done' : break
try :
userinpt = int(userinpt)
except :
print('Invalid input')
continue
# if count == 0 :
# largest = userinpt
# smallest = userinpt
if l... |
633a04139a398a02f2c02826a3bc5e9c5e57c67d | HmirceaD/ProgHomeworks | /Lab5/rectangle_class.py | 329 | 3.65625 | 4 | from shape_class import Shape
class Rectangle(Shape):
def __init__(self, name, length1, length2):
super(Rectangle, self).__init__(name)
self.length1 = length1
self.length2 = length2
def display(self):
print(self.name)
def getarea(self):
return self.length1 * self... |
d4bc489380e7235e9a7409ce2553bb502573eee5 | HmirceaD/ProgHomeworks | /Lab6/soldier_class.py | 1,666 | 3.9375 | 4 | class Soldier:
def __init__(self, type, attack,
defense, armored, cost):
self.type = type
self.attack = attack
self.defense = defense
self.armored = armored
self.cost = cost
self.joined_army = None
def join(self, player, army):
"""Join ... |
534207e8839937ba75a6241d8de92f7ce2197ba5 | HmirceaD/ProgHomeworks | /Lab5/circle_class.py | 296 | 3.796875 | 4 | from shape_class import Shape
from math import pi
class Circle(Shape):
def __init__(self, name, radius):
super(Circle, self).__init__(name)
self.radius = radius
def display(self):
print(self.name)
def getarea(self):
return pi * (self.radius ** 2)
|
c15a66aabbcde732b8a388ba1beb634f30bfec2e | Digit314/TP_Quoridor-2020 | /TP_Quoridor2020/Quoridor-CA-master/reglas.py | 6,270 | 3.5 | 4 | import random
from random import randint
from busqueda import bfs
class Jugador(object):
def __init__(self, jugador_num):
self.jugador_num = jugador_num
self.posicion_ganadora = False
if (jugador_num == 0):
self.x = 4
self.y = 0
self.opp = 1
elif ... |
b37eec60b749467c5e879bf065bae1f3efc63a1f | jmerkin3/pythonblob1 | /pythonblobfile.py | 4,189 | 3.625 | 4 | import Myro
from Myro import *
from Graphics import *
from random import *
width = 500
height = 500
sim = Simulation("Maze World", width, height, Color("gray"))
#outside walls
sim.addWall((10, 10), (490, 20), Color("black"))
sim.addWall((10, 10), (20, 490), Color("black"))
sim.addWall((480, 10), (490, 490), Color("b... |
352294ce7eaa1d01a246a0893e59adabab012cad | ethancordell/ITSE-1329-Python | /CC2/CC2-Ex09/code.py | 345 | 3.921875 | 4 | h = input('Hours? ')
r = input('Rate? ')
try:
if float(h) > 40:
ot = float(h)-40
otr = float(r)*1.5
otpay = 40*float(r)+float(ot)*float(otr)
print('Pay', float(otpay))
else:
pay = float(h)*float(r)
print("Pay:", float(pay))
except:
print('Error, please enter n... |
00f516b00dad44e20f5417e44f3aa77184a3d15b | ethancordell/ITSE-1329-Python | /CC1/CC1-Ex10/code.py | 100 | 3.984375 | 4 | C = input('What is the temp in celcius? ')
F = (int(C)*9/5)+32
print('Fahrenheit temp is:',float(F)) |
e0900e1ed857fe2942eed9b4ff367ca3f89aff1d | ethancordell/ITSE-1329-Python | /CC2/CC2-Ex12/code.py | 125 | 3.9375 | 4 | kc = "sit"
c = input('What is the command? ')
while c != kc:
c = input('What is the command? ')
print('*puppy dog sits*') |
410449ea1108079d6e519ff78b24d680d787b2df | mattmakesmaps/python-junk | /global_vars/twofuncs.py | 470 | 3.859375 | 4 | #global var_s #does nothing
def f1():
# if no 'global' is present, will not implicitly
# create a global variable, e.g. that f2() can use.
global var_s
var_s = "f1 var, first assignment"
print var_s # non-func var
var_s = "f1 var"
print var_s # f1 var
def f2():
global var_s # if ommite... |
cd3244fa96e2770921a1d2831791ecc34b597bf6 | h2rashee/coconut_delivery | /delivery.py | 3,862 | 3.8125 | 4 | #Author: Harris Rasheed
# Variables initialised on start-up
jetStreams = []
mileCost = 0
# Stores the dynamic programming results of the minimum cost of getting to the
# end point of that jetstream (matches jetstream index number as above)
endOfStreamCost = []
# Stores whether the matching jetstream (index) had it's... |
73714b78366b06f582bfbe7a9c16c48eceb76dd3 | santhiya1214/DataScienceWorkspace | /OddEven.py | 732 | 4.46875 | 4 | # coding=utf-8
# Ask the user for a number.
# Depending on whether the number is even or odd,
# print out an appropriate message to the user.
# Hint: how does an even / odd number react differently when divided by 2?Extras:DiscussionConcepts for this week:
# • Modular arithmetic (the modulus operator)
# • Conditi... |
1945554439bf7bfc5013d1f33e1cae0cc1ed30fa | varunsinghal/data-structures-python | /1.11_naming_slice.py | 180 | 3.515625 | 4 | #Naming a slice
record = [23, 54, 32, 67, 56, 33]
SHARES = slice(0,3)
PRICES = slice(3,6)
print record[SHARES]
#Output: [23, 54, 32]
print record[PRICES]
#Output: [67, 56, 33]
|
66efde819c4063f5c26295cb1ca7fa1fde4b0573 | Tasuja/Python | /Workshop 5/intSumnatural.py | 183 | 3.96875 | 4 | number=[]
num=int(input("Enter a number:"))
a=0
while a<=num:
number.append(a)
a+=1
print(number)
print("The sum of all the natural numbers from 0 to %d are: %d"%(num,sum(number)))
|
2b6f6bc5b345954e0ee348c29f7f1411abec5091 | Stefaniv-M/Stefaniv_Mykola_coursework | /Coursework_Stages/3/3.4 - user_trees_test.py | 687 | 3.53125 | 4 | from user_trees import *
print("Creating a tree...")
root_user = User(1)
root_user.set_children([User(12), User(32), User(41)])
print("Height: " + str(root_user.height()) + "\n")
print("Adding children to children of root...")
for child in root_user.get_children():
child.set_children([User(234), User... |
183fc502bbf2993d780a781ee19f594ad87edc4e | vrotmanh/Cracking-the-Coding-Interview-Python- | /Chapter 1 (Arrays and Strings)/4_palindrome_permutation.py | 372 | 3.734375 | 4 | def is_palindrome_permutation(s):
d = {}
for i in s:
if i in d:
d.pop(i, None)
else:
d[i]=1
return len(d)<=1
print(is_palindrome_permutation('lheehllol'), 'expected: True')
print(is_palindrome_permutation('hay'), 'expected: False')
print(is_palindrome_permutation('lheehllolaa'), 'expected: True')
print(i... |
d601c9221f838973d99ef59be18d1c95e3444118 | nikitaminchenko01/Project_Linear_Algebra | /matrix_sum.py | 1,031 | 3.984375 | 4 | def matrix_sum(A, B):
""" Функция находит сумму двух матриц.
В качестве аргументов функция принимает две матрицы одиноковой размерности. Создается новая матрица суммы,
куда записываются элементы, каждый из которых равен сумме соответствующих элементов данных матриц.
После нахождения всех элементов э... |
6c7e006d2dad80e1a78268e1d49d1625c2fd65a4 | ksrinidhipatil/PythonDataStructure | /SingleCircular.py | 3,915 | 4 | 4 | class Node(object):
def __init__(self,data, pointer = None):
self.data = data
self.pointer = pointer
class CircularLinkedList(object):
def __init__(self,head = None, tail = None):
self.head = head
#Insert on at head
#@param {Integer} - Data to be entered
... |
2cb58329ab4fccd0d3347a4ed564222f4ba104b8 | rabustamante/Lab-5 | /Heaps.py | 3,670 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Author:Ruben Bustamante
Instructor: Diego Aguirre
TA:Gerarado Barraza
Course: CS 2302
Assigment: lab 5 part B
Date of last modification: 11/20/2019
Purpose of program:uses heaps to find the most occurneces of list of strings
"""
import time
import math
class node:
def __ini... |
b87f3754942f9f1a08c3965c024d089d18e0a707 | aisuluudb/Ch.2-Task-13 | /Task13.py | 178 | 3.734375 | 4 |
# n = int (input("Enter the number.."))
n = 25
i = 1
while i**i <= n:
print (i**i)
i += 1
# x = int
# i = 1
# while i*i <= x:
# print(i*i)
# i += 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.