blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
17ff19a4dac63f95748c16212864afef954cade2
jtlai0921/yuanta_python3-master
/yuanta_python3-master/lesson03/lesson_work_linhsinkae.py
676
3.515625
4
import random iMax, iMin = 100, 0 iTarget = random.randint(iMin, iMax) def check(iGuess, iMin, iMax): if iGuess == iTarget: # print("Good") return True, iMin, iMax elif iGuess > iTarget: iMax = iGuess # print("{0}~{1}".format(iMin, iMax)) return False, iMin, iMax e...
6a94155849e03487e9db2b1afa16ce4b38e20d8b
jtlai0921/yuanta_python3-master
/yuanta_python3-master/lesson03/WhileDemo.py
121
3.625
4
import random x = 0 while True: x = random.randint(1, 9) if x % 2 == 0: print(x) else: break
7bf5e74c66f1085c1313685c205b4d621aab5d8d
jtlai0921/yuanta_python3-master
/yuanta_python3-master/lesson03/lesson_work_jiansheng.py
388
3.59375
4
import random range_start = 0 range_end = 100 ans = random.randint(range_start+1, range_end-1) while True: inpu = int(input("%d~%d -> " % (range_start, range_end))) if(ans == inpu): print("OK") break elif(inpu < range_start or inpu > range_end): continue elif(inpu > ans): ...
7c6bfef7dc24ddff519dde302c0883d3b2d3c557
jtlai0921/yuanta_python3-master
/yuanta_python3-master/演算法/無重複數字.py
239
3.8125
4
# 有1、2、3、4個數字,能組成多少個互不相同且無重複數字的三位數? for i in range(1, 5): for j in range(1, 5): for k in range(1, 5): if i != j and j != k: print(i, j, k)
16df58e81a9fd53c35a772d4f3c6b3f40f390f0f
jtlai0921/yuanta_python3-master
/yuanta_python3-master/作業/Youbike/William Huang.py
2,725
3.796875
4
# coding: utf-8 import requests as re import pandas as pd def get_lat_lng(address): """ Returns the latitude and longitude of a location using the Google Maps Geocoding API. API: https://developers.google.com/maps/documentation/geocoding/start # INPUT -----------------------------------------------...
bb19a51c212e8e53e8dac061b3176da022f6399b
panluluy/PythonBase
/Louis/装饰器/decorator3.py
1,072
3.75
4
import time # 装饰器=高阶函数+嵌套函数 def timer(func): def wrapper(name,*args,**kwargs): start_time = time.time() ''' 注意此处必须是*args和**kwargs,如果是args和kwargs,在传入test1函数时 name传递给name,args和kwargs全部传递给*args ''' func(name,*args,**kwargs) end_time = time.time() print('t...
66290562855f0956b3c009e0768f90c5fbdbd2ee
panluluy/PythonBase
/Louis/生成器/2生成器.py
1,751
4.03125
4
""" https://www.cnblogs.com/alex3714/articles/5765046.html 通过列表生成式,我们可以直接创建一个列表。但是,受到内存限制,列表容量肯定是有限的。而且, 创建一个包含100万个元素的列表,不仅占用很大的存储空间,如果我们仅仅需要访问前面几个元素, 那后面绝大多数元素占用的空间都白白浪费了。所以,如果列表元素可以按照某种算法推算出来, 那我们是否可以在循环的过程中不断推算出后续的元素呢?这样就不必创建完整的list, 从而节省大量的空间。在Python中,这种一边循环一边计算的机制,称为生成器:generator。 要创建一个generator,有很多种方法。第一种方法很简单,只...
ebcdc2243ee93cbdee048c144b8ee14c320def05
odeclasonarres/Prog.de-Redes---Becas-Digitaliza
/Ejercicios/Introducción a Python/04_if.py
579
3.8125
4
#Crear un script en el que guardéis en una variable un número num=input("Dime un número -----> ") #Controlar el tamaño del número en 4 rangos #(menor de 20, entre 20 y 39, entre 40 y 59, mayor de 60) #En cada uno de los casos imprimir por pantalla el número que se haya introducido. if(int(num)<20): print("Su val...
7c07ff2499bbdbee545d3b0bccbd6921e4d59687
odeclasonarres/Prog.de-Redes---Becas-Digitaliza
/PCAP Programming Essentials in Python - PUE/5. Orientación a objetos/5.2/PCA_5_2_11.py
306
3.75
4
class Stack: def __init__(self): self.__stk = [] def push(self, val): self.__stk.append(val) def pop(self): val = self.__stk[-1] del self.__stk[-1] return val stack = Stack() stack.push(3) stack.push(2) stack.push(1) print(stack.pop()) print(stack.pop()) print(stack.pop())
dca9128a8ed3a671261c7a314dedf45ecec49c3e
odeclasonarres/Prog.de-Redes---Becas-Digitaliza
/PCAP Programming Essentials in Python - PUE/4. Módulos/4.6/PCA_4_6_3.py
178
4.125
4
from math import tan,radians angle = int(input('Enter integral angle in degrees: ')) # we must be sure that angle != 90 + k*180 assert angle% 180 != 90 print(tan(radians(angle)))
27c264d66d9ef07b13b2fda68de2c6b8981bae21
odeclasonarres/Prog.de-Redes---Becas-Digitaliza
/Ejercicios/Introducción a Python/05_calculator.py
2,865
3.9375
4
import sys def bienvenida(op=1): if op==0: p="Bienvenido a la".center(100,'.')+'\n'+'CALCULADORA'.center(100,'*') print(p) else: p="GRACIAS, hasta la próxima".center(100,'.') print(p) sys.exit() def captura(txt,ty=0): if ty==0: retorno=float(input(txt)) ...
7b646166222be886ff9020dd220e6dedd33e3e7f
odeclasonarres/Prog.de-Redes---Becas-Digitaliza
/PCAP Programming Essentials in Python - PUE/4. Módulos/4.5/PCA_4_5_14.py
272
3.828125
4
import math x = float(input()) assert x>=0.0 x = math.sqrt(x) print(x) """ VERSIÓN CORREGIDA CON try-except: import math x = float(input()) try: assert x>=0.0 x = math.sqrt(x) print(x) except AssertionError: print("No puedes calcular la raíz") """
65f0346adbefecd5d051125262ed8a129564d455
ra1ski/data-structures
/hash-tables/implementation.py
2,337
3.78125
4
from typing import Any class HashMap: """ Hashmap implementation search O(1) insert O(1) lookup O(1) delete O(1) """ def __init__(self, size): self.size = size self.map = [None] * self.size def _get_hash(self, key: str) -> int: """ Args: ke...
463e03c293b97013c1e5e547a6d2a8a37667f3a7
shuoshuren/PythonPrimary
/18文件/xc_06_eval.py
141
3.984375
4
# eval() 将字符串当成有效的表达式来求值,并返回计算结果 str = input("请输入要计算的表达式:") print(eval(str))
896796db2b16dfaf47dad6ab0bae28358ab9e76f
shuoshuren/PythonPrimary
/03循环/xc_02_偶数求和.py
97
3.546875
4
result = 0 i = 0 while i <= 100: if i % 2 == 0: result += i i += 1 print(result)
ed616e5a97204bfde2a4e5f64388344bca474376
shuoshuren/PythonPrimary
/12面向对象封装/xc_02_设置对象属性.py
355
3.890625
4
class Cat: def eat(self): # 哪一个对象调用的方法,self就是哪一个对象的引用 print("%s爱吃鱼" %self.name) def drink(self): print("%s要喝水" %self.name) # 创建对象 tom = Cat() # 可以使用.属性名,利用赋值语句就可以了 tom.name = "tom" tom.eat() tom.drink() print(tom.name)
4228d90052f5301e781e2ba2220051f5ea3cec64
shuoshuren/PythonPrimary
/15异常/xc_02_捕获错误类型.py
856
4.34375
4
# 捕获错误类型:针对不同类型的异常,做出不同响应 # 完整语法如下: # try: # 将要执行的代码 # pass # except 错误类型1: # 针对错误类型1,要执行的代码 # except (错误类型2,错误类型3): # 针对错误类型2,3要执行的代码 # except Exception as result: # print("未知错误%s" %result) # else: # 没有异常才会执行的代码 # pass # finally: # 无论是否有异常,都会执行的代码 try: num = int(input("请输入一个整数:"))...
c5f77abd24beda2a2a33197b59b8550e45594109
shuoshuren/PythonPrimary
/06_元组/xc_02_元组的操作.py
248
4.0625
4
""" count: index: """ info_tuple = ("zhangsan",18,12.5,"zhangsan") # 取值和取索引 print(info_tuple[0]) print(info_tuple.index(18)) # 统计计数 print(info_tuple.count("zhangsan")) # 元组的遍历 for info in info_tuple: print(info)
ae58bf2d9ff3b06589a1c11decbd964df669ba70
MarcinBaranek/num_analysis_project
/matrix_input.py
1,000
4.03125
4
import numpy as np def input_matrix_from_user(): # Take matrix size as input while True: try: row_number = int(input("enter number of rows: ")) column_number = int(input("enter number of columns: ")) break except ValueError: print("That was no val...
27b8e98acdd4c3e3a3eff0b4f131751a9a9c29db
jfbm74/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-number_of_lines.py
440
4.28125
4
#!/usr/bin/python3 """ Module that returns the number of lines of a text file: """ def number_of_lines(filename=""): """ function that returns the number of lines of a text file :param filename: File to read :type filename: filename :return: integer :rtype: int """ counter = 0 wit...
d5490fc4962001fdb36c4885e757827a11de0225
jfbm74/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
679
4.4375
4
#!/usr/bin/python3 """ Module print_square This module prints a square with the character # Return: Nothing """ def print_square(size): """ Function print_square This function prints a square with the character # Args: size: is the size length of the square Returns: Nothing """ ...
bb1ce5396bb4be344aecfba5068cb84a9386d82f
jfbm74/holbertonschool-higher_level_programming
/0x02-python-import_modules/2-args.py
320
3.578125
4
#!/usr/bin/python3 if __name__ == "__main__": import sys argc = len(sys.argv) if argc == 1: print("0 arguments.") exit() else: print("{} argument{}:".format(argc - 1, '' if argc == 2 else 's')) for i in range(1, argc): print("{}: {}".format(i, sys.argv[i]))
726fe34c5fb07ec803e758da3776c4e5533979ac
MayurKasture/Mayur_Python_Foundation_Cource
/Python_Foundation/Class_In_Python_Demo(Account).py
992
4
4
#create the class Account class Account: def __init__(self,acno,name,currbal): self.acno=acno self.name=name self.currbal=currbal def display(self): print("Account No:",self.acno) print("Name:", self.name) print("Current balance:", self.currbal) ...
44d3469210798b78658689d71bdfe9c6f5166a50
MayurKasture/Mayur_Python_Foundation_Cource
/Python_Foundation/Overloading_demo.py
2,570
3.90625
4
class point: x=0 y=0 def __init__(self,x,y): self.x=x self.y=y def __str__(self): return"("+str(self.x)+","+str(self.y)+")" def __add__(self, other): return(self.x+other.x,self.y+other.y) 6 def __sub__(self, other): return(self.x-ot...
671227e9c162b45516d8466aafdecbcd8c3318ad
MayurKasture/Mayur_Python_Foundation_Cource
/Python_Foundation/Employee_Data_Opeartions3.py
445
3.828125
4
class employee: def __init__(self,code,name,salary): self.code=code self.name=name self.salary=salary class emplst(employee): def show(self): print("code:",self.code) print("name:",self.name) print("salary:",self.salary) def list(self): ...
03f42d8fce0813e508db18eb3c95c48b30965686
badrjarjarah/SchoolHomwork
/Python/hw5a.py
4,242
4.03125
4
# Joseph Leiferman # Student ID: 00990636 # Discussion Section: A06 import time # Two words are neighbors if they differ in exactly on letter. # This function returns True if a given pair of words are neighbors def areNeighbors(w1, w2): count = 0 for i in range(len(w1)): if w1[i] != w2[i]: ...
ebae54fdce4d335e316cff633376d9641694e745
badrjarjarah/SchoolHomwork
/Python/Projects/recommenderOneRun.py
13,587
3.734375
4
# Joseph Leiferman # Student ID: 00990636 # Discussion Section: A06 import math import random import time # Reads information about users from the file u.user. This information is stored as a list dictionaries and returned. # Each dictionary has keys "age", "gender", "occupation", and "zip". The dictionary for user i...
0022986af95ce6ad144c40436e54888205a2cdda
rraj29/Dictionaries
/game_challenge.py
1,826
4.21875
4
locations = {0: "You are sitting in front of a computer, learning python.", 1: "You are standing at the end of a road before a small brick building.", 2: "You are at the top of a hill.", 3: "You are inside a building, a well house for a small stream.", 4: "You are in ...
4b7ef56e7abace03cacb505daa6b34bdf90897b5
sandrahelicka88/codingchallenges
/EveryDayChallenge/happyNumber.py
796
4.09375
4
import unittest '''Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endl...
0d2e5ff146429d2209e75b4531d833848ee66784
sandrahelicka88/codingchallenges
/EveryDayChallenge/fizzbuzz.py
855
4.3125
4
import unittest '''Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output Fizz instead of the number and for the multiples of five output Buzz. For numbers which are multiples of both three and five output FizzBuzz.''' def fizzBuzz(n): result = [] ...
92a4be0c06bd7ef132cd8359ff3b35f8db0a8fdf
sandrahelicka88/codingchallenges
/Google/wallsandgates.py
1,287
3.84375
4
import unittest '''You are given 2D grid MxN initialized with three possible values: -1 -wall or an obstcle, 0 -gate, INF means an empty room. Fill each empty room with a distance to its nearest gate. If its impossible to reach the gate, it should be filled with INF.''' def dfs(i,j,count, matrix): if i <0 or i>=l...
8887f3fcd70c28c9f9d2e75d0980b68a53b257e4
koko1123/basic-algorithms
/Algorithms/search-divide-conquer/NumComparisonsQuickSort.py
1,078
3.96875
4
import random """ Modify canonical quicksort to count number of comparisons """ def quick_sort(arr): print(quick_sort_helper(arr, 0, len(arr) - 1)) def quick_sort_helper(arr, start, end): if end - start <= 1: return 0 p = partition(arr, start, end) left_sum = quick_sort_helper(arr, start, p...
47cc5e80ae1df2ea139761e4ce76158fb810e658
koko1123/basic-algorithms
/Algorithms/search-divide-conquer/Karatsuba.py
803
3.765625
4
import math """ implement Karatsuba multiplication """ def multiply(x, y): if len(x) in [1, 2] or len(y) in [1, 2]: return int(x) * int(y) middle_of_x = int(len(x) / 2) a = x[:middle_of_x] b = x[middle_of_x:] middle_of_y = int(len(y) / 2) c = y[:middle_of_y] d = y[middle_of_y:] ...
57497fada904308a244b543a50b8e59074a3d2ed
kush-1277/encryption_algorithms
/caesar_hw.py
1,302
3.984375
4
# Simple Caesar's Cipher Demo Code import sys #Encoding Function def caesar_str_enc(plaintext, K): ciphertext="" for ch in plaintext: encch = caesar_ch_enc(ch, K) ciphertext = ciphertext + encch return ciphertext #Core Encoding Function def caesar_ch_enc(ch, K): if ch.isalpha(): ...
1585691f271d7d31363a50017dde366007929418
C-CCM-TC1028-102-2113/tarea-1-programas-que-realizan-calculos-A01661455
/assignments/09Telefono/src/exercise.py
376
3.890625
4
def main(): #escribe tu código abajo de esta línea #Leer los datos pass print('Dame el número de mensajes: ') m=int(input()) print('Dame el número de megas ') meg=float(input()) print('Dame el número de minutos: ') mi=int(input()) cm=((m*0.80)+(meg*0.80)+(mi*0.80)) cm=round(cm,2) print('Es costo mensual e...
6969d18f21f2633af4fdb2b76b293ed3f9eea4cd
SakshamTolani/stonepaperscissor
/Stone Paper Scissors.py
1,161
3.890625
4
import random lst=['Stone','Paper','Scissors'] i=1 c=0 while i<=10: r=random.choice(lst) print('Here are choices: \n Stone \n Paper \n Scissors ') user=input('Enter Your choice: ') if user in lst: if r=='Stone': if user=='Scissors': print(f'You Lose from {r}') ...
60159b7e98e136879607645dadbf4fe56ad1a76e
victordalet/nsi
/python/tp noté chien/screen.py
610
3.734375
4
import sys def display(animal): """ affiche les valeur du dictionnaire de l'animale animal : dictionnaire """ for name, valeur in animal.items(): # boucle contenant deux variables pour le nom et la valeur de chaque clef dans le dictionaire print("donnée de votre animal: {} : {}".format(name...
294e21d8904156f41a963a187618dfc505ac997e
victordalet/nsi
/python/tp noté chien/demande.py
716
3.96875
4
def firstQuestion(): """ demande à l'utilisateur qu'elle est le nom de son animal return : le nom de l'animal """ nom_animal = input("quelle est le nom de votre animal ?") return nom_animal def demandeTatoue(): """ Permet de demander à l'utilisateur si son chien est tatoué renvoie ...
b3bc5b9352cb839eab71962ebc5fb1c277871913
victordalet/nsi
/python/tp liste/recherche_liste.py
517
3.5
4
def afficherInitial(prenoms): """ Permet d'afficher l'initial de chaque element de la liste :param prenoms: :return: """ for i in prenoms: print(i[0]) def prenomSuperieure(prenoms): """ detecte le prénom fait le plus de fois :param prenoms: :return: """ prenoms_m...
65277a9e3e3763d8e56a6ff9d72b7480d73c5563
initzx/magma
/core/events.py
3,225
3.546875
4
from abc import ABC, abstractmethod class Event(ABC): """ These event classes are similar to that of Lavaplayer's All business rules should be handled using these and an EventAdapter """ @abstractmethod def __init__(self, player): self.player = player class TrackPauseEvent(Event): ...
0a0a0dbb4ae228b7f833e870931c2d047455d5b9
davinakeane1/Week2
/CoinToss.py
144
3.75
4
import numpy as np np.random.seed(123) coin = np.random.randint (0,2) print (coin) if coin == 0 : print("heads") else : print("tails")
b22ea3d77d53c6924d981928e3d9c351e9fc2002
pny4711/aoc2020
/3/3.py
668
3.75
4
import math def check_slope(lines, right, down): offset = 0 trees = 0 part_down = 0 for line in lines: if part_down: part_down -= 1 else: if offset >= len(line): offset -= len(line) if line[offset] == '#': trees += 1 offset += right part_down = down - 1 return trees all_lines = [line...
4bd55e9b1d92dd1f6583e699b262347673d2d89a
dinaerteneto/python-gerenciando-arquivos
/operations.py
2,300
3.921875
4
from bank_account_variables import accounts, money_slips import getpass def do_operation(account, option) : if option == '1' : show_balance(account) elif option == '2' : withdraw(account) elif option == '10' and account['admin'] : insert_money_slips() def show_balance(account) : ...
ab92ff7dd6a3bc0921296dc2ba8574dfd097dca5
havockedFury/competitive-programming
/OJ/URI/python3/1008.py
190
3.609375
4
#!/usr/bin/python3 empNum = int ( input () ) Hours = float ( input () ) PayPerHour = float ( input () ) ans = PayPerHour*Hours; print ( "NUMBER = %d\nSALARY = U$ %.2f" % ( empNum , ans ) )
e18ba8bbede04c0fb4b45027edac5412c15caace
Barzabel/py
/Graph/forest.py
5,917
3.640625
4
class Vertex: def __init__(self, val): self.Value = val class SimpleGraph: def __init__(self, size): self.max_vertex = size self.m_adjacency = [[0] * size for _ in range(size)] self.vertex = [Vertex(None)] * size def AddVertex(self, v): if v < s...
4bf02845cb4fe1a6a624a04425c2e9d9d7dae3ec
Barzabel/py
/Trees/SimpleTree.py
2,619
3.796875
4
class SimpleTreeNode: def __init__(self, val, parent): self.NodeValue = val # значение в узле self.Parent = parent # родитель или None для корня self.Children = [] # список дочерних узлов class SimpleTree: def __init__(self, root): self.Root = root; # корен...
1340b620295bd76c581807ca1b15d148e616f2b5
Tanqiandong/LeetCode-With-Python
/Find Minimum in Rotated Sorted Array.py
355
3.8125
4
# Created by Clyde on 15/4/2. #! /usr/bin/env python # -*- coding: utf-8 -*- class Solution: # @param num, a list of integer # @return an integer def findMin(self, num): if len(num)==1: return num[0] for i in range(len(num)-1): if num[i]>num[i+1]: ret...
eff052ffc7c0350855f6357c4dcde48d56f16b56
Tanqiandong/LeetCode-With-Python
/Unique Paths.py
566
3.5625
4
# Created by Clyde on 15/4/5. #! /usr/bin/env python # -*- coding: utf-8 -*- class Solution: # @return an integer def uniquePaths(self, m, n): if m<1 or n<1: return 0 if m==1 or n==1: return 1 dp = [[0 for col in range(n)] for row in range(m)] for i in ...
09fcaff64f56e96aef383b98e23f3d822f245f32
Tanqiandong/LeetCode-With-Python
/Minimum Path Sum.py
726
3.5625
4
# Created by Clyde on 15/4/13. #! /usr/bin/env python # -*- coding: utf-8 -*- class Solution: # @param grid, a list of lists of integers # @return an integer def minPathSum(self, grid): rows, cols = len(grid), len(grid[0]) dp = [[0 for col in range(cols)] for row in range(rows)] dp...
04dc7656acb214c36e211693af49d97a7cc208a9
Winiex/pyalgor
/leetcode/p3.py
944
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # https://leetcode.com/problems/longest-substring-without-repeating-characters/ class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ s_len = len(s) if s_len <= 1: r...
7afca2fe87c446bb446cfbf41b088c5c265444ff
Winiex/pyalgor
/leetcode/p2.py
924
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # https://leetcode.com/problems/add-two-numbers/ class ListNode(object): def __init__(self, val): self.val = val self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ...
6f81afaf69d81242171ff7c0dfbb4227b2d0dd7d
Winiex/pyalgor
/leetcode/p15.py
1,134
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # https://leetcode.com/problems/3sum/ class Solution(object): """ Brute force solution. Time limit exceeded. """ def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ nums_len = len(nums) ...
7cfe1b8615048f17eb458aa2e2a501ddc46c2e09
alex93skr/Euler_Project
/009.py
335
3.53125
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- print(f'----------------------9--') # import functools def triplet(n, m): return [m ** 2 - n ** 2, 2 * m * n, m ** 2 + n ** 2] res = [triplet(i, j) for i in range(100) for j in range(i + 1, 100) if sum(triplet(i, j)) == 1000] print(res, res[0][0] * res[0][1] * res...
8f12d5d67d13eba6f5efc1611e52118abeec7fd3
alex93skr/Euler_Project
/007.py
478
4.125
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- print(f'-----------------------7--') def prost(n): """простые числа from prime""" if n == 2 or n == 3: return True if n % 2 == 0 or n < 2: return False for i in range(3, int(n ** 0.5) + 1, 2): # only odd numbers if n % i == 0: return ...
dac91fec591c915b38290ee1f998bfedb6c27db6
alex93skr/Euler_Project
/015.py
1,263
3.78125
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- print(f'----------------------15--') import copy side = 3 matrix = [] routes = [] def make_matrix(n): for stroka in range(n): zz = [] for ryad in range(n): zz.append('0') matrix.append(zz) def print_matrix_border(name): for ...
44361249971184cfb2969b0d02e708c320dcf8ce
alex93skr/Euler_Project
/002.py
309
3.59375
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- print(f'-----------------------2--') sum = 2 fb1 = 1 fb2 = 2 i = 3 nn1, nn2 = 0, 0 while i <= 4_000_000: # print(i, end='') if i % 2 == 0: # print(' shet') sum += i fb1 = fb2 fb2 = i i = fb1 + fb2 print('>>>', sum, '♥')
40dfeb29c03cb31c428c868f49d1d47a38273241
alex93skr/Euler_Project
/036.py
477
4.0625
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- print(f'----------------------36--') def palindrome(string): # палиндром reversed_string = string[::-1] return string == reversed_string res = 0 for i in range(1, 1_000_001): # print(i, palindrome(str(i)), bin(i), str(bin(i))[2:]) if pal...
6dcd0acdb32f896ae58110ed8ea2fea977606d58
NITHIN1241/PYTHON_12_OCT_2021
/demo/net_amount.py
262
3.984375
4
# Calculate net amount based on qty and price qty = int(input("Enter Quantity :")) price = int(input("Enter price :")) amount = qty * price # calculate 10% discount discount = amount * 10 / 100 netamount = amount - discount print('Net amount = ', netamount)
26d6971789fe1b8c3aa9ccefe7f81f3fc4e83c67
akifselbii/SchoolProjects
/ProgramlamaDersi/hafta4ödevquiz/170401041_hafta_4_ödev.py
1,564
3.875
4
#Mehmet Akif SELBİ 170401041 """ Parametre olarak bir array ve bir index alır. Aldigi indexteki degeri sag ve sol cocugu ile karsilastirir kendisinden kucuk bir deger varsa onunla yer degistirir """ def min_heapify(array,i): left=2*i+1 right=2*i+2 length = len(array)-1 smallest = i if left <= leng...
d6424f8b73c33a69fce8b17d79fd6d3c8c52874d
efstathios-chatzikyriakidis/skrobot
/skrobot/tasks/base_task.py
2,043
3.71875
4
import copy from stringcase import snakecase from abc import ABC, abstractmethod class BaseTask(ABC): """ The :class:`.BaseTask` is an abstract base class for implementing tasks. A task is a configurable and reproducible piece of code built on top of scikit-learn that can be used in machine learning pipelines...
43892ca5faa3960d45f835d8093e556877cfcb64
Alikev42/Exam-3
/KRS Exam 3 Task2.py
3,557
3.796875
4
#########1#########2#########3#########4#########5#########6#########7#########8 # Kevin R. Salger # IS 640 Business Application Programming (Python) # #########1#########2#########3#########4#########5#########6#########7#########8 # 11111111112222222222333333333344444444445555555555666666666677777777778 #2345...
9fc2a21c6949fda00e94d71227713fe5f6ed53cc
Tigarana/Python
/Hangman/hangmanDrawer.py
928
3.671875
4
class hangmanDrawer: 'This object will draw the hangman figure, depending on the amout of failed tries.' def __init__(self, maxTries = 10): self.failedTries = 0 self.maxTries = maxTries def failedAttemt(self): self.failedTries += 1 def drawHangman(self): for _ in rang...
1ba5ba6e1135166d6532661af9b085c2493d3560
Matt9172/PythonWorkUni
/Week02/conversion_fahrenheit_to_celsius.py
145
4.09375
4
print("Hello, please enter your temperature in fahrenheit.") fahrenheit = float(input ()) print("It is", round((fahrenheit - 32) / 1.8, 2),"c")
ad4fe089c188ca3dd9771e3f4759e8740372d8cb
Matt9172/PythonWorkUni
/Week03/hello_knight.py
119
4.09375
4
print("Hello, whats your name?") name = str(input()) print("Hi Sir", name.capitalize(), "it's very nice to meet you!")
ec1c0d3bfd9f11b1c72ddc5a4d38411fb3eb42e5
shainy-marine/sentiment-emotion-analysis
/train_dataset.py
1,905
3.578125
4
# Trained data with emotions using Logistic Regression Algorithm import logging import warnings from warnings import simplefilter import pandas as pd import seaborn as sns from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.linear_model import LogisticRegression from sklearn.metrics import ...
41469b9bda77c40d341de5cb8f3a18cd0c091cfc
imouiche/Python-Class-2016-by-Inoussa-Mouiche-
/BinomialToNormal.py
1,305
3.515625
4
""" Binomial to normal distribution""" from __future__ import division # help avoid mistake for integer division import pylab as pl import random import math as m import numpy as np def gaussian(x, mu, sigma): """return the value of the gaussian function""" y = 1./np.sqrt(2*m.pi*sigma**2)*np.exp(-(x - mu)**2/(2*si...
02e8d20dddbfe8032b4ce26369424f33cd1b5525
imouiche/Python-Class-2016-by-Inoussa-Mouiche-
/Advance1.py
299
3.546875
4
def vowel(): vow = 'aeiouAEIOU' stence = raw_input(':') word = stence.split() d = 0 for w in word: W = [] d += 1 P = [] j = 0 for i in range(len(w)): if w[i] in vow: j +=1 P.append(i) W.append(w[i]) print '%d word:%s has %d vowels %s at position %s' %(d,w,j, W,P)
aff05dd8d75e9eaec62fd5a6e23ca482c651d193
imouiche/Python-Class-2016-by-Inoussa-Mouiche-
/Conditional_prob.py
1,350
3.765625
4
"""Box u = 1 contains 1 red ball and 3 black balls. Box u = 2 contains 1 red ball, 1 white ball, and 1 black ball. Box u = 3 contains 1 red ball and 1 black ball.""" from __future__ import division from random import * if __name__=="__main__": S = 0 box1 = 0 box2 = 0 box3 = 0 trial = 10000 for n in range(tria...
c5cfe95c8dfed8b12dfc2c6940857c4fb8946777
imouiche/Python-Class-2016-by-Inoussa-Mouiche-
/ClassPerson.py
608
3.671875
4
"""class person""" class Person: def __init__(self, Name, Surname): self.name = Name self.surname = Surname def __str__(self): return "%s %s" %(self.name, self.surname) def Getsurname(self): print self.surname class Student(Person): def __init__(self, Name, Surname, StudNumber): Person.__init__(self.name...
b48ee8f5835cb7d3de709e54aa5b40935340db81
BillMills/python-testing
/genomics/matching.py
237
3.515625
4
def matchScore(seqA, seqB): score = 0 for i in range(len(seqA)): if seqA[i] == seqB[i]: score += 1 elif seqA[i] == '-' or seqB[i] == '-': score += 0 elif seqA[i] != seqB[i]: score -= 1 return score
27b06dd6bc0963ed1f71153a1af59e7dbf8c3187
ArshRiar/Algorithmic-toollbox
/fib_last_digit.py
237
4.03125
4
def Fibonacci_Number(n): if n<=1: k=n else: i=0 j=1 for num in range(n-1): k=(i+j)%10 i=j j=k return k n=int(input()) print( Fibonacci_Number(n))
2304ebdb7092d679925a02b481bcf17d81cde73e
RayanSt/Iterator
/venv/iterator.py
858
3.84375
4
class _IteradorListaEnlazada(object): " Iterador para la clase ListaEnlazada " def __init__(self, prim): """ Constructor del iterador. prim es el primer elemento de la lista. """ self.actual = prim def next(self): """ Devuelve uno a uno los elementos de la lista. """ ...
ee493b811028fc4f709027be3ef01a938bd4173b
rawalpurvi/ATRCar-API
/data_csv.py
2,702
3.578125
4
import csv ''' Car_Data: class read model and owner csv file and return information in dictionary. Write model and owner csv file using database information. ''' class Car_Data: def __init__(self, csv_name): self.csv_name = csv_name ''' read_model_csv: Read model csv return infromation into dict...
60025f84d20d64fc0f173a3209c99e6680743b14
benadida/helios-server
/helios/crypto/numtheory.py
41,387
3.953125
4
################################################## # ent.py -- Element Number Theory # (c) William Stein, 2004 ################################################## from random import randrange from math import log, sqrt ################################################## ## Greatest Common Divisors ##############...
91d00858659250a73c9c31a1e14fb015cca6fd61
008karan/Data-structure
/Searching/Binary search.py
538
4.03125
4
def Binary_search(list,l,r,key): if(r>=l): mid=l+(r-l)//2 if(list[mid]==key): return mid if(list[mid]>key): return Binary_search(list,l,mid-1,key) if(list[mid]<key): return Binary_search(list,mid+1,r,key) ...
3af2058ef69af15ae8539e8879e55bb2e237a481
SidharthPati/Algorithms
/Dynamic Programming/unbounded_knapsack.py
1,276
3.859375
4
""" __author__ = 'spati' Given a knapsack weight W and a set of n items with certain value val and weight wt, we need to calculate minimum amount that could make up this quantity exactly. This is different from classical Knapsack problem, here we are allowed to use unlimited number of instances of an item. Find maximum...
7b8004e2055f1db5c43aba0a6dc615af24127bb9
wcsten/python_cookbook
/data_structure/separate_variables.py
575
4.25
4
""" Problema Você tem uma tupla ou sequência de N elementos que gostaria de desempacotar em uma coleçāo de N variáveis. """ """ Soluçāo Qualquer sequência (ou iterável) pode ser desempacotada em variáveis por meio de uma operaçāo simples de atribuiçāo. O único requisito é que a quantidade de variáveis e a estrutur...
de03fc8af99d4468b8900526b6ca9b01a6c799a8
turdasanbogdan/PythonExs
/PythonWork/guessing_game1.py
303
3.671875
4
from random import randint number = input("test your luck: ") number = int(number) i= randint(1,9) if number == i: print("Lucky bastard") elif number - i < 0: print("you were too low with: " + str(abs(number-i))) else : print("you were to high with: " + str(number-i)) print(i)
67bcc1c879d5638076247351744cd5c8ac2829b7
turdasanbogdan/PythonExs
/PythonWork/odd_even.py
148
3.8125
4
nr = input("get number: ") nr = int(nr) nr2 = input("ia mai da unu: ") nr2= int(nr2) if nr %nr2 == 0: print("Good") else : print("Bad")
e2f0f47696c45840ceb4847131ee88ab0ac2905a
Stuming/lpthw
/ex5.py
715
3.96875
4
# -*- coding: utf-8 -*- my_name = 'Stuming' my_age = 22 # not a lie my_height = 175 # centimeters my_weight = 55 # kilograms my_eyes = 'Brown' my_teeth = 'White' my_hair = 'Black' print("Let’s talk about %s." % my_name) print("He’s %d cm tall. Equal to %d inches." % (my_height, my_height / 2.54)) print("He’s %d kg he...
6fc5bc218372d71afd7797346f75d13a68dd1320
bildschirmtext/bildschirmtext
/server/editor.py
10,476
3.828125
4
import sys import pprint from cept import Cept from util import Util ''' An Editor object is used for single or multi line text input. Every field on a dialog page is backed by one Editor object. ## Features * An editor has a position, a size, a foreground and a background color. If the color properties ar...
af4e0da176e746bd3692aa50c693618c77d6d8ce
C-CCM-TC1028-102-2113/tarea-3-programas-que-usan-funciones-TaniaGuillen
/assignments/10Bisiesto/src/exercise.py
283
3.640625
4
def main(): #escribe tu código abajo de esta línea a = int(input('Dame el año: ')) if a%4=0: print('es año bisiesto') elif a%100=0: print('No es año bisiesto') else: print('No es año bisiesto') pass if __name__=='__main__': main()
46a5f0c2e5618e80ed9aec030faf878e09a93e4e
grkheart/Python-class-homework
/homework_1_task_6.py
1,136
4.34375
4
# 6. Спортсмен занимается ежедневными пробежками. В первый день его результат составил # a километров. Каждый день спортсмен увеличивал результат на 10 % относительно # предыдущего. Требуется определить номер дня, на который общий результат # спортсмена составить не менее b километров. Программа должна принимать # знач...
93d1196dba3f7745718d64da935ad2b3e96b631e
grkheart/Python-class-homework
/homework_3_task_1.py
734
3.875
4
# Реализовать функцию, принимающую два числа (позиционные аргументы) и # выполняющую их деление. Числа запрашивать у # пользователя, предусмотреть обработку ситуации деления на ноль. def my_div(*args): try: arg_1 = int(input("Введите первое число: ")) arg_2 = int(input("Введите второе число: ")) ...
eb5f823180f5c69fafb99a9c0502f55045bf517b
RutujaMalpure/Python
/Assignment1/Demo10.py
335
4.28125
4
""" . Write a program which accept name from user and display length of its name. Input : Marvellous Output : 10 """ def DisplayLength(name): ans=len(name) return ans def main(): name=input("Enter the name") ret=DisplayLength(name) print("the length of {} is {}".format(name,ret)) if __name__=="__ma...
40a4576cdb3acbf89c83ad6031133094279320f6
RutujaMalpure/Python
/Assignment2/Module/Demo1.py
521
3.796875
4
""" Create on module named as Arithmetic which contains 4 functions as Add() for addition, Sub() for subtraction, Mult() for multiplication and Div() for division. All functions accepts two parameters as number and perform the operation. Write on python program which call all the functions from Arithmetic module by...
cdbaac13c9d4a49dd7c6fb425b6372929aab870d
RutujaMalpure/Python
/Assignment3/Assignment3_3.2.py
842
4.15625
4
""" .Write a program which accept N numbers from user and store it into List. Return Maximum number from that List. Input : Number of elements : 7 Input Elements : 13 5 45 7 4 56 34 Output : 56 """ def maxnum(arr): #THIS IS ONE METHOD #num=arr[0] #for i in range(len(arr)): #if(arr[i]...
91783962c2c19c78334a6ac465f066bf8bf438eb
motmietmai/Mohinhngaunhien
/src/api/base_examples_generator.py
3,843
3.828125
4
''' Created on Jul 3, 2011 @author: kjell ''' from random import random from random import choice import unittest example_alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] def get_example_alphabet(): return example_alphabet def generate_examples_...
56ab707bb364b9edf9ab003041c8b25668f57fd1
hankkkwu/Custom-yolov4-tiny-model
/helper_functions.py
1,666
3.546875
4
import os import glob def add_a_underscore_between_two_word(): """ This is for changing "traffic light" to "traffic_light", or "stop sign" to "stop_sign" etc. """ # change directory to the correct path directory = 'test/Label' for filename in os.listdir(directory): if filename.endswit...
b1df4f19a341ac58f5b67eae1ce2d36a7c2ccab7
r4ndompuff/vkbotpython
/src/text_gen.py
5,477
3.515625
4
# -*- coding: utf-8 -*- from nltk.corpus import stopwords import dict_reader import pymorphy2 import nltk import re class TextGenerator: """ Text generator class. Methods: - text(text) - generate text from given input. """ def text(self, text, simplicity = 0): """ Method that ...
8d320f16d9ab715efda548016fa5bc02e96e0588
zkevinbai/LPTHW
/ex34.quiz.py
2,904
4.46875
4
# my first app # this is a quiz program which tests a novice programmer's ability to understand # how indexing works with ordinal (0, 1, 2) and cardinal (1, 2, 3) numbers # list of animals/answers, and indexes/questions animal = ['bear', 'python', 'peacock', 'kangaroo', 'whale', 'platypus'] List = [0, 1, 2, 3, 4, 5, ...
c8b593feaa5b5d4528656d4af5626c72ca433d74
zkevinbai/LPTHW
/ex43.py
1,449
3.671875
4
### I cannot get this to run, nor can i figure out the relationship ### between Scene, Engine and Map ### Gothons from Planet Percal #25 class Scene(object): def enter(self): self.map() class Engine(object): def __init__(self, scene_map): self.scene_map = scene_map def play(self): ...
c925b58fd1c717cd76feb44899fe65d3ac87722c
zkevinbai/LPTHW
/ex20.py
965
4.3125
4
# imports argument variables from terminal from sys import argv # unpacks argv script, input_file = argv # defines print_all() as a function that reads a file def print_all(f): print f.read() # defines rewind() as a function that finds def rewind(f): f.seek(0) # defines print_a_line as a function that print...
bd7ddf51ee71cefe95f39f50047acdc423c6909f
zkevinbai/LPTHW
/ex36.riddledungeon.py
8,059
4.09375
4
# my first game from sys import exit print "\n\t Welcome to the Riddle Dungeon, you must play if you want to leave.\n" # enter rooms function, thank you tuples!!! def enter_room(choice): if "starting" in choice: starting_room() elif choice in ("north", "North"): North_room() elif choice...
1911a872e08ddb22f9674351577daf6bba0db3d0
mutouren2020/pythonPractise
/sheet07/input.py
145
4.03125
4
message = input("Please input , I will repeat you :") print(message) message = input("Please input your name : ") print(message + ",你好")
2c467cf061a43911b7391ce9668f67f6c046d728
rwzhao/working-open-data-2014
/notebooks/Day_17_Midterm_with_Answers.py
21,665
4.375
4
# -*- coding: utf-8 -*- # <nbformat>3.0</nbformat> # <markdowncell> # *Working with Open Data* Midterm (March 18, 2014) # # There are **94** points in this exam: 2 each for the **47 questions**. The questions are either **multiple choice** or **short answers**. For **multiple choice**, just write the **number** o...
22229d10e2a6b00a00db4e4784fe3047606b6b83
shraddhabhise/Cracking-the-coding-interview
/Strings and Arrays/Zero matrix.py
688
3.671875
4
class matrix: def zero_matrix(self, list1): rows=len(list1) cols=len(list1[0]) rows_list=[] cols_list=[] for i in range(rows): for j in range(cols): if list1[i][j]==0: if i not in rows_list: rows_list.append(i) ...
7272b56160693e9426346495f303b9f043e0dcf3
shraddhabhise/Cracking-the-coding-interview
/Strings and Arrays/String permutation.py
773
4.0625
4
class palindrome_check: #using hashmap; set , requires memory but def palindrome(self, str1, str2): hash1 = set() hash2= set() for ch in str1: if ch not in hash1: hash1.add(ch) for ch in str2: if ch not in hash2: hash2.add(ch) if hash1!=hash2: return F...
b1fcc904632b417ef244d978a2516a52d04f0544
summir/hogwarts_lg3
/python_homework1/homework1.py
1,078
3.953125
4
""" 一个多回合制游戏,每个角色都有hp 和power, hp代表血量,power代表攻击力,hp的初始值为1000, power的初始值为200。打斗多个回合 定义一个fight方法: my_hp = hp - enemy_power enemy_final_hp = enemy_hp - my_power 谁的hp先为0,那么谁就输了 """ def game(): my_hp = 1000 # 我的生命值1000 my_power = 200 # 我的攻击力 200 your_hp = 1000 # 敌人的生命值1000 your_power = 195 ...
c0198a49744791975960a77368121721fc92c3d0
wsl3/Interpreters
/Monkey/tokens.py
1,215
3.703125
4
""" token's type """ class Token(object): def __init__(self, TokenType, Literal): self.TokenType = TokenType self.Literal = Literal def __str__(self): return "Token({}, {})".format(self.TokenType, self.Literal) __repr__ = __str__ # 算术符号 ADD = "add" SUB = "sub" MUL = "mul" DIV = ...