blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
d329df75181a44f965c277f879caeaac0b28b47c
M-RAY47/Turtle-graphic
/random_walk.py
467
3.59375
4
from turtle import Turtle, Screen, pensize, title import random as rd title("Random walk") screen = Screen() screen.bgcolor("white") milo = Turtle() milo.heading() milo.speed(1) directions = [0, 90, 180, 270] colors = ["CornflowerBlue", 'green', 'red', 'wheat', 'yellow', 'violet', "orange"] milo.shape('turtle') milo.p...
5416a2cbc8430b1e80ec9b85694a2d98d6bd7881
barnuts/atbs
/CollatzSequence.py
315
4
4
#Simply Impossible def collatz_sequence(x): seq = [] x = (int(input())) if (x != 1): print("Number can't be 1") while x > 1: if x % 2 == 0: x = x / 2 else: x = 3 * x + 1 seq.append(x) return seq print(collatz_sequence(5))
f3da9de307b71f6ed9a4baaed9129ff09bf6cb47
Hoelog/BaekJoon_Study
/BaekJoon_2739.py
388
3.625
4
""" N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다. 입력 첫째 줄에 N이 주어진다. N은 1보다 크거나 같고, 9보다 작거나 같다. 출력 출력형식과 같게 N*1부터 N*9까지 출력한다. """ num = int(input()) for i in range(1, 10): print(num, "*", i, "=", num * i)
9ace26af065a7d173f2704d1e2e9c0adcbbbccde
LuAzamor/exerciciosempython
/dezenasinversas.py
502
4.0625
4
dezena1 = int(input("Digite um número inteiro terminado por zero: ")) dezena2 = int(input("Digite um número inteiro terminado por zero: ")) dezena3 = int(input("Digite um número inteiro terminado por zero: ")) dezena4 = int(input("Digite um número inteiro terminado por zero: ")) dezenas = [dezena1, dezena2, dezena3, d...
7b956d486613c4a40924bc8ef2f6be012f833c4e
LuAzamor/exerciciosempython
/maximo.py
313
3.96875
4
def maximo (n1, n2, n3): if n1 > n2 and n1 > n3: return n1 elif n2 > n1 and n2 > n3: return n2 else: return n3 n1 = int(input("Digite o primeiro número: ")) n2 = int(input("Digite o segundo número: ")) n3 = int(input("Digite o terceiro número: ")) print(maximo(n1, n2, n3))
4733063008b4fc20e5876d956ed4f79c8519992a
LuAzamor/exerciciosempython
/crescente.py
219
4.15625
4
num1= int (input ("primeiro número: ")) num2= int (input ("segundo número: ")) num3= int (input ("terceiro número: ")) if num1 < num2 < num3: print ("crescente") else: print ("não está em ordem crescente")
155e3da4e2113cb57fa186f3f887ab42c3fe40d0
marcoslorhanbs/PharmView
/DataBaser.py
835
4.125
4
import sqlite3 # conectando... conn = sqlite3.connect('Data/Remedios.db') # definindo um cursor cursor = conn.cursor() # criando a tabela (schema) cursor.execute(""" CREATE TABLE IF NOT EXISTS Remedios ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Nome TEXT NOT NULL, Preco...
2ca0c2f8fa73241114f43126a6fe763338650489
vipulshah31120/PythonDataStructures
/Stack.py
381
3.5625
4
stack = [] stack.append('A') stack.append('B') stack.append('C') print('Initial Stack: ', stack) print('Elements poped from Stack: ') print(stack.pop()) print(stack.append('1')) print(stack.append('2')) print(stack.pop()) print('Final Stack: ', stack) from collections import deque stack = deque() print(dir(stack)...
f93a0e365415b56b37ddc49187da509706235061
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Trees/Root_to_leaf_paths_binary_tree.py
1,489
4.40625
4
#1. Idea here is we want to return a list of strings which contains all of the root to leaf paths in the binary tree. #2. So initialize a list (path_list) then we are going to make a recursive call function. In the function we will pass the root of the binary tree and a empty string which we will modify and add node v...
3b01133e7372619a720fef3df6139aefef230d9f
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Trees/Evaluate_division.py
1,833
3.796875
4
def calcEquation(self, equations, values, queries): # Step 1: Build the graph graph = collections.defaultdict(dict) # Default dict beacuse if a value DNE it won't throw an expection unlike normal dict for (num, denom), product in zip(equations, values): # zip(equations, values) = [([a, b], ...
646cba760c4b035fddb46306a5f338aa14233c3e
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Array Problems/RotatingString.py
332
3.671875
4
def isRotation(s1, s2): count = 0 for index, letter in enumerate(s1): if letter != s2[0]: count += 1 else: if s1[:count] in s2 and sorted(s1) == sorted(s2): return True else: return False print(isRotation("CurryHot",...
5010bcc2eca73c0f2dd965382aee852fd793c090
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Stacks/valid_parentheses.py
473
3.5625
4
def isValid(self, s): stack = [] validBrackets = ["[]", "{}", "()"] openBracket = ["(", "[", "{"] for i in s: if i in openBracket: stack.append(i) elif len(stack) > 0: bracket = stack.pop() if bracket + i in validBrackets: pas...
8546f6029e88845a1701aee40bd3159232b0ce1f
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Trees/Build_Tree_Inorder_Preorder_Optimal.py
756
3.984375
4
#* This is the optimal way to build a binary tree using inorder and preorder lists. #* Once again same pattern as building a postorder and inorder tree algorithm. Alll we are doing is just popping from the front of the preorder list #* Remember this hashmap and binary search sort of pattern! def buildTree(preorder, ...
fb7836dbed72f2d4b94c4d66ebd09cc0a0bb0257
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Array Problems/Two_sums.py
512
4
4
def twoSum(nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ hash_table = {} for index, element in enumerate(nums): what_i_need = target - element if what_i_need in hash_table: return [hash_table[what_i_need], index] ...
5524114bbb1f357a069e2d69cdd0b692a661d446
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Stacks/Stacks revision.py
4,673
3.921875
4
class Stack: def __init__(self): self.__list = [] def get_Stack(self): return self.__list def is_empty(self): return self.__list == [] def size(self): return len(self.__list) def push(self, item): self.__list.append(item) def pop(self)...
f9609ba1cd7bbfd142c37ee3a85f5d47da3276db
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Stacks/decode_string.py
1,733
3.96875
4
#1. Idea is we use a stack, where each element in the stack is a list, the list contains the current string and current repeat value, we know it is the current string because we have not yet hit a closed bracket because once we hit the closed bracket we pop off. #2. Initialize a stack which contains an empty string an...
1ec4efeca06d234bc78638718a48814b07ef6ede
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Trees/DFS_Preorder_Iterative_Stack.py
932
3.84375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def preorderTraversal(self, root): # root = [1, None, 2, 3], preorder = node, left, ...
2705e51ea697db6571abb590e11ab34ad5b6932d
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Array Problems/Plus_one.py
504
3.640625
4
def plusOne(self, digits): """ :type digits: List[int] :rtype: List[int] """ if len(digits) == 0: return digits digits = "".join([str(i) for i in digits]) digits = int(digits) + 1 return [int(i) for i in str(digits)] digits = [1,2,3] print(plusOne(digits)) # Output:...
4c4b94ca6467f49e4d8309393d0b64723a85c59c
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Trees/Max_path_sum_in_binary_tree.py
2,107
4.4375
4
#1. Firstly, understand what the question wants. It wants the MAX PATH. Recall a path is a sequence or iteration of nodes in a binary tree where there are no cycles. #2. Now, I want you to approach the recursion this way - "What work do I want to do at EACH node?" Well at each node we want to find the value of its lef...
83694dab55c9d3d75e08e762736cfd154a6ceb3c
Tanmay-Thanvi/DSA-and-Leetcode-Walkthroughs
/Dynamic Programming/Container_with_most_water.py
1,028
3.609375
4
# Dynamic sliding window where we adjust both end accordingly and all we are doing is finding the max area so w x h between the start of the window and end of the windows def maxArea(height): maxSum = 0 windowStart = 0 windowEnd = len(height) - 1 while windowStart < len(height): runningSum...
a93f8cf93a21d7b61bb96b31721a25c34693cc7c
smk71/Discount-program-
/new 11.py
2,152
3.796875
4
def BookOptions(): book_option = [[1, "Moby Dick (1851) ",15.20 ], [2, "The Terrible Privacy of Maxwell Sim (2010)", 13.14], [3, "Still Life With Woodpecker (1980)", 11.05], [4, "Sleeping Murder (1976)", 10.24], [5, "Three Men in a Boat (1889)", 12.87], [6, "The Time Machine (1895)", 10.43], [7, "The Caves o...
591103e328101ee883a219fc0f9dd94517eca43a
Treshank/College
/assignments/day2_ex1.txt
161
3.90625
4
list = input("Enter list of ele separated by comma: ").split(',') n = int(input("Enter the size to sort: ")) for e in list: if len(e) > n-1: print(e)
f606f173db6aaed085796b59e07a07e80a8bdb02
Treshank/College
/Mar5/Mar5p6.py
376
3.734375
4
# Write a pyhton fn to find the 1st appearance of the sub string 'not' and 'poor' from a given string. If not followed # poor, Replace the whole 'not.... poor' with good return the resulting string def findthis(str): p1 = str.find('not') p2 = str.find('poor') if p1<p2: news = str[::p1] news...
5c3c26fa6e36a549d95bf5df93c1b1669de1ed9a
Treshank/College
/Feb25/Feb25p4.py
139
3.828125
4
import random while True: if(random.randint(1, 9)==int(input("Enter a number: "))): break else: print("Try again")
4afedaf57c6000e915ae5ff61154ebad9fb6acac
quanhoang288/neural-networks-with-PyTorch
/utils/timer.py
382
3.578125
4
from datetime import datetime import numpy as np class Timer(object): """Record training durations""" def __init__(self): self.running_times = [] def start(self): self.starting_time = datetime.now() def stop(self): self.running_times.append(datetime.now() - self.starting_time)...
aae38bd4011ef8830ee4d2206d427e970a54124c
David0leo/project-euler-python
/problem-2.py
681
3.53125
4
# Project Euler Problem 2 ###################################### # ** Find the sum of even Fib. Numbers # not greater than four million ###################################### # Fibonacci numbers f(n), starting with f(1) = 1 def fib(n): assert type(n) is int, "n is not an integer" assert n > 0, "Strictly pos...
3c392f9c43e40783cd84f6191035cdd11fdbb469
b-jazz/configurati
/configurati/loaders/utils.py
902
3.53125
4
import code import re import sys def isstring(s): """Version of isinstance() that should work with python 2.6/2.7 and python 3+""" if sys.version_info[0] < 3: return isinstance(s, basestring) else: return isinstance(s, str) def substitute(s): """Contents of `...` evaluated in Python""" if isstring...
382f4bf542d76715526265ce4c70cda77072f4d6
jmbert/2D-Planets
/main.py
3,270
3.71875
4
import turtle import time import math turtle.tracer(0, 0) turtle.speed(0) s = turtle.Screen() DeltaTime = 1 G = 6.6743 * pow(10, -11) class Vector : x = 0.0 y = 0.0 def Scale(self, b) : return Vector(self.x * b, self.y * b) def Length(self) : return math.sqrt((self.x * self.x)...
d7231cbade06c700c30708774976b59c5e94cca8
noahgallagher1/Data-Structures
/DLList.py
1,985
3.828125
4
class Node: def __init__(self,item): self.item = item self.next = None self.prev = None self.recover = 0 class DLList: def __init__(self): self.n = 0 self.dummy = Node(None) dummy = self.dummy dummy.prev = self.dummy dummy...
684dee2e51211935d82cf610877bb15aeb511be2
Charling-Huang/EulerProblems
/Euler1.py
1,201
3.78125
4
def euler_one(num): """ - triangle numbers used to produce results in constant time - modified its formula Tn = n * (n + 1) / 2 for multiples of x => n = # of multiples of x => Tnx = x * n * (n + 1) / 2 Proof at: http://jwilson.coe.uga.edu/EMT668/EMAT6680.F99/Jones/EMAT%206600/Problem%20Solv...
96b924453a8f40c5fe118b63d27b8e0c7fcd3ac4
lannyMa/flask_info
/demo-test/demo7.py
618
3.875
4
#!/usr/bin/env python # coding=utf-8 class DictDemo: def __init__(self, key, value): self.dict = {} self.dict[key] = value def __getitem__(self, key): return self.dict[key] def __setitem__(self, key, value): self.dict[key] = value def __len__(self): return len...
1fbff5cb976834ad51492b4f4b3cd65afafd51e7
paull87/think-like-a-programmer
/problem_side_triangle.py
723
3.6875
4
char = '#' end_char = '\n' def create_half_square(number, char=char, end_char=end_char): output_format = '{}{}' output = '' for idx in range(number, 0, -1): output += output_format.format(str(char) * idx, end_char) return output def create_triangle(number, char=char, end_char=end_char): ...
bcffc88f3cee0f80b84daedb5799477bed2b2f0b
sk-vojik/Intro-Python-I
/src/hello.py
410
3.796875
4
# Print "Hello, world!" to your terminal print("hello world") # class Animal: # # define attributes, assign initial values # def __init__(self, sound, leg_count=4): # self.leg_count = leg_count # self.sound = sound # def set_let_count(self, leg_count): # self.leg_count = leg_count # def make_sou...
a69d0878e2ff7235a4490064fe8ef716923c83a9
pllim/playpen
/tribute_finder.py
1,810
3.734375
4
"""Pick a tribute to run a meeting or whatever.""" import random from collections import Counter def pick_tribute(population, previous_tributes, seed=None): """Pick a tribute. May the odds be ever in your favor. Parameters ---------- population : list List of all the choices to choose from. ...
c73d3d7e714c617aefb91d27c221e40f29cdc7f3
pllim/playpen
/advent_2019/advent_code_2019_day04.py
1,083
3.515625
4
import numpy as np def is_possible_password(pw, min_pw=None, max_pw=None): if min_pw is not None and pw <= min_pw: # Must be in range return False if max_pw is not None and pw >= max_pw: return False pw_chars = np.array([c for c in str(pw)]) if len(pw_chars) != 6: # Also must be 6-...
fcfe2621dbce6fa4a7173a7579d2b68c21b46773
pllim/playpen
/fileinfo.py
2,995
3.546875
4
"""Files related functions. Examples -------- >>> import fileinfo Find total file size for all '*py': >>> total_size = fileinfo.get_filesize('*py') 0.073599 MB for 24 files Find last modified '*py' in the directory: >>> myfile = fileinfo.get_latest_file('*py') """ from __future__ import print_function # STDLIB i...
13b2d2509c6bb61a1c6f5a92c63bfeb81d4e754e
Mesheo/U.R.I-python
/URI - 1930 Tomadas.py
315
3.6875
4
#Recebe as tomadas tomadas = input().split() #Armazena cada tomada em uma variável tomada1 = int(tomadas[0]) tomada2 = int(tomadas[1]) tomada3 = int(tomadas[2]) tomada4 = int(tomadas[3]) #Soma cada tomada e subtrai 3, o numero de tomadas perdidas. total = (tomada1 + tomada2 + tomada3 + tomada4) -3 print(total)
35bf7060d2c277cae1ef74dfc84ff380396651bc
mammarijaz/python-universe
/universe.py
3,878
3.5
4
import random import star from star import Star from star import DwarfStar from star import GiantStar from star import MediumStar class Universe: def __init__(self): self.dwarf_Gaseous_Planets=0 self.dwarf_Rocky_Planets=0 self.dwarf_Habitable_Planets=0 self.dwarf_Intelligent_Planet...
23122581193d52723febfbc01911a907767f6958
sondoan/MoodList
/normalize.py
195
3.59375
4
# Normalize the word list import os,sys def norm(file): fin = open(file) for line in fin.readlines(): print line.strip().lower() fin.close() if __name__=="__main__": norm(sys.argv[1])
98e4c7f36a3cffe0155cdbd44092d2482108e9b2
wglee0511/python-nomad-codechallenge
/CodeChallenge/challenge1.py
492
3.96875
4
days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] def is_on_list(day_list, day): return day in day_list def get_x(day_list, day_num): return day_list[day_num] def add_x(day_list, day_add): return day_list.append(day_add) def remove_x(day_list, day_remove): return day_list.remove(day_remove) print("...
e152702f3c7f12029e3b8051aaf62982fc6d53c7
smitdylan2001/GnIAdventOfCode2018
/Vincent/Day1/Puzzle2/main.py
351
3.515625
4
def solve(input): n = 0 d = { 0: 1 } found = False while not found: with open(input) as f: for line in f: n += int(line) if not n in d: d[n] = 1 else: found = True break ...
58092f269e42d816789dbebbeadfc7eb5b6819cf
AlexandrKosteki/string
/problema 2 string.py
482
3.78125
4
s=str(input('Introduce sirul de caractere')) majuscule=0 cifre=0 speciale=0 for n in s: if ord(n) in range(65,91): majuscule+=1 if ord(n) in range(48,58): cifre+=1 if ord(n) in range(33,48) or ord in range(58,65) or ord in range(123,127) or ord in range(91,97): speciale+=1 ...
72506ad7bf8a3dfd8cdee6bcb661f5f6afb0a9b8
c-huynh/algorithms1
/homework5/dijkstra.py
5,026
4.34375
4
""" Implementation of Djikstra's shortest path algorithm with min heap. The file (dijkstraData.txt) contains an adjacency list representation of an undirected weighted graph with 200 vertices labeled 1 to 200. Each row consists of the node tuples that are adjacent to that particular vertex along with the length of tha...
f6d749dd0bcbbfd273ce6133af766d0c21dc5315
c-huynh/algorithms1
/homework6/medians.py
1,621
3.84375
4
""" The goal of this problem is to implement the "Median Maintenance" algorithm (covered in the Week 5 lecture on heap applications). The text file contains a list of the integers from 1 to 10000 in unsorted order; you should treat this as a stream of numbers, arriving one by one. Letting xi denote the ith number of th...
62a8275512631d81087db377968e9ad3b7670875
vesselofgod/Data_Structure_Lecture_Note
/Stack/9012(괄호).py
664
3.625
4
N=int(input()) for i in range(N): String= input() List=[] List.append(String[0]) i=1 j=0 while i<len(String): if String[i]== '(' or String[i]== '{': List.append(String[i]) i=i+1 elif len(List)==0: print('NO') j=j+1 brea...
4480dd4d7daab8cd57a96118acda472fd5f4e5a0
vesselofgod/Data_Structure_Lecture_Note
/Queue/listQueue.py
1,092
3.546875
4
class Queue: #큐 : 대기열과 같은 FIFO 구조(first in first out front=(-1) # 맨 앞 원소의 index를 의미함 back=(-1)# 맨 뒤 원소의 index를 의미함 item=[] def isEmpty(self): return self.back==-1 def push(self, item): self.back+=1#맨 뒤 원소의 idx 1 증가 self.item.append(item)#맨 뒤부터 삽입되므로 appe...
beb0ad87cd7cf11dc96b2c88a07d319003e55374
vahidfazelrezai-projects/textcompare
/textcompare/vocabulary_utils.py
6,419
3.5
4
import math import os from textdoc import load_directory from textdoc import TextDocFromWordSet from metric import generate_metrics # Given a list of books, a vocabulary, and a metric, return the book that is # most similar to the vocabulary. # # Input: # textdocs - a list of TextDoc objects representing the books # v...
83cadf4c7ee9350ffacc82d7c12734784d968b97
annaprok/Weather-Diary
/model.py
2,756
3.828125
4
import datetime import json import doctest # Получить все записи из дневника def getAll(): """Get all elements from array. """ with open("data.json", "r") as read_file: days = json.load(read_file) return days # Получить один елемент по id, None если не найден def getById(id): ...
0feb565bea79bc4279a38538c6cafda236c727b2
sajdik/School-Projects-BIT
/IPP/Task2/Frame.py
1,086
3.59375
4
from ErrorHandler import ErrorHandler class Frame: """Storing variables, info about them and their values""" def __init__(self): self.store = dict() self.initialized = set() def define(self, name): """Define variable in frame""" assert name is not str if name in se...
7d41d4678474eed33fcf6e048028d878287cfab2
Tienta/Techkids_C4E_Assignment
/Assignment 4/4_9 (9).py
188
3.859375
4
import turtle rua = turtle.Turtle() rua.speed(-1) rua.pensize(3) def drawFivePointStar(t): for i in range(5): t.forward(100) t.rt(144) print(drawFivePointStar(rua))
0087cab17b7896443ede8cbc664a97baeab100e8
Tienta/Techkids_C4E_Assignment
/Assignment 4/4_9 (10).py
349
3.578125
4
import turtle bg = turtle.Screen() bg.bgcolor("light green") rua = turtle.Turtle() rua.speed(-1) rua.color("hotpink") rua.pensize(3) def drawFivePointStar(t): for i in range(5): t.forward(100) t.left(216) for i in range (5): drawFivePointStar(rua) rua.penup() rua.fd(350) r...
40bf9f8db1ee3a036d177f51471f50d9dac69d2e
lvwuwei/pythoncode
/showmecode/day11/replaceword.py
528
3.734375
4
import os def Words(path): filterWords=[] with open(path, 'r',encoding= 'utf-8') as f: for word in f: filterWords.append(word.strip('\n')) print(filterWords) return filterWords if __name__=='__main__': filterwords=Words('filtered_words.txt') while(True): my...
fd48d3838051c589b4366407ccea8875ebb98f0f
pshatov/teacherctf-2020
/tasks/zoomers/writeup/original_encryptor.py
538
3.53125
4
earth_alhpabet = 'abcdefghijklmnopqrstuvwxyz{}_ ' zoom_alphabet = 'zoumna' keys = [4, 6, 5] a, b, c = keys[0], keys[1], keys[2] translated_zoom_alphabet = [ (zoom_alphabet[(len(earth_alhpabet) - i) % a] + zoom_alphabet[(len(earth_alhpabet) - i) % b] + zoom_alphabet[(len(earth_alhpabet) - i) % c]) ...
0bf9c45e025e061d10eb1bbd299e8bf58f0d0089
bgoldfarb/DataScienceWithPython
/NumpyOperations.py
1,976
3.75
4
import numpy as np arr = np.arange(0,11) print(arr) #Double each element of array print(arr+arr) #Scalars print(arr+100) #Universal Array Functions print(np.sqrt(arr)) print(np.exp(arr)) print(np.max(arr)) print(np.sin(arr)) print(np.cos(arr)) print(np.log(arr)) #Numpy Problems #Create an array of 10 zeros z...
03b6c82db851d82230aeaae0aceca8de0d71bc75
bhairavmehta95/neural-networks-and-deep-learning
/src/implementation/Network3.py
7,504
3.6875
4
''' Tensorflow implementation of network3.py Slightly different network architecture than in the book Not GPU accelrated Network Architecture: CNN: 1st Convolutional Layer: Convolution computes 32 features for each 5x5 patch Max Pooling 2nd Convolution Layer: 64 features for each 5x5 patch Max Pooling Image red...
e864f950f6954159af078f6592af6e7d894202ad
violazhu/hello-world
/closure.py
1,769
4.15625
4
""" 实现计数器统计函数调用次数 """ # def createCounter(): # """ 方法1:list的原理类似C语言的数组和指针,不受作用域影响 # 直接改变值对应的地址。也就是说不是改变值的引用,而是永久改变值本身 """ # L=0 # def counter(): # L=+1 # return L # return counter def createCounter1(): """ 方法1:list的原理类似C语言的数组和指针,不受作用域影响 直接改变值对应的地址。也就是说不是改变值的引用,而是永久改变值本身 ""...
50f5f37fefdb6ba01d648a4efaff118b1ba2470a
violazhu/hello-world
/sorted_func.py
748
3.5625
4
# L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)] # # L={'Bob':75, 'Adam':92, 'Bart':66, 'Lisa':88} # # def get_keys(value1,dict1): # for key,value in dict1: # if value1==value: # return key # # def by_score(**dict1): # values_sorted=sorted(dict1.values()) # # new_dict={} # #...
2c759583412371a39d2b1286f2107c2021bd5dc5
mrG7/tgene
/lengthdist.py
2,438
3.546875
4
"""lengthdist.py State length distributions""" from maths import * from io import * class LengthDist: """Base length distribution class. GHMM module will provide constructor with string 'params' taken from ghmm.cfg file.""" def probLength(self, length): """Log of probability of emitting a state of...
2fc237949c700925f1f56c06aa73d5988feaf90c
rholdberh/pythonScripts
/calc/graphicCalc.py
2,059
3.65625
4
from graphics import * win = GraphWin('Calculator', width=200, height=200) # create a window win.setBackground('white') win.setCoords(0, 0, 12, 12) text_area = Text(Point(2, 11), "") text_area.setFill('blue') text_area.draw(win) def numeric_buttons(): button_color = 'black' # x,y x,y _1 = Rectangle(P...
63bdbe4ccee706b12c9632d3c9e7054497660dbe
Multiverse-Mind/MIPT-programming-practic
/lab2/Упр 9.py
512
4.125
4
import turtle from math import sin, pi def polygon(n, r): for i in range(n): turtle.forward(2 * r * sin(2 * pi / (2 * n))) turtle.left(180 - (((n - 2) * 180) / n)) turtle.shape('turtle') turtle.penup() r = 20 turtle.forward(r) turtle.pendown() for n in range(3, 13): turtle.le...
12cbb9b004d8360c72ca0e797b88094b86037cdb
ctec121-spring19/programming-assignment-2-beginnings-JLMarkus
/Prob-3/Prob-3.py
1,055
4.5
4
# Module 2 # Programming Assignment 2 # Prob-3.py # Jason Markus def example(): print("\nExample Output") # print a blank line print() # create three variables and assign three values in a single statement v1, v2, v3 = 21, 12.34, "hello" # print the variables print("v1:", v1) ...
24523e86b444a80e5c7b44248d3defeb41bf892d
Brenda-b/Training-python-
/Tkinter/ejercicio-calculadora.py
3,517
3.53125
4
import tkinter from tkinter.constants import CENTER, END ventana= tkinter.Tk() ventana.title("Calculadora") ventana.geometry("400x600") ventana.resizable(False,False) ventana.configure(background="gray") #funciones operacion="" resultado= tkinter.StringVar() def click(valor): global operacion global...
0ccde729640adf5831c3aa889e5b775acc36a8fe
tayashigenori/project_euler_memo
/problem14_longest_collatz_sequence.py
3,993
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys """ Problem 14 "Longest Collatz sequence" の解法 http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2014 """ #collatz 列を計算する。 #すでに計算済みの数字が見つかった時点でやめる def get_collatz_sequence(n, collatz_length_stored): """ 例えば 13 から開始した Collatz 列 col...
2e8b80ac79dcf81144de4b9a764286ae45d4b5f7
A-CHRI/Bacteria_Data_Analysis
/dataFilterTest.py
5,995
3.6875
4
from dataLoadTest import dataLoad import numpy as np # Creates a list for the different filters, and creates a list of the different applied filters filters = ["Bacteria", "Temperature", "Growth rate"] appliedFilters = [] # Creates a list of the different bacteria, and creates a list of the different applied bacteria...
bfdc7240a60d40cd773efab38a02a155ea8e19f1
0002sejwal/pYThOn
/Task_1_part_1.py
138
4.40625
4
radius=float(input("Enter radius of circle: ")) print(radius) pi=3.14 area = pi*radius*radius print("The area of the circle is %f" %area)
0e2f54ed372dea3f779db63a644f8a7496ea4c52
Bhartisharma28/Practice-DSA
/Python/playing.py
91
3.640625
4
l=[1,2,3,4,5,6] res=l[::-1] print(res) f=["abc", "ghj","lhb"] result=f[::-1] print(result)
113166c6fe6c68bdf7035945b598734d403895de
Bhartisharma28/Practice-DSA
/Python/avg.py
146
4.125
4
n=int(input("enter total numbers: ")) sum=0 for i in range(n): nums=int(input("enter the no: ")) sum+=nums avg=sum/n print(avg)
620e01a6fabe5a8cfff84218ff27fe502829bce9
rajspathak/AssignmentDemo
/Day3.py
385
3.578125
4
''' Implement a decorator mod_div() which assures that the numerator is always greater than the denominator e.g. if a = 2, b = 4, then div(a, b) should return 2.0 as the output and not 0.5 ''' def div(a, b): print(b / a) def div_rev(fun): def inner(a, b): if a > b: a, b = b, a fun(a,...
508d840ccd9ac1795f2f9702d724aff30e1fc037
firdosh-nasim/Accion_SDET
/Q2_Return_Unique.py
4,485
3.953125
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 16 18:48:31 2018 @author: firdo """ """ 2. Programming Challenge Description: Write a function that accepts two arbitrary strings and returns a new string containing only the unique characters present in both inputs. Input: The function must accept two string parameter...
200f0850d131c4d4b3f6338fa50add853b967dce
simanadya/class_work
/class_work8.py
2,777
3.515625
4
dict_vocab_en_es = { 'world':'mundo', #ключ:значение 'language': 'idioma', 'See you later': 'Hasta la vista' } print (dict_vocab_en_es["world"])#только поиск по ключу, нельзя наоборот capitals = { 'United Kingdom':'London', ...
fe4a7c469078c0ce742414a6d3af6b824e237b9d
ludviglundgrens/Hashtable-Linked-List
/hashtable.py
1,279
3.796875
4
class HT: def __init__(self, length): self.length = length self.array = [None]*length def add(self, key, value): index = hash(key) % self.length start_index = index while self.array[index] != None: if index == self.length-1: index = 0 ...
b6fe9ce584b44496159e6a3a197fa85322b6260a
ravitkhurana/watchout
/watchout/main.py
7,833
3.8125
4
import pygame import enum class Color(enum.Enum): """ Enumeration for common colors """ BLACK = (0, 0, 0) WHITE = (255, 255, 255) BLUE = (0, 0, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) class Constants(object): """ Class to hold constants used in game """ GRAVITY =...
4823e9efdb5f48c662ef29911b36324b86ea2be2
joyonto51/Programming_Practice
/Python/Old/Python Basic/Problem/24-08-17/Problem-2.2.py
248
3.96875
4
inp=input("Please enter a number:") a=float(inp) B=a%1 if B<0.5: b=int(a) print("the number is:"+str(b)) if B>=0.5: c=int(a) print("The number is:"+str(c+1)) else: d=int(a) print("The number is:"+str(d))
2d541360ec9bd6bd6dd94914964985d2e7492102
joyonto51/Programming_Practice
/Uva Problems/Python/12149.py
138
3.625
4
while True: N=int(input()) if N==0: break a = 0 for i in range(1,N+1): a += i*i print("{}".format(a))
0a3dd701256da1c24202326e7c798583013cc7fd
joyonto51/Programming_Practice
/Python/Old/Python Advance/Practise/Addition.py
268
3.65625
4
class Test: a, b, c, d = 1, 2, 3, 4 def __init__(self): pass def __add__(self, other): self.a += other.aprint(A.a) return self A = Test() B = Test() C = Test() print(A.a) print(B.b) print(A + B) print(C.a)
77f7d32957642a8c4fd1700da259253a0e74865b
joyonto51/Programming_Practice
/Python/Old/Python Basic/Problem/24-08-17/Problem-2.5.1.py
180
3.9375
4
inp=input("Enter the Position:") a=float(inp) if (a>=1.0 and a<=1.9) or (a<=-1.0 and a>=-1.9): print:("The number of Term: 1") else: print("The number of Term: 2")
9e7130c29640af62aa5f3da73053b689a260caf4
joyonto51/Programming_Practice
/Uva Problems/Python/11150.py
249
3.671875
4
while True: try: n=int(input()) except: break N=n while True: x = n%3 n = (n//3) N+=n n+=x if n==2: N+=1 if n<3: break print("{}".format(N))
db0479a9cb64020a74d3226af0b38ebbda140e66
joyonto51/Programming_Practice
/Python/Old/Python Advance/Practise/Factorial_by_Recursion.py
347
4.21875
4
def factorial(number): if number == 0: return 1 else: sum = number * factorial(number - 1) return sum number=int(input("please input your number:")) ''' num=number-1 num1= number for i in range(num,0,-1): sum=num1*i print(num1,"*",i,"=",sum) num1=sum ''' ...
904a0ade4b1427f9aca0adb00df7b83e16592452
joyonto51/Programming_Practice
/Python/New/working_with_files/file_write_2.py
259
3.53125
4
#open a file for writing and create it if doesn't exist f = open("guru99.txt", "a+") #write some lines of data to the file for i in range(10,20): f.write("This is line %d\r\n" %i) f.close() with open("guru99.txt") as file: for line in file: print(line)
8b14001d5a10800e1a00684877a11a64324e8a79
joyonto51/Programming_Practice
/Python/Old/PyCamp Task/test_Prime_num.py
404
3.515625
4
import unittest def prime(num): p = True if num > 2: n = num//2 + 1 for i in range(2, n+1): if num % i == 0: p = False break return p class Testprime(unittest.TestCase): def test_prime(self): self.assertEqual(prime(4), False) ...
52c8c0cf95855c1fba3bae288b8e39d55bc26de5
joyonto51/Programming_Practice
/Python/Old/Python Basic/Problem/22-08-17/Problem-1.1.2.py
370
3.828125
4
inp=input("Plz enter an year:") n=int(inp) if n%4==0 and (n%400==0 or n%100!=0): print(str(n)+" is a Leap year") print("the next leap year is:"+ str(n+4)) else: print(str(n)+" is not a Leap year") for a in range(1,7,1): if (n+a)%4==0 and ((n+a)%400==0 or (n+a)%100!=0): prin...
cbe6431539a5159881dd18b2ed02469c0f6a2e6c
joyonto51/Programming_Practice
/Python/Old/Python Advance/Practise/Iterator.py
455
3.625
4
class revrange: def __init__(self,n): self.n = n self.i = n def __iter__(self): print(10) return self def __next__(self): if self.n >= 0: print("first1") self.i = self.n self.n = self.n - 1 retu...
7003088910745a7c2b61c2ef6974e6c682c21db9
joyonto51/Programming_Practice
/Python/Old/Parctice/Dict_to_list.py
251
3.859375
4
## Task 1 test_dict = {"a": 1, "b": 2, "c": 3, "d": 4} # Write your code here test = [] for key, value in sorted(test_dict.items()): a = (key, value) test.append(a) test_dict = test print(test_dict) # [('a', 1), ('b', 2), ('c',3), ('d',4)]
ecfdc0076568c983b004554a249dc786416a23bc
joyonto51/Programming_Practice
/Python/Old/Python Basic/Loop/54.py
165
3.921875
4
a=int(input("Enter a number:")) b=int(input("Enter another number:")) if(a>b): c=a-b print(a,"-",b,"=",c) else: c=b-a print(b,"-",a,"=",c)
ec86fbd921f49c815bc186b629d07754ff77b857
lucastorress/finalchallenge-api
/api/controllers/helpers/convertDate.py
606
4.09375
4
def convert_ISO8601_to_normal(date): full_date = date.split('-') day = full_date[2][:2] month = full_date[1] year = full_date[0] return f'{day}/{month}/{year}' def convert_normal_to_ISO8601(date): date_ISO8601 = 'T12:00:00-03:00' date_input = date.split('/') day = date_input[0] mon...
8fa0346bce52d1c227b25dcc9dcb9da7294d5d4d
robre/attacking-mlaas
/client.py
1,062
3.546875
4
import random class Client: """ This class simulates a Client who polls a Server for predictions on data Such as prediction of coordinates within a building by providing wifi AP data """ def __init__(self): #TODO pass poll_count = 0 def poll_server(self, server, predi...
90d6f45188cd37274453b2b944ad5432de3a60d5
sunshine55/python-practice
/lab-01/solution_exercise1.py
2,140
4.1875
4
def quit(): print 'Thank you for choosing Python as your developing tool!' exit() def choose(choices=[]): while True: choice = raw_input('Please choose: ') if len(choices)==0: return choice elif choice in choices: return choice else: print 'You must choose from one of the following: ', sorted(choic...
ec532784ebdb6297da1742f8f476866152cee7d6
sunshine55/python-practice
/session-03/setop.py
556
3.921875
4
# -*- coding: utf-8 -*- a = set(['java','c#','php']) b = set(['php','python','ruby']) z = set(['php', 'c#']) print 'Union – Merge two sets' print a.union(b) # OR a | b print 'Subtraction – Remove members from a set' print a - b print b - a print 'Intersection – Take the common members from two sets' print a.interse...
5cc9d0c6200b585b5a177d1c4ecaa9cb7407a33b
sunshine55/python-practice
/session-03/comprehension.py
1,321
3.609375
4
class Student: def __init__(self, name, grade, favorite): self.name = name self.grade = grade self.favorite = favorite students = [Student('Tom',10,'PHP'), Student('John',6,'Python'), Student('David',6,'C#'), Student('Paul',8,'C#'), S...
a3c96d2d50f0e25f0e31a5541594c7851fe7c2a6
riccardo-lomazzi/projects
/Python/corspoapi_exercises/conta_coppie_stessasomma.py
529
3.515625
4
def check(arr): if(len(arr)%2 == 0): arr.sort() print("Sorted:") print(arr) t = arr[0]+arr[len(arr)-1] print("t: " + str(t)) for i in range(1,len(arr)): sum = arr[i]+arr[len(arr)-i-1] print("arr[i]: " + str(arr[i])) print("arr[n-i-1...
4dded3cf27d0a9db068c40cfedc3a8f7f1eef69a
riccardo-lomazzi/projects
/Python/automate_boring_stuff_with_python/Magic8Ball/magic8ball.py
409
3.65625
4
import random print('Pallina magica') messages = ['Andrà tutto bene', 'Potrebbe andare meglio, ma ok', "L'inverno sta arrivando"] print('Digita E per uscire, o qualsiasi altro carattere per continuare') userInput = input() while(userInput != 'E'): print("Messaggio random: " + messages[random.randint(0, len(messa...
f7da5f7d247732a7b3f12767524f4cd1e82e3935
riccardo-lomazzi/projects
/Python/corspoapi_exercises/quicksort.py
388
3.8125
4
def partition(A, p, r): x = A[r] i = p-1 for j in range(p,r-1): if(A[j]<=x): i = i+1 A[i],A[j] = A[j], A[i] A[i+1],A[r] = A[r], A[i+1] print(A) return i+1 def quicksort(A, p, r): if(p<r): q = partition(A, p, r) quicksort(A, p, q-1) quicksort(A, q+1, r) a = [70, 60, 50, 40, 30, 20, 10] print("un...
a8f036275a8c33370c0375d88d98fb541817efb8
jasmithadivya/pythonprograms
/addonlyeven.py
320
3.734375
4
num = eval(input("Enter the number")) if(isinstance(num,int)): l1 =list(range(0,10,2)) print(l1) print(sum(l1)) print(list(range(0,10,7))) t1 = (1,2,3,4,5,6,8) for i in range(0,10): print(i) for i in range(0,10): print("python") else: print("Not python")
405169f55703c2ae0e1a5baa757078c929059387
matteo-andreuzza/MCD-py
/main.py
1,641
3.90625
4
#import import time import os print("benvenuto nel calcolatore autmatico dell'MCD") print("versione 0.0.1") time.sleep(1) cor = input("se vuoi che il programma non si chiuda dopo aver restituito il risultato, scrivi 'ok', altrimenti premi invio... ") print("per prima cosa inseriamo i numeri di cui vuoi calcolare l'...
671443c555f412d1c03018de29760dbf5bb67f82
nicap84/mini-games
/Guess the number/Guess the number.py
2,218
4.125
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console #import simplegui try: import simplegui except ImportError: import SimpleGUICS2Pygame.simpleguics2pygame as simplegui import random # initialize global var...
9bc74c23f02083d471d6c6bb25f314f7a8ecfbcc
KomorebiL/calculator
/main.py
752
3.875
4
from tokenizer import Tokenizer from paser import Paser def calculator(s): tokens = Tokenizer(s).tokens if len(tokens) > 1: p = Paser(tokens) print('结果为:', p.counter(p.n)) return p.counter(p.n) else: print('结果为:', tokens[0][1]) return tokens[0][1] def main(): ...
d76e6b2b9722197068c1e8660b1b36de214e29d7
erdhruv1/sample_first
/leapyear2.py
716
3.78125
4
class LeapYear(object): #input funcion def input(self): self.year = int(input("Enter the year: ")) print("the entered year is {0}".format(self.year)) #condiditional satsfaction function def conditions(self): if self.year % 4 == 0: if self.year % 100 == 0: ...
a494592c8ddae808910b1aa2538d2efde4e45898
erdhruv1/sample_first
/music_adelphi.py
1,643
3.59375
4
class Track: def __init__(self, title, duration, genre): self.title = title self.duration = duration self.genre = genre class Album: def __init__(self, trackObj): self.album_dict = {} self.album_dict[trackObj.title] = trackObj class Artist: def __init__(self, ...
a17ed5d40be9ea8dac5d0e25e7c8409b56dc9b0e
erdhruv1/sample_first
/nested_2nd_lowest.py
621
3.828125
4
def main(): lst = [] n = int(input()) for i in range(n): l = [input(), float(input())] lst.append(l) grades = {} for i in lst: grades[i[0]] = i[1] marks = set((grades.values())) sorted_marks = sorted(marks) second_lowest_mark = sorted_marks[1] final_stude...
f277f379306f74151213c149429ee873f1a566bf
sophiehospel/Assignments-Enpicom
/Assignment 2/main.py
5,409
4.125
4
""" Algorithm to compare DNA sequences with point mutations. Problem: http://rosalind.info/problems/corr/ Author: Sophie Hospel Last update: 07-12-2020 """ def get_file(): """ Ask user to enter filename which will be used for comparing the sequences. :return filename : Name of the Fasta file as String...