blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6a8192187c62ab05b04cca015c7791217202ac65
ishauchuk/crash_course
/10.4.py
210
3.78125
4
filename = 'guest_book.txt' while True: name = input('Introduce yourself:\n') if name: with open(filename, 'a') as file_object: file_object.write(f"Your name is {name}. I added you.\n") else: break
de0d16cf9325655966a55ecec3e658c9e9d27a5f
ofk16fsm/DVG304
/Assignment_1/Assignment_simple.py
341
3.78125
4
import csv f = open(r'USCounties.csv','r') reader = csv.reader(f) #creating the reader object headers = next(reader) #getting the list of headers print (headers) r = list(reader) uniq = [] for row in r: STATE_NAME = row[1] if STATE_NAME not in uniq: uniq.append(STATE_NAME) for i in uniq: print(i)...
122c36b72655ab048c2e6ab7bd1772f27a59c5c9
LiuKaiqiang94/PyStudyExample
/python_program/inputdialog.py
1,219
3.796875
4
#输入框 from graphics import * from button import Button class InputDialog: def __init__(self,angle,vel,height): self.win=win=GraphWin("Initial Values",200,300) win.setCoords(0,4.5,4,.5) Text(Point(1,1),"Angle").draw(win) self.angle=Entry(Point(3,1),5).draw(win) self...
1f0314c2810d669dd2a66679680273c6eb49a02a
renukadeshmukh/Leetcode_Solutions
/122_BestTimetoBuyandSellStockII.py
1,659
4.28125
4
''' 122. Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times). Note: You may not enga...
bc3a8eda1fbf3060cd35dda88d4d60eca5915010
ajmainankon/OOP
/task6.py
2,348
3.59375
4
class Bank: def __init__(self, code, address): self.code = code self.address = address def manages(self): return (f'Manages Bnak with ID {code} at {address}') def mantains(self, booth=None): if booth != None: return (f'mantains ATM at {booth.location}'...
3e4b61ba79e9da36c85cf084ad9bbdfb54698fb1
mdwcrft/python-scripts
/multiprocessing.py
423
3.71875
4
''' Chad Meadowcroft Credit to Sentdex (https://pythonprogramming.net/) ''' import multiprocessing def spawn(num): print('Spawned! {}'.format(num)) if __name__ == '__main__': for i in range(5): # .process spawns a process object, works similar to threading.thread p = multiprocessing.Process(t...
cdfa39192080ded154e8293f2c8cfb6799dcc5e6
frankieliu/problems
/leetcode/python/617/sol.py
898
4.125
4
Short Recursive Solution w/ Python & C++ https://leetcode.com/problems/merge-two-binary-trees/discuss/104301 * Lang: python3 * Author: zqfan * Votes: 32 python solution ``` class Solution(object): def mergeTrees(self, t1, t2): if t1 and t2: root = TreeNode(t1.val + t2.val) ...
b51c44618813b1d9c2033d4df445ecd5691f57b7
i-am-Shuvro/Project-GS-4354-
/Main File.py
8,972
3.96875
4
def greet(str): name1 = input("[N.B: Enter your name to start the program.] \n\t* First Name: ") name2 = input("\t* Last Name: ") return "Hello, " + str(name1) + " " + str(name2) + "! Welcome to this program, sir!" print(greet(str)) print("This program helps you with some information on tax-rate on...
0b4c5b32e2bafb7df915028484ca6965ce073309
ggerod/Code
/PY/gcjCryptopangrams.py
2,774
3.53125
4
#!/usr/local/bin/python3 import sys numcases = int(sys.stdin.readline()) alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ" def euc_gcd(a,b): while (b!=0): t=a a=b b=t%b return(a) def findfirstnonrepeat(): for i in range(1,len(cryptedpangram)): if (cryptedpangram[i] != cryptedpangram...
8bf208f66541668c8d46cb705591b5c9be2e8444
tmsteen/training
/python-IV/lab_flask.py
1,495
4.03125
4
#!/usr/bin/env python3 # *-* coding:utf-8 *-* """ :mod:`lab_flask` -- serving up REST ========================================= LAB_FLASK Learning Objective: Learn to serve RESTful APIs using the Flask library :: a. Using Flask create a simple server that serves the following string for the root route ('/'): "<h...
8eee5224dc63e7b790bcce7fc713371f78c43367
apatti/csconcepts
/sorting/mergesort/python/mergeSort.py
628
3.875
4
def Sort(input : list)->list: if len(input)<=1: return input midPoint = len(input)//2 left = Sort(input[:midPoint]) right = Sort(input[midPoint:]) return merge(left,right) def merge(left:list,right:list)->list: merged = [] i=0 j=0 while i<len(left) and j<len(right): ...
c2b3310565093c3e780d2dc69d7f407e4be5ea81
AAlkaid/Learn_PyTorch
/nn.ReLu.py
468
3.53125
4
import torch from torch import nn from torch.nn import ReLU input = torch.tensor([[1, -0.5], [-1, 3]]) input = torch.reshape(input, (-1, 1, 2, 2)) print(input.shape) class zhenyu(nn.Module): def __init__(self): super(zhenyu, self).__init__() self.relu1 = ReLU() def for...
8d537b8649cf865382e1dd87a841634851d541e2
huazhige/EART119_Lab
/hw1/late/passerscarlet_26789_1245979_HW 1 #3 .py
1,607
4.3125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- #anaconda2/python2.7 #HW 1 #3 """ HW 1 problem 3 This script does the following: Given a circle with a radius r = 12.6mm, and a rectangle with sides 'a' and 'b' with only 'a' known from the outset (a = 1.5mm). This program uses a while loop to find the lar...
03e70e46652539d6a72d9b6f601128fbeb0473b9
enw860/leetcode
/code37.py
5,572
4.0625
4
# 37. Sudoku Solver # https://leetcode.com/problems/sudoku-solver/ # Write a program to solve a Sudoku puzzle by filling the empty cells. # to be validated according to the following rules: # Each row must contain the digits 1-9 without repetition. # Each column must contain the digits 1-9 without repetition. # Each ...
1448a1712fae70329d1df40488dffe22afd2e7d6
bryner18/secretnumber
/secretnumber.py
1,433
3.984375
4
import random import sys def main(): guess_the_number() try_again() def guess_the_number(): number = (random.randint(0, 100)) tries = 0 print("---------------------------------------------\nYou need to guess a number between 0 and " "100\n----------------------------------...
91be9b35a880c90150ae4bbbbd48454cfefce3b2
Makhanya/PythonMasterClass
/Decorators/Decorator.py
633
4.1875
4
""" Decorator *Decorators are functions *Decorators wrap other functions and enhance their behavior *Decorators are examples of higher order functions *Decorators have their own syntax, using "@" (syntactic sugar) """ def be_polite(fn): def wrapper(): print("What a pleasu...
0e2a69a0896adea308ffb622f5205f0c1d3ee0ff
holonking/ts-findSecurities
/loop.py
172
3.578125
4
import datetime today=datetime.date.today() for j in range (10): if j==2: continue delta=datetime.timedelta(days=j) xday=today-delta print(str(j)+ " - "+ str(xday) )
4d4ce89fc733be4fd022bcc522184c708e462019
andrewsmedina/projecteuler
/python/1.py
269
4.21875
4
''' Problem 1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. ''' print sum(filter(lambda x: x%3==0 or x%5==0, range(1,1000)))
30dc148e683f67eec7ece23fe74f6c4cf6ccfcdb
xingzhicn/MyLeetCode
/easy/1. 两数之和.py
1,709
4.0625
4
class Solution: """ 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 For Examples: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] """ def twoSum(self, nums: list, target: int) -> list: ...
9539d81ff866aae9ccc9ebc51561e53d55f7524c
SubhamPanigrahi/Python_Programming
/copying_from_list.py
226
4
4
# there is a predefined list and a tuple, return the common elements in form of list x = ["1", "2", "abc", "def", "ghi", "4", "5"] y = ("abc", "2", "5", "def", 3) z = [] for i in y: if i in x: z.append(i) print(z)
5d83365afa1d15c306c4be3985bb0b26a6a6ff50
diskpart123/xianmingyu
/python程序语言设计/E4.18/E4.18.py
458
4.0625
4
rate = eval(input("Enter the exchange rate from dollars to RMB: ")) convert = eval(input("Enter 0 to convert dollars to RMB and 1 vice versa: ")) if convert == 0: dollars = eval(input("Enter the dollars amount: ")) amount = dollars * rate print("$",dollars,"is",amount,"yuan.") elif convert == 1: rmb =e...
f197bbe8138cee951622ae7ea3e02c76248e18ae
Streetplayr1/STEM-Prep-Exercises
/Allen_Trey_STEM_Project_3.py
3,758
3.5625
4
#author: Trey Allen #STEM Prep Project, Exercises 3 ## START OF 3-1 ## #the good ol' reliable import random #we will initialize variables, as per usual for keeping track of numbers #first, our list(s), noting that activity (1) does not change #we will need a list to keep track of the state, and a list of l...
e8fdf28ca8c48fad222d006331494595961296a7
nefelinikiforou/compilers1718a1
/scanner.py
2,391
3.65625
4
def getchar(words,pos,state): # added state """ returns char at pos of words, or None if out of bounds """ if pos<0 or pos>=len(words): return None c = words[pos] if (c == '0' or c == '1') and state == 'q0' : return 'HOUR_01' if c == '2' and state == 'q0': return 'HOUR_2' if (c >= '3' and c <= '9') and st...
8a1e97db689c383b7299423085a6f01f4d48b7e7
premkrish/Python
/Functions/func_default_args.py
532
4.375
4
""" this script contains functions with default arguments """ def cm_convert(feet=0, inches=0): """ This function converts feet and inches to cms """ feet_to_cm = feet * 12 * 2.54 inch_to_cm = inches * 2.54 return feet_to_cm + inch_to_cm # Convert 5 feet to cm print(f"Convert 5 feet to cm(s): {cm_conv...
1111fb35c383062b2376200d8f4f7530da8b8bea
Gporfs/Python-s-projects
/dictdados.py
510
3.515625
4
from random import randint from time import sleep from operator import itemgetter ranking = {} jogador = {} for num in range(1, 5): jogador[f'jogador{num}'] = randint(1, 6) print('Valores Sorteados:') for k, v in jogador.items(): sleep(1) print(f'O {k} tirou o número {v}') print('-='*30) print('...
217181bd0b40fab7589d2e576c4f6a87fbb59f94
suruisunstat/leetcode_practice
/amazon/python/110. Balanced Binary Tree.py
1,974
4.03125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): # def getHeight(self, root): # if not root: # return -1 # return 1 + max(self.get...
fde7098fbcbc018a35b7063afe7dbfde4f0ef460
andoorve/Neural-Net
/layer.py
1,195
3.515625
4
#Learned from "Neural Networks and Deep Learning" - http://neuralnetworksanddeeplearning.com by Michael Nielson #See Neural-Net-2 for improved version import numpy as np #www.numpy.org import node class layer: def __init__(self, in_num, n_nodes, func): self.input = in_num self.func = func ...
69c9cf873f915fec0f4711722f9101f38f21a478
gss13/Leetcode
/leetQ448_Find_All_Numbers_Disappeared_in_an_Array.py
727
4.03125
4
''' 448. Find All Numbers Disappeared in an Array Given an array of intergers where 1 <= a[i] <= n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Could you do it without extra space and in O(n) runtime? You may assum...
cb93dd4992deae12a521ba8b4c1c81d60a3abe4b
axllow91/python-tut
/classes.py
1,874
4.25
4
# A class is like a blueprint for creating objects. An object has properties and methods(functions) associated with it. # Almost everything in Python is an object class User: # Constructor # self is similar to this in java (mandatory to be passed on constructor when created, first in order) def __init__(...
2015515fc8b40ff8e1cf0370b58f7f03149e7c9d
nekapoor7/Python-and-Django
/HACKER_RANK/string_count.py
799
4.1875
4
'''In this challenge, the user enters a string and a substring. You have to print the number of times that the substring occurs in the given string. String traversal will take place from left to right, not from right to left. NOTE: String letters are case-sensitive. Input Format The first line of input contains the ...
d7ed0060a80629e0ed62ccf9e78f963b145550d1
hansrajdas/random
/practice/is_linked_list_palindrome.py
2,147
4.03125
4
class Node: def __init__(self, k): self.k = k self.next = None class LinkedList: def __init__(self): self.head = None def insert_begin(self, k): if self.head is None: self.head = Node(k) return n = Node(k) n.next = self.head s...
37b288a080f02d54fd3b2bf2c6b7fd544a0ad0a6
bdavies3/Calculator
/src/Calculator.py
1,371
3.515625
4
from CsvReader import CsvReader import math def addition(a, b): c = a + b return c def subtraction(a, b): c = b - a return c def division(a, b): return float(a) / float(b) def mean(data): mean = data return mean def multiplication(a, b) -> object: c = float(a) * float(b) ret...
fbc152ea75844a42966274aac5509420eeab67b8
massimilianocasini/misigram
/calcolatrice_web.py
1,485
3.59375
4
import math print "-" * 60, "\n" print "\t" * 2 ,"CALCOLATRICE", "\n" print "Completamente sviluppato da Alessandro Alfieri.\n" print "Licenza: Open Source " print "Data: 17 Novembre 2010" print "-" * 60, "\n" * 2 print "Scegli l'operazione che vuoi fare..." print "1:Addizione-Sottrazione-Moltiplicazione-Divisione" p...
6ee9fa76551f9fad26def5a2cf3809e6dafd7dab
titisarinurul/purwadhika_modul1
/coret3.py
206
3.609375
4
# cuma jadi nama alias testList = [1,2,3] newList = testList newList[2] = "test" print(testList) print(newList) # duplikasi list testList = [1,2,3] newList = testList.copy() print(testList) print(newList)
84d2c11bf4f886fca3fedf89eb3ce7274e72a0ed
andrei-kozel/100daysOfCode
/python/day002/project.py
654
4.15625
4
#If the bill was $150.00, split between 5 people, with 12% tip. #Each person should pay (150.00 / 5) * 1.12 = 33.6 #Format the result to 2 decimal places = 33.60 #Tip: There are 2 ways to round a number. You might have to do some Googling to solve this.💪 #Write your code below this line 👇 print("Welcome to the ti...
ceac0e4f06857e739aee1e73f9b4566b5af5e5d6
Rachanahande/python1
/New folder/day2assign5.py
206
3.953125
4
'''5. Write a program to add the elements of 2 arrays that are of the same dimension''' l1 = [1,2,3,4] l2 = [5,6,7,8] l3 = list(map(lambda x,y: x+y,l1,l2)) print(f"after adding l1{l1} and l2 {l2} is {l3}")
38accd5077279e0b8f5058dab3b4777217398fab
b1ueskydragon/PythonGround
/practice/switch-case.py
344
3.515625
4
import re my_tuple = ( ("t1", "path1"), ("t2", "path2"), ("t3", "path3"), ("t4", "path4") ) my_func = lambda s: next(v for k, v in my_tuple if re.match(k, s)) print(my_func("t1")) print(my_func("t3")) my_dict = { "a": "A", "b": "B" } simple_func = lambda k: my_dict[k] print(simple_func("b"...
938fb7b11c7aaeb522fc8bc8326ec383990a78b6
BenTimor/Sidur
/calculations.py
6,359
4.125
4
from typing import List from .schedule import * from random import shuffle from . import config def embedding(schedule: Schedule, employees: List[Employee]): """ Embedding all of the employees into the schedule :param schedule: The schedule :param employees: The employees """ # Embedding the pr...
736a02dc221c3e421d0be1f2a92191c9d730e185
rekiko/geekbrains.python
/lesson02/home_work/hw02_normal.py
2,532
3.78125
4
# Задача-1: # Дан список заполненный произвольными целыми числами, получите новый список элементами которого будут # квадратные корни элементов исходного списка, но только если результаты извлечения корня не имеют десятичной части и # если такой корень вообще можно извлечь # Пример: Дано: [2, -5, 8, 9, -25, 25, 4] Ре...
e9ec9bfe76d578bf6e85f24e8a5f72ac88890365
Jelowis/Ejercicios-Python-U
/EJERCICIO4.py
623
3.765625
4
# Comprehension – [var for var in datos condicion] [car for car in['a','e','i','o','u'] if car not in('a','i','o')] edad,_peso = 50, 70.5 nombres = 'Daniel Vera' dirDomiciliaria= "Chile y Guayaquil" Tipo_sexo = 'M' civil = True usuario = ('dchiki','1234','chiki@gmail.com') materias = ['Programacion Web','PHP','...
3531e074c981cd0bd7cad07ee4c7e9e94062f6fb
josephkuhn/CS581-Social-Networks
/Triads/triad_graphs.py
4,747
4.125
4
# Author: Joseph Kuhn # triad_graphs.py takes data from a CSV file and determines how many triangles there are, # as well as how many different types of relationships exist. # This program identifies triads and calculates a lot of different data, including the expected # number of different relationships vs. the a...
4ca575e0ea60d7dd2014da6960a29f867174021c
JustEmpty/algorithms
/problems/max_depth.py
476
3.859375
4
class TreeNode: def __init__(self, x): self.val = x self.right = None self.left = None # Time complexity: O(n), visit each node exactly once # Space complexity: O(n)(worst case: completely unbalanced), O(log(n))(best case: the height of the tree would be log(n)) def max_depth(root): if ...
ffb14de6057125b15aec75993f3ededcabbe8758
ghazi-naceur/python-tutorials
/3-statements/if_elif_else_statements.py
237
3.875
4
def compare(a): if a == 3: print("Equal to 3") elif a == 5: print("Equal to 5") else: print("This is another value") if __name__ == '__main__': compare(3) compare(5) compare("something")
f98480d32647d5a2a63b66882864deb3cd173555
kabmkb/Python-DeepLearning
/ICP5/Sourcecode/Program3.py
1,754
3.9375
4
"""Importing pandas library""" import pandas as pd """Using linear_model from sklearn library""" from sklearn import linear_model from sklearn.metrics import mean_squared_error, r2_score """Importing numpy library as np""" import numpy as np """Importing matplotlib.pyplot library for plotting graphs""" im...
6d577d4f07fea159e8573dbd540bea95aec2b39f
33Da/pytorch
/1_线性回归.py
2,374
3.5625
4
import torch learning_rate = 0.01 # 准备数据 x = torch.rand([500, 1]) # 500行1列 y_true = x * 3 + 0.8 # 通过模型计算y_predict w = torch.rand([1, 1], requires_grad=True) b = torch.tensor(0, requires_grad=True, dtype=torch.float32) # 4. 通过循环,反向传播,更新参数 # for i in range(2000): # # y_predict = torch.matmul(x, w) + b # matmul矩阵...
cdaba15e987b834f5d69679ab7fad4a84664fd9b
Keonhong/IT_Education_Center
/Jumptopy/Codding_dojang/namedtuple( ).py
1,732
3.75
4
# collections.nametuple()의 메소드들 # 1) _make(iterable) import collections # Person 객체 만들기 Person = collections.namedtuple("Person", 'name age gender') P1 = Person(name='Jhon', age=28, gender='남') P2 = Person(name='Sally', age=28, gender='여') # _make()를 이용하여 새로운 객체 생성 P3 = Person._make(['Peter', 24, '남']) P4 = Person....
fc1d3ba12a5e13e8e002d503e2a5e1f9e16e4736
RLuckom/python-graph-visualizer
/abstract_graph/Edge.py
1,026
4.15625
4
#!/usr/bin/env python class Edge(object): """Class representing a graph edge""" def __init__(self, from_vertex, to_vertex, weight=None): """Constructor @type from_vertex: object @param from_vertex: conventionally a string; something unambiguously represent...
01740c52fdd43d9e8ed2e305c7771c43ebcb4053
howardbyrd/SortingVisualizer
/bubbleSort.py
422
3.9375
4
import time # O(N^2) Time Complexity # O(1) Space Complexity def bubbleSort(data, drawData, timeTick): for i in range(0, len(data) - 1): for j in range(0, len(data) - 1 - i): if data[j] > data[j+1]: data[j], data[j+1] = data[j+1], data[j] drawData(data, ['red...
b314f76577a9988d992043245da553a7552682a8
davidlwr/InternetExplorers
/web/Entities/activity.py
2,437
3.578125
4
import datetime class Activity(object): ''' This class represents an activity event created from 2 sensor_logs ''' daytime_start = datetime.time(6, 30) daytime_end = datetime.time(21, 30) def __init__(self, uuid=None, start_datetime=None, end_datetime=None, start_log=None, end_log=None): ...
189c16119be11e8199ca842ba29b8d39c4e19e94
newking9088/Data-Science-Materials-from-Coursera
/Python-Classes-and-Inheritance/testingClasses.py
2,910
4.78125
5
"""To test whether the class constructor (the __init__) method is working correctly, create an instance and then make tests to see whether its instance variables are set correctly. Note that this is a side effect test: the constructor method’s job is to set instance variables, which is a side effect. Its return val...
9cc0c0864a28633dca337f1a4d793db6c4ce346f
rafaelperazzo/programacao-web
/moodledata/vpl_data/303/usersdata/287/82711/submittedfiles/testes.py
150
3.890625
4
# -*- coding: utf-8 -*- n=int(input('digite o valor de n: ')) i=1 cont=0 while (i<n): if i%2==1: cont=cont+1 i=i+1 print(cont)
552ce70b7429f583a86e43f0cc572104ba7655b0
sycoumba/TPPYTHON
/EX06.py
160
3.921875
4
import math x1=int(input("x1?")) x2=int(input("x2?")) y1=int(input("y1?")) y2=int(input("y2?")) d=math.sqrt(pow(x1-x2)+(pow(y1-y2)2) print("la racine est",+d)
2bc740fef9a2588d0d0376b7eaaf6daeda4b067d
rookiy/Leetcode
/MinimumDepthOfBinaryTree_2rd.py
929
3.859375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None # 递归方式得出最小高度,根,左子树,右子树 class Solution: # @param {TreeNode} root # @return {integer} def minDepth(self, root): if not root: retu...
b83621385f9685613f566deef56849499cd27786
c940606/leetcode
/Path Sum.py
1,000
3.78125
4
from listcreatTree import creatTree # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def hasPathSum(self, root, sum): """ :type root: TreeNode :type sum: int :rtype: bool """ self.all_sum = [] self.find_all...
634b9269b5a586fee579722d81c7619921fb62bb
djarufes/Python_Crash_Course
/Excercises/HW07/pet.py
1,107
3.53125
4
######################################################## # Author: David Jarufe # Date: April. 19 / 2019 # This program is a Class that can be imported # for later use ######################################################## #The Pet class (pet.py) class Pet: def __init__(self, petName, petType, petAge): self...
c331b015cb0e381b0f71de34dd1f1ce853a51c50
lixiang2017/leetcode
/explore/2021/april/Triangle.py
1,345
3.546875
4
''' approach: Iteration / DP Time: O(N*N) = O(N^2), where N is the length of triangle. Space: O(N + N) = O(N) You are here! Your runtime beats 59.65 % of python3 submissions. You are here! Your memory usage beats 95.11 % of python3 submissions ''' class Solution: def minimumTotal(self, triangle: List[List[int]])...
1c8b669ff5b78cda4ff56753e91fd4dc57bcab70
blendmaster/Rokkit-Tanx
/PhysicsObject.py
20,970
3.625
4
from math import * from Vector import * import pygame from pygame.locals import * DEBUG_DRAW_HULLS = True DEBUG_DRAW_VELOCITY = False GRAVITY_ENABLED = True GRAVITY = Vector(0.0, -1.0) ELASTIC_COLLISION_DAMPENING = .95 class PhysicsObject: """ An circle exibiting rigid body non angular velocity physics ( n...
e0352e5c5217ed1bbad0cc7cffefcc1021fe8443
gguillamon/PYTHON-BASICOS
/python_ejercicios basicos_III/bucles/ejercicio4.py
741
3.90625
4
# Realizar un algoritmo que pida números (se pedirá por teclado la cantidad de números a introducir). # El programa debe informar de cuantos números introducidos son mayores que 0, menores que 0 e iguales a 0. num=input("Introduzca numeros o 's' para salir:") contador1=0 contador2=0 contador3=0 sumacontadores=contad...
7c57ed35f105ae0fafce3681846f9e702cc865f8
ck-unifr/hackerrank-cracking-the-code-interview
/bit-manipulation-lonely-integer.py
800
3.671875
4
# https://www.hackerrank.com/challenges/ctci-lonely-integer/problem # !/bin/python3 # Input format # The first line contains a single integer n, denoting the number of integers in the array. # The second line contains n space-separated integers describing the respective values in A. # Output format # Print the uniqu...
2cd4c5fef290fb28c914ad2ba8cef584cc35854b
MichalGilprog/PythonBasic
/tutorial_python/dziedziczenie.py
640
3.515625
4
class Osoba: def __init__(self, imie, nazwisko): self.imie = imie self.nazwisko = nazwisko def przedstaw_sie(self): return "nazywam sie " + self.imie + " " + self.nazwisko class Student(Osoba): def __init__(self, imie, nazwisko, numer_indeksu): Osoba.__init__(self, imie,...
95a9fbc51e15c488e4a94ac11e9d9d2e7a11750e
Ramezcua/PythonCardGames
/Cards/War.py
478
3.671875
4
import Cards def main(): print('Welcome to war!') while(True): user_input = input('Would you like to start the game? [y/n]') if user_input.lower() in ['yes', 'y', 'ya']: print('Start game') elif user_input.lower() in ['no', 'n', 'n...
f5445e04295d17e270163ba13c242c04e45bf6e9
Mujju-palaan/Flask01
/section2/28)Inheritance.py
649
3.640625
4
class student: def __init__(self, name, school): self.name = name self.school = school self.marks = [] def average(self): return sum(self.marks/ len(self.marks)) def friend(self, friend_name): return student(friend_name, self.school) class Workingstudent(student): ...
a541f87159190ed55ed1f7ba3ccecf9580693193
zhsee/daily_coding_challenge
/day41_itinerary.py
2,227
4.0625
4
# Given an unordered list of flights taken by someone, each represented as (origin, destination) pairs, and a starting airport, compute the person's itinerary. If no such itinerary exists, return null. If there are multiple possible itineraries, return the lexicographically smallest one. All flights must be used in the...
892e4b12c8e1b2b19fdc437d3a3b50b795ade06c
johnta0/AtCoderSolutions
/abc/164/a/main.py
128
3.546875
4
s, w = map(int, input().split()) print('un' * (w >= s) + 'safe') # if w >= s: # print('unsafe') # else: # print('safe')
92140e190a034d7908563141c402a5091ea3db31
gjkim44/Test
/Module05/Module05Demo/Lab5-1test.py
1,118
4.25
4
# 2) Add code that lets users appends a new row of data. # 3) Add a loop that lets the user keep adding rows. # 4) Ask the user if they want to save the data to a file when they exit the loop. # 5) Save the data to a file if they say 'yes' lstRow0 = ['Id','Name','Email'] lstRow1 = ['1','Bob Smith','BSmith@Hotmail.com...
86af50de4673f8470f4e9388b2d866ae4a38ecd6
GreenBlitz/Deep-Space-Vision
/utils/image_objects.py
7,379
3.546875
4
import cv2 import numpy as np from pipeline import PipeLine class ImageObject: def __init__(self, area, shape=None ,shape3d=None): """ constructor of the image object which is an object on field :param area: the square root of the area of the object (in squared meters), float ...
4d17279a9670b6c07d337bf8ce907df0d1eb3e65
CCChang1996/-python-
/Numpy.py
1,198
3.59375
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 16 20:13:22 2019 @author: 13486 """ import matplotlib.pyplot as plt import numpy as np # 创建数组 myarray = np.array([1, 2, 3]) print(myarray) print(myarray.shape) # 创建多维数组 myarray = np.array([[1, 2, 3], [2, 3, 4],[3, 4, 5]]) print(myarray) print(myarray.shape)...
42fff1cc764c42451433406b2710336bac618064
julianShi/chess_game
/TestChessGame.py
382
3.515625
4
from ChessGame import ChessGame chessGame = ChessGame() chessGame.initializeBoard() # chessGame.printBoard() # steps = [("e2","e4"),("d7","d5"),("e4","d5")] steps = [("e2","e4"),("f7","f5"),("d1","h5"),("g8","f6"),("h5","e8")] for startPosition,endPosition in steps: if(chessGame.move(startPosition,endPosition)): ...
cb17c242facb138920202c80ee988a149363ac20
ljw1126/python-for-coding-test
/7장이진탐색/bisect_lib_method.py
749
3.609375
4
""" 값이 특정 범위에 속하는 데이터 개수 구하기 >> bisect 라이브러리를 활용하여 해당 값에 대한 count도 구할 수 있고 해당 범위내에 데이터 갯수도 구할 수 있음 # 실행결과 2 6 """ from bisect import bisect_left, bisect_right # 값이 [left_value, right_value]인 데이터의 개수를 반환하는 함수 def count_by_range(a, left_value, right_value): right_index = bisect_right(a,right_value) ...
53e0fb6b92e0b8c8b6b54d2048f971276261fddd
mydevops-ec-projectsapps/paytm
/devops.py
120
3.734375
4
print("PLease Name") name = input("Please enter your name please") add= input("Please address please") print(name,add)
a1c0f1b591b3af569836a8ce79b6e49560d9194e
seanchen513/leetcode
/tree/binary_tree.py
3,857
3.875
4
""" class TreeNode() print_tree(root, depth=0) array_to_bt(arr) array_to_bt_lc(arr) # arr in LeetCode format bt_find(root, val): """ from typing import List import collections class TreeNode(): def __init__(self, val, left=None, right=None, parent=None): self.val = val self.left = left s...
668f62fdbc35dc29a224978647092b60235376cb
UWPCE-PythonCert-ClassRepos/Self_Paced-Online
/students/smitco/lesson02/series.py
1,057
3.703125
4
#lesson 02 series #step 1- print fibonacci value def fibonacci(n): fib = [] for num in range(n+1): if num == 0: fib.append(0) elif num == 1: fib.append(1) else: f = fib[num-1] + fib[num-2] fib.append(f) return(fib[n]) #step 2- pri...
b453626e87b3091c8c409f586bd10fe8edda6dde
BiswasAngkan/BasicPython
/NewItem_Insertion.py
536
4.21875
4
# Angkan Biswas # 26.5.2020 # To insert a new item in a list or a dictionary ''' Empty list ''' x = [] print('x = {}'.format(x)) ''' Insert new items in a list ''' x.append('Angkan') print('x = {}'.format(x)) x.append(23.44444444) print('x = {}'.format(x)) ''' Empty dictionary ''' y = {} print('y = {}'.for...
f1887e458f05e99281ce352d195ab43796815cb9
gauravsaxena1997/pycode
/webscrap.py
186
3.609375
4
import urllib.request, urllib.error, urllib.parse url = input ("Enter the URL: ") fhand = urllib.request.urlopen('http://'+url) for line in fhand: print ( line.decode().strip() )
ac5e5362017d3e398c85bba8b2ca4cea4b06787a
lafabo/i-love-tutorials
/lpthw/ex5.py
774
3.828125
4
name = 'D\'artanyan' age = 35 # i don't know exactly height = 185 # cm #height cm -> inches height_inc = height * 0.39 weight = 75 # kg #weight kg -> pounds weight_pou = weight * 2.2 eyes = 'Blue' teeth = 'White' hair = 'Brown' print 'Let\'s talk about %s.' % name print 'He\'s %d cm tall.' % height print 'He\'s %d...
61d264882bd557541e26548d58a644b1ccdd1322
ColinTing/Python-Specialization
/ex_15_enrollment/enrollment.py
1,707
3.609375
4
import json import sqlite3 conn = sqlite3.connect('enrollmentdb.sqlite') cur = conn.cursor() # 表命名不要加复数 “Users” 改成 “User” #改了建表语句及插入sql中的User,却忘了删除表中的User cur.executescript(''' DROP TABLE IF EXISTS User; DROP TABLE IF EXISTS Course; DROP TABLE IF EXISTS Member; CREATE TABLE User ( id INTEGER NOT NULL PRIMARY KE...
dc10e1d5c334d49ecb73610ccc9ef87435d0728c
gudianirudha/python_programs
/find.py
147
3.78125
4
sent='Anirudh' find=input("Enter what you want to search") pos=sent.find(find) if pos > 0: print("found",pos) else: print("Not found",pos)
baaa352456549d8b3ff7bd1cedade8e1f08f4ae5
eecs110/winter2021
/course-files/lectures/lecture14/answers/02b_list_animation_different_speeds.py
1,353
3.765625
4
from tkinter import Canvas, Tk import time import utilities import math import random gui = Tk() gui.title('Animation') canvas = Canvas(gui, width=500, height=500, background='white') canvas.pack() ########################## YOUR CODE BELOW THIS LINE ############################## # 1. generate a list of rules that e...
d3becaf2eb46765e15254df1784c5f4b42f4d80b
wheresmichel/my-first-blog
/hello.py
265
4.09375
4
print("hello") print("hi alex") x = "hi alex" print(x) x = "there are two alex" print(x) x = "django girls project" print(x) x = ["tomato","potato","ice cream"] print(x) for food in x: print(food) x = [1,2,3,4,5] sum = 0 for num in x: sum += num print(sum)
71c347ea25381ea29856d2de1e0fe8eef5b26265
danila28/laba
/4.py
1,541
3.578125
4
filename = input("Введите имя файла для чтения:> ") f = open(filename, 'r') f = f.read() numb = "0123456789" latin = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" rusodnglas = "уыаоэиУЫАОЭИ" rusdvuglas = "еёюяЕЁЮЯ" rusship = "жшчщЖШЧЩ" ruszvonk = "бвгдзжлмнрБВГДЗЖЛМНР" dlina = len(filename) numb1 = 0...
9bafc9c67022ced2577c0f4091fff787c7036c6e
ykim5470-Lewis/westagram
/Info1110/week03/seminar.py
150
3.59375
4
ham = "10" int(ham) print("This is"+ ham) print("This is" +str(ham)) report= "progess: {:.2f}".format(12.345) print(report) x= 10 x= x == x print(x)
0af6bedee66312a51569e1e36a23d53d4b3ed2ac
adityak74/HackerrankSolutions
/ai-ml-corrreg1-numpy.py
602
3.546875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import numpy as np phy_scores = [15,12,8,8,7,7,7,6,5,3] his_scores = [10,25,17,11,13,17,20,13,9,15] phy_his = np.multiply(phy_scores,his_scores) phy_sqr = np.power(phy_scores, 2) his_sqr = np.power(his_scores, 2) phy_his_sum = np.sum(phy_his) phy_s...
ac56e5f46136818dba4fd1ea3aa87f822159fe37
kritikagupta0007/Guess-Number
/main.py
452
4.09375
4
import random def guess(num): random_number = random.randint(1,num) guess = 0 while guess != random_number : guess = int(input(f"Guess the number between 1 to {num} : ")) if guess > random_number : print(f"Number you choose is too high") elif guess < random_number : ...
e56977acf4b461bcf27df539efb45712be8cbd07
Nan-Do/DailyCoding
/Daily_54.py
3,270
3.515625
4
def get_free_positions(sudoku): free_positions = [] for r in range(9): for c in range(9): if sudoku[r][c] == -1: free_positions.append((r, c)) return free_positions def get_square_val(position): r = position[0] c = position[1] ri = 0 re = 3 if r >= ...
b76bb07d524c7698b89801534d32da9a5fd3f3db
Victor-Deidon/Python
/lab5/lab5.py
683
3.578125
4
class __task1(): Nu = [] St = [] for i in range (0,5): print("type number") Nu.append(input()) for j in range (0,5): print("type string") St.append(input()) def f(Nu): res = 0 for h in range (0,5): res = res + Nu[h] print(res) def u(St): ...
7f9a9d78888058dd8f96387862a1b0cd631e6702
salabhsg/PY-Projects
/Python_ALPHA.py
912
3.984375
4
#Excercise (1)=====================================>>>>>>>>>>> numbers = [] strings = [] names = ["John", "Eric", "Jessica"] # write your code here numbers = [1,2,3] strings = ["Hello","World"] second_name = names[1] # this code should write out the filled arrays and the second name in the names list (Eric). print(...
a8bd64094cad2b2a47f0a20999a4d0619b62af5f
alexandraback/datacollection
/solutions_5738606668808192_0/Python/johnclyde/jamcoin.py
625
3.90625
4
#!/usr/bin/env python from sys import argv script, N, J = argv def integer_to_binary_string(n): if n == 0: return '0' binstr = '' x = n while x > 0: binstr = '{}{}'.format(x % 2, binstr) x = int(x / 2) return binstr print "Case #1:" num_zeroes = int(N) / 2 - 1 starting_po...
3dbf5904fcac88dcdda8cafa897313e2c8046d10
justcodemore/python
/requsentslearn/test.py
278
3.75
4
# __author__ = 'admin' # -*- coding: utf-8 -*- score = raw_input('please write your score:') score = int(score) if score >= 90: print 'excellent' elif score >= 80: print 'good' elif score >= 60: print 'passed' else: print 'failed' f = lambda a: a+2 print f(2)
8a516cc3fc02c62e6bc982d7901da945f1800d49
saded/volume3Ds
/elips.py
2,599
4.03125
4
import bpy from random import randint, random from math import sqrt, pi # Function to calculate the distance between two points def distance(a, b) : ''' list , list --> float a = list with three element b = list with three element return the distance between two points in float ''' ret...
a3948c2d2d70b34eb1d3c1be25050e082e9d83c2
banggeut01/algorithm
/code/list/5120.py
2,461
3.71875
4
# 5120.py 암호 import sys sys.stdin = open('5120input.txt', 'r') class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None self.tail = None def printList(self): if self.head is None: pri...
707526bb1b2c25856c19f5d4fc48dad1dc92e35f
Yuchen1995-0315/review
/01-python基础/day08/exercise02.py
195
4.03125
4
# 练习:定义函数,多个数值相加的函数. def sum(*args): result = 0 for item in args: result += item return result print(sum(1,2)) print(sum(1,2,3,54,3,5,65,67))
c69a2133c61655fbfe3a6f4bb73e1fa07de06de6
paulorjmx/bd_pt3
/Controller.py
1,754
4
4
from Atividade import Atividade as A # Controlador principal, recebe os inputs necessários para realizar operações. class Controller: class Insert: def atividade(self): nome = input("Digite o nome da atividade: ") descricao = input("Digite a descrição: ") tipo = input("Digite o tipo: 'PESQUISA' ou 'ESTAGIO...
dcb61a2cecd01d6bde7b7540d9a47569a15386c6
rafaelperazzo/programacao-web
/moodledata/vpl_data/396/usersdata/288/81075/submittedfiles/av1_programa2.py
2,259
4.03125
4
# -*- coding: utf-8 -*- #COMECE AQUI ABAIXO a=int(input("Digite um numero: ")) b=int(input("Digite um numero: ")) c=int(input("Digite um numero: ")) d=int(input("Digite um numero: ")) e=int(input("Digite um numero: ")) f=int(input("Digite um numero: ")) g=int(input("Digite um numero sorteado: ")) h=int(input...
c850601c3c98b0ff6ccd9d18f02e4f5c7447f2e5
mohdsanadzakirizvi/algos
/document_distance.py
1,605
3.515625
4
from math import sqrt, acos from string import maketrans def openFile(docname): with open(docname, 'r') as doc: return doc.readlines() def wordSplit(lines): lines2 = [] tranTable = maketrans('?.!;:,-(){}[]_\n\t', ' '*16) for line in lines: line = (line.lower()).translate(tranTable) ...
0aa848a4ed5653aef2243e63e1708f5f755d2440
shubhamshah14102/robospark-2021-prog-rohan-gaikwad
/12_10_DS_task_17_Shubham Shah/prog.py
1,832
3.6875
4
# 1. Shape detection: Images contains different shapes with different colors. # Your task is to detect the shape by knowing the number of sides present on that shape. # Draw the edges on the shape masked. import cv2 import numpy as np img = cv2.imread("vllCR.png") gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) _, th...
dfc69a3eada7da7e5cad63646d52269f8303dc0b
Elephant333/Project-Euler
/p9-SpecialPythagoreanTriplet.py
949
3.734375
4
#Nathan Li - 3/11/2021 - P9: Special Pythagorean Triplet import time startTime = time.time() flag = False """for a in range(1,999): for b in range(a, 1000): for c in range(b,1001): if a**2 + b**2 == c**2: if a+b+c == 1000: print(a*b*c) fl...
959b3a80152fa964739145d187f3ed4efcf73e18
arnet95/Project-Euler
/euler297.py
1,311
3.515625
4
#Project Euler 297: Zeckendorf Representation import time fib_cache = {0: 1, 1: 1} def fib(n): if n in fib_cache: return fib_cache[n] else: tmp = fib(n-1) + fib(n-2) fib_cache[n] = tmp return tmp S_cache = {1: 0, 2: 1, 3: 2, 5: 5} def S(n): if n in S_cache: return S...
774c5b6528c921f08815b0065445fae948cf360a
safakhan413/interview-faangs
/codesignal/easy/isLucky.py
561
3.9375
4
# path: Ticket numbers usually consist of an even number of digits. A ticket number is considered lucky if the sum of the first half of the digits is equal to the sum of the second half. # Given a ticket number n, determine if it's lucky or not. def isLucky(n): newS = str(n) lenN = len(newS) halfLen = lenN ...
f9f85f8911132feacf62a656ad56b59451d76511
sijanbhandari/captcha-solver-1
/model/src/models/Network.py
865
3.65625
4
from torch import nn class NeuralNetwork(nn.Module): """ Neural networ class. Contains a Stack with the different layers to be used. The first layer size is fixed to the size of a digit image. The output is fixed to 36. 26 letters and 10 digits. """ def __init__(self): supe...
decc31eb60f4bba93e6099bb8e5933fa7f4ae852
melany202/programaci-n-2020
/clases/segundaclase.py
455
3.96875
4
nombre =input("Ingrese el nombre : ") print ("Hola" , nombre, "eres bienvenido a este código") edad = int(input("Por favor ingrese su edad : ")) estatura = float(input("Por favor ingrese su estatura : ")) print (edad) print (estatura) print (type(nombre)) print (type(edad)) print (type(estatura)) if (edad >= 1...