blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7ede3841c60258f9223a2d3829fc554132ddc8f8
konicua/Python-Codes-For-IT-Step-Academy
/code19( exstention of 18th ).py
252
3.59375
4
import turtle bro = turtle.Turtle() secondbro = 100 bro.speed(10) a = int(input("number")) for i in range(a*2): secondbro = secondbro+10 bro.forward(secondbro) bro.right(90) bro.forward(secondbro) bro.right(90) input()
1b3839e650c3ccc33dca6570217b6e758b8191d6
Sammion/PythonStudy
/source/tests/test05.py
426
4.0625
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 3 15:30:52 2017 @author: shuai.qian """ def fact (n): if n == 1: return 1 return n*fact(n-1) print (fact(10)) def move (n, a, b, c): if n == 1: print('move', a, '-->', c) else: move (n-1, a, c, b) move (1,...
75e1b613e054cc5ceb7eddd46881c2a927d1631d
newjokker/PyUtil
/BuiltinModule/Collections/deque.py
634
3.859375
4
# -*- coding: utf-8 -*- # -*- author: jokker -*- """ 使用list存储数据时,按索引访问元素很快,但是插入和删除元素就很慢了,因为list是线性存储,数据量大的时候,插入和删除效率很低。 deque是为了高效实现插入和删除操作的双向列表,适合用于队列和栈: deque除了实现list的 append() 和 pop() 外,还支持 appendleft()和 popleft(),这样就可以非常高效地往头部添加或删除元素。 """ from collections import deque q = deque(['a', 'b', 'c']) q.append('x') q....
9bedc59e215e145afb0b0997fcccab6899262376
NerdJain/Python
/empty_list.py
756
3.859375
4
def main(): l = [] #1st List l1 = [1,2,'3',4.7,5] l.append(l1) #2nd list l2 = [] l.append(l2) #3rd list l3 = ['A','b','h','i','s','h','e','k'] l.append(l3) #4th list l4 = ["Python","Numpy","Pandas","Lambda"] l.append(l4) #5th list l5 = [] l.append(l5) for item in l: ...
94a14b365b7b746a79f2f3de836c6960651c63fe
dyarnall/python_immersive
/sets.py
502
4.0625
4
# a = [1,2,3,3,2,1,5,6,5,5,5] # b = [1,4,6,6,7,3,9,0,0,0] # new_set_a = set(a) # new_set_b = set(b) # print(new_set_a, new_set_b) # intersect = new_set_a.intersection(new_set_b) # print(intersect) new_set = set() def add_to_set(word): new_set.add(word) if word == "quit": flag = False else: flag = True retur...
0a5c6e9c38ff7a8820a4b0b49c66cfee22909e3e
deqv/COMP-3006
/Project 1/count.py
3,207
3.96875
4
# Varun Suresh # 873569280 # This program counts the frequency of the characters that appear in the files that it is fed. import sys from string import ascii_lowercase import csv # add_frequencies is a function that adds the frequency counts of the characters to the dictionary d. def add_frequencies(d, f...
3137f122eaf00b6962f6050668253d8bcd8b20d3
vivekkhimani/Python_Learning_Practice
/1_BinarySearchTrees/fuckK.py
327
3.890625
4
class MyClass(object): def __init__(self,name,email): self.__name = name self.__email = email def fuckOff(self): return "Fucker" class YourClass(MyClass): def __init__(self): self.__name = "Vivek" vivek = MyClass("Vivek","Khimani") print(isinstance(vivek,Your...
2f0564e2fcc67dd9dddba1f7a767de30fc42f1ae
Aasthaengg/IBMdataset
/Python_codes/p02272/s947251418.py
844
3.796875
4
m=0 def merge(a,left,mid,right): n1=mid-left n2=right-mid el=range(0,n1+1) ar=range(0,n2+1) for i in range(n1): el[i]=a[left+i] for i in range(n2): ar[i]=a[mid+i] el[n1]=float("inf") ar[n2]=float("inf") i=0 j=0 for k in range(left,right): global m ...
3ab6f879b274b04525e7471d515e49ec3c917d26
leanndropx/px-python-logica-de-programacao
/04 - Manipulação de strings - funções find()-rfind()-count() - Conte as letras A.py
885
4.375
4
# - DESCREVENDO O DESAFIO print('''04 - Faça um programa que leia uma frase pelo teclado e mostre: 1 - Quantas vezes aparece a letra A 2 - Em que posição ela aparece a primeira vez 3 - Em que posição ela aparece a ultima vez''') print() #INICIALIZANDO O PROGRAMA ...
1746b0b0901444cf66a807c55ef7255c5736543b
piercep8/Data-Analytics-for-Business
/Shape Areas.py
415
4.1875
4
# Import Math package to give me the value of Pi import math # Calculate the area of a circle def calc_circle_area(radius): circle_area = round(math.pi * radius ** 2, 3) return circle_area # Calculate the area of a sphere def calc_sphere_area(radius): sphere_area = round(4 * math.pi * radius...
f7bf2c1f3e83af98ad3e0cfd9a3621861d800aa7
PohSayKeong/python
/practical2/q08_top2_scores.py
411
3.921875
4
students = [] scores = [] another = "y" def enter(): student = str(input("enter name of student: ")) score = int(input("enter score of student: ")) another = input("add another student? (y/n) ") students.append(student) scores.append(score) if another == "y": enter() enter() sort = sorte...
5e3c7df9cfd49cf9648abe372e751fd1291612c5
AnaTomomi/tscfat
/build/lib/tscfat/Analysis/calculate_similarity.py
1,801
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jul 2 12:28:09 2020 @author: arsi Functions for distance matrix and similarity matrix calculation. Numpy pdist function is used for the calculation. Full reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance....
4ab2f657f82e6cd15e09f060c84a8eacf8eb675e
pallavipant1/Spark-Foundation
/Prediction using supervised learning-Task 1.py
2,310
3.515625
4
#!/usr/bin/env python # coding: utf-8 # # Prediction using Supervised ML # In[1]: # Predict the percentage of an student based on the no. of study hours # In[2]: import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') # ...
87a7965be1432c9ba4585b66308ed45be4af1635
SachinDangayach/session12-SachinDangayach
/calculator/math_func/log_func.py
1,154
3.890625
4
# log.py import math import numbers from ..helper import string_rep @string_rep def log(x:float,base:float)->float: """ Function expects positive real number as input. base should be greater than 0 and not 1. Function returns log(x) to the base n as output """ if not (isinstance(x, numbers.Real) a...
18db1f987f9c01f8612d29603a78e4cd17f7dbf5
makiimura/mpd-check
/arg_test.py
895
4.25
4
# import argparse import argparse # # Howto run test program # # python arg_test.py --in something --out something # Create parser object for parsing incoming arguments parser = argparse.ArgumentParser() # Add arguments that we want to parse parser.add_argument('--in', action="store", dest='inputFileName') p...
3579ec69a00d1156d2bf925ffa1860cb318c4ec8
najpodge/AdventOfCode2020
/src/day15.py
1,102
3.65625
4
def insert_num(num, last_seen, turn): if not num in last_seen: last_seen[num] = [] last_seen[num].append(turn) def get_num_at_turn(num_turns, starting_nums): last_seen = {} turn = 0 last_turn_value = 0 for i in range(len(starting_nums)): turn += 1 insert_num(starting_num...
e878b96101b3e4108246aa1d7a89c3cbe484f493
isnakie/CMPS115
/scatter.py
5,573
3.671875
4
""" Created on April 13, 2016 Reads a csv file containing stock market data and shows and saves a plot of the trend line, given optional starting and ending date information. Call makeChart() with return value of readFile() and a list of prices, e.g., ['Open','Close']. @author: Johnnie Chang """ import argparse import...
71b2714714c64711d41a17011ab387cdcd2e9078
magira01/PythonPrimerosPasos
/guia1/ejercicio10.py
290
4.0625
4
#Ejercicio 10: Crear un programa que pida al usuario su edad y # muestra por pantalla si #es mayor de edad o no, siendo 18 años la mayoría de edad. edad = int( input("¿Que edad tienes? ")) if edad < 18: print ( "Eres menor de edad") else: print ("eres nayoor de edad")
a4c82a86fdf677abefb3b6b2d4c8d017ac53fac1
mimi-sl/misc_scripts
/age_appropriateness/age_appropriateness.py
633
3.984375
4
from decimal import * age = float(raw_input('Age in question? ')) def appropriateness(age): lower_bound = (.5 * age) + 7 upper_bound = (age - 7) * 2 #tests to see if the resulting lower bounds are whole numbers. if not, makes them display without too many zeros if int(upper_bound) == upper_bound and int(lower_bo...
fc65bf51152bfbb6d214118daea71430665a7f07
iamlmn/PyDS
/algos/patterns/twoPointers/minWindowSort.py
1,848
4.25
4
# Minimum Window Sort (medium) # # Given an array, find the length of the smallest subarray in it which when sorted will sort the whole array. # Example 1: # Input: [1, 2, 5, 3, 7, 10, 9, 12] # Output: 5 # Explanation: We need to sort only the subarray [5, 3, 7, 10, 9] to make the whole array sorted # Example 2: # I...
a4d2bd1eb7b6faf32ef724468b3be4b191ba8d10
scottgallacher-3/pyinterpolate
/pyinterpolate/idw/idw.py
2,224
3.765625
4
import numpy as np from pyinterpolate.distance.calculate_distances import calc_point_to_point_distance def inverse_distance_weighting(known_points, unknown_location, number_of_neighbours=-1, power=2.): """ Function performs Inverse Distance Weighting with a given set of points and an unknown location. IN...
762ceac193dadc9dedda904438bd7170552ca74f
dizdiz/leetcode_solutions
/144_Binary_tree_preorder_traversal/solution_Morris_Traversal.py
1,024
4
4
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # @param root, a tree node # @return a list of integers def preorderTraversal(self, root): #using Morris Traversal ...
2ac3f7cf51b45fff8dca9764e99629754c0541d3
MRbaiyh/package
/代码/4.py
315
3.5625
4
import sys print(type(sys.path)) print(sys.path) class Parent(): x = 4 y = 5 def sum(self, a, b): self.z = a + b print("求和结果为:{0}".format(self.z)) class son(Parent): def f(self): print(self.x+self.y) a = input() b = input() t = son() t.sum(int(a),int(b)) t.f()
f5ad9cdf8d97bbf3b0732cfd05655669b21aa381
vovagusse/stuff
/gridmovementplan.py
1,364
4.53125
5
print(''' 1)Tuples with "_" as empty space and a * as a player 2)Def's. A lot of them. to go right, left, up, down 3)Input number "n" is making the grid "n" by "n" steps, each step represents a part of a tuple. So to make it i should set the 1st tuple's 0th digit equal to "*" and the 1 to n-1 digit equal to "_" ...
9997f714daf4ac55c98c46ce875b72220cebb08f
Aruilcrude/Aruil
/untitled1/推导式/集合/lenx.py
65
3.625
4
lenx = {xue for xue in range(2,8) if xue % 3 ==1} print (lenx)
4c85ec7ab5f312b954c090156c68dac7757636d1
VoTonggg/nguyenvanhung-fundamental-c4e18
/Session03Homework/sheep_flock.py
1,005
3.921875
4
size_list = [5, 7, 300, 90, 24, 50, 75] print("Hello, my name is Hiep and these are my ship sizes") print(*size_list, sep=', ') biggest = max(size_list) print("Now my biggest sheep has size", biggest, "Lets shear it") position = size_list.index(biggest) size_list[position] = 8 print("After shearing, here is my floc...
12b609f6f41b3b78b3f95f59ba6254bde5bf6d0a
Vk-Demon/vk-code
/ckbegs872.py
268
3.8125
4
vstr=input() cv=0 for i in range(0,len(vstr)): if(vstr[i]=="a" or vstr[i]=="e" or vstr[i]=="i" or vstr[i]=="o" or vstr[i]=="u" or vstr[i]=="A" or vstr[i]=="E" or vstr[i]=="I" or vstr[i]=="O" or vstr[i]=="U"): cv=cv+1 if(cv>0): print("yes") else: print("no")
0dfbd54fd9cb1aa9cc32aeda7102dca362f529f3
nick-tala/p18234
/asksi1.py
1,396
3.796875
4
from array import * import random print('askisi 1') #create matrix with zeros matrix = [[0 for i in range(10)] for j in range(10)] #print matrix with zeros for r in matrix: for c in r: print(c,end = " ") print() #set matrix with random zeros and ones for i in range(10): for j i...
207ed82ea4db5cf97700626c5ee22d86f93f7fdb
pdecks/lpthw
/ex41.py
2,651
4.1875
4
# Learn Python The Hard Way: Exercise 41 - Learning to Speak Object Oriented import random from urllib import urlopen import sys WORD_URL = "http://learncodethehardway.org/words.txt" WORDS = [] # define key/phrase pairs # %%% --> class # *** --> instance, function ('other') # @@@ --> parameter PHRASES = { "class %%...
1f9d4cc9ff531bd990bb96eff8de494f99ba216d
Adelina360/Python_Projects
/Problem Solver/Python/Cycles 8.py
190
3.828125
4
#la suma de los primeros n números n = int(input('Ingrese un número: ')) suma = 0 for i in range (1, n +1): suma = suma + i print('La suma de los n números hasta ',n,'es',suma)
6830949073606b8c5f9e2e97413228119ee74ed2
jadikerjadiker/firstworkspace
/LateNights/BasicDeck.py
1,916
3.546875
4
import random ''' Ranks: 2 3 4 5 6 7 8 9 10 J Q K A Kind: D H C S ''' class Card(): ranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'] values = {} #set the values of the ranks based on the order of the ranks in the list above. for index, val in enumerate(ranks): values[index] = val k...
c5c7c31a6c58a44b90caf225b6536b525cf9d0ad
Acinate/python
/leetcode/387_first_unique_character.py
546
3.5625
4
import collections import unittest class Solution: def firstUniqChar(self, s: str) -> int: # Build a hashmap that contains the count of every char in string s count = collections.Counter(s) for idx, ch in enumerate(s): if count[ch] == 1: return idx retu...
bbae9333edd75b90742c6cf685901bfa08d7bb75
LucianoUACH/IP2021-2
/PYTHON/Clase13/matriz.py
703
3.859375
4
if __name__ == "__main__": filas = 4 columnas = 3 suma = 0 M = [None] * filas for fila in range(filas): M[fila] = [None] * columnas for fila in range(filas): for columna in range(columnas): print("Ingrese un valor [" + str(fila) + ","+str(columna) + "]: ") ...
65a4b226be8a93f4d1c8d37e24b3456a3d0e1529
hossainlab/PY4B
/book/_build/jupyter_execute/notebooks/LIVE! Coding.py
3,800
3.734375
4
12/33 seq1 = 'ATGGACCAGATATAGGGAGAGCCAGGTAGGACA' seq2 = 'ATNGACCAGATATTGNGAGAGCCGGGTAGGACN' # length len(seq1) len(seq2) print("No. of A: ", seq1.count("A")) print("No. of T: ", seq1.count("T")) print("No. of G: ", seq1.count("G")) print("No. of C: ", seq1.count("C")) print("RF. of A: ", seq1.count("A")/len(seq1)...
377bc6acefc0112ccf86528e576c8a712da8759a
baradist/udacity-technical_interview
/collects/linked_list.py
2,998
4.03125
4
class Element(object): def __init__(self, value): self.value = value self.next = None self.previous = None class LinkedList(object): def __init__(self, value=None): self.first = None self.last = None self._size = 0 if not value == None: sel...
38c67b86c8274378e92e2f405a9cf80a7126ce4f
R-Llewellyn96/Python-4HourTutorial
/venv/Tut5.py
1,735
4.46875
4
#Welcome to Python Tutorial 5! #Lists in Python (Arrays) #You can mix data types in an array in python if you want! friendsList = ["Alice", "Bob", "Caitlin"] #You can access array elements based on their index print(friendsList[0]) #you can also access array elements from reverse by using negative values print(frie...
e4aac10a720987e6129c1f192097f7c32943b5c1
cuiboautotest/learnpython3
/16_class/class_5.py
722
4.0625
4
class BoyFriend(object): # 类属性 height = 175 money = 20 age = 25 name = '周杰伦' ''' 定义类方法 什么时候去定义类方法? 1.如果你想直接通过类名.函数名调用 2.方法跟属性没有直接的关联 3.当有初始化函数可以直接定义为类方法 ''' # 装饰器 @classmethod def cooking(cls): # cooking用不到上面的类属性 print('会做饭') @staticmethod ...
c8c4c4039fc90c1c169b5fe02deda77eb3f5cd5f
whitepaper2/data_beauty
/leetcode/062_unique_paths_withobstacles.py
2,238
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/12/5 下午2:21 # @Author : pengyuan.li # @Site : # @File : 062_unique_paths.py # @Software: PyCharm from typing import List def unique_paths_with_obstacles(obstacleGrid: List[List[int]]) -> int: """ note: 大问题拆分为子问题,矩阵表示与常规正好相反 动态规划,机器人只...
dddbb1d123b1440890289561f23b29278fd85ab4
TGITS/programming-workouts
/exercism/python/grade-school/grade_school.py
554
3.640625
4
class School: def __init__(self): self.students_by_grade = {} def add_student(self, name, grade): if grade not in self.students_by_grade: self.students_by_grade[grade] = [] self.students_by_grade[grade].append(name) def roster(self): return [student for...
e50a561324442c18e2165d4758371f0b0bd608c4
mireiagasco/Calculadora
/class_calculadora.py
5,631
3.6875
4
from tkinter import * import tkinter.messagebox #classe que genera una finestra tkinter amb aparença de calculadora class Calculadora: def __init__(self): self.reiniciar = False #creem la finestra self.finestra = Tk() self.finestra.title("Calculadora") ...
534ba455b7be545835aa91e721ce126eb01459b2
schappidi0526/IntroToPython
/5_Whileloop.py
374
4.03125
4
user_floor=6 current_floor=0 while user_floor!='exit': difference=user_floor-current_floor if difference>0: print ('Move up') elif difference<0: print ('Move down') elif difference==0: print('Open the door') current_floor=user_floor user_floor=input() if u...
a1e02dd9d3fb2b8c417274ec67c03f5e9e7986c0
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/jesse_magat/Lesson03/mailroom.py
833
3.9375
4
donors = [ ["Michael Jordan", 500.00, 1, 500.00], ["Jeff Bezos", 877.33, 1, 877.33], ["Bill Gates", 653784.49, 2, 326892.24], ["Mark Zuckerberg", 16396.10, 3, 5465.37], ["Paul Allen", 708.42, 3, 236.14] ] def menu(): return input( "\nSelect an option number:" "\n1. Send a Tha...
ac84cc6fb67ae4c2e64ba2067e1f69818e1d7ca4
SoulDuck/cntk
/input_solar.py
4,116
3.515625
4
import os import pandas as pd import numpy as np from urllib import urlretrieve def generate_solar_data(input_url, time_steps, normalize=1, val_size=0.1, test_size=0.1): """ generate sequences to feed to rnn based on data frame with solar panel data the csv has the format: time ,solar.current, solar.total ...
133788e5734025dd2e5f065aba92a61d14d56b66
xinmu01/python-code-base
/Data_Structure_and_Algorithm/Graph/Graph_class.py
1,955
3.734375
4
class Vertex: def __init__(self,key): self.id = key self.connectedTo = {} def addNeighbor (self, nbr, weight = 0): # nbr is a vertex object self.connectedTo[nbr] = weight def __str__(self): return str(self.id) + " connected to " + str([x.id for x in self.connectedTo]) def...
1c10f9fbf1bcf6072d4c6c1e85eb0ef6ba57444a
Sky-zzt/lintcodePractice
/pythonAlgorithm/twopointer/Two Sum - Closest to target.py
1,033
3.625
4
class Solution: """ @param nums: an integer array @param target: An integer @return: the difference between the sum and the target 给定整数数组num,从中找到两个数字使得他们和最接近target,返回两数和与 target 的差的 绝对值。 Example 样例1 输入: nums = [-1, 2, 1, -4] 并且 target = 4 输出: 1 解释: 最小的差距是1,(4 - (2 + 1) = 1). 样例2 输入: nums = [-1, ...
76c3f41abc8942342b3d23546c9bfcaf7297d18a
msjozwiak/Udemy_The_Modern_Python3
/week_generator.py
3,492
4.4375
4
# EX1 ''' days = week() next(days) # 'Monday' next(days) # 'Tuesday' next(days) # 'Wednesday' next(days) # 'Thursday' next(days) # 'Friday' next(days) # 'Saturday' next(days) # 'Sunday' next(days) # StopIteration Remember - Generator functions returns a generator. Generator is an iterator. ''' def week(): days_o...
758f2f232711a76d3fdf727691caee2708398103
diogohxcx/PythonCemV
/desafio012.py
515
3.953125
4
#print('Feito por mim') #valor = float(input('Qual o valor do produto?')) #desc = valor * 5/100 #total = valor - desc #print('Com desconto de 5% você economiza {:.2f}'.format(desc)) #print('O produto que custava R${}, agora custa R${:.2f}.'.format(valor, total)) print('Feito pelo professor') preco = float(inpu...
c4d51f9af058d40b0c78ad73eb09862bbc24b77d
shuledelizi/miao
/绘制各种图形+基于最小矩形的重叠算法.py
6,041
3.609375
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 24 08:30:03 2019 @author: 薛 """ import matplotlib.pyplot as plt import numpy as np import math pi = 3.1415 cos = math.cos sin = math.sin def rotation_matrix(rotation): R = rotation matrix = [[cos(R),-sin(R)], [sin(R), cos(R)]] return np.array(ma...
d58598e31ecda8dffa71f40f2ca76faf432c45f1
srdonovan/decisionAnalysis
/decisionAnalysis.py
1,276
3.71875
4
class Stock: def __init__(self,ticker,name): self.ticker = ticker self.name =name class Transaction: def __init__(self,stock,tranDate,tranType,shares,amount,cost): #stock - the stock involved in the transaction #date - the date of the transaction #type - The type of the transaction - buy or sell #share...
8871983a17415c96bbabcebf12f930153a7279a1
Jakub71/kody
/2 klasa/python/potegi.py
431
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # potegi.py # def potega_it(a, n): wynik = 1 for i in range(n): wynik = wynik * a return wynik def main(args): a = int(input("Podaj liczbe: ")) n = int(input("Podaj wykladnik potegi: ")) print("{} do potęgi {} wynosi {} ". format(a, ...
10bb78bd28a4314459180a89f59e29ba70510183
Lycurgus1/python
/OOP/Calculator exercise/Subtraction.py
225
3.734375
4
from Addition import Addition class Subtraction(Addition): # Intialising the class def __init__(self, num1, num2): super().__init__(num1, num2) def subtraction(self): return self.num1 - self.num2
854b4db1463f515edbf836a070d282c5133df0c6
inu-noob-capstone/banana-storage
/LightControl/test.py
140
3.65625
4
while True: a = input('첫 번째 숫자를 입력하세요: ') b = input('두 번째 숫자를 입력하세요: ') print(a+b)
a937461f72e07baf17c916788f59605fad382ad9
KonstantinAlxVlasenko/san_report_automation
/utilities/dataframe_operations/dataframe_presentation.py
3,458
3.96875
4
"""Module with auxiliary functions to perform operations on DataFrames to change it's presentation (slice, move columns). All operations on DataFrame which don't add data to existing columns, create new columns with processed data or create new DataFrame""" import re import pandas as pd def dataframe_slice_concaten...
f420b329651777d6cc713a6074f0bce113415d17
doom2020/python-javascript
/link_table.py
7,372
3.828125
4
""" 简单的单链表 循环链表: 尾部(next)指向首部 双向链表: 相互之间指向 双向循环链表 """ class Node(object): def __init__(self, data): self.data = data self.next = None class SimpleLink(object): def __init__(self): self.head = None def is_empty(self): return self.head is None def l...
0884f07614f64fd5edde14583a39f0e4e3515b4f
ladosamushia/PHYS639
/Pendulum/pendulum_pjtheriault (3).py
4,927
4.3125
4
# coding: utf-8 # In[1]: #Written by Paul Theriault #The purpose of this program is to simulate pendulum motion import numpy as np import math import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') #Problem I: Simple Pendulum a = float(input('Please input a launch angle in degrees be...
287cf1a43190445ff6faf67c0c19804854b94c67
Yuvv/CSES
/introductory-problems/012-palindrome-reorder.py
1,065
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @File : 012-palindrome-reorder.py # @Date : 2021/06/22 # @Author : Yuvv <yuvv_th@outlook.com> def solve(ss: str) -> str: ch_set = set() ch_list = list() for c in ss: if c not in ch_set: ch_set.add(c) else: ch_lis...
228509847ab90fea172b0c7b3206017007b54f6e
macantivbl/Python
/Generadores/Fibonachi.py
234
3.59375
4
def fib(n): a = 0 b = 1 for i in range(n): yield a temp = a a = b b = temp + b print(list(fib(32))) x = fib(100) print(next(x)) print(next(x)) print(next(x)) print(next(x)) print(next(x))
83cb5c33314ec80d14cfed618c701ae2ff85e570
Merical/education_ai
/lesson5/binary_search_and_simple_search.py
858
3.875
4
import time def binary_search(list, item): low = 0 high = len(list) - 1 while low <= high: mid = (low + high) // 2 guess = list[mid] if guess == item: return mid if guess > item: high = mid - 1 else: low = mid + 1 time.slee...
72855f663981b824b34563f492f7ee84edd7ac30
ThreeFive85/MyStudy
/python/basic_grammar/set.py
654
3.90625
4
# 집합 (set) # 중복 안됨, 순서 없음 my_set = {1, 2, 3, 3, 3} print(my_set) java = {"renerd", "ammy", "shellden"} python = set(["renerd", "penny"]) # 교집합 (java와 python을 모두 할 수 있는 개발자) print(java & python) print(java.intersection(python)) # 합집합 (java 또는 python을 할 수 있는 개발자) print(java | python) print(java.union(python)) # 차집합 (...
39593ddeecd7ff5d6f87f02fd68786c5dadb3f27
ccpromise/Code-Log
/Language/Python/t2.py
307
3.71875
4
import sys import t1 f = t1.fibonacci(10) while True: try: print(next(f), end=" ") except StopIteration: break print(sys.path) def f(x): x+=1 def g(x): x = x+"hello" def h(x): x = x.append([1,2,3]) x, y, z = 1, "s", [2,3,4] f(x);g(y);h(z); print(x);print(y);print(z); input("enter to quit")
e28c1f8da9810fac1dbc8915319c8046caf8e11c
alexruma/harvard-major-trends
/scraper_tools.py
2,764
3.65625
4
import requests from bs4 import BeautifulSoup def main_page_scrape(): """Scrapes Fields of Concentrations page and returns list of links to each concentration.""" url = "https://handbook.fas.harvard.edu/book/fields-concentration" page = requests.get(url) soup = BeautifulSoup(page.content, 'html.parser...
6a0abf80d0d062e8b598a994998e01e4861f5909
dagute/holbertonschool-web_back_end
/0x01-python_async_function/0-basic_async_syntax.py
298
3.6875
4
#!/usr/bin/env python3 """The basics of async""" import random import asyncio async def wait_random(max_delay: int = 10) -> float: """ waits for a random delay between 0 and max_delay""" random_num = random.uniform(0, max_delay) await asyncio.sleep(random_num) return random_num
8f1c0ee2f4d811ebb2c18033f3cdba421172a3ba
maxwab/comp767_a2
/test_env.py
880
3.515625
4
import numpy as np import gym env = gym.make('Pendulum-v0') # Printing information about the environment print('Size of the environment action space: {}'.format(env.action_space)) print('Size of the environment observation space: {}'.format(env.observation_space)) # Action space is 1 dimensional: this is the torque ...
f5d059391c120a0db2c19bd437d4253512edaa1f
PRKKILLER/Algorithm_Practice
/LeetCode/0025-Reverse Nodes in k-Group/main.py
1,372
3.953125
4
""" Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. Example: Given this linked ...
ed97da02606ee1b5f0112ea8d9e5caca97da3211
Ghasak/Motion_Fundamentals
/src/E7_BezierCurve.py
3,781
3.765625
4
""" bezier.py - Calculates a bezier curve from control points. https://www.pygame.org/wiki/BezierCurve 2007 Victor Blomqvist Released to the Public Domain """ import pygame from pygame.locals import * class vec2d(object): def __init__(self, x, y): self.x = x self.y = y gray = (100,100,100) lightg...
ccd0728252e7bb9f5622892d7851382d187ed536
noahmancino/DataStructureReview
/quicksort.py
545
3.75
4
def partition(nums, low, high): pivot = nums[high] i = low - 1 for k in range(low, high): if nums[k] < pivot: i += 1 smaller = nums[k] nums[k] = nums[i] nums[i] = smaller i += 1 nums[high] = nums[i] nums[i] = pivot return i def quickso...
d920ab43dfa73626c03d09c0fff413853b109c4a
ChenLaiHong/pythonBase
/test/leetcode/最长公共前缀.py
996
3.734375
4
""" 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 输入: ["flower","flow","flight"] 输出: "fl" 示例 2: 输入: ["dog","racecar","car"] 输出: "" 解释: 输入不存在公共前缀。 说明: 所有输入只包含小写字母 a-z 。 """ def longestCommonPrefix(strs): # w = input().split(",") # 记录列表中每个字符串的长度 length = [] for i in strs: length.append(len(i)...
cbf40822515ab7f7ae7c5beacd92fbaab875933b
gkaeso/exercism-python
/exercices/perfect-numbers/perfect_numbers.py
768
3.65625
4
def classify(number): return _classify(number) if number != 1 else 'deficient' def _classify(number) -> str: classif: str aliquot: int = _aliquot(number) if aliquot > number: classif = 'abundant' elif aliquot < number: classif = 'deficient' else: classif = 'perfect' ...
ccdcde42f9c52195ae81155820aa9b8bc85dedcf
roselijack/python-masterclass1
/blocks.py
247
3.90625
4
age = int(input("age:"))#输入的需要是整数,不然报错 if age >= 18: #>=是个算术运算符 print(age) elif age == 3: print("rose") else: print("please come back in {0} years".format(18-age))#format里可以是个表达式
fca47d8e4d31c327c6d9d838765795fb1faeb7cd
vasil-panoff/PYTHON-ADVANCED-SEPT-2020_repo
/PYTHON-ADVANCED-SEPT-2020/PYTHON OOP/07_SOLID/LAB/SOLID LAB/02_OCP/animal.py
882
4.125
4
from abc import ABC, abstractmethod class Animal(ABC): def __init__(self, species): self.species = species def get_species(self): return self.species @abstractmethod def make_sound(self): pass def animal_sound(animals: list[Animal]): for animal in animals: print(a...
0d390b4c4fd40eee49f5ac31b4b2eed7639105bf
j-3-1415/CoffeeBarSimulation
/Code/Customers.py
5,706
3.921875
4
################################################################################ # Part 2 of Python Final Project: Simulation of Coffee Drinkers # Group Partners: Andy Boomer and Jacob Pichelmann # This script introduces customer classes used in the subsequent simulation ################################################...
90d1835bee61205e8166f89bdd18264f8b245a5e
shreykuntal/My-other-Python-Programs
/programs/Force between two celestial bodies..py
433
3.8125
4
import math G=(6.7)*(10**-11) M=float(raw_input("Enter value of M(kg): ")) m=float(raw_input("Enter value of m(kg): ")) d=float(raw_input("Enter value of d(m): ")) F=(G*M*m)/(d**2) print "Force= ",F,"N" c=raw_input("Do you want to see what is meaning of e: ") if c.lower()=="yes": print "e=10^x.For example:...
83978f800c7f08f236dd20785cf43eeabd7a9855
JacAbreu/ProjetoEuler
/problem9_solucao_burra.py
316
3.6875
4
from math import * from itertools import * a = 3 for a in xrange(1, 1000): for b in xrange(a+1, 1000): c = 1000 - (a+b) legs = (a*a) + (b*b) hypotenuse = (c*c) if legs == hypotenuse: print "a*b*c = " +str(a*b*c)+" a ="+str(a)+" b ="+str(b) +" c ="+str(c) break
664349bd1917b3cb9564df384df3b30d4c6bd83b
vincentvancouver/dice_game
/dice_program.py
430
4.1875
4
def dice_roll(): import random if input('Would you like to roll the dice? y/n ') == 'y': while True: print('The dice says: ' + str(random.randint(1,6)) + '\n') if input('Would you like to roll again? y/n ') == 'y': continue else: print(...
ef43bd6f393d1f92d40f2cbeef2427b0fad08548
naitsric/credyty
/test.py
2,151
3.671875
4
import re class FromRandomCharactersGetPassword: def __init__(self, path): """ from a file this class discover a possible banking password. :param path: path file """ data = [line.rstrip('\n') for line in open(path, 'r')] # order data data.reverse() ...
3f0263a913a1ff33f8c32c2adf3f22bab60f0bfb
tsabz/python_practice
/exponent_function.py
255
4.3125
4
print(2**3) def raise_to_power(base_num, pow_num): result = 1 # store the result of doing the math for index in range(pow_num): #if pow num is 2 loop through twice result = result * base_num return result print(raise_to_power(2, 3))
80f22e56981551db6607dc8c247a6bbec31a1159
pratikdesai/learnpython
/ex05.py
697
3.578125
4
name = "Jet Pack" age = 66 height = 72 # inches weight = 230 # pounds eyes = "Hazelnut Brown" teeth = "White-ish" hair = "Salt n Pepper" # unit conversion height_cm = height * 2.54 weight_kg = weight * 0.454 # %s, %d, %r are all Formatters print "Let's talk about %s." % name print "He's %r inches tall." % height prin...
172d329c033cd3168666b59c2894b7c72be47c0d
RandSinger1/TicTacToe-Project
/TicTacToeXL Neural Network/src/miniGame.py
3,217
3.75
4
''' Created on Jun 16, 2021 @author: Rand ''' # Assigns names for integers to avoid magic numbers PLAYER_X = 'X' PLAYER_O = 'O' EMPTY = ' ' PLAYER_X_VAL = -1 PLAYER_O_VAL = 1 EMPTY_VAL = 0 HORIZONTAL_SEPARATOR = '|' GAME_STATE_X = -1 GAME_STATE_O = 1 GAME_STATE_DRAW = 0 GAME_STATE_NOT_ENDED = 2 ROW_METHOD=0 COL_METH...
d3a967dce908204010e79b68bb7b7b26254d6573
Neftali56/Tarea_03
/Asientos.py
824
3.796875
4
#encoding: UTF-8 #Autor: Neftalí Rodríguez, A01375808. #Calcula el total a pagar por núm de asientos A, asientos B y Asientos C. #Calcula el pago total dependiendo el núm de asientos A, B y C. def calcularPago(asientosA, asientosB, asientosC): totalpago = ((asientosA * 400) + (asientosB * 250) + (asientosC...
efd3fd01fd90d41f11e680166caeb305f04ed8d2
ssak32/Tutotrials
/Python/Udemy_PythonCoreAdvanced/multithreading/bookmybus.py
1,011
3.53125
4
from threading import * class BookMyBus: def __init__(self, availableSeats): self.availableSeats = availableSeats self.l = Lock() #Lock approach for locking an object # self.l = Semaphore() #Semaphore approach for locking an object def buy(self, seatsRequested): self.l.acqui...
ccc138056e6b31eec8751752510b5b59ef45a782
Trip4077/Intro-Python-I
/src/16.1_sieve.py
931
4.21875
4
import sys import math def find_primes( last ): # Number Array valueRange = [ value for value in range(2, last+1) ] # Highest Value to Check Against highestValue = math.floor( math.sqrt( last ) ) for number in valueRange: # See if all required numbers have been checked if number > ...
ce91af0dd78453b6ed7f8802a44de3829712d81d
mahuanli/1807-2
/31day/01-机试住店.py
891
3.515625
4
import time import re list = [] class xuanze(): while True print("1,入住") print("2,离店") print("3,统计") print("4,退出") class D(): def __init__(self,name,phone) self.name = name self.phone = phone self.list = [] self.money = 0 def ruzhu(self.people): people.time = int(input.time()) people.islive = Tr...
16ca9f72daa70610f5877f52d40e65e9d06c9e08
IraqiZakaria/crypto-orders
/check_connection.py
712
3.546875
4
import socket import time def is_connected(): """ https://stackoverflow.com/questions/20913411/test-if-an-internet-connection-is-present-in-python """ try: # connect to the host -- tells us if the host is actually # reachable socket.create_connection(("www.google.com", 80)) ...
7fcb80208e887e47dca179a97aa9ff122b085247
ivo-bass/SoftUni-Solutions
/programming_basics/EXAM_PREPARATION/3_easter_trip.py
342
3.875
4
destination = input() dates = input() nights = int(input()) prices = { "France": {"21-23": 30, "24-27": 35, "28-31": 40}, "Italy": {"21-23": 28, "24-27": 32, "28-31": 39}, "Germany": {"21-23": 32, "24-27": 37, "28-31": 43} } total = nights * prices[destination][dates] print(f"Easter trip to {destination} ...
108a610687980dbaf3bda30ca84f6f0e5e56c859
kyon1920/Python
/Python-语法基础/基本输入和输出.py
790
3.984375
4
# 基本输入和输出 # 输入:在键盘上输入、输出:在屏幕上输出 # 输入 # variable = input("提示输入提示") tip = input("请输入文字:") # 如果需要的其它数据类型,则需要强制数据类型转换 print (tip) print (type(tip)) # 输出 # print (输出内容) 基本输出函数,输出内容可以是数字、字符串、表达式 a = 10 b = 6 print ("数字:" , 6) # “,”将输出放在一行,不过系统会自动加上一个空格 print ("表达式a*b:", a*b) print ("字符串:", "快乐学习,快乐成长!"...
d9f6f19995532092a561b7c06ada0a833a8dffcd
TomaszSzyborski/Python_Basics
/Tortoise/tortoise.py
1,992
3.71875
4
import turtle import urllib.request from PIL import Image def download_grass_pic(image_name): """ Downloads grass image from photobucket and saves as @image_name""" url = "http://i171.photobucket.com/albums/u288/ilybbygrlx3/grass.gif" urllib.request.urlretrieve(url, image_name) def resize_image(...
c3cc64e4062bbe89f0951f29bbecbc0dbe5a3a51
cerealito/replicate
/src/replicator/logger.py
1,106
3.53125
4
import logging from logging import FileHandler, StreamHandler, Formatter def configureOutput(logger_p, path='./Log.txt'): """ configures the logging """ # if no handlers have been configured... if 0 == len(logger_p.handlers): # let everything pass by default log...
b24e249ee9adc34f7e81da11a0e57ace3cb5f329
Aasthaengg/IBMdataset
/Python_codes/p03265/s613980258.py
285
3.609375
4
from collections import defaultdict def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() x1,y1,x2,y2 = readInts() dx = x2-x1 dy = y2-y1 print(x2-dy,y2+dx,x1-dy,y1+dx)
33b7d0c664ab85412379f20ec06d049b029a470f
ChrisFloresM/Coding-Python
/Python_Crash_Course/Chapter_6_Dictionaries/glossary.py
327
3.609375
4
#Christian Flores 10/02/2021 glossary = {"Dog": "Men's best friend", "Cat": "Men's best partner", "Bird": "Men's best pana"} for k, v in glossary.items(): print(f"{k}: {v}") glossary["fish"] = "Men's best water friend" glossary["mosquito"] = "Men's worst enemy" print("\n") for k, v in glossary.items(): pr...
a44e6b6e36f5653998846781a4f894662dd0a000
MarehanRefaat/HackerRank_Solutions
/10 Days of Statistics/Day 9: Multiple Linear Regression/solution.py
677
3.6875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT from sklearn import linear_model def pre(x, y, x_pred): lm = linear_model.LinearRegression() lm.fit(x, y) y_pred = lm.predict(x_pred) return y_pred def main(): n,m= map(int,input().strip().split()) x=[] y=[] for i in range(m)...
bc15dbfc90e22e00c3c2bb2c8c9bfb9a46bbaaf1
laiqjafri/LeetCode
/problems/geeksforgeeks/circle_lattice_points.py
759
4.4375
4
# Circle and Lattice Points # Given a circle of radius r in 2-D with origin or (0, 0) as center. The task is to find the total lattice points on circumference. # Lattice Points are points with coordinates as integers in 2-D space. # # Example: # # Input : r = 5. # Output : 12 # Below are lattice points on a circle wit...
a2764d5f53569911eb5b427bf23f98bcda025901
andrewlee224/algorithms-part2
/week1/scheduling.py
1,512
3.875
4
""" Greedy algorithm for minimizing the weighted sum of completion times. Implemented versions with two scoring functions: w_i - l_i (suboptimal) and w_i/l_i (optimal) """ def score1(w, l): return w - l def score2(w, l): return w/float(l) def loadData(fName): with open(fName, 'r') as fileObj: ...
c10f6a38cd02e7fd828567cab1690c4d0fadd043
pacocp/Cracking-the-Coding-Interview
/ArraysandStrings/question1-5.py
1,130
3.921875
4
'''Question 1.5 @author: Francisco Carrillo-Perez ''' def check_change(string1, string2): diff = False for i in range(len(string1)): if string1[i] != string2[i]: if diff: return False else: diff = True return True def check_insert(string1, ...
9618dae91ab5619a77c135952bc7f7a8b90a42a4
jorvis/biocode
/sandbox/jorvis/calculate_feature_coverage.py
5,205
3.578125
4
#!/usr/bin/env python3 """ Reads one or more evidence files and reports coverage information for user-chosen feature types in a GFF3 file. This allows you to answer, as an example, the following question, "What is the coverage of all mRNAs in my source GFF3 file given a set of reference annotations (gff3), aligned re...
5856297500a1ba2582ba8156771889352b1c3c31
littlefattiger/My_LC_solution
/python/by_tag/binary_search/1818. Minimum Absolute Sum Difference.py
1,178
3.78125
4
# You are given two positive integer arrays nums1 and nums2, both of length n. # The absolute sum difference of arrays nums1 and nums2 is defined as the sum of |nums1[i] - nums2[i]| for each 0 <= i < n (0-indexed). # You can replace at most one element of nums1 with any other element in nums1 to minimize the absolute...
fd6f9669dfb470d9080a45747101a4353f7a66d1
aaronyong/hello-world1
/bubear.py
127
3.578125
4
print("hello bububear") for i in range(8): print(i) print("hello world, Aaron has joined the team") detox = 1 babyboy = 2
15f60bc0546bd76b1240cf70b35a5d6075c104df
Swathi-N-Shayana/CodeDump-Python
/day2.py
497
4.375
4
#Task #Given an integer,n , perform the following conditional actions: #If n is odd, print Weird #If n is even and in the inclusive range of 2 to 5, print Not Weird #If n is even and in the inclusive range of 6 to 20, print Weird #If n is even and greater than 20, print Not Weird n = int(input()) if (n%2 ==1): ...
625f685de150ad941fab73f25072ddaecac8e8df
spetz911/delme-temp
/floyd_warshall.py
2,003
3.609375
4
import sys def recover_path(path, n, step, i, j): """ Use paths matrix to recover negative cycle """ ans = [0] * (step + 1) ans[step] = i+1 while step: ans[step-1] = path[i][j][step] + 1 j = path[i][j][step] step -= 1 return ans + [j+1] def resolve_internal(g, path): ...
7e783f16641f1e5ee6448fc9f378f8b2a61fb447
karanjakhar/python-programs
/prac 5.py
2,242
4.1875
4
print("write the program to demonstrate the use of creation and accessing of list and apply different kinds of operations on them") print("1.Program to create and access list") print("2.Progrm to demonstrate various list operation") print("3.Program to demonstrate the use of functions and methods") print("4.program...
ac73ce03956333cc307733c54443b612c013d6c8
krystal199/GeekBrainsBA
/Homework01/Task03.py
265
3.671875
4
n = int(input("Введите число >>> ")) number = n count = 0 nn = number while nn: nn //= 10 count += 1 row_one = (10 ** count) + 1 row_two = (10 ** (count * 2)) + row_one result = number + (number * row_one) + (number * row_two) print(result)