blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
0197aaa5a0b5d0a29726f2b008b632b31dd98a1d
DouglasAllen/Python-projects
/my_code/wr_files.py
556
3.75
4
the_file = open('temp.txt', 'w') print(the_file) the_file.close() the_file = open('temp.txt', 'r') the_file.read() the_file.close() with open('my_list.py', 'r') as my_file: read_data = my_file.read() print(read_data) print(my_file.closed) #~ with open('my_list.pl', 'r') as my_file: #~ read_data = my_file.read...
8955f7bc9a508a7540b60afd515c11a27a0d4ad4
vck3000/SYNCS_Hackathon_2021
/backend/src/engine/item.py
466
3.53125
4
from .coord import Coord class Item: def __init__(self, size: Coord, mass_density: int, strength: int): self.size = size self.mass_density = mass_density self.strength = strength def get_area(self): return self.size.x * self.size.y def get_mass(self): return self....
bfb1f30eb1356884c5971ec11c8304b453fe3d36
symbooo/LeetCodeSymb
/demo/21.MergeTwoSortedLists.py
2,753
4.1875
4
#!/usr/bin/env python # -*- coding:utf-8 -*- """ YES, WE CAN! @Time : 2018/8/29 8:55 @Author : 兰兴宝 echolan@126.com @File : 21.MergeTwoSortedLists.py @Site : @Project : LeetCodeSymb @Note : [describe how to use it] """ # Enjoy Your Code # Definition for singly-linked list. class Li...
956c588867ec2cffbaa6f7559ef2bebe287d7259
doonguk/algorithm
/20200409/98.py
346
3.765625
4
def isValid(self, s: str) -> bool: open_set = set(["(", "[", "{"]) bracket_map = {"(": ")", "{": "}", "[": "]"} stack = list() for v in s: if v in open_set: stack.append(v) elif stack and v == bracket_map[stack[-1]]: stack.pop() else: return Fa...
203b430f5b592bf3c45c56459a1db2acc1435ad9
ultimate010/codes_and_notes
/547_intersection-of-two-arrays/intersection-of-two-arrays.py
1,490
3.609375
4
# coding:utf-8 ''' @Copyright:LintCode @Author: ultimate010 @Problem: http://www.lintcode.com/problem/intersection-of-two-arrays @Language: Python @Datetime: 16-06-19 09:15 ''' class Solution: # @param {int[]} nums1 an integer array # @param {int[]} nums2 an integer array # @return {int[]} an integer...
2ea7cfb747d3aaf7e2ade9b29f89b6fde1ff8cfb
fearnoevil7/PythonStack
/python/fundamentals/functions_basic2.py
1,046
3.875
4
# def countdown(num): # array = [] # for i in range (num, -1, -1): # array.append(i) # return array # b = countdown(5) # print(b) # def print_and_return(array): # for i in range(0, len(array), 1): # print(array[i]) # if i == 2: # return (array[i]) # b = print_and_...
dedf2ce88bc1bac8b85fd1be3c76a23751b26da3
anaghsoman/Py2
/dt_cipher.py
1,130
3.515625
4
#!/usr/bin/python import string def get_order(key): key = key.replace(' ', '') order = len(key) * [None] sorted_key = sorted(key) for i, ch in enumerate(sorted_key): order[i] = key.index(ch) key = key.replace(ch, 'z', 1) # string is immutable # print order return order def transp...
2aeaaafa212680b91e0343554f22164e5c9fd047
KrishnaB7/python
/graphics/tkinter/pattern4.py
771
3.515625
4
#! /usr/bin/python3 import time from tkinter import * tk = Tk() canvas = Canvas(tk, width=800, height=800) canvas.pack() d = canvas.create_oval(700, 300, 800, 400, fill="springgreen") e = canvas.create_oval(0, 400, 100, 500, fill="aqua") k = canvas.create_oval(300, 0, 400, 100, fill="springgreen") l = canvas.create_ov...
8ccc3fa469cb3870eacf04f86d92476e1f233db5
BoobeshP/turtle-projects
/turtle p05 (stars).py
390
3.5
4
import turtle as t a = t.Turtle() a.getscreen().bgcolor("black") a.penup() a.goto(-200,50) a.pendown() a.hideturtle() a.color("orange") a.speed(0) def star(t,size): if size <=10: return else: for i in range(5): t.begin_fill() t.forward(size) star(t,size/3) ...
16bbfb1f29636ac714f3cd2e227fe96f6ab98465
microsoftdealer/first_repo
/quad.py
1,863
3.609375
4
import copy def draw_matrix(matrix): for row in matrix: print(row) def count_quads(matrix_raw): r = 0 t = 0 matrix = copy.deepcopy(matrix_raw) quad_counter = 0 length = len(matrix) * len(matrix[0]) for sym in range(length): if matrix[r][t] == 0: pass els...
c98800866e3a69c635fad3904fe51209d93e7777
battyone/Solar_Flare
/alphaestimator2.py
969
3.5
4
import numpy as np import powerlaw def get_alpha(data): data = np.array(data) result = powerlaw.Fit(data) xminimum = result.power_law.xmin #xmin from power law package xminimum = xminimum - 0.5 summand1 = 0 datanew = [] #alpha2 is the estimation ...
29602cd959c065b4e1bf7fb81bc4c991fb7fbc35
marcellinuselbert/Python-Course-2020
/criminal.py
854
3.65625
4
import time def rapih(dictionary): for key,value in dictionary.items(): print (f'{key} : {value}' ) john = { "Fullname" : "John Smith", "Age" : "25", "Crime" : "Stealing" } bill = { "Fullname" : "Bill Turner", "Age" : "30", "Crime" : "Drug Dealing" } rose = { "Fullnam...
cbea9a7015b18790931168722ce31112a380aa67
mkieft/Computing
/Python/Week 8/Lab 8 Q 6.py
332
3.984375
4
#Lab 8 Q 6 #Maura Kieft #10/20/2016 #6. Write a function which test divisibility (mod def main(): x=eval(input("Enter first integer: ")) y=eval(input("Enter second integer: ")) divis(x,y) def divis(a,b): if a%b==0: print(a,"is complete divisible by ",b) else: print("There is a rem...
d6d8c45347009a4bbc6a3a2301a30aa8cb21ec22
kilura69/softuni_proj
/0_admission_prep/02_conditional_statements/03_gymnastics.py
1,108
4.15625
4
# ******* 03.gymnastics (nested condtiinal statements) ************************* country = input() tool = input() difficulty = 0 performance = 0 if country == 'Russia': if tool == 'ribbon': difficulty = 9.100 performance = 9.400 elif tool == 'hoop': difficulty = 9.300 perform...
8f7331a4a15e542fbee7ae708e7bafedacaf6960
cristearadu/CodeWars--Python
/arithmetic.py
418
3.9375
4
def arithmetic(a, b, operator): return{ 'add': a+b, 'subtract': a-b, 'multiply': a*b, 'divide': a/b }[operator] print(arithmetic(10,3,'add')) def arithmetic(a,b,operator): dict_op_a_b ={ 'add': a+b, 'subtract': a-b, 'multiply': a*b, ...
7e2ad29afcbcfa78fda469b8be665b9cf7025478
Anirudh-Muthukumar/Python-Code
/string append.py
168
3.5
4
t=input() for _ in range(t): s=raw_input() p='' dollar=0 for i in s: if i not in p: dollar+=1 p+=i print dollar
1f4df1c91897663025259af6071d33e1daf5224f
VanessaVallarini/uri-online-Python-3
/2510.py
122
3.734375
4
t=int(input()) for i in range(t): nome=input() if nome!="Batman": print("Y") else: print("N")
3e96e16af9b164196a86fc7c4493e2d1a4c48e3d
Darvillien37/Forebot-Py
/Storage/XP.py
374
3.59375
4
from random import randint def getXPFromMessage(message: str): ''' Get an amount of XP based off a message string ''' # the smallest maximum amount minMax = int(len(message) / 3) if minMax < 3: minMax = 3 amount = randint(1, minMax) return amount def calculate_xp_for_next_lev...
fd8ebb441d42745a9f4514ac78ba076a10ecaf85
mpsb/practice
/codewars/python/cw-give-me-a-diamond.py
1,253
4.0625
4
''' Jamie is a programmer, and James' girlfriend. She likes diamonds, and wants a diamond string from James. Since James doesn't know how to make this happen, he needs your help. Task You need to return a string that looks like a diamond shape when printed on the screen, using asterisk (*) characters. Trailing spaces ...
6c11e1bbef0680fb6fe780f9a31b298866dedac5
muhammad-masood-ur-rehman/Skillrack
/Python Programs/username-domain-extension.py
550
3.984375
4
Username Domain Extension Username Domain Extension: Given a string S which is of the format USERNAME@DOMAIN.EXTENSION, the program must print the EXTENSION, DOMAIN, USERNAME in the reverse order. Input Format: The first line contains S. Output Format: The first line contains EXTENSION. The second line contains DOMAIN...
0e9d72e568ffe6e07f6c96bb05cbb7f60351a8a0
Dayoming/PythonStudy
/codingdojang/unit07/string_03.py
487
3.71875
4
# 문자열에 + 를 사용하면 문자열이 연결되고, * 를 사용하면 문자열이 반복됨 # 문자열1 + 문자열2 # 문자열 * 정수 hello = 'Hello, ' world = 'world!' print(hello + world) print(hello * 3) # 0 또는 음수를 곱하면 빈 문자열이 나오며 실수는 곱할 수 없다. print(hello + str(10)) # 문자열에 정수를 더하려고 하면 에러가 발생 # 이때는 str를 사용하여 숫자(정수, 실수)를 문자열로 변환하면 됨
529b79bcce69130a53c308a9b2ba0290e1931355
dangerous3/geekbrains-python-algorithms-and-data-structures
/m2-cycles-functions-recursion/task6.py
1,093
3.921875
4
''' В программе генерируется случайное целое число от 0 до 100. Пользователь должен его отгадать не более чем за 10 попыток. После каждой неудачной попытки должно сообщаться, больше или меньше введенное пользователем число, чем то, что загадано. Если за 10 попыток число не отгадано, вывести ответ. ''' import random as...
b52dbc3940779236c4850fd04db19454bc27d0c4
workwithfattyfingers/testPython
/first_project/nameletter.py
200
3.6875
4
name= input("Please enter name") i=0 tem_var = "" while i < len(name): if name[i] not in tem_var: tem_var += name[i] print(f"{name[i]} : {name.count(name[i])}") # i=i+1 i += 1
9d89f2604608df29eb0bc9c619a885433c1df8c1
palaciosdiego/pythoniseasy
/src/FunctionsAssignment.py
450
3.59375
4
# Functions def album(): name = "The Dark Side of the Moon" return name def artist(): artist = "Pink Floyd" return artist def yearReleased(): year = 1973 return year def tryBooleans(code): value = "Enter T or F" if(code == "T"): value = True elif(code == "F"): ...
6bcd645dd8a4c79003cf4dc4cda1a460f4cddda9
sanjingysw/github_sync
/python学习/高级变量/ysw_07_zifucuan.py
2,582
4.09375
4
str1 = "hello hello world!" # 只有当字符串中需要双引号""时,才用单引号''定义字符串 str2 = '我的外号是"大西瓜"!' ''' # 遍历字符串,字符串一个一个显示 print(str1[5]) for c in str2: print(c) # 获取字符串长度,获取字符串出现的次数 print(len(str2)) print(str1.count("llo")) #index 获取字符串第一次出现的位置 ,注意单引号双引号的配合使用 print(str2.index('"')) # 判断字符串中是否只包含空格或者制表符 space_str = "\n\t\r a" pri...
935ab12aaf5d9eaa843ed52189121c3ed759a985
Cadols/LearnPython
/lpthw/11-20/ex19_add2.py
381
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def func(name): print("What's your name?") print("My name is %s.\n" % name) # 1 func("Will") # 2 func("Will" + "Wang") # 3 name1 = 'Hello' func(name1) # 4 func(name1 + "Will") # 5 name2 = 'Woo' func(name1 + name2) # 6 name3 = input("Please input your name.\n> ") func(na...
deeb2e019422ff7e7f7d7b39eef6fc24e9732089
jmcguire/learning
/algorithms/sorting/bubble_sort.py
603
4.25
4
# bubble sort: # # type: transposition # best time: O(n) # average time: O(n²) # worst time: O(n²) # # look at each pair, if they're out of order then swap them # go through the entire list twice def bubble_sort(A): #print "from %d to %d" % (len(A)-1, 0) for i in xrange(len(A)-1, 0, -1): #print " from %d...
d541e2d4bda0ee5f3ed661cc0d9a0373fe9420de
Rkluk/uri
/2108 Contanto Caracters.py
345
3.9375
4
bigger = '' while True: st = input() if st == '0': break st = st.split() numlist = [] for c in st: if bigger == '' or len(c) >= len(bigger): bigger = c numlist.append(str(len(c))) r = '-'.join(numlist) print(r) print('') print('The biggest wo...
d61fae9e17f2a1b08caf1528fdf3fbfa6477017a
ibardi/PythonCourse
/session05/exercise3a.py
2,825
4.3125
4
import turtle import math tom = turtle.Turtle () print(tom) def polygon(t,length,n): for i in range(n): t.fd(length) t.lt(360/n) def invpolygon(t,length,n): for i in range(n): t.fd(length) t.rt(360/n) def circle (t,r): circumference = 2 * math.pi * r n...
447e627472285ca9ae2a6c437093a5d153486eac
saquibfortuity/python_github
/conditional.py
168
4.125
4
age = input("enter your age") age = int (age) if age > 18: print("you can vote") elif age < 18: print("you cannot vote") else: print("register yourself")
a8e79bd8a22849ec228ff39f040fc94a23733216
schleppington/HackerRank
/Maximum Perimeter Triangle/maxtriangle.py
435
3.59375
4
n = int(raw_input().strip()) arr = map(int, raw_input().strip().split()) if(n<3 or n>50): print -1 else: arr.sort() triangle = [0,0,0] for i in xrange(n): if(triangle[0]+triangle[1]>triangle[2]): print(str(triangle[0])+" "+str(triangle[1])+" "+str(triangle[2])) break ...
e62912381c050532e582e3e3a50ab1c314be6ad5
samirgadkari/Intro-Python-I
/src/03_modules.py
1,041
4
4
""" In this exercise, you'll be playing around with the sys module, which allows you to access many system specific variables and methods, and the os module, which gives you access to lower- level operating system functionality. """ import sys # See docs for the sys module: https://docs.python.org/3.7/library/sys.html...
b01934680f22ae16b3e695dfcfeb55eb8fb9c7a2
lotusstorm/stepik_courses
/kurs_1/step_4.py
698
4.25
4
import math def main(): ''' В зависимости от заданной в fig фигуры запрашивает стороны этой фигуры затем вычисляет площадь ''' fig = str(input()) if fig == "прямоугольник": print(int(input('сторона: ')) * int(input('сторона: '))) elif fig == "треугольник": a, b, c = [...
61bc9e888cf3ddd8d2545166d772cf899bb62f8d
maverick-zhang/Algorithms-Leetcode
/leetcode_day11/Q92_reverse_list2.py
1,035
3.828125
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None # 输入: 1->2->3->4->5->NULL, m = 2, n = 4 # 输出: 1->4->3->2->5->NULL # 反转从位置 m 到 n 的链表。请使用一趟扫描完成反转。 class Solution: def reverseBetween(self, head: ListNode, m: int, n: int) -> ListNode: ...
ff31fa44a164a29e91943212fdade97aa38e9b21
FRAndrade/Python
/python/listadeexercicio/EstrutrutaDeDecisao/vogal/vogal.py
134
3.75
4
letra=input("Digite a letra: ") vogais = ["a","e","i","o","u"] if(letra in vogais): print("É vogal!") else: print("É consoante!")
9a099c54f36cf12596d4265def943a64556f085a
rlebrao/10-Days-of-statistics
/quartiles.py
806
3.6875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT size = input() data = list(map(int,(input().split()))) data.sort() def getMedian(data, size): size = int(size) dataNumber = [] for i in data: dataNumber.append(int(i)) dataNumber.sort() if(size % 2 == 0): return (d...
1cddef78ca17b74166f910c78f554b74559004cd
pxblx/programacionPython
/practica01/alternativas/E10Alternativas.py
976
4.125
4
""" Ejercicio 10 de alternativas Algoritmo que pida los puntos centrales x1, y1, x2, y2 y los radios r1,r2 de dos circunferencias y las clasifique en uno de estos estados: - Exteriores. - Tangentes exteriores. - Secantes - Tangentes interiores. - Interiores. - Concentricas. """ import math # ...
cac58590f3e67f338242119cc18d97dfd13b5634
malikdamian/codewars
/6kyu/Count characters in your string.py
311
4.28125
4
""" The main idea is to count all the occurring characters in a string. If you have a string like aba, then the result should be {'a': 2, 'b': 1}. What if the string is empty? Then the result should be empty object literal, {}. """ def count(string): return {char: string.count(char) for char in string}
f306d4a266b79909d285c7c0ffc722c9634b335b
Artekaren/Trainee-Python
/D14_genera_patron.py
466
3.8125
4
#Desafío14: Generar patrón #Debe crear un programa que logre replicar el siguiente patrón, donde el usuario ingrese un número, y ese número corresponderá al número de filas que se debe generar. La soluciṕon debe estar dentro delprograma llamado genera_patron.py . #1 #12 #123 #1234 #12345 num = int(input("Ingrese núme...
73c7371de9d4017beb5a10e2e087ec65bc8bd765
saikiranrede/Coding-challenges
/password_checker.py
313
3.859375
4
correct_password = "python123" name = input("Enter your name: ") surname = input("Enter your surname: ") password = input("Enter your password: ") while correct_password != password: password = input("Wrong passwrod!!, Enter again: ") message = "Hi %s %s, you're logged in" % (name, surname) print(message)
4140dfb0b29b264b5ca20c7f8b621ec71db6cd38
vinniechandak/python-basics
/dictionaries.py
839
4.40625
4
# This is about dictionary data structure in python. d = {'a': 'b', 'c': 'd', 'e': 'f'}; print("Print Dictionary ==> " , d); d['Vinod'] = 'Chandak'; # appending element to dictionary print("Print Amended Dictionary ==> " , d); d['a'] = 'Modified key a'; # value overriding. print("Print Value Overridden Dictionary =...
3ed1150049f7e7a4d52d8a4f090210a41ba2a277
avanish981/python
/graphs/breadth_first_search.py
830
4.03125
4
# Breadth First Search from collections import defaultdict class Graph: def __init__(self): self.graph = defaultdict(list) def add_edges(self,_from,_to): for t in _to: self.graph[_from].append(t) def display(self): print self.graph def bfs(self,graph,start): ...
f60c174f523f0724ac9adf42472f097bc3a04240
neM0s/books
/for_and_back.py
263
3.8125
4
# Type your code here def pattern_sum(a, b): sum = 0 for i in range(1, b+1): sum = sum + (a ** i) return sum print(pattern_sum(5,3)) a = 1 b = 3 stringunio = str(a) for i in range(b): stringunio = stringunio + stringunio(a) print str
2ce770f2b33dae55a2f633670db9eca305f91066
coley-dot-jpg/CS177.BoilerGoldRush
/project3 w music and score. WIP.py
26,394
4
4
# # CS 177 - project3.py # Devin Ersoy, 00305545351 Juliana Peckenpaugh, 0030606114, Emelie Coleman, 0031104038 # Following Coding Standards and Guidelines # This program creates a control window and a game window. The control window is used to get a payer's # name, start a game, or exit a game. The program has a gam...
a906bbc1f0ba8b914af5bdd18781acfe319fc64b
Cyclone96/Bootcamp
/Guessthenumber.py
1,494
4.0625
4
import random number = random.randint(1, 10) player_name = input("State your name: ") number_of_guesses = 0 print('Hola '+ player_name+ ' Guess any number between 1 to 10:') print() def game(): number = random.randint(1, 10) print("You got five guesses to make starting now....!") i = 1 r =...
3df395d1649f498f66b47fdee9cff2e50e2158b9
Jackyzzk/Algorithms
/搜索-DFS-03-0547. 朋友圈-并查集.py
2,488
3.578125
4
class UnionFindSet(object): def __init__(self, n): self.parent = [i for i in range(n)] self.depth = [0] * n self.count = n def find(self, x): if self.parent[x] != x: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def union(self, a, b): ...
b0068da9c5509cce9f44b7ab16015327c6585c12
rusheelkurapati30/Python
/oxfordDictionary.py
1,620
3.515625
4
# Program on oxford dictionary to print the meaning of the given word. import requests app_id = "cd9f1a0d" app_key = "1f766ec01c258b21809ed532ff88579f" language = "en-gb" word_id = input("\nPlease enter a word: ") url = "https://od-api.oxforddictionaries.com:443/api/v2/entries/" + language + "/" + word_id.lower...
c131c5141baf172e34d220ab98ed9e78cf9384b7
Aasthaengg/IBMdataset
/Python_codes/p03573/s049454534.py
137
3.625
4
args = input().split() a = int(args[0]) b = int(args[1]) c = int(args[2]) if a == b: print(c) elif a == c: print(b) else: print(a)
464ef743d367211f28dd54f311c3f360ad32a737
songyingxin/python-algorithm
/排序算法/select_sort.py
921
4.0625
4
# -*- coding:utf-8 -*- import util def find_smallest(arr, left, right): smallest = arr[left] smallest_index = left for i in range(left, right + 1): if arr[i] < arr[smallest_index]: smallest = arr[i] smallest_index = i return smallest_index def selection_sort(arr): ...
dde6e505ef16327ef1738fe759999c99dc8a1fab
LiHuaigu/Tomasulo_Simulatior
/mem.py
552
3.578125
4
from tabulate import tabulate class mem(object): def __init__(self, name, value): self.name = name self.value = value class Memory(object): def __init__(self, size, values): self.memoryList = [] self.size = size for i in range(size): mem = mem("R"+str(i), va...
2c1b3fd327c5b326fd66ba5eb8dc5657f3865913
ChocolatePadmanaban/Learning_python
/Day7/part_11.py
401
3.890625
4
# milti dimenstional element finding(find the location of first occurance) A= [[1,2],[2,[5,6]],3] def Extract(a, e): for i in a: b = [a.index(i)] if i == e: print(i) break elif type(i) == list and Extract(i,e) != None: c = Extract(i,e) b = b ...
47944a85911ec15b8d430ab832320dafed06de48
CiyoMa/leetcode
/searchForARange.py
1,100
3.515625
4
class Solution: # @param A, a list of integers # @param target, an integer to be searched # @return a list of length 2, [index1, index2] def searchRange(self, A, target): low = 0 high = len(A) - 1 # find lower bound, first target lowerBound = -1 while low <= high...
f1076cefdf169812644489c76ffd38daddd3e3b7
cgarrido2412/PythonPublic
/Learning Tutorials/Automate The Boring Stuff/sending_email.py
997
3.53125
4
import smtplib import datetime #Connecting to outlook smtp server and establishing tls session smtpObj = smtplib.SMTP('smtp-mail.outlook.com', 587) smtpObj.ehlo() smtpObj.starttls() #login and authentication email = str(input('Please enter your e-mail:')) password = str(input('Please enter your password:')) smtpObj.l...
a10dc0c1c050f14f5b4c76bcead2f2805d2bbfcd
indo-seattle/python
/rakesh/Exercise2.py
154
4.09375
4
print("Exercise 2 - String Concatenation") fName = str(input()) lName = str(input()) fullname = fName + " " + lName print("The full name is " + fullname)
a23e15ae8dbf80097241b05617fd065e6fdd3a6b
lion7500000/python-selenium-automation
/Python program/longest_words.py
456
4.21875
4
str = input ('Input text:') # converting string to list list_str = str.split() # index max word = 0 max_word = 0 # for i in range(1,len(list_str)): # if len(list_str[max_word])<len(list_str[i]): # max_word = i # # print (list_str[max_word]) #alternative def max (str): max = 0 for i in str.split(' ...
79e7f531f1e83f7ec118c6acd9d28c19355bb3b3
angadsinghsandhu/tensortorch
/Examples/regression_eg.py
942
3.734375
4
from Framework.RegressionFramework import NeuralNetwork from Framework.predict import predict_regression as predict from Framework.normalize import normalize from Data_Creation import regression_data def run(): # getting data x_train, y_train = regression_data.data(values=1000) # normalizing data # x...
d2bab5b3e5e8443923a0a7967243c40766f3763d
noahsug/connect4ann
/data_generation/heuristic.py
1,057
3.59375
4
import board class Heuristic: def setState(self, state): self.state = state def getMove(self): pass ## # Report the result of a game, or that it is unfinished. # @param {GameState} state # @return {int} The game result: # 2 for unfinished game, # 1 for first player victory, # -...
472614957563d51493fbf6a12a47a267906f2c00
nkhanhng/namkhanh-fundamental-c4e15
/session2/sum-n.py
209
3.796875
4
x = int(input("Enter a number: ")) total = 0 #squence = range(n+1) #result = sum(squence) for i in range(x + 1): total += i print(total) #c2
fcf4ede757ff0851657472ae0a4f1848e7274043
jbhennes/CSCI-220-Programming-1
/Chapter 13 - Algorithms/Student.py
2,260
3.921875
4
# Student.py # Author: RoxAnn H. Stalvey # Student class # Student's data members: id number, firstName, lastName, # list of grades, date of enrollment from Date import Date class Student: def __init__(self, stuNum, firstName, lastName, grades, date): self.studentNumb...
3f9041d3d1c2b9444d5929b395c869d754232ac7
klistwan/project_euler
/108.py
619
3.640625
4
from time import time print "#108 - Diophantine Equation: What is the least value of n for which\n\ the number of distinct solutions exceeds one-thousand?\n" start = time() result = 0 def main(e): n = 30 while True: c = 0 for x in xrange(n+1,n*2+1): y = float(-n*x)/(n-x) ...
0a27a09c20487c9ba37cc36439a347776823a56d
nanfeng729/code-for-test
/python/python_course/pythonStudyDay3/whilelianxi.py
541
3.96875
4
# 导入random模块 # 使用random模块下的randrange()函数随机生成一个数字 # n = random.randrange(0, 100) # 从键盘输入数字猜n的值,如果猜大了给出猜大了的提升,如果猜小了给出猜小了的提升 # 猜错了一直猜下去,猜对了结束程序 import random from random import randrange n = randrange(0, 100) m = int(input("猜:")) while m != n: if m>n: print("猜大了") else: print("猜小了"...
c58316c7acba0d93a5628cc8e0c70101e36c462b
afrid18/Data_structures_and_algorithms_in_python
/chapter_4/exercise/C_4_14.py
851
3.515625
4
# IntheTowersofHanoipuzzle,wearegivenaplatformwiththreepegs,a, b, and c, sticking out of it. On peg a is a stack of n disks, each larger than the next, so that the smallest is on the top and the largest is on the bottom. The puzzle is to move all the disks from peg a to peg c, moving one disk at a time, so that we neve...
80f095435fbb7c1575644a5bd9663c1a8473136f
NishantNair14/complex--number-calculator
/code.py
1,699
3.515625
4
# -------------- import pandas as pd import numpy as np import math #Code starts here class complex_numbers: def __init__(self,real,imag): self.real=real self.imag=imag #return(self.real,'+' if self.imag>=0 else '-', abs(self.imag)) print(self.real,'+',self.imag,'i') ...
2b8ea0ec1523bc137fc4c35d365cacf4358991b9
wecchi/univesp_com110
/Sem2-Texto21.py
1,308
4.1875
4
''' Texto de apoio - Python3 – Conceitos e aplicações – uma abordagem didática (Ler: seções 2.3, 2.4 e 4.1) | Sérgio Luiz Banin Problema Prático 2.1 Escreva expressões algébricas Python correspondentes aos seguintes comandos: (a)A soma dos 5 primeiros inteiros positivos. (b)A idade média de Sara (idade 23), Mark...
6100a7aceb52152b245f8889db0dcf2f4e074eb4
M45t3rJ4ck/Py-Code
/HD - Intro/Task 17/Homework/alternative.py
516
4.34375
4
# Create a program called “alternative.py” that reads in a sting and makes # each alternate character an Uppercase character and each other alternate # character a lowercase character. # Collecting user input U_string = input("Please enter your sentence to convert: \n").lower() U_string = list(U_string) while len(U_s...
e24147247fc053f8a7b844f840adbeb6c81fa259
chydream/python
/base/obj7.py
2,302
3.609375
4
# 1.异常处理 异常类 Exception def test_divide(): try: 5/0 except: print("报错了,除数不能为0") def test_div(num1,num2): return num1 / num2 # 2.自定义异常 class ApiException(Exception): err_code = '' err_msg = '' def __init__(self, err_code = None,err_msg = None): self.err_code = self.err_co...
6797066f06fa4e56aa0741334551e044c5da157d
Naz2020/python
/phone_number.py
1,893
3.96875
4
''' Anas Albedaiwi albedaiwi1994@gmail.com ''' def _check_first_format(phone_number): if len(phone_number) < 14: return False if phone_number[0] == '(' and phone_number[4] == ')' and phone_number[5] == ' ' and phone_number[9] == '-': digits= [1, 2, 3, 6, 7, 8, 10, 11, 12, 13] for d in d...
4ca0559dc1ae075a6e2b8c6ada8647ee2ca79794
saurabhpiyush1187/python_project
/pythonProject/common_factors2.py
1,142
4
4
# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. from math import sqrt # Write your code here # Function to calculate gcd of two numbers def gcd(a, b): ...
c72203bcb69712eca8a6ad97a7485da81c09d042
AFatWolf/cs_exercise
/2.3- Let start python/assignment4.py
175
3.828125
4
total_legs = int(input("total legs:")); num_turtles = int(input("number of turtles:")) num_cranes = (total_legs - num_turtles*4)//2 print("number of cranes are:", num_cranes)
1b8afdc67d9b4fd21e143e7bb17db3b4da7e7954
disatapp/Operating-Systems
/Operating Systems/Homework2/Problem3.py
1,035
3.734375
4
# Pavin Disatapundhu # disatapp@onid.oregonstate.edu # CS344-400 # homework#2 Question3 import os import sys import urllib2 import urlparse def main(argv): win = '' wout = '' infolder = os.environ['HOME']+"/Downloads" if len(argv) == 3: win = argv[1] wout = argv[2] if not os.path.i...
e4b892a58f40e89206477d0c220daecb02046440
knparikh/IK
/LinkedLists/longest_balanced_parenthese_string/longest_parenthese_string.py
1,283
4
4
#!/bin/python3 # Given a string with brackets (, ), find longest substring which is balanced. import sys import os # Use a stack to record positions of open bracket. When ) bracket is encountered, pop last char (mostly a ''(''). # If stack is not empty, record length of current string as curr index - index before popp...
2002bf7e49fbe8c7bf4ecce82d8993913d44e541
AshishOhri/machine_learning_course_python
/simple_linear_regression/simple_linear_regression.py
1,186
4.40625
4
''' This notebook is a simple implementation of linear regression from scratch in python. ''' # Equation y=theta(0)*x0+theta(1)*x1 # We are trying to get the values of theta which is where the learning in machine learning takes place. import numpy as np def hyp_fn(theta,X): # hypothesis function return theta.T@X ...
adef42fb162acdfcb4b6e1703a6256afa7e6be35
Ojitos369/sumaVectores-MulpiplicacionComplejos
/src/vectores.py
1,146
3.65625
4
#----------- IMPORTACIONES ---------- from src.extras import limpiar import src.menus as menus import matplotlib.pyplot as plt #----------- FUNCIONES ---------- def suma(v1,v2): vr = [0,0] vr[0] = v1[0]+v2[0] vr[1] = v1[1]+v2[1] return vr def main(): vector1 = menus.vectores('primer') vecto...
081532556a5e23e852475e7a0d064d671b32c3a4
tlyons9/draftcompanion
/tap_beer.py
2,982
3.515625
4
import requests import csv import pandas # starting off, we need to get the beer sheet from the internet # given the league settings, get the correct beer sheet. kickers = ['Greg Zuerlein', 'Justin Tucker', 'Harrison Butker', 'Stephen Gostokowski', 'Wil Lutz', "Ka'imi Fairbairn", 'Mason Crosby', 'Jake Ellio...
f8f10d0a0a538ff53c5afc9338b507063738e153
fionnmccarthy/pands-problem-sheet
/secondstring.py
904
4.1875
4
# secondstring.py # Weekly Task 03. # This program asks a user to input a string and outputs every second letter in reverse order. # author: Fionn McCarthy - G00301126. # The input function is used below in order to get the user to enter a sentence. input_string = input('Please enter a sentence:') # From research I ...
fb97a2b7ecc888f642eb51ff5f288f681da56c7a
aiswaryasaravanan/practice
/hackerrank/12-30-gameOfStack_half.py
477
3.609375
4
def popValue(a,b): if len(a)>0 and len(b)>0: return a.pop() if a[len(a)-1] < b[len(b)-1] else b.pop() elif len(a)==0 and len(b)>0: return b.pop() else : return a.pop() def twoStacks(x, a, b): a.reverse() b.reverse() count=0 poppedValue=popValue(a,b) while x-popp...
62be46a0eba7962abb218ae7ddfa73af768b272a
ChenWenHuanGoGo/tulingxueyuan
/练习/random模块.py
658
4.0625
4
import random # random.random()获取0-1之间的随机小数,[0,1) for i in range(10): print(random.random()) # random.randint(x,y),返回[x,y]之间的随机整数 print(random.randint(1,10)) # random.randrange(start, stop[, step=1]),取[x,y),步进默认为1,可修改,整数 print(random.randrange(1,10,step=5)) # random.choice() 随机获取序列中的值,一定是一个序列 print(random.choic...
cfb5d02fa68ec617a2260e31e739d888135212ad
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_1_neat/16_0_1_MisterStabbeh_problem_A.py
407
3.5
4
def solution(starting_num): if starting_num == 0: return "INSOMNIA" counting_set = set() i = 1 while len(counting_set) < 10: result = str(i * starting_num) counting_set.update(set(result)) i += 1 return result num_of_test_cases = int(input()) for i in range(1, num_of_test_cases + 1)...
3bcc6da0be94b3a346e1a4727fcde54836c8e925
blacklc/Practice-for-python
/src/Test/logicTest.py
671
3.984375
4
#!/usr/bin/env python #coding:utf-8 ''' Created on 2016年5月11日 @author: lichen ''' #逻辑判断 arr1=['name1','name2',1] i=10 #在录入数字的时候使用input,在录入字符串的时候使用raw_input #n=input('please enter a number:') #或者使用强制类型转换 n=int(raw_input('please enter a number:')) if n >= i: print "the number >10" elif n==6: print "the number=6...
10bd457622b1560038f9214e95e270cc9722e2a3
ananyaarv/Python-Projects
/DrinkBasedonNumber/main.py
438
3.921875
4
# Name: Ananya Arvind # Date: 3/10/2021 # Period: 8 # Activity: Lab 2.04 Part 1 prize=['A Pepsi', 'A Root Beer', 'A Mountain Dew', 'A Sierra Mist', 'A Water Bottle', 'A Coca-Cola', 'A Doctor Pepper', 'A Lemonade', 'A Sunny D', 'A Fanta'] userinput=input("Pick a number from 1 to 10:") userinput= int(userinput) if(user...
d703bf16375648a8835448edb8591e9f1ac59ed8
daniel-reich/ubiquitous-fiesta
/yfTyMb3SSumPQeuhm_12.py
451
3.828125
4
memo = {1: 1, 2: 1} ​ def matrix_mult(A, B): C = [[0 for row in range(len(A))] for col in range(len(B[0]))] for i in range(len(A)): for j in range(len(B[0])): for k in range(len(B)): C[i][j] += A[i][k]*B[k][j] return C ​ A = [[1, 1], [1, 0]] A = matrix_mult(A, A) n = 2 w...
9079bab375f92982900cdc7fab976c4bae565a68
juneadkhan/InterviewPractice
/singleNumber.py
566
3.90625
4
""" Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. Input: nums = [4,1,2,1,2] Output: 4 """ def singleNumber(nums): counts = Counter(nums) # Counts a...
2668991cb4092afbe5b687314f4ab9ee9408b42b
joeyoun9/Muto
/muto/accessories/__init__.py
545
3.546875
4
''' This will hold useful side functions and methods ''' import time, calendar def s2t(str, fmt): ''' Use functions to grab an epoch time from a string formatted by fmt. Formatstrings can be identified in the strtotime module/guide str = time string fmt = format string ''' return ...
78dfc7706f6c0465efafcf7f8ed121499bd4e5ee
a5192179/readStockAccountBill
/computeProfit/testClass.py
971
3.90625
4
class ClassA: member_A = 0 list_A = [] def __init__(self): self.selfmember_A = 1 self.selflist_A = [] self.selflist_A.append(1) def add(self, num): self.selfmember_A = num self.selflist_A.append(num) A1 = ClassA() print('-------A1 ori-------') print(A1.member_A) ...
42d17f73bf5f810c82ff5d69ee84f9b2b8306c9a
kevalrathod/Python-Learning-Practice
/OOP/polymorphism.py
227
3.84375
4
#overidding Polymorphism class ABC: def Speak(self): print("afakfh") class XYZ: def Speak(self): print("gaduia") def typesOfSpeak(spktyp): spktyp.Speak() obj1 = ABC() obj2 = XYZ() typesOfSpeak(obj1) typesOfSpeak(obj2)
2458582079217f0f22100e393be606f1f51b7150
samutrujillo/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/square.py
1,382
3.890625
4
#!/usr/bin/python3 """ class Square """ from .rectangle import Rectangle class Square(Rectangle): """docstring for .""" def __init__(self, size, x=0, y=0, id=None): """ class constructor""" super().__init__(size, size, x, y, id) def __str__(self): """Defines print attribute """ ...
288ec9d83e5e7854248227151cac9af41d635724
berubejd/SQLite3-Helper
/sqlite3_helper.py
2,058
3.703125
4
#!/usr/bin/env python3.8 import sqlite3 from collections import namedtuple from contextlib import contextmanager def namedtuple_factory(cursor, row): """ Usage: con.row_factory = namedtuple_factory Source: http://peter-hoffmann.com/2010/python-sqlite-namedtuple-factory.html """ fields = ...
7cac2c46c6a3c3425c371dce46388fc134a844ca
rmuzyka/pyhon
/pluralsight-python-standard-library.py
660
3.625
4
from collections import Counter from collections import defaultdict from collections import namedtuple from app c = Counter() c['bananas'] += 2 c['apples'] += 1 c['apples'] += 3 c['bananas'] -= 1 print c.most_common() print c['lemons'] class Fraction(object): def __init__(self): self.n = 1 se...
4d3823fab86c4a20f4143ba4d96760a51088dd4e
barnamensch056/DS_Algo_CP
/Python for CP & DS Algo/size_of_tree.py
1,178
3.671875
4
class Node: def __init__(self,info): self.right=None self.info=info self.left=None class BinaryTree: def __init__(self): self.root=None def create(self,val): if self.root==None: self.root=Node(val) else: current=self.root w...
c792c81e6357bdfcae75b075c7595d69c09096af
zmh19941223/heimatest2021
/04、 python编程/day04/3-code/17-列表和元组的转化.py
183
3.84375
4
list1 = [1,2, 4, 2] tuple1 = tuple(list1) # 把list1转化为元组类型 print(tuple1) tuple2 = (3, 6, 12, 100) list2 = list(tuple2) # 把元组tuple2转化为列表 print(list2)
20e5c691d8a999a1066a083e5418a7b4cdf92748
sppliyong/day01
/day03/zuoye6.py
363
3.703125
4
import math if __name__ == '__main__': str1=input("请输入一个数:") a=int(str1) mlist=[] while True: b=a%2 mlist.append(b) a=a//2 if a==0: break print(mlist) mlist.reverse() print(mlist) bb="" for i in mlist: bb+=str(i) print("这个数的二进制...
25475bbccc69ea6ed2d42cd138a9446c81712a56
nikhilmborkar/fsdse-python-assignment-3
/letter_digit.py
196
3.515625
4
def letterAndDigit(s1): d = {"DIGITS":0, "LETTERS":0} for i in s1: if i.isalpha(): d['LETTERS'] +=1 elif i.isdigit(): d['DIGITS'] +=1 return d
1e5c622d7598a03464b70f3ec0b7773a4353a753
klaus2015/py_base
/code/day05/r7.py
429
4
4
""" 在列表中[54, 25, 12, 42, 35, 17],选出最小值(不使用min) """ list01 = [54, 25, 12, 42, 35, 17] # 假设第一个值为最小值 min_value = list01[0] # for item in list01: # if min_value > item: # 如果item小于最小值,将item赋值给min_value # min_value = item # print(min_value) for i in range(1,len(list01)): if min_value > list01[i]: ...
21242c868dcaf41a84467d957bc433000caa3d2e
blaz-k/lesson
/vaja/main1.py
188
3.9375
4
#secret number secret = 26 guess = int(input("Guess my number: ")) if guess == secret: print("Congratulations, you guessed it!") else: print("it is not correct. lets go again!")
1672ca44a3e5aaab504163dc494cc71bcbc53123
rmcclorey1125/Python-practice
/LCalc.py
734
3.984375
4
print("Welcome to the Love Calculator!") name1 = input("What is your name? \n") name2 = input("What is their name? \n") names = name1 + name2 lower_case_names = names.lower() t = lower_case_names.count("t") r = lower_case_names.count("r") u = lower_case_names.count("u") e = lower_case_names.count("e") true = t + r + ...
b7e2eb687f865d2b5251d172ea77f76c241b2eb8
zsbati/PycharmProjects
/Key Terms Extraction/Topics/Math functions/Octahedron/main.py
170
3.875
4
import math edge = int(input()) area = round(2 * math.sqrt(3.0) * math.pow(edge, 2), 2) volume = round(math.sqrt(2.0) * math.pow(edge, 3) / 3, 2) print(area, volume)
a81fd8e5397ea5d9361ddc55675d93a58e8828e5
Fernandoleano/Rock-Paper-Scissors
/code/python/Rock_Paper_Scissors.py
1,830
3.96875
4
''' My TODO LIST: This sucks but hey I made it at least am pro coder 😎 when I was stuck I used this website: https://thehelloworldprogram.com/python/python-game-rock-paper-scissors/ Rock Paper Scissors with bot 1. I need random with the bot with a choice or randint (randint is easier to use) 2. many functions for bot ...
f7fdf2b87245100ac416b5ba5fc54783456adbc7
pedroth/python_experiments
/Test/ExpExperiment.py
1,991
3.53125
4
import math import matplotlib.pyplot as plt def powInt(x, n): if n == 0: return 1 elif n == 1: return x else: q = math.floor(n / 2) r = n % 2 if r == 0: return powInt(x * x, q) else: return x * powInt(x * x, q) def expEuler(x, n): ...
c95dd53b471aaca77d3ba32f95607f5e8a6877f4
yannsantos1993/Exercicios-Python
/Modulo_1/Lista UFMG/33.py
516
4.0625
4
'''33 - Escreva um algoritmo em PORTUGOL que calcule o resto da divisão de A por B (número inteiros e positivos), ou seja, A mod B, através de subtrações sucessivas. Esses dois valores são passados pelo usuário através do teclado. ''' contador = 0 soma_a = 0 soma_b = 0 a = int(input("Digite um número:")) for contador...
2470f13bf9b0455e1f52301fc0b8f1f70b0e9894
paul0920/leetcode
/question_leetcode/442_2.py
492
3.71875
4
# nums = [4, 3, 2, 7, 8, 2, 3, 1] nums = [4, 4, 2, 3] for i in range(len(nums)): while i != nums[i] - 1 and nums[i] != nums[nums[i] - 1]: nums[nums[i] - 1], nums[i] = nums[i], nums[nums[i] - 1] # !!! The following order is incorrect because the 2nd element, # nums[nums[i] - 1], uses the...