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
dff3452cc45aa3b42a25843ad6af707bc81b6e19
jihongeek/Algo
/pyalgo/maximum.py
270
3.53125
4
#리스트에서 최댓값 구하기 nums=[67,65,98,55,0] max=nums[0] for i in range(1,len(nums)): if max < nums[i]: max = nums[i] print(max) #리스트에서 최솟값 구하기 min = nums[0] for i in range(1,len(nums)): if min > nums[i]: min = nums[i] print(min)
808d001b6d159a59663e3e478ff2c07554397e70
nikaxx/python_zadania
/petle/zad_2_2_c.py
828
3.578125
4
""" ### Zadanie 2.2 | Choinka Napisz program, który wczytuje liczbę całkowitą, a następnie na konsolę wypisuje w tylu liniach "choinkę" ze znaków `*`. Np. dla parametru 3 powinno się wypisać: ``` * * * * * * * * * ``` r = 2 a1 = 1 an = a1 + (n − 1)r """ wysokosc_choinki = int(input("Podaj wysokosc choinki: "))...
8171e529d72f8dc4b583a61305ee9f2562873eb3
nikaxx/python_zadania
/petle/zad_2_5_a.py
1,183
3.859375
4
""" ### Zadanie 2.5 Zamiana elementów na liście Napisz program zamieniający miejscami w zadanej liście liczb element największy z najmniejszym. na wejsciu: [49, 50, 20, 40, 35, 10] na wyjsciu: [49, 10, 20, 40, 35, 50] Jak to zrobimy? 1. Musimy znaleźć indeks elementu o największej wartosci i indeks elementu o najmniej...
c713b53cfecdbe0cf3decf69cba8cda9b7b225ce
nikaxx/python_zadania
/interakcja/zad_1_2.py
1,218
3.953125
4
""" ### Zadanie 1.2 | Buty do szewca (ok. 1 godz.) Napisz taki program: użytkownik ma podać, w jaki dzień tygodnia oddał buty do szewca (poniedziałek to dzień 1, wtorek to dzień 2 itp.). Ma też podać, ile dni będzie trwała naprawa. Program ma wypisać, w jaki dzień tygodnia buty będą gotowe do odbioru. Jeśli tak bę...
fb2e5ad9d8d5bbd3199d1ec3b8e754735fd6c08b
zyzlik/py_scripts
/friends.py
1,434
4.03125
4
""" We have class Friend, it can have some friends, it can add friend. We have to write method to check if the suggested friend in the connection net of the object. If suggested friend is a friend of the object or a friend of friend of the object etc, the should return True for this method. Otherwise, False. Example: f...
34f75ab70f73ba01b28be9b2428a4955eaa59e87
zyzlik/py_scripts
/moria.py
1,834
3.953125
4
""" words = ['friend', 'fred', 'and', 'friend', 'ted'] 0 1 2 3 4 lengt = 5 matrix 5*5 matrix = [['-', '', '', '', '']] # 0-0 (no-count) 0-1 0-2 0-3 0-4 """ def find_word(message): words = message.lower().split(' ') for word in words: word.strip(',.:;') matrix...
fe101a321f57d297c2b2c3118e3b7d6a50a9726d
Jack-Kingdom/portal
/utils/decr/cached.py
1,741
3.65625
4
""" this file defined a decorator, used to cached func result """ import random import functools DEFAULT_TIMEOUT = 600 DEFAULT_RATIO = 0.25 DEFAULT_FACTOR = 1.5 def cached(to_key, clients, prefix=None, timeout=DEFAULT_TIMEOUT, ratio=DEFAULT_RATIO, factor=DEFAULT_FACTOR): """ cache current functio...
d20170f4f46b07f1e27696b197e2d6a53cf7362a
MarkTopor/data_Science
/Project 0/game.py
593
4
4
"""guess the number""" import numpy as np number = np.random.randint(1,101) #загадываем число #количество попыток count = 0 while True: count += 1 predict_number = int(input("Guess the number from 1 to 100: ")) if predict_number > number: print("число должно быть меньше") elif predict_n...
c3e5bce720be7b1d73cdc72befdaf18f9e6c27da
dipikarpawarr/TQ_Python_Programming
/PythonPracticePrograms/String/Remove_Occurrances_Of_Specific_Character.py
257
4.28125
4
# WAP to remove all occurences of given char from String strInput = input("\nEnter the string = ") charRemove = input("Which character you have to remove = ") result = strInput.replace(charRemove,"") print("\nBefore = ", strInput) print("After = ",result)
06970f054e1768bc231abc16a32fff9286e053f6
dipikarpawarr/TQ_Python_Programming
/PythonPracticePrograms/String/Anagram_String.py
456
4.15625
4
# WAP to accept 2 string and check whether they are anagram or not eg) MARY ARMY strInput1 = input("Enter the first string = ") strInput2 = input("Enter the second string = ") if len(strInput1) == len(strInput2): sorted1 = sorted(strInput1) s1 = "".join(sorted1) sorted2=sorted(strInput2) s2 = "".join...
39d0df328b0285ce51b267c880c8a8a641d94328
dipikarpawarr/TQ_Python_Programming
/PythonPracticePrograms/Basic Program/Square_Of_Number.py
112
3.953125
4
num = int(input("Enter the number : ")) print("\nNumber = ",num) print("\nSquare of ", num, " is : ", num * num)
77bd1bf62927f89fbbfc01fd300a2d5ca7677dc3
dipikarpawarr/TQ_Python_Programming
/PythonPracticePrograms/Flow Control - Loops/Count_Digits_In_Given_Number.py
247
4.28125
4
# Write a Python program to count number of digits in any number num = int(input("Enter the number = ")) numHold = num count = 0 while(num>0): digit = num %10 count += 1 num //= 10 print("Total digits in the ",numHold," is = ", count)
09bb6d3b60ebacbc67a9be127b8cf8be6fe4ad5d
dipikarpawarr/TQ_Python_Programming
/PythonPracticePrograms/Flow Control - Loops/Krishnamurthy_Number.py
421
3.90625
4
# WAP to check given no is Krishnamurthy or not # eg) 145=1!+4!+5!=145 ===> (1)+(4*3*2*1)+(5*4*3*2*1)=145 num = int(input("Enter the number = ")) numHold = num sum=0 while (numHold > 0): digit = numHold % 10 fact = 1 for i in range(1, digit+1): fact *= i numHold //= 10 sum += fact if num =...
85bd50a7ef08b61082969d3a7a8b5a9a7efc04e9
dipikarpawarr/TQ_Python_Programming
/PythonPracticePrograms/Flow Control - Loops/Pallindrome_Number.py
576
4.125
4
# WAP to check given no is palindrome or not. Original =Reverse # Eg 1221, 141, 12321, etc num = input("Enter the number = ") print("\n---- Solution 1 ----") reverse = num[::-1] if num == reverse: print(num," is palindrome") else: print(num, " is not palindrome") # OR print("\n---- Solution 2 ----") num1 = ...
212843de2e24216a58fd802ca82455285c4c9dd3
dipikarpawarr/TQ_Python_Programming
/PythonPracticePrograms/Flow Control - Loops/Harshad_Or_Niven_Number.py
424
4.03125
4
# WAP to find given number is Harshad/Niven number or not # An harshad number is an integer number divisible by sum of its digit # Eg 18 sum=9 and 18 is divisible by 9 num = int(input("Enter the number = ")) numHold = num sum=0 while(numHold>0): digit = numHold%10 sum += digit numHold //= 10 print("sum=",s...
d09b5c2f0c04fc87fec9c8b88cc9eae2f563715b
dipikarpawarr/TQ_Python_Programming
/PythonPracticePrograms/Basic Program/Count_Strings_To_Match_Given_Criteria.py
524
3.9375
4
# Write a Python program to count the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings list1 = ["a","dipa","def","diya","priya","dipali","dipshikha"] print(list1) count = 0 for i in list1: if len(i) >= 2: for j in list1: ...
5cd68cbca6d7a97d205928809ae0bf62766a4911
ssf-czh/alien_invision
/settings.py
1,508
3.640625
4
class Settings(): ''' 存储游戏的所有设置 ''' def __init__(self): #初始化游戏屏幕之类的 #屏幕设置 self.screen_width = 1400 self.screen_height = 700 self.bg_color = (255,255,255) #self.bg_color =(255,251,240) self.ship_speed_factor =1.5 self.ship_limit = 3 ...
1e84bdb4a9b10c65c4d724553f007ce4e0642249
igorzamyslov/advent_of_code_2020
/day03/solution.py
902
3.765625
4
import operator from functools import reduce from itertools import starmap from typing import List def read_input() -> List[str]: with open("input.txt") as f: data = [line.strip() for line in f.readlines()] return data def find_answer_part_one(right_step: int, down_step: int) -> int: counter = 0...
9e404899b018eb6a2dfa0c58a46d4fccf6dccdef
catawba/Schedule_Map
/School_Schedule.py
2,231
3.890625
4
class Teacher(object): def __init__(self, name): self.name = name class Course(object): def __init__(self, name, teacher, conflicts, color, combowith, audiance, lockperiod, allclass): self.name = name # course name self.teacher = teacher self.conflicts = conflicts # ...
11d7a81ebc649bde05fdefa28ef398afbbbcbe44
yesy12/aprendendo_selenium
/aula04/aula04_3.py
503
3.84375
4
# Selenium com Python #04 - Navegação e atributos # Busca aninhada # Atributos # Navegação from selenium.webdriver import Firefox from time import sleep driver = Firefox() url = "http://selenium.dunossauro.live/aula_04_b.html" driver.get(url) sleep(2) boxs = ["box-1","box-2","box-3","box-4"] for box in boxs: ...
3f8ec4ccc13de1218e3394e2f6b31b23c023a12d
advaitp/Data-Structures-and-Algorithms
/OOPS/complexNumber.py
938
3.84375
4
## Read input as specified in the question. ## Print output as specified in the question. class complex: def __init__(self,r,c): self.real=r self.complex=c def prints(self): if self.real ==0 and self.complex==0: print(0) else: print(self.real,'+ i'+str(se...
01a3e367e3d840d70fa500cb410f6a752ddd5cf5
advaitp/Data-Structures-and-Algorithms
/Queues/queueUsingll.py
1,500
3.703125
4
class Node: def __init__(self, data): self.data = data self.next = None class queue: def __init__(self): self.__head=None self.__tail=None self.__count=0 def enqueue(self,data): node=Node(data) if self.__head is None: self.__head=node ...
ac9b0d022d29140804a1e04892c467821e14a173
datng-dev/Gradient-Descent-Demo
/gradient_descent_parabol.py
3,728
3.671875
4
import numpy as np import matplotlib import matplotlib.pyplot as plt from sklearn import linear_model import matplotlib.animation as animation # hàm fx def cost(x): m = A.shape[0] return 0.5/m * np.linalg.norm(A.dot(x) - b, 2)**2 # hàm tính khoảng cách, norm lấy 2 giá trị Ax - b và Euclidean norm # đạo hàm fx...
c4cc1c3bcd07a3a1cba1e854160ba18a1b95e939
bobrayEden/python-katas
/arrays.py
324
3.8125
4
""" Move zero to right Avec une liste d'entiers L en entrée, retourner une liste en bougeant les zéros vers la droite et sans altérer l'ordre original de la liste """ # Ma solution def move_zeros(array): filtered = list(filter(None, array)) zeros = [0] * (len(array) - len(filtered)) return filtered + zeros...
07eb3b4582f1d3d462ff56167e7e85c946df5e95
jodelcour/ML
/Exo3ML_Q6
2,439
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Sep 24 14:25:23 2021 @author: josedelcour For this question, we'll see how to use a linear regression model from Scikit-Learn We'll need to use the original column 'price'. Apply the logarithmic transformation to this column. Fit the Ridge regression mo...
0e71ee102d8e7d78b2a091460ba94caa14fa3381
garciajuli/reactPython
/models.py
1,028
3.515625
4
""" model.py : database row <-> objet python """ from sqlalchemy import Boolean, Column, Integer, String, Numeric, SmallInteger, Date, ForeignKey, Table from sqlalchemy.orm import relationship from database import Base play_table = Table('play', Base.metadata, Column('id_actor', Integer, ForeignKey('stars.id')), ...
64b77ce61af1efe89ab2805d7074d1c7b50f3dc6
mymorkkis/chess-python
/src/game_pieces/game_piece.py
1,266
3.78125
4
"""GamePiece Abstract Base Class.""" from abc import ABC, abstractmethod class GamePiece(ABC): """Abstract Base class for game pieces. Attributes: type: Class name as str color: Piece color (black/white) x_coord: Piece current x_coordinate on board y_co...
d0ea7c5487fd879aa801c73854c9056f8039b0bf
mymorkkis/chess-python
/tests/test_game_piece.py
977
3.671875
4
"""Test module for GamePieces ABC.""" import unittest from src.game_pieces.game_piece import GamePiece from src.game_pieces.pawn import Pawn class TestGamePiece(unittest.TestCase): def test_that_game_piece_cant_be_instantiated(self): self.assertRaises(TypeError, GamePiece) def test_that_child_class...
7b2493bfb3c13300f93665a38118c450d4d85392
PhilippeNguyen/ConvPaperPublic
/models/k_allModelInfo.py
4,225
3.625
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 20 14:49:08 2016 @author: phil Module for information on all models. For a model to work in pySIA, it should match the abstract classes here. Of course, you can build your own abstract classes outside of the these functions, so long as they have the following functions ...
6d06c9de15468f6c210a9119a3d077892c6ca515
srillaert/project-euler
/p055.py
377
3.546875
4
result = 0 for number in range(1, 10000): str_number = str(number) str_reverse = str_number[::-1] for iterations in range(1, 51): number += int(str_reverse) str_number = str(number) str_reverse = str_number[::-1] if str_number == str_reverse: break # palindromic ...
aa68fb5cd540eeb370d0cb283de23c17206f15f2
srillaert/project-euler
/p022.py
290
3.65625
4
def get_alphabetical_value(name): return sum(ord(c) - ord('A') + 1 for c in name) names = open('p022.input').read().replace('"','').split(',') names.sort() total_names_score = sum(position * get_alphabetical_value(name) for position, name in enumerate(names, 1)) print(total_names_score)
68cb9b681516bf72f8a1f12dde65a6447a7766cb
srillaert/project-euler
/p035.py
371
3.625
4
# Based on https://github.com/nayuki/Project-Euler-solutions/blob/master/python/p035.py from prime import get_is_prime_array till = 10**6 is_prime = get_is_prime_array(till) def is_circular_prime(n): str_n = str(n) return all(is_prime[int(str_n[i:] + str_n[:i])] for i in range(len(str_n))) result = sum(1 for n in ...
d38c67b6e1098c91cc2883181f641fb65ed3cbd8
srillaert/project-euler
/p051_wip.py
688
3.640625
4
from prime import get_is_prime_array is_prime = get_is_prime_array(99999) def check_pattern(pattern): step = int("".join(map(lambda c: "1" if c == "*" else "0", pattern))) initial_digit = 1 if pattern[0] == "*" else 0 stop_multiplier = 10 - initial_digit start = int(pattern.replace("*", str(initial_di...
77423dc5ce08af196da5b23ee96ed193c1d6126a
srillaert/project-euler
/p032.py
637
3.671875
4
def is_pandigital(n): if n < 10**8 or n > 10**9: # outside of the range of 9 digit numbers return False # make sure the number contains unique digits 1 to 9 has_digit = [False] * 9 while n > 0: digit = n % 10 if digit == 0 or has_digit[digit-1]: return False has_digit[digit-1] = True n //= 10 return T...
dab737006d211142bc6e0c99498bf951c027fed4
srillaert/project-euler
/p029.py
307
3.5
4
# Generate a list with the power terms sequence = [] for a in range(2,101): for b in range(2,101): sequence.append(a**b) # Count the distinct terms sequence.sort() previous = -1 count = 0 for i in range(0, len(sequence)): if sequence[i] != previous: count += 1 previous = sequence[i] print(count)
0864c06e57b0e2ca215fb87bd7c3f8e46556501a
AP-MI-2021/lab-3-VladVeltan
/main.py
6,254
4.125
4
def data_introduction(): """ citeste o lista :return: returneaza lista citita """ lst = [] givenstring = input("Introduceti lista de numebere insiruite prin virgula: ") numersasstring = givenstring.split(",") # pune in numersasstrings toate numere din given string fara virugla for x in ...
af70b26453d1411d85f34a633d88c208e4eb616c
RyanHenry-henryrya/centimetresToFt
/test.py
115
3.5625
4
cm = float(input("centimetres: ")) ft = int(cm/2.54//12) rft = cm/2.54/12 print(ft, 'ft', int((rft-ft)*12), 'in')
e9f6c423bded4e9cedd97c1be8029fc071484c05
sidneisilvadev/projetos
/calculadora elaborada.py
407
4.125
4
n1=int(input("digite numero :")) n2=int(input("digite numero :")) oper=input("digite soma = +,subtração = -,multiplicação = *,divisao = /:") #soma if (oper=="+"): print("resultado = ",n1+n2) #subtração if (oper=="-"): print("resultado = ",n1-n2) #multiplicação if (oper=="*"): print("resultado = ",...
ca4897466a959ba2c5086a872e7d0ca7f5237859
lerahkp/Coffee-Machine-Project
/main.py
4,702
3.8125
4
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, "cappuccino": { ...
b6075d053a9ac91d5c3bc896651e3b71749319e5
JustChillin21/Python
/student/movie-system/movie_menu.py
3,048
3.984375
4
#Load #Save #Add #Delete #Print #Show Watched #Exit import json import os from user import User def menu(): name=getUserName() user=checkFileStatus(name) filename=user.name+".txt" use_menu=True while use_menu: user_input=input("Please select an option:" "\n\t(a)Add a movie" ...
6bcbf8ec472dbdc2236803213e21b7357ee80600
JustChillin21/Python
/student/projects/playthelottery.py
1,838
4.0625
4
# User can pick 6 numbers #lottery calculates 6 random numbers between 1 and 20 #Then we match the user numbers to the lottery numbers #Calculate the winnings based on how many numbers the user matched import random import math def nCr(n,r): f = math.factorial probab = f(n) / f(r) / f(n-r) print(probab) ...
32f65a3045c160d41a0233299a2deca98efc7499
NineLive/Any
/Any scripts/циклический сдвиг, Решето Эратосфена.py
569
3.609375
4
"""Циклический сдвиг влево""" A = [0,1,2,3,4] N = 5 tmp = A[0] for k in range(N-1): A[k] = A[k+1] A[N-1] = tmp print(A) """Циклический сдвиг вправо""" A = [0,1,2,3,4] tmp = A[N-1] for k in range(N-2,-1,-1): A[k+1] = A[k] A[0] = tmp print(A) """Решето Эратосфена""" N = 200 #A = [x for x in range(N)] A = [...
228423f490795c84b179421b74792f13d9cd6cd9
NineLive/Any
/Any scripts/invert_array.py
614
4.0625
4
def invert_array(A:list, N:int): """Инвертирует массив в рамках индексов от 0 до N-1""" for k in range(N//2): A[k],A[N-1-k] = A[N-1-k],A[k] def test_invert_array(): A1 = [1,2,3,4,5] print(A1) invert_array(A1,5) print(A1) if A1 == [5,4,3,2,1]: print('#test1 - ok') else:...
56537d48d6dfc0d2421572d172f2aef026304b7f
Gayathrichennaioutlook/python_in_one_video
/conditions.py
265
4.03125
4
num = 10 if num > 0: print("Positive number") elif num == 0: print("Zero") else: print("Negative number") # age = 30 # if age > 18: # print('You can vote') # else: # print('You cannot vote') # print('This will always be executed')
5dd3aa878cc69c05ceb41fb7d73637fd3fde5125
FinnBuick/CtCI-Python-Solutions
/Chapter1/1_Is_Unique/IsUnique.py
756
3.671875
4
import unittest def isUnique(string): counter = {} for char in string: if char in counter: counter[char] += 1 else: counter[char] = 1 for char in counter: if counter[char] > 1: return False return True class Test(unittest.TestCase): da...
37ac5e0c06bf6676c2d6dc3d49e87c5c940edcc4
r-ym/Othello-AI-CS360
/othello.py
6,379
3.78125
4
import math import random import sys import copy EMPTY = 2 PLAYER1 = 0 PLAYER2 = 1 PLAYER_NAMES = ["O", "X", "."] OTHER_PLAYER = {PLAYER1:PLAYER2, PLAYER2:PLAYER1} class OthelloMove: def __init__(self, player , x , y ): self.player = player self.x = x self.y = y def __str__(self)...
ea15fae56ad27636c9a4ed356277ddc3ad451594
huansern/python-revision
/sorting/algorithm/bubble.py
394
4.09375
4
from sorting.common import util def sort(data, visible = True): '''Sort a list of integers using bubble sort algorithm ''' swapped, n = True, len(data) while swapped: swapped = False for i in range(n - 1): if data[i] > data[i + 1]: util.swap(data, i, i + 1,...
6d6b50a1a32c1d4362c8bd9f67533b470f5a5b12
huchangyan/StudentManagerSys
/bin/main.py
3,225
3.796875
4
""" 主题:学员管理系统 需求: 用户角色,讲师\学员, 用户登陆后根据角色不同,能做的事情不同,分别如下 讲师视图   管理班级,可创建班级,根据学员qq号把学员加入班级   可创建指定班级的上课纪录,注意一节上课纪录对应多条学员的上课纪录, 即每节课都有整班学员上, 为了纪录每位学员的学习成绩,需在创建每节上课纪录同时 为这个班的每位学员创建一条上课纪录   为学员批改成绩, 一条一条的手动修改成绩 学员视图 提交作业 查看作业成绩 一个学员可以同时属于多个班级,就像报了Linux的同时也可以报名Python一样, 所以提交作业时需先选择班级,再选择具体上课的节数 ...
4e3a45870bf5ee77ddc067cb16e763d78ac77f14
chzhanpeng/Simple-Duck-hunt
/duckhuntplayers.py
1,349
3.65625
4
#This module contains all the player classes and their respecsctive helper classes. ##==================================================== class Player(object): #Player class constructor def __init__(self): #Initializes score to zero. self.score = 0 self.name = "P" #Returns a 2-tuple with the location a...
74c6abc3e60c8c690df984edb197c319326da9a8
moonshot-3817/Greenway-Class-Projects
/Comp_Sci_Image/VideoGame Hysteria.py
19,788
3.609375
4
import pygame import random from pygame.locals import * pygame.init() yscreen = 1000 xscreen = 1000 screen = pygame.display.set_mode((xscreen, yscreen)) pygame.display.set_caption("Adventure Seeker") White = (250, 250, 250) Red = (250, 10, 10) Day = (135, 206, 235) Night = (25, 25, 112) Times=(Day, Night) ...
4ff221b85910b4c63fedd359b97b0eba142f4ec1
sleebapaul/MIT_6.001x-Assignments-
/MIT 6.001x/Test_pset4/test2_pset4.py
2,588
3.546875
4
WORDLIST_FILENAME = "C:\Users\sleeba\Canopy\scripts\Codes\pset4\ProblemSet4\words.txt" SCRABBLE_LETTER_VALUES = { 'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4,...
33b9550359cb4965b7be2ce1f03fd41db00644e0
sleebapaul/MIT_6.001x-Assignments-
/MIT 6.001x/Final Exam/pb1.py
631
3.734375
4
d = {1:10, 2:20, 3:30,3:40} def dict_invert(d): v = {} for key, value in sorted(d.iteritems()): v.setdefault(value, []) return v print dict_invert(d) d= {"George":'G.MacDonald', "Luke":'G.MacDonald', "Larry":'G.MacDonald'} #d = {1:100, 2:20, 3:30, 4:30} d={4:True, 2:True, 0:True,4:False}...
6b93ced586a6f433a4feb7cd66a3c4607ead3b2e
florin-postelnicu/Cynco
/realistic.py
1,223
3.5
4
import asyncio # this is o corutine definition async def fake_network_request(request): print("making network call for request : ", request) # simulate newtork delay await asyncio.sleep(1) return "got network request for request: " + request # this is a corutine definition async def we...
7a2f97189cca1692bc42b2b1067b59f7745a2a45
UdeM-LBIT/polytomy-solver-web
/cgi-bin/utils/TreeLib/ClusterUtils.py
10,454
3.84375
4
#usr/bin/env python from numpy import * from TreeClass import TreeClass import os import numpy numpy.set_printoptions(precision=3) numerictypes = numpy.core.numerictypes.sctype2char Float = numerictypes(float) def find_smallest_index(matrice): """Return smallest number i,j index in a matrice A Tuple (i,j) is retu...
5ec27524319d795a5d3e7052c701483eccebb293
shanep805/p3l-library
/examples/machining/turning/turning_programming_advanced.py
1,595
3.515625
4
# A - Geometric Definitions # A.1 - Set units units_in() # A.2 - Set our geometric interrogation. # Read more here: https://help.paperlessparts.com/article/42-p3l-language-features lathe = analyze_lathe() # B - Feature and Feedback Count # B.1 - Define Feature Count and Feedback Count feature_count = len(get_features(...
caf17508e2a565ea9c5ad97a7c3f1cf94d1ca2eb
songjy6565/alg-py
/programmers/level3/A21.py
650
3.5625
4
def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) def solution(n, k): answer = [] order = [] for i in range(1,n+1): order.append(i) for j in range(1,n+1): fac = factorial(n-j) index = k//fac k = k % fac if k == 0: ...
50d19930cdeb2081d6d0dd12428bd88a939f170b
songjy6565/alg-py
/programmers/level1/A7.py
194
3.6875
4
def solution(arr): answer = [] target = -1 for i in range(len(arr)): if target != arr[i]: answer.append(arr[i]) target = arr[i] return answer
e43bb5a7481a409719f4e631542bea027813ce12
songjy6565/alg-py
/programmers/level4/A.17685.py
1,639
3.546875
4
def solution(words): answer = 0 words = sorted(words) length = len(words) target = 'dummy' index = 0 while True: #print(index, length, answer, words) if length <= 1: if target == words[0][0]: answer += 2 return answer answer...
4f2b232b9e9f0c29786602c2da01d0a1bddbf213
supryma/CodeWars
/nb_dig.py
560
3.875
4
"""Take an integer n (n >= 0) and a digit d (0 <= d <= 9) as an integer. Square all numbers k (0 <= k <= n) between 0 and n. Count the numbers of digits d used in the writing of all the k**2. Call nb_dig (or nbDig or ...) the function taking n and d as parameters and returning this count.""" def nb_dig(n, d)...
9a311a631e8651b14d129b47e61bedaa8dc79301
supryma/CodeWars
/create_new_list.py
469
3.796875
4
"""Given a list lst and a number N, create a new list that contains each number of lst at most N times without reordering. For example if N = 2, and the input is [1,2,3,1,2,1,2,3], you take [1,2,3,1,2], drop the next [1,2] since this would lead to 1 and 2 being in the result 3 times, and then take 3, which...
c0344d9a5f9b554b9bf00b331c367b224c82e891
agradhika-gh/basicjava
/first_if.py
75
3.828125
4
x=10 y=10 if x==y: print ("Yes, x is equal to y") else: print("no")
0a6eb07133ff86ec963c8004bda302f8ee382f05
mdfox760/pypractice
/tax.py
416
3.859375
4
# works in python3.6 interpreter on cli. # In interactive mode, the last printed expression is assigned to the variable _. # The variable should be treated as read only by the user. Don't explicityly assigned # a value to it. You would create an independent local variable with the same # name masking the built-in varia...
4480bee0ef9545850813c86dc89463e0a42015a8
mdfox760/pypractice
/range.py
364
4.15625
4
for i in range(5): print(i) print('***') for x in range(5, 10): print(x) print('***') for b in range(0, 10, 3): print(b) print('***') for c in range(-10, -100, -30): print(c) a = ['Mary', 'had', 'a', 'little', 'lamb'] for i in range(len(a)): print(i, a[i]) print(range(10)) range(0, 10) # Cr...
a5b82446e28409271d7e77fa36a89de5a68f076d
codrinleonte/python_labs
/LabIII/Ex1.py
657
3.734375
4
# 1. Sa se scrie o functie care # primeste ca parametri doua liste a si b si returneaza # un tuplu de seturi care sa contina: (a intersectat cu b, a reunit cu b, a - b, b - a) def listOperations(a, b): operation = {} result = [] operation = set([n for n in a + b]) result.append(operation) operati...
9844309814a1624337f521e8ac75a1941c55260d
codrinleonte/python_labs
/LabI/Ex4.py
428
3.75
4
#Scrieti o functie care primeste # ca parametri doua siruri de caractere si care returneaza numarul de aparitii ale primului sir de caractere in al doilea. def numberOfOccurences(string,substring): count = 0 while 1: idx = string.find(substring) if idx == -1: break count += ...
e6e82aea2a5263d844b92805c60a9a13a46a30ca
godad/py-learning
/day5/格式化输出.py
422
3.75
4
# -*- coding: utf-8 -*- # @Time : 2018/3/16 16:16 # @Author : flyfish # @Email : im@flyfish.im name = input("Name:") age = int(input("Age:")) job = input("Job:") salary = int(input("Salary:")) msg = ''' ---------------info of %s ---------------- Name : %s Age : %d Job : %s Salary : %d You will be retire...
8b565735d1a8aaf80b47751add542edbb20b5467
lelehehe/interviewing
/Python-Algorithms/StacksQueuesDeques/02_QueueUsingTwoStacks.py
830
4.09375
4
# Problem Statement: # The key insight is that a stack reverses order (while a queue doesn't). A sequence of elements pushed on a stack comes back in reversed order # when popped. Consequently, two stacks chained together will return elements in the same order, since reversed order reversed again is original order. # ...
0b48f5fb42dd53dd834a8430cfbb6c78e7864a1d
44306261/ACST_Assignment1
/Q4.py
120
3.9375
4
import random a=int(input('Enter an integer as a:')) b=int(input('Enter an integer as b:')) print (random.randint(a,b))
55c986710dc439d7818700236233a042e3ca1a76
jerome1232/datastruct-tut
/src/2-topic-starter.py
1,629
4.34375
4
class Queue: ''' This represents a queue implemented by a doubly linked list. ''' class Node: ''' An individual node inside a linked list ''' def __init__(self, data): '''Initialize with provided data and no links.''' self.data = data self.previous = N...
47f966adae31358284fc408907a2eea4a60f5c23
kensekense/unige-fall-2019
/metaheuristics/example_for_kevin.py
2,864
4.4375
4
''' When you're coding, you want to be doing your "actions" inside of functions. You are usually using your "global" space to put in very specific values. Here's an example. ''' import random def modifier_function (input1, input2): ''' For simplicity, I've named the inputs to this function input1 an...
0db57230a80f8aaeff668822dee9084c6e3ce529
kensekense/unige-fall-2019
/metaheuristics/tp_4/random_cities/ant_search.py
10,613
4.15625
4
#Ning #09 Nov 2019 import numpy as np import math import random import time def create_city (cityfile): ''' create a dictionary of cities locations taken directly from previous TP3 implementation ''' cityscape = {} with open(cityfile, "r") as city_file: for line in city_...
c6c4220850ef09b4e3cf205e73f61a3d8daa53d5
turtlesbro/Strings
/9-16/Mad lib v2.py
1,009
3.53125
4
file = open("MAd2", "r") data = file.read() string = str(data) stringedit = string.split() def filereplace(numb, pos): numb = str(numb) numb9 = str(input(pos)) return numb9 replacewords = {} numb1 = filereplace(9, 'Name or nickname:') replacewords['9'] = numb1 numb2 = filereplace(11, 'Noun:') replaceword...
b9f0d8c8fba40a18cbc9855e93b12fb057a20ddb
turtlesbro/Strings
/9-18/inclass.py
812
3.8125
4
def countAl(text): countAll(text, 'a') countAll(text, 'b') countAll(text, 'c') countAll(text, 'd') countAll(text, 'e') countAll(text, 'f') countAll(text, 'g') countAll(text, 'h') countAll(text, 'i') countAll(text, 'j') countAll(text, 'k') countAll(text, 'l') countAll(...
2801c06e582b6642358240011b1a550250d9fd9a
turtlesbro/Strings
/10-3/inclass.py
420
3.65625
4
def encrypt_6(): message = str(input("secret code here:")) alphabet = 'abcdefghijklmnopqrstuvwxyz' newsent = [] for letter in message: if letter in alphabet: letter = alphabet.index(letter) + 6 letter = alphabet[letter:letter+1] newsent.append(letter) ...
146daf083101d1e6128e074f64916c3890f78ddd
lizbianco/dsp
/5/q5_datetime.py
583
3.59375
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 18 15:41:47 2016 @author: EBianco """ from datetime import datetime def solve(d1, d2, f): print(datetime.strptime(d2, f) - datetime.strptime(d1, f)) '#5a' date_start_a = '01-02-2013' date_stop_a = '07-28-2015' form_a = '%m-%d-%Y' solve(date_start_a, date_stop_a, ...
90606f4c3821e24d7bfae29708b5e80c30a776e9
leilacc/varada
/sentence_to_synset.py
3,175
3.671875
4
#!/usr/bin/env python '''Processes a sentence into a list of lists of synsets for each word with a given part of speech.''' __author__ = 'leila@cs.toronto.edu' from nltk.corpus import wordnet as wn from nltk.stem.wordnet import WordNetLemmatizer from tag import tag LMTZR = WordNetLemmatizer() PARTS_OF_SPEECH = { wn...
0b607f84efbb70914145a1373b5f44f21ecb24af
DenBeke/CodingTheory
/vigenere/vigenere.py
6,106
3.59375
4
from collections import Counter from itertools import permutations """ For an (untransposed) text encoded using Vigenere, find the likely key lengths (no higher than maxLen) To do this, for each possible key length, the index of coincidence is calculated. (http://en.wikipedia.org/wiki/Index_of_coincidence) As monoalph...
fe48166ffd3fa7b776ef72f67c8a14fab5e49972
ICC3103-202110/proyecto-01-rios_rodriguez
/console.py
988
3.65625
4
class Console(): def print_menu_and_select(self): print("\nSelect an option: ") print("0. Start the game ") print("1. Add player ") print("2. Show players ") print('3. Quit') return int(input()) def print_turn_menu(self): print("") print("S...
13912ef3b53e03a28d29df031ae1838ff33ba7a3
jlaframboise/StockPrediction
/data_loading.py
1,739
3.6875
4
import pandas as pd import numpy as np import yfinance as yf def process_stock_data_from_yf(data): """ A function to take in the data from yahoo finance retrieved by yfinance, and it will convert it from a wide format to a long format which will allow easier manipulation for our workflows. ""...
8467bfb5ea72e3d41430594dfcbb1bc50f0cb800
dejuata/CursoPython
/Fase 4 - Temas avanzados/Tema 13 - Interfaces graficas con tkinter/label.py
732
3.671875
4
from tkinter import * #Configuracion de la raiz root = Tk() #Configuracion de un marco #frame = Frame(root, width=480, height=320) #frame.pack() #label = Label(frame, text='¡Hola mundo!') #label.place(x=210, y=160) """ #Variables dinamicas texto = StringVar() texto.set("Un nuevo texto") Label(root, text="¡Hola mund...
1eafc06083e85e6fff87c4a0c26b0c7a759844f9
deleks-technology/myproject
/simpleCal.py
1,493
4.21875
4
print("Welcome to our simple Calculator... ") print("====================================================================") # Prompt User for first number # to convert a string to a number with use the int()/ float() first_number = float(input("Please input your first number: ")) print("=========================...
fbb9ec9bed439f92d7088488610a29c80f1d62b3
Joseph-Xavier/GRADE
/functions.py
431
3.75
4
def name(): return "Joe" na=name() print(na) # adition def add(num1 , num2): return num1+num2 arg1 =int(input("Entervyour first number")) arg2 =int(input("Enter your second number")) total =add(arg1,arg2) print(total) # Age def add(Currentyr ,Baseyr ): return Currentyr-Baseyr arg1=int(input("Enter your year...
ffedfe4c9a7a5f2a1e59d6a75a14c380f54b307b
abhishekjani123/PersonalAssistantChatbot
/ToDo.py
965
3.859375
4
from datetime import datetime import os file = "userData/toDoList.txt" def createList(): f = open(file,"w") present = datetime.now() dt_format = present.strftime("Date: " + "%d/%m/%Y"+ " Time: " + "%H:%M:%S" + "\n") f.write(dt_format) f.close() def toDoList(text): if os.path.isfile(file) == False: createList(...
24dccadfc40fb85d20305d92ba298bc511a6ea64
niranjan2822/PythonLearn
/src/Boolean_.py
804
4.375
4
# Boolean represent one of two values : # True or False print(10 > 9) # --> True print(10 == 9) # --> False print(10 < 9) # --> False # Ex : a = 200 b = 300 if b > a: print("b is greater than a") else: print("b is not greater than a") # Output --> b is greater than a # bool() --> The bool() function all...
e195b51af2d8f3d4866dc7afdf77140378d57fc2
fxmag/python
/sys.arg/args.py
1,187
3.734375
4
import sys #print(sys.argv[0], sys.argv[1]) # Getting help with '--help' or -h if sys.argv[1] == '--help' or sys.argv[1] == '-h': out = """ Usage: args [options] [file] '-s' Salamander. Turns on the salamander flag. '-g' Groan. Turns on the groan flag. '-i' Igloo. Turs off Igloos. '-e' Encrypt. ...
4a56526814e4d0865bbd386a4dfca4e918ec79d7
caiodsc/ed_python
/Deque/deck.py
881
3.75
4
class Deck: def __init__(self): self.deck = [] self.len = 0 def empty(self): if self.len == 0: return True return False def push_front(self, e): self.deck.insert(0,e) self.len += 1 def push_back(self, e): #self.deck.insert(self.len,...
223bf6f986a50959f1f6f61520204ad384e2daec
sachdevavaibhav/CFC-PYDSA-TEST01
/Test-01-Py/Ans-03.py
281
4.1875
4
# 3. Write a Python program to sum of two given integers. However, if the sum # is between 15 to 20 it will return 20. num1 = int(input("Enter a number: ")) num2 = int(input("Enter a number: ")) ans = num1 + num2 if 15 <= ans <= 20: print(20) else: print(ans)
72dfad17a9798d02d8d09452543d52a04d4169e7
destructor1022/CodeNamesBot
/table.py
4,383
3.53125
4
import random from math import sqrt class table: def __init__(self, names, bold, ulin, evil, board_size): self.binary = [] self.group = [] self.names = names self.bold = bold self.ulin = ulin self.evil = evil self.board_size = board_size self.count =...
b33055a431c1b5bf1241a760a1076f1359f2fafe
amaria-a/secu2002_2017
/lab08/code/church_theft.py
2,216
3.65625
4
import csv from matplotlib import pyplot as plt # CREATE_AXIS: create y-axis for list of entries # input: entries (as list) # output: number of entries with start date in a given month (as list) def create_axis(entries): yaxis = [0 for x in range(12)] for entry in entries: # pull out month from entry ...
81b55360c687c51eae7d47071f7ecd6c2ec4d550
amaria-a/secu2002_2017
/lab03/code/swap.py
342
4.09375
4
# with these lines commented in, values should be same before and after #x = 10 #y = 5 # with these lines commented in, values should swap x = 5 y = 7 print 'x is', x, 'and y is', y # swap values is x is less than y if x < y: # swap using intermediate tmp variable tmp = x x = y y = tmp print 'now x ...
17eec4b963a4a7fb27a29279261a1df059be22e3
amaria-a/secu2002_2017
/lab03/code/hangman.py
2,022
4.15625
4
# load secret phrase from file f = open('secret_phrase.txt','r') # ignore last character as it's a newline secret_phrase = f.read()[:-1] # get letters to guess, characters to keep, initialize ones that are guessed to_guess = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' to_keep = " ,'-" guessed = [] # creat...
534d6748161d19a2474eabc95d7fa27c8e0b71a7
amaria-a/secu2002_2017
/lab05/code/filter.py
988
4.0625
4
# LOOP_FILTER # input: a numeric list mylist and a number n # output: a list containing all elements in mylist greater than n def loop_filter(mylist,n): filtered_list = [] for x in mylist: if x > n: filtered_list.append(x) return filtered_list print '------------' print 'TESTS FOR LOOP...
50a344533148bfd4dcc8558282745c8b2de0de2d
adriancleung/CoECrimeMap
/task_2.py
3,745
3.6875
4
import sqlite3 import folium import os import webbrowser def task_2(conn, c, count_2): # Purpose: Asks uer to input the number of neighbourhoods to show and # the task will visualize, on a map, the N most populous and N least # populous neighbourhoods # Parameters: Takes in the connection to the databa...
4b26bd34d2f6992f3cd0288d1ce0a6db82a2936c
bhklab/Pharmacodb-Scripts
/PharmacoDBDrugAnnotations/merge_central_pharmacodb_only_drugs.py
1,360
3.6875
4
""" This python code will grab the details of the compounds that are present in the pharmacodb database from the drugUIDCentral.csv file. """ import csv # input and output file variables. # input file with pharmacodb drugs and corresponding UIDs. pharmacodb_input_drugs = 'drugsUID.csv' # input central file with the dr...
cc852f92959c4e5b5f85355dbb3803297109d9e2
farzamkhan/firstapp
/Multiplication.py
118
3.625
4
# set numbers a = 10 b = 10 #print Multiplication print ("A=", a) print ("B=", b) print ("Multiplication = ", a*b)
42e1b76389b3f6dd99e36f7d8f4d3f89fe3af8c0
mguid73/basic_stats
/basic_stats/basic_stats.py
788
4.40625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Basic stats module """ def mean(a): """ input is the list of numbers you want to take the mean """ # computing amount ctlist= [] for n in a: n=1 # changing every value in the list to 1 ctlist.append(n) # creating a new list made up...
968ea9dfbe526cb43c04f68fda877b49122a285d
mateogomez125/desarrollo_de_tps_P1
/tp02_2.py
1,445
3.921875
4
''' Leer una matriz de tres filas por tres columnas y calcular la suma de cada una de sus filas y de sus columnas, colocando los resultados en dos vectores, uno para la suma de las filas y otro para la suma de las columnas. ''' import numpy as np import random matriz=np.array([[0]*3]*3) def mostrar_matriz(matriz):...
43e2dccabe35905571ca61822de501fd25906b79
AlexanderHurst/CrackingVigenereCypher
/vigenere.py
2,009
4.1875
4
from sys import argv import string_tools from sanitization import sanitize # takes a secret message and key and returns # vigenere ciphertext # note secret message and key must be a list of numbers # use string tools to convert def encrypt(secret_message, secret_key): cipher_text = [] # encrypting adds the k...
0fb2df5118c34bd94b90f5769f185fab951a2819
ConnerTenn/Legacy_Python
/Platformer-V1.0.0/Object Test2.py
691
3.625
4
class Program(): def Main(self): Object1 = ObjectClass(1,2,3,4,5,6) Object2 = ObjectClass(7,8,9,10,11,12) Object3 = ObjectClass(13,14,15,16,17,18) print(Object1.Value1) Object1.Func1() print() print(Object2.Value1) Object2.Func1() ...
7b55e988e4db68d4ab457473e0435816a46d3268
ConnerTenn/Legacy_Python
/Key_Events.py
1,786
3.53125
4
#Imports from tkinter import * import time #Classes class Main: def __init__(self, Width=500, Height=400, Title="Python Program"): self.Width=Width self.Height=Height self.Title=Title self.Right=0 self.Up=0 self.Play=True self.tk=Tk() self.tk.title(s...