blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
841cee9afb2ed761006857ee5770a08d2008e444
chrispun0518/personal_demo
/leetcode/7. Reverse_Integer.py
861
3.859375
4
class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ if x == 0 or x >= 2**31 - 1 or x <= -2 ** 31: return 0 if x < 0: ans = -int(str(x)[-1:0:-1]) else: ans = int(str(x)[::-1]) if an...
9dec25a836809f655081c320e5fdeaa34220aee7
jediofgever/HackerRank_Solutions_Python
/Mini-Max_Sum.py
340
3.765625
4
#!/bin/python3 import sys def miniMaxSum(arr): minimal = min(arr) maximal = max(arr) maximum_val = sum(arr) - minimal minimal_val = sum(arr) - maximal result = print(minimal_val, maximum_val) return result if __name__ == "__main__": arr = list(map(int, input().strip().split(' '))) ...
de3f540819c4fd0fea8f5ec490268e093ed720ef
markyashar/Python_Scientific_Programming_Book
/formulas/length_conversion.py
969
3.9375
4
""" Convert from meters to British length units Make a program where you set a length given in meters and then compute and write out the corresponding length measure in inches, in feet, in yards, and in miles. Use 1 inch = 2.54 cm, 1 foot = 12 inches, one yard = 3 feet, 1 British mile = 1760 yards. As a verification,...
6ad2a9436b95ac45fc3e80e5993f9eda6faefcca
edutak/TIL-2
/python/day05/test03.py
137
3.65625
4
num = input('숫자를 입력하세요....?') if not(num.isspace()) and num.isnumeric(): result = int(num) * 100 print(result)
da14fe0152e4dbf43081ba43134f28194d29ac9b
Jaydanna/practice
/test.py
560
4.09375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- ''' ''' def product(x,y): '''Returns the product of a two number''' return x*y def score(num): '''Judgment score''' num = num/10 if num>=9 | num<=10: return "A" elif num>=8: return "B" elif num>=7: return "C" elif num>=6: return "D" elif num<6: return "F" ...
2b1f4adf84b08458b5c4f790cefabfa734e988a7
dsf3449/CMPS-150
/Labs/lab10/lab10.py
1,400
3.671875
4
# Author: David Fontenot # CLID/Section: dsf3449/C00177513/Section 002 def process(type, previousBalance, changer): if type == 'W': newBalance = (previousBalance - changer) if newBalance < 0: print("Withdrawal", format(changer, '10.2f'), format("Insufficient Funds", '>23s')) ...
65f77b62e4f7e5c9ca2dfd619c8f254896f743fc
zooee/PyDevtest1
/Student/studentGrade.py
1,628
3.9375
4
#coding=utf-8 ''' Created on 2016年3月30日 @author: Administrator ''' class Student(object): def __init__(self, name, score): self.__name = name self.__score = score def get_name(self): return self.__name def get_score(self): return self.__score def set_...
f2f7d2cf276dd84736e9163ace75e9e9c54cd2b2
gagnongr/Gregory-Gagnon
/Exercises/list.py
134
3.71875
4
numbers = [1,2,9] x = numbers numbers.sort() if x == numbers: is_ascending = True else: is_ascending = False print(len(numbers)
39e5b972857f55282ed6e752efa1203c626268c4
Williamcassimiro/Programas_Basicos_Para_Logica
/Desafio 39.py
2,185
4.1875
4
from datetime import date ano = int(input("Informe ano que voce nasceu? ")) sexo = str(input("Digite voce é Mulher ou Homem:")).title().strip() idade = date.today().year - ano if sexo == 'Mulher': print("Voce não e obrigada a se alistar") sim_nao = str(input("Voce gostaria de se alistar? Sim ou Nao?")).title().strip(...
958d74b8f724ac88e3e2e29cf1ec1dd75f3f73d6
svahaGirl/Python-Project
/Create connection with sqlite3
561
3.890625
4
#!usr/bin/python3 # Creating Tables in Python Sqlite import sqlite3 as lit def main(): try: db = lit.connect('dns_search.db') cur = db.cursor() tablequery = "CREATE TABLE users (id INT, Case_Number INT,name TEXT, email TEXT, DNS_Search TEXT,VirusTotal_Indicator BLOB, note TEXT, timeStamp D...
b2cb903eef543db09b785f15130c7ea2c3600d77
OldFuzzier/Data-Structures-and-Algorithms-
/DynamicProgramming/322_Coin_Change.py
927
3.703125
4
# # coding=utf-8 # 322. Coin Change # 硬币问题 # Solution: https://leetcode.com/problems/coin-change/solution/ class Solution(object): # PCway DP button-up def coinChange(self, coins, amount): """ :type coins: List[int] :type amount: int :rtype: int """ dp = ...
c609308750e5e204f8650b5bff00f25a09942bfb
gscr10/Python_study
/r_25_文件操作.py
1,427
4.0625
4
# 文件操作 # 1个函数,3个方法 # 打开文件 open file = open("test.txt", "a+") """ r 只读 指针放在开头 默认模式 文件不存在,抛出异常 w 只写 文件存在,覆盖 不存在,创建新文件 a 追加 文件存在,指针放在结尾 不存在,创建新文件 r+ 读写 指针放在开头 文件不存在,抛出异常 w+ 读写 文件存在,覆盖 不存在,创建新文件 a+ 读写 文件存在,指针放在结尾 不存在,创建新文件 """ # 读写文件 read write file.write("hello python") txt = file.read() # 执行...
16b4d37277ff08aced158e04438d86801518f78c
EzequielCosta/ifpi-ads-algoritmos2020
/espiral.py
836
3.796875
4
import turtle , math bob = turtle.Turtle(); bob.speed(10); def polyline(t, n, length, angle): for i in range(n): t.bk(length) t.lt(angle) def polygon(t, n, length): angle = 360.0 / n polyline(t, n, length, angle) def arc(t, r, angle): arc_length = 2 * math.pi * r * angle / 360 n =...
892b3842575022cf0217768b758cc6af80df2471
afreese1/CS201
/Lab12.py
2,579
4.09375
4
def create (): print("create list") lst=[] element=input("enter element, enter no when done") while element!= "no": lst.append(int(element)) element=input("enter element, enter no when done") return lst def binarysearch (x,lst): selectionsSort(lst) low=0 high=len(lst...
32598c023a4de86f001a692ded5dad21f8d3b8ce
dannybombastic/python
/radiobutton.py
500
3.703125
4
from tkinter import* root = Tk() def pintar(): texto = opcion.get() label.config(text=texto) opcion = IntVar() texto = StringVar() texto.set(str(opcion.get())) r1 = Radiobutton(root,text='Opcion 1', command=pintar ,variable=opcion,value=1).pack() r2 = Radiobutton(root,text='Opcion 2', command=pintar ,vari...
74d39b23775b765ed8aa2371550e332c4e7f3071
bhoomika909/Hacktoberfest2021-1
/Python/25. How to get a factorial of number using while loop.py
152
4.09375
4
x = abs(int(input("Insert any number: "))) factorial =1 while x > 1: factorial *= x x -= 1 print("The result of factorial = ", factorial)
128230e436703ad51fc3c1a64df9c554ba6899a2
onestarshang/leetcode
/add-strings.py
1,266
3.828125
4
''' https://leetcode.com/problems/add-strings/ Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < 5100. Both num1 and num2 contains only digits 0-9. Both num1 and num2 does not contain any leading zero. You must not use any...
1c8cb8283e6b4d91d28e0f174e77b1271ddb4da0
komalsorte/LeetCode
/Arrays/349_IntersectionOfTwoArrays.py
1,144
3.703125
4
""" LeetCode - Easy """ from typing import List class Solution: def intersection(self, nums1, nums2): dict_int_1 = dict() dict_int_2 = dict() index_1 = 0 index_2 = 0 flag = True while flag == True: if index_1 != len(nums1): if nums1[inde...
138e1e8b1eae55d2f1eca420ba331929affcea66
jhembe/python-learning
/utils.py
673
4.0625
4
def find_max(numbers): max_value = numbers[0] #lets use the for loop to itterate through the list for number in numbers: if number > max_value: max_value = number return max_value def add_people(): num_people = int(input("Enter the number of people you want to add : ")) ...
6b96bc7e4067e8d291217e4334e054eafa407fcd
b-ark/lesson_23
/Task3.py
438
3.875
4
def mult(a: int, n: int) -> int: if n < 0: raise ValueError("This function works only with positive integers") elif a == 0 or n == 0: return 0 elif n == 1: return a else: return (a + mult(a, n - 1)) def main(): print(mult(2, 4)) print(mult(2, 0)) print(mult(...
5197a3d9d7017c4c11cdf67915441c3624537d9c
ZacCui/cs2041_software-Construction
/ASS1/test01.py
117
3.875
4
#!/usr/bin/python3 x = 1 while x >= 1: break while x < 10: x = x+1 if x == 5: continue print(x)
974c1fd00d69d0505152c96dc226cf046cc24b62
CodingWithPascal/Python-Games-and-Challenges
/Hangman.py
304
3.953125
4
h = ['head', 'body', 'left leg', 'right leg', 'left arm', 'right arm'] word = 'candy' word_length = len(word) dashes = '' for i in word: dashes += '- ' print(dashes) u = input('Letter? ').lower() while if u.lower() in word: print('True') else: print('You guessed wrong!') print(h[0])
6edd6dbb1a11de8cb00e51f0165d5d3a5a741426
mikaelbeat/Robot_Framework_Recap
/Robot_Framework_Recap/Python_Basics/Functions_different_type_arguments.py
585
3.953125
4
# Functions with different types arguments # Keyword arguments def takeInput(number1, number2): sumOfNumbers = number1 + number2 print("\nSum of numbers " + str(number1) + " and " + str(number2) + " is " + str(sumOfNumbers) + ".") takeInput(number1=1000, number2=4000) # Default argument # Defa...
c1aee4795bea625123f40623dbc3a916ee5d018b
mateoadann/Ej-por-semana
/Ficha 1/ejercicio1Ficha1.py
316
3.546875
4
# 1. División con resto # Plantear un script (directamente en el shell de Python) que permita informar, # para dos valores a y b el resultado de la división a/b y el resto de esa división. # Dates: a = 10 b = 3 # Process division = a/b resto = a % b # Results print(round(division, 1)) print(resto) print('FIN')
03a0f6ae69fe9db16cbf7f8c149cf24fe65a34bb
chaoyi-he/algrithm
/select_sort.py
1,324
4.15625
4
__author__ = 'hechaoyi' ''' 选择排序 选择排序比较好理解,好像是在一堆大小不一的球中进行选择(以从小到大,先选最小球为例):   1. 选择一个基准球   2. 将基准球和余下的球进行一一比较,如果比基准球小,则进行交换   3. 第一轮过后获得最小的球   4. 在挑一个基准球,执行相同的动作得到次小的球   5. 继续执行4,直到排序好 时间复杂度:O(n^2). 需要进行的比较次数为第一轮 n-1,n-2....1, 总的比较次数为 n*(n-1)/2 直接上代码: ''' def selectedSort(myList): #获取list的长度 length = ...
5efc82532a8852fabc00adaffa8baa68d0c24041
ziperlee/leetcode
/python/13.py
1,315
3.53125
4
class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ # if len(strs) == 0: # return '' # res = strs[0] # for s in strs[1:]: # len_res, len_s = len(res), len(s) # length = len_...
b53390b0fcc2c79b72621e0b7f8683b3b2ae1da3
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_200/4687.py
658
3.765625
4
#!/usr/bin/python3 # -*- coding: iso-8859-15 -*- import sys def is_increasing_no(n): return sorted(str(n)) == list(str(n)) def largest_tidy_no(N): for n in reversed(range(1, N + 1)): if is_increasing_no(n): return n def main(): print("here") filename = sys.argv[1] with open...
e7fc98098e655f8ac8386dd4cec83a384561fd4e
rsangiorgi1/adventofcode2020
/day_2/get_valid_passwords.py
679
3.625
4
def count_valid_passwords(passwords): valid_passwords = 0 for pw in passwords: pieces = pw.split() number = pieces[0] lower_limit = number.split("-")[0] upper_limit = number.split("-")[1] letter = pieces[1][0] # trim the ":" password = pieces[2] hits = pas...
95063f020e33dc02deca007d43dabdb37a5df995
JAGGER99/PythonFiles
/Python Code #18 Return Statements in Functions.py
289
3.921875
4
# Return statements demo: def square(number): return number*number result = square(2) print(result) ###################### #################### ################### # by default all functions return "None" # never contain the receiving of input or the printing of output!!!!!!
b350b29a94308d2b5d0adb427174bd6dd2d2525f
forty47seven/with_dahir
/acronym.py
173
3.6875
4
#Acronym name = input('Enter the name: ') l_name = name.split() x = '' for i in range(len(l_name)): y = l_name[i] x = x + y[0] print (x.upper())
3aa38412a1a47089bfb75907084b8a1caf82e08b
Toastyroasty/ctci
/ch2/ch2q1.py
829
3.90625
4
from LinkedList import * def massDelete(head, value): # Given the head of a linked list, removes all nodes with a given value. # Returns a (reduced) linked list if head is None: return head if head.data == value: if head.next is None: return None head = head....
6f0f87804da3e98106f0fb8849083107539fd376
jask05/CodigoFacilito-Python
/05_tuplas.py
617
3.765625
4
# -*- coding: utf-8 -*- # No es necesario corchetes. Sin corchetes = TUPLAS # Pero ES IMPORTANTE que los elementos estén separados por comas. t = 1, True, "Hola" print t print "\n ------------ \n" print "+ Es recomendable poner paréntesis cuando se define. \n" t2 = (3, False, "Chau") print t2 print type(t2) print "\...
6e05b45e492295cac0276169e78acf6f8ef4d478
jskyzero/Python.Playground
/projects/NoteBook/notebook/model.py
2,434
3.625
4
#!/usr/bin/env python #-*- coding:utf-8 -*- import sqlite3 import os class User(object): """A Class to store User""" def __init__(self, name, password): self.name, self.password = name, password def read_user(tup): """A func to make tuple to User""" return User(*tup) class Note(object):...
a095b4d3aab1df57c29e51f1a62cd0f25f8b0377
hugoreyes83/scripts
/codewars12.py
253
3.640625
4
from collections import Counter def find_uniq(arr): count_items = Counter(arr) for i in count_items: if count_items[i] == 1: return i else: continue result = find_uniq([ 0, 0, 0.55, 0, 0 ]) print(result)
e84a684505fe99f250e4fd5f9b111973ba651fdd
AdrianoCavalcante/exercicios-python
/lista-exercicios/ex011.py
302
3.84375
4
h = float(input('Qual a altura da perede que você deseja pintar? ')) l = float(input('Qual o comprimento da parede? ')) a = h*l print(f'Sua parede tem {h:.2f} metros de altura por {l:.2f} metros de comprimento, a área corresponde a {a:.2f} m², você vai precisar de {a/2:.2f} litros de tinta!')
78aec55a2855fc4218d47eecc560fb7f47bcab24
425776024/Learn
/pythonlearn/Class/MagicMethods/staticmethod.classmethod.py
1,122
3.6875
4
# -*- coding: utf-8 -*- class Hero(object): def say_self_hello(self, value): print("Helllo self..., then %"% value) @staticmethod def say_hello(name): print("Hi %s..." % name) @staticmethod def say_son(name): pass @classmethod def say_class_hello(...
9d8c5bd83dc0cebf9b8e9208c0882eb7d40625eb
lucasrsanches/Python-3
/Python 3/Curso em vídeo - Guanabara/Mundo 01 - Fundamentos/Exercício 007 - Média aritmética.py
249
3.78125
4
'''Desenvolva um programa que leia as duas notas de um aluno, calcule e mostre a sua média ''' nota1 = float(input("Digite sua primeira nota: ")) nota2 = float(input("Digite sua segunda nota: ")) print("A sua média é: ", (nota1+nota2)/2)
46976bc15f059b6139fcc4173f225d2001eaed13
TyDunn/hackerrank-python
/GfG/Binary Tree/binary_tree.py
354
3.859375
4
#!/bin/python3 class Node: def __init__(self, key): self.left = None self.right = None self.val = key def trav_in_order(node): if node: trav_in_order(node.left) print(node.val) trav_in_order(node.right) if __name__ == '__main__': root = Node(1) root.left = Node(2) root.right = Node(3) root.left.l...
caea88780b33767456aec96022b6edc0832209ae
harveywang0627/design_patterns
/iterator/class_iterator.py
870
3.90625
4
import abc class Iterator(metaclass=abc.ABCMeta): @abc.abstractmethod def has_next(self): pass @abc.abstractmethod def next(self): pass class Container(metaclass=abc.ABCMeta): @abc.abstractmethod def get_iterator(self): pass class MyListIterator(Iterator): def __init__(self, my_lis...
516452d4503612b1a1b6b4a551e50b9b434f3c65
jsyoungk/Python-Practice
/tart_turtle.py
536
4.125
4
print ("hello world.") import turtle, random from turtle import * color('red', 'purple') begin_fill() while True: forward(200) left(170) if abs(pos()) < 1: break end_fill() done() # DIST = 100 # for x in range(0,6): # print ("x", x) # for y in range(1,5): # print ("...
591ee5f8a9340b676201a31d424b6cef89325540
windy54/legoRobot
/legoRaspiConnect.py
8,471
3.59375
4
#!/usr/bin/python #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ #|W|i|n|d|y| |S|o|f|t|w|a|r|e| | | | | | | | #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ # # this program is based on lots of sources, apologies for not including all references # wifi car from brickpi python # # oct 10th corrected turn logic for large err...
6d7150976b3112a7c3fdb7e9ad3a7b0fbabb1c8a
RishiVaya/Sudoku-Solver
/base.py
2,008
4.21875
4
# Sudoku solver which uses backtracking algorithm. def find_empty(board): for row in range(len(board)): for col in range(len(board[0])): if board[row][col] == 0: return [row, col] return None def printer(board): for row in range(len(board)): if row % ...
238c309c9452e2811d94870ec2c0471508ab9488
savyasachibabrekar/python_basic_programs
/while_loop.py
231
3.640625
4
i=0 while i<10: print("Yes") i=i+1 print("Done") #--------------------------------------------- fruits = ['Mango','orange','chickoo','banana'] i=0 while i<len(fruits): print(fruits[i]) i+=1
76c833bce6bc5584da170952e1a1ad8bb64e8126
mindcrime-forks/nengo-1.4
/simulator-ui/python/spa2/bgrules.py
8,756
3.53125
4
import inspect import numeric class Match: def __init__(self,a,b,weight): self.a=a self.b=b self.weight=weight class Sink: def __init__(self,name,weight=1,conv=None,add=None): self.name=name self.weight=weight self.conv=conv self.add=add ...
4860bc045cdd4cbd75227d1d6f358b82202748a5
jupe/puml2code
/test/data/car.python.py
2,334
3.84375
4
import abc """ @package Interface Vehicle """ class Vehicle(abs.ABC): def __init__(self): """ Constructor for Vehicle """ pass @abc.abstractmethod def getType(self): """ :return: String """ return null """ @package Abstract Car """ class Car...
399638db2accfd36080e56c921f5b3df9a25f9a9
andreworlov91/PyProj
/FunctionTwoLesson.py
555
3.625
4
def create_record(name, telephone, address): """"Create Record""" record = { 'name': name, 'phone': telephone, 'address': address } return record userOne = create_record("Vasya", "+7484234234", "Moscow") userTwo = create_record("Petya", "+7484543534234", "SaintP") print(userOn...
2a1f42737bfc0b70ed0ba6153882323c62b74814
ZubritskiyAlex/Python-Tasks
/hw_3/task_3_1.py
76
3.640625
4
a = int(input("Enter the number")) if a % 1000 == 0: print("millenium")
412da113af767f8acd82f91caf36de4eb8a085e1
BrysonGalapon/dvs_structures
/python3/src/union_find/UnionFind.py
4,262
3.75
4
""" Python implementation of UnionFind datastructure. Solves disjoint set problem. Let alpha be the inverse Ackermann function (https://en.wikipedia.org/wiki/Ackermann_function), which is a super super super ... super slow growing function -- basically constant in all practical applications. Proof: alpha...
aa44f396aaebfae8e46b5ee2837257911d20ea7e
shraddhaagrawal563/learning_python
/numpy_datatype5.py
208
3.671875
4
# -*- coding: utf-8 -*- import numpy as np x = np.linspace(10,20,5) #starting from 10, ending on 20 and spacing would be divided into 5 intervals print(x) a = np.logspace(1,10,num = 10, base = 2) print (a)
6cb08995781786dbe9752288a1ce91310e080476
wuxu1019/1point3acres
/Google/test_418_Sentence_Screen_Fitting.py
2,102
4.34375
4
""" Given a rows x cols screen and a sentence represented by a list of non-empty words, find how many times the given sentence can be fitted on the screen. Note: A word cannot be split into two lines. The order of words in the sentence must remain unchanged. Two consecutive words in a line must be separated by a sing...
3b2c37c071cad7ceebd674a3f63d765811bf4d01
p12345vls/lab15
/lab15.py
5,723
4.15625
4
# Lab 15 # Team MakeSmart # Pavlos Papadonikolakis, Maco Doussias, Jake McGhee #PROBLEM 1: craps() Typing function into console fulfills problem 1 #PROBLEM 2: birthMonthCal() prints calendar of birth month # daysToBday() will calculate days left until your next birthday # getDayOfWe...
f76ef6b6c0f4d7997737bc35c43722717646127b
ClarkThan/algorithms
/sort/QuickSort.py
849
3.6875
4
#QuickSort def middle(seq): length = len(seq) index = 0 for i in xrange(1, length): if seq[i] < seq[index]: key = seq[i] j = i while j > index: seq[j] = seq[j-1] j = j - 1 seq[index] = key index += 1 return index def quickSort(seq): if len(seq) <= 1: return seq mid = middle(seq) left...
8d9e30ac632e4c3d2da31cc6e41f2b5f5d7c630c
AISWARYAK99/Python
/flow.py
1,073
3.8125
4
''' a=10 b=15 if a==b: print('They are equals') elif a>b: print('a is larger') else : print('b is larger') #nested if else stmnts n=int(input('Enter a number')) if n>=0: if n==0: print('Number is Zero') else: print('Number is positive' else : print('Number is...
fad06b6efc08f858e7f209edc645b7676cb79b23
Lazysisphus/Zen-Thought-on-LeetCode
/回溯/0039组合总和.py
1,089
3.5625
4
''' 给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的数字可以无限制重复被选取。 说明: 所有数字(包括 target)都是正整数。 解集不能包含重复的组合。  示例 1: 输入:candidates = [2,3,6,7], target = 7, 所求解集为: [ [7], [2,2,3] ] 示例 2: 输入:candidates = [2,3,5], target = 8, 所求解集为: [   [2,2,2,2],   [2,3,3],   [3,5] ] ''' cla...
58627622c2a83879a5346ee6b1b3bc64ed22e2f1
lilitom/Leetcode-problems
/Tree/Leetcode_111_easy_二叉树最小路径.py
2,393
3.984375
4
''' Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. ''' #South China University of Technology #Author:Guohao #coding=utf-8 #---------------------------------------------------------------------------...
7ca35231cef2a2fdbc72139d08d4a93febe46283
ymsk-sky/atcoder
/abc104/b.py
253
3.53125
4
s=input() if s[0]=='A' and s[2:-1].count('C')==1: for i in range(len(s)): if not (i==0 or i==s[2:-1].index('C')+2): if not s[i].islower(): print('WA') exit() print('AC') exit() print('WA')
edab65965b81b8411e45acebb0dd27a9829ca19b
ddh/leetcode
/python/first_unique_character_in_a_string.py
954
3.90625
4
""" Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contain only lowercase letters. """ from collections import defaultdict class Solution: def firs...
9c57eef242b543e34574753cf6b652b49f0e6a0f
taikinaka/youngWonks
/python/dictionary/dictionaryQuiz.py
310
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jun 1 18:34:35 2019 @author: taikinaka """ friend = { 'Kouki' : 'pees cream', 'Taiki' : 'gum', 'Masako' : 'chocolate', 'Masashi' : 'peanuts'} for a in friend: print(friend[a]) friend.pop('Taiki') print(friend)
eda899cc6cdbea2211b77f07844c305869b0d332
xander5zer/python
/age.py
309
3.84375
4
age = 12 if age < 2: print("младенец") elif age >= 2 and age < 4: print("малыш") elif age >= 4 and age < 13: print("ребенок") elif age >= 13 and age < 20: print("подросток") elif age >= 20 and age < 65: print("взрослый") else: print("пожилой человек")
675fe9c20f78be81d0934f7aaf174cd0e9f4b493
lynellf/learing-python
/python_lists/addition.py
371
4.09375
4
# Addition # Adding items to the end of a list count = [1, 2, 3] count.append(4) print(count) # [1, 2, 3, 4] # Merging two arrays extended_count = [5, 6, 7] count.extend(extended_count) print(count) # [1, 2, 3, 4, 5, 6, 7] # Literally adding two arrays more_counting = [8, 9, 10] more_counts = count + more_counting p...
0de1a32ae305150387f2a5f1fc6c4bc039c62f95
MKRNaqeebi/CodePractice
/Past/same_prime_factors.py
1,154
3.828125
4
import math def primeFactors(first, second): n = first if first < second: n = second if first % 2 == 0 and second % 2 > 0: return False if second % 2 == 0 and first % 2 > 0: return False while first % 2 == 0: first = first / 2 while second % 2 == 0: sec...
390fc8ab463aad910188c384d8bfeef4fc8eeca8
Purushotamprasai/Python
/Rohith_Batch/Vamsi pyhton exam/prime_number.py
225
3.90625
4
def main(): num = int(input("Enter a number: ")) if (num % 2) == 0: print(num,"is not a prime number") else: print(num,"is a prime number") if(__name__ == "__main__"): main()
198bdb3ed509771a1af7cc9f6cca6b6ddeb19acb
zacharytwhite/project-euler-solutions
/project_euler_py/problem_026.py
1,300
3.890625
4
"""A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given: 1/2 = 0.5 1/3 = 0.(3) 1/4 = 0.25 1/5 = 0.2 1/6 = 0.1(6) 1/7 = 0.(142857) 1/8 = 0.125 1/9 = 0.(1) 1/10 = 0.1 Where 0.1(6) means 0.166666......
291ec1475e7f2b59d2e28f693dc7802ea27074b0
ToSev7en/LearningPython
/000-VariableScopeRule/variables-in-function-without-assignment.py
541
4.09375
4
# 一个函数,读取一个局部变量和一个全局变量 # 变量未在函数的定义体中赋值 b = 6 def func(a): print(a) print(b) func(3) """ 如果 b = 6 被注释的话: 3 Traceback (most recent call last): File "/Users/tsw/Documents/CodeCampus/LearningPython/000-VariableScopeRule/variables-in-function.py", line 7, in <module> func(3) File "/Users/tsw/Documents/C...
f0f375241a34ebad05d4d6cbccfdb35c26d439cc
segordon/old-code
/john_cleese_transform_string.py
117
3.6875
4
name = 'John Marwood Cleese' first,middle,last = name.split() transformed = last + ', ' + first + ' ' + middle print(transformed)
7399a59f9b02db5e363ce7c7c267f1c256b86130
wangxiaobai123/first-origion
/helloGit.py
175
3.546875
4
def strtoint(chr): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}[chr] list1 = ['1','2','3','4'] list2 = map(strtoint,list1) print(list(list2))
65298a1055f28d7610136d8c725cd40d536de49c
heysushil/python-practice-set
/basics/dictonary.py
1,284
3.953125
4
# DICTONARY - THIS IS A SINLGE LINE COMMENT ''' THIS IS A MULTILINE COMMENT DICTONARY IS SAME AS ASSOCIATIVE ARRAY WHICH HOLDS KEY AND VALUE NOT DUBLICATE VALUE NO NAME TELPHONE 1 RAJA 98797978 ''' # print(string_value) if 3 > 5: print('IIm in if') print('Im in print body') ...
f4d0353d17cd1d9ddcb23dd345b8ab71dca96a5e
Armen281989/git2
/tryexcept.py
1,589
4.125
4
# try: # print('Hello') # except NameError: # print("Variable x is not defined") # except: # print("Something else went wrong") # try: # print("Hello") # except: # print("Something went wrong") # else: # print("Nothing went wrong") # try: # print(x) # except: # print("Something went wrong") # finally: # p...
e643291d7ab09fb4257b3872f73595432a227e46
marinella16/marinella
/Assignment 1.py
1,787
3.859375
4
#Question 1 m_str = input('Input m: ') # do not change this line m_str = float(m_str)# change m_str to a float c = 300000000# remember you need c e = m_str * c **2# e = print("e =", e) # do not change this line #Question 2 in_str = input("Input s: ") in_int = int(in_str)# in_int = print("in_int = ", in_int) in_floa...
22cec6695d2ca2d5ad196940546e0ac861c9fe76
zangwenjie/pythonpractices
/pythonpractices/py3-6.py
5,972
4.0625
4
# names=["nana","weiwei","yazheng","yanmei"] # lon=len(names) # for i in range(0,lon): # #print(names[i]) # pep=['xue','meizhi','junmei','lina'] # bulai='junmei' # pep.remove('junmei') # pep.append('yanxia') # lon=len(pep) # print(bulai+" will not come, what a pity!") # print("I found a bigger desk !") # pep.in...
4d9524d92682140bda32f1ffd23e1cf1fe59886c
abhisheksingh75/Practice_CS_Problems
/Sorting/Reverse pairs.py
1,913
4.15625
4
""" Given an array of integers A, we call (i, j) an important reverse pair if i < j and A[i] > 2*A[j]. Return the number of important reverse pairs in the given array A. Input Format The only argument given is the integer array A. Output Format Return the number of important reverse pairs in the given array A. Constra...
19a8919aa266908b383812feda71cce14d1f0a39
Xoptuk/game-light-it
/game.py
4,182
3.625
4
# -*- coding: utf-8 -*- from random import randint, choice from time import sleep class Player: """ Класс игрока. Принимающий имя игрока и имеюющий флаг PC, который определяет игрок это или компьютер. """ def __init__(self, name, pc=False): self.name = name self.health = 100 s...
15cd28079f8ab13b55f04d5e3f73b5b506382956
frankiegu/python_for_arithmetic
/力扣算法练习/day16-两数相除.py
4,188
4.0625
4
# -*- coding: utf-8 -*- # @Time : 2019/3/14 21:19 # @Author : Xin # @File : day16-两数相除.py # @Software: PyCharm # 给定两个整数,被除数 dividend 和除数 divisor。将两数相除,要求不使用乘法、除法和 mod 运算符。 # # 返回被除数 dividend 除以除数 divisor 得到的商。 # # 示例 1: # # 输入: dividend = 10, divisor = 3 # 输出: 3 # 示例 2: # # 输入: dividend = 7, divisor = -3 # 输出: ...
4609a820394aa84a38f618214dfc9f939130edb3
cassie-hudson/gis-programming-py
/Sept30_Ch2ProgrammingExercises.py
2,854
3.953125
4
#1 Name = raw_input("Please enter your first and last name: ") Address = raw_input("Please enter your address, including address, city, state and ZIP: ") Telephone = raw_input("Please enter your telephone number: ") Major = raw_input("What is your college major? ") print Name,Address,Telephone,Major #2. Sale Predicti...
a6fcdef0cd73157b5c394de1d8f884e3c71c5249
lucaryholt/python_elective
/39/angry_birds.py
2,066
3.78125
4
from os import system, name import random import sys class Bird: def __init__(self): self.icon = '🐥' self.x_loc = random.randint(0, 9) self.y_loc = random.randint(0, 9) def move(self, input): move = input.lower() if(move == 'w'): self.x_loc -= 1 eli...
1cc5babc307920700e274e1f9db4bc3a0fed5b06
vavronet/text-based-game
/game_intro.py
1,041
3.6875
4
import time def run(): print("Welcome to The Heart-Hands and the Pants!\n") avatar = input("Enter your avatar name here: \n") print("\nGrettings, {}!\nThe kingdom of pants has been conquered by the evil hat masterminds!\nSave the pant people and defeat the evil hat wizard! \nMay the odds be with you Hear...
d8a9132844a34c684b21d6c37dab9d270b062876
Anbumani-Sekar/python-codings
/maximum list.py
58
3.5
4
list=[1,2,3,6,9] print("the maximum of list",max(list))
02af4760b1eaa0e35773e3ecc6d6302cf8a2218a
EchuCompa/Cursos-Python
/funciones.py
713
3.765625
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 12 17:58:54 2020 @author: Diego """ # numero_valido=False # while not numero_valido: # try: # a = input('Ingresá un número entero: ') # n = int(a) # numero_valido = True # except: # print('No es válido. Intentá de nuevo.') # print(f...
8e813322f8a53628eb0552e054700a9625478720
rjbarber/Python
/String Data Type Functions and Operators/In operator.py
276
4.5
4
#This program looks at the string In operator (in) #This operator searches for a specified character #in a target string. If the character exists in #the string a value of ‘True’ is returned, else it returns ‘False’. str1="Hello" print('e' in str1) print('a' in str1)
e1b2447d6539deec40fa9ce84e271e67f3d5c820
Mattemyo/datascience-az
/Part 1 - Data Preprocessing/data_preprocessing_template.py
765
3.78125
4
# Data Preprocessing Template # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv( r"C:\Users\Matias\Documents\datascience-az\Part 1 - Data Preprocessing\Data.csv") # y is the one to be predicted, X contains the rest of the...
d62497e64ac953368586720a647f5eed4905a49e
brandondonato/College-Coursework
/CS110/RandallDevonFinal Project 2/CardClass.py
1,798
3.890625
4
""" Donato, Brandon bdonato1@binghamton.edu CS 110 - B57 Jia Yang FinalProjectCardClass """ class Card(): #-- Constants ---------------------------------------------------------------- # These are the values of each of the cards in the game TWOS = 2 THREES = 3 FOURS = 4 FIVES = 5 SIXES = 6 SEVENS = 7 ...
88264cb0fb2f1e24dfdb3e01356bb22b5d0d422d
allenchen/facebook_hackercup_2013
/r1/balanced_smileys.py
1,094
3.515625
4
input = open("balanced_smileys.in", "r") def is_balanced(s, open_paren_count): #print str(open_paren_count) + " - " + s if len(s) == 0: return open_paren_count == 0 if len(s) == 1: return (s not in ("(", ")") and open_paren_count == 0) or (open_paren_count == 1 and s == ')') or (open_paren...
6d6a2dee49923f42598fe3f80b8d8bc0d886f1a1
srcsoftwareengineer/datah-pokerhand
/tests/test_pokerhand.py
5,327
3.578125
4
#!/usr/bin/python3.7 ''' Created on 27 de set de 2021 @summary: Unit test for PokerHand class @author: Sandro Regis Cardoso | Software Engineer @contact: src.softwareengineer@gmail.com ''' import unittest from bin.pokerhand import PokerHand import random class Test(unittest.TestCase): def test_card_values_0(se...
5e0fe83902a0903ffbbbea28288d547118119c49
elvistony/pyHangman
/verify.py
555
3.84375
4
#Validation from hangman import * def verify(letter,str2): #letter=input(":") while letter in str2: if letter in str2: for i in range(len(str2)): if str2[i]==letter: a=str2[:i] b=str2[i+1:] str2=a+letter.up...
643496ce564c5e60d25881f0756efe0a07f9a566
RaymondDashWu/CS-1.3-Core-Data-Structures
/strings.py
7,841
4.375
4
#!python def contains(text, pattern): """Return a boolean indicating whether pattern occurs in text. Time Complexity: O(n) - find_all_indexes iterates through text once Space Complexity: O(n) - find_all_indexes keeps track of all indexes """ assert isinstance(text, str), 'text is not a string: {}'....
d6490c45cbe947dceaac7a9e0db10824153891ec
Omkar02/FAANG
/MergeKSortedArrays.py
1,795
3.78125
4
import __main__ as main from Helper.TimerLogger import CodeTimeLogging fileName = main.__file__ fileName = fileName.split('\\')[-1] CodeTimeLogging(Flag='F', filename=fileName, Tag='Array', Difficult='Medium') ''' Given K sorted arrays arranged in the form of a matrix of size K*K. The task is to merge them into one ...
a4d7de60b4fb1ac49125f55a8a3ad12729561e5a
kammitama5/Distracting_KATAS
/heronsformula.py
141
3.59375
4
def heron(a, b, c): import math s = (a + b + c) / 2 area = (s * ((s - a) * (s - b) * (s - c))) return math.sqrt(area)
b0ebd242fffc3583fcd845c8e6c3112a08ea5cfe
DeepFreek/AI_alg
/Square.py
2,582
3.609375
4
import copy from move_func import move_up,move_down,move_left,move_right,find_void combination={ 'начало': [[2, 8, 3], [1, 6, 4], [7, 0, 5]], 'конец': [[1, 2, 3], [8, 0, 4], [7, 6, 5]] } def print_array(array): for row in range(len(array)): print(array[row]) print('\n') def up_down(array):...
51210938a5be973ceb3dd656a09b4d3dc2e1ccca
manosriram/Learning-Algorithms
/Linear-Regression/CostFunction.py
425
3.734375
4
import pandas as pd import numpy as np data = pd.read_csv("./ex1data1.txt", sep=",", header=None) m = len(data) X = data[0] def computeCost(X, y, theta): predicted = X * theta actual = y # sqrError = np.power((predicted - actual), 2) print(len(predicted)) cost = 1 / (2 * m) * np.sum([1, 2, 3]) ...
74e87bf28436a832be8814386285a711b627dab9
ohaz/adventofcode2017
/day11/day11.py
2,179
4.25
4
import collections # As a pen&paper player, hex grids are nothing new # They can be handled like a 3D coordinate system with cubes in it # When looking at the cubes from the "pointy" side and removing cubes until you have a # plane (with pointy ends), each "cube" in that plane can be flattened to a hexagon # This mean...
4010aea472f4517a12accba30bc4f19d7cfe0575
sunilsm7/python_exercises
/python_3 by pythonguru/Python File Handling.py
4,991
4.59375
5
Python File Handling 9 Replies Get started learning Python with DataCamp's free Intro to Python tutorial. Learn Data Science by completing interactive coding challenges and watching videos by expert instructors. Start Now! We can use File handling to read and write data to and from the file. Opening a file Before re...
d392b4669cd9aa974429420b7744788b104159b7
gabrielsalesls/curso-em-video-python
/ex088.py
506
3.546875
4
from random import randint from time import sleep numjogos = int(input('Quantos jogos você quer: ')) print(f'Sortetando {numjogos} jogos') jogo = [] apostas = [] for j in range(0, numjogos): cont = 0 while True: num = randint(1, 60) if num not in jogo: jogo.append(num) ...
0da61ecebf9cc88e56608c67521070bcbfb11e8e
n-rajesh/Python
/Scrape_text.py
1,185
3.984375
4
""" This is a program that performs Web Scraping for text. It extracts all text in given webpage and saves it to input.txt. """ import urllib.request as req from bs4 import BeautifulSoup as Soup from html.parser import HTMLParser class MLStripper(HTMLParser): def __init__(self): super().__init_...
984fe75cb5c78b14bae08e7d7b92b04447020ef2
HYuHY/Small_training_Games
/Small_training_Games/Компьютер угадывает число.py
1,064
4.09375
4
# coding: utf-8 # Computer Guess My Number """ The user inputs a random number between 1 and 100 The computer tries to guess it and lets the player know what number was tried """ import random print("Welcome to 'Comp Guess My Number'!") the_number = 1000 while the_number > 100 or the_number < 1 : p...
75409105547626392efc6f96a726ff7689d800cf
ChicksMix/programing
/unit 5/HicksBirds.py
191
3.703125
4
#Carter Hicks #1/12/18 n=0.0 t=0.0 c=0.0 while n<>-1: n=float(input("Enter a score or -1 to stop: ")) if n<>-1: t=t+n c=c+1 a=round(t/c,2) print "Your average score is",a
0c02b258ffc6ecb83a4ae97a3bbe40c55c4b63a3
vgates/python_programs
/p003_validate_input.py
516
4.4375
4
# Ask user to input until he/she enters valid input # For example: Get age from the user. The input should be always an integer value while True: try: age = int(input("Please enter your age: ")) except ValueError: print("Invalid input provided. Type your age") continue else: ...
36243c81f9b3555b69ec55487778bcba8f41206d
freebz/Deep-Learning-from-Scratch
/ch03/ex3-7.py
171
3.703125
4
# 다차원 배열 import numpy as np A = np.array([1, 2, 3, 4]) print(A) np.ndim(A) A.shape A.shape[0] B = np.array([[1,2], [3,4], [5,6]]) print(B) np.ndim(B) B.shape
f969d6b184677eefe48cf86f4063fe345dfd53a5
kkaixiao/pythonalgo2
/leet_0387_first_unique_character_in_a_string.py
1,118
3.875
4
""" Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contain only lowercase letters. """ class Solution: # first dictionary approach def firstUn...
638e66ad73b7ae93a4e7c2c32bc90c7957a4567c
c-hering/project_euler
/problem_2.py
650
4
4
#!/usr/bin/env python # Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the...
94173514769f10e9be39a466033620ca0b11468b
ladykillerjason/leet
/Sum Root to Leaf Numbers.py
728
3.71875
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def sumNumbers(self, root): """ :type root: TreeNode :rtype: int """ if not root:return 0 return self.dfs(root,0) d...