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
eb411cf008c254763e381e25be388f73e3974de0
antigvozd/hh_school
/task2.py
7,859
3.78125
4
def search_index(num): minim = 0 index = 0 for i in range(1, len(num)+1): # прорабатываем все возможные распределения по разрядам if i == len(num): # если длина разряда равна длине подпоследовательности num1 = [int(x) for x in num] a...
4c6e4e2a24d879f99b9d385f4224f1d719acc230
majdjamal/manifold_learning
/models/isomap.py
1,513
3.515625
4
"""isomap.py: Isomap, used for dimensionality reduction and to capture manifold. """ __author__ = "Majd Jamal" import numpy as np import matplotlib.pyplot as plt from scipy.sparse.csgraph import shortest_path from scipy.spatial import distance_matrix from models.mds import mds class Isomap: """ Isomap """ def...
ecd4ab2e73dfd487f8b33c681b7790608e1eafcc
yeboahd24/Python201
/PYTHON LIBRARY/collections_deque.py
512
3.75
4
import collections # in a list operation # d = collections.deque('abcdefg') # print('Deque:', d) # print('Length:', len(d)) # print('Left end:', d[0]) # print('Right end:', d[-1]) # d.remove('c') # print('remove(c):', d) # Add to the right. d1 = collections.deque() d1.extend('abcdefg') print('extend...
eb7d3b3358b6780a073af11ebca422ddb68a08da
flyfatty/PythonTutorial
/leetcode/array_dict/1365.py
1,044
3.578125
4
# @Time : 2020/10/26 9:26 # @Author : LiuBin # @File : 1365.py # @Description : # @Software: PyCharm """有多少小于当前数字的数字 关键字: 数组 思路: 方法1、预置数组 方法2、排序 """ from typing import List class Solution: def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: dic = [0] * 101 for n in nums: ...
660ac067a3feb2a5319ee24f2b7864093ca24ec4
Patrick1ruls/Bouncy-Ball
/SpaceInvadersTutorial/SpaceInvaders.py
6,259
3.609375
4
# Space Invaders # Set up the screen import turtle import os import math import random # Global variables # Set up the screen wn = turtle.Screen() wn.bgcolor("black") wn.title("Space Invaders") wn.bgpic("space_invaders_background.gif") # Image must be in same folder as code (Not ready yet) # Register player and enemy ...
dcea4ac71d772c590a21b02f07088111dd16773f
Thilagavathycse/assignment1
/break_statement.py
285
4.28125
4
"""break This statement used to exit or break the loop,It brings the control out of the loop,if there is nested loop,it breaks the inner most loop then proceed with the outer loop""" for val in "break": if val == "e": break print(val) print("The end recehd at :",val)
b702de49acc7382a7c45e9691b39990a03a59082
liupy525/LeetCode-OJ
/39_Combination-Sum.py
1,257
3.59375
4
#!/usr/local/env python # -*- coding: utf-8 -*- ''' Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unlimited number of times. Note: All numbers (including target) will be positive int...
2669204f72191d909892a06ee07a445979668abd
Alokaraj/ML
/Artificial_neural_network/ANN_on_bank_DS.py
4,067
4.09375
4
# Artificial Neural Network #predicting the customer's gonna leave the bank or not according to the dataset # Part 1 - Data Preprocessing # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Churn_Modelling.csv') print(dataset...
7e7b13cc713a73b93b9922fa4890545534bec49f
Pasquale-Silv/Improving_Python
/Python Programming language/DataCampPractice/Corso_CISCO_netacad/modules/platform_module/m9_platform.py
939
3.625
4
""" But sometimes you want to know more - for example, the name of the OS which hosts Python, and some characteristics describing the hardware that hosts the OS. There is a module providing some means to allow you to know where you are and what components work for you. The module is named platform We'll show you some ...
b7318897d7956099fb3052089445f7e21ca6478c
imn00133/algorithm
/BaekJoonOnlineJudge/CodePlus/800DivideAndConquer/Main/baekjoon_10815.py
1,252
3.640625
4
# https://www.acmicpc.net/problem/10815 # Solved Date: 20.05.21. import sys read = sys.stdin.readline def search(cards, number): left = 0 right = len(cards) - 1 while left < right: mid = (left + right) // 2 if cards[mid] < number: left = mid + 1 else: right...
da745d258fe9ba4373705fc60a6b54db86d9e202
JuanmaVU-Dev/JuegoLaberinto
/Laberinto.py
772
3.75
4
""" Laberinto representa la clase principal del juego """ class Laberinto: def __init__(self): self.habitaciones = []; self.i = 0 # Metodos # Se añade una habitación def agregarHabitacion(self, hab): self.habitaciones.append(hab) # Se entra a la primera habitacion de la...
fe653741023249b637051407ae42fd5977682ba4
Ash25x/PythonClass
/triangle9-23.py
668
4.3125
4
#make function with 3 parameters #use if statement and or statements #print result #use else and print #call function and assign values to test it # # def tricheck(x, y, z): # if (x > y + z) or (y > x + z) or (z > x + y): # # print("You can't make a triangle") # # else: # print("You can make a ...
b07d47fcfea3842b65d808f486e9cda4ddee4336
Programmer-Foundation/python_codes
/calculatorbyme.py
3,401
3.75
4
from tkinter import * #importing tkinter module fvalue = "" def click(event): #defining applicable function global fvalue text = event.widget.cget("text") if text == "=": """when = is pressed the expression will be evaluated """ if fvalue.get().isdigit(): ...
1ae504c7ec4f1133f5c19c6824d06ea20b5b8566
tychtych/Python-for-everybody
/math/pay_chapter4.py
283
3.921875
4
def computepay (hrs, r): if hrs <= 40: pay = hrs * r return pay elif hrs > 40: pay = 40 * r + (hrs-40) * 1.5 * r return pay hrs = input("Enter Hours:") h = float(hrs) rate = input ("Enter Rate:") r = float(rate) p = computepay(h, r) print (p)
0cc1374192a54581592891074f0c8c31c6d79b29
vitorsemidio-dev/curso-python-guanabara
/Desafios/Aula 017/ex080.py
371
3.65625
4
from random import randint numeros = [] for i in range(5): index = 0 x = randint(0, 20) print(x, end=" ") if not len(numeros): numeros.append(x) continue for i in range(len(numeros)): if x < numeros[i]: break index += 1 numeros.insert(in...
f6bb6905594d50aae22195354b40c2b062562953
yeyifu/python
/test/mypy01.py
1,427
3.65625
4
''' a = "我叫{0},今年{1}岁" print(a.format('yyf','23')) print("{:*^10}".format('123')) ''' # a = input("请输入一个数:") # if int(a) < 10: # print("{0}<10".format(a)) # else: # print("{0}>10".format(a)) ''' a = input("输入一个数字:") print("小于10") if int(a) < 10 else print("数字大于10") ''' # score = int(input("请输入你的考试分数:")) #...
ace7b73ccb4986a334cfd5fb413c6b39b8df1dc9
AlgorithmDuo/Algorithm
/BOJ/Python/Practice/2장/02-Q7.py
84
3.515625
4
a = ['Life', 'is', 'too', 'short'] print(a[0] + " " + a[1] + " " + a[2] + " "+a[3])
3ea01bb147188f8ccfa4308c6f15aa02f68ac520
moshekagan/Computational_Thinking_Programming
/frontal_exersices/recitation_solutions_4/ex2.py
263
4.0625
4
dec_number = int(input("Enter a decimal number: ")) bin_number = "" while dec_number > 0: if dec_number % 2 == 0: bin_number = "0" + bin_number else: bin_number = "1" + bin_number dec_number = int(dec_number / 2) print(bin_number)
d83f2db7d73829968ecbdf1fe2cfc260ff8818e9
DIas-code/ICT_2021
/Task2/2.py
854
3.796875
4
year=int(input()) m=month=int(input()) d=day=int(input()) print("Date is: ",year,"-","%.2u"%month,"-","%.2u"%day) if year%4==0 and m==2 and d==29: print("Next days date is: ", year,"- 03 - 01") elif year%4==0 and m==2 and d==28: print("Next days date is: ", year,"- 02 - 29") elif year%4!=0 and m==2 and d==2...
c95bddce494d01d88edc92f39741a7aa7a679c97
itsolutionscorp/AutoStyle-Clustering
/assignments/python/wc/src/532.py
220
3.984375
4
def word_count(sentence): word_list = {} for word in sentence.split(): if word not in word_list: word_list[word] = 1 else: word_list[word] += 1 return word_list
947bcaf434f81b8a476ba38b691b826b2a307731
DEEPTHA26/python6.1
/54.py
71
3.65625
4
modi=int(input()) if(modi%2==0): print(modi) else: print(modi-1)
d6e88c9cb2688261c61a4b8e3cbb353216084560
shoumu/HuntingJobPractice
/leetcode/74_search_2d_matrix.py
1,359
3.671875
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- # Author: shoumuzyq@gmail.com # https://shoumu.github.io # Created on 2016/3/9 14:50 class Solution(object): def searchMatrix(self, matrix, target): """ :type matrix: List[List[int]] :type target: int :rtype: bool """ ...
02f81f73a56198f6b5573516f59f556b21a6ca01
valletw/aoc
/2019/day12.py
3,409
3.5
4
#! /usr/bin/env python3 import argparse import math import re class Day12: """ Day 12: The N-Body Problem """ def __init__(self, input_file): self.moons_init = [] self.moons = [] self.velocities_init = [] self.velocities = [] self.steps = 1000 self.process(input...
82bb1f6b51bebf481a551afc4f4113446453afa4
fanxiao168/pythonStudy
/AIDStudy/01-PythonBase/day14/exercise05.py
251
3.625
4
# 实现字符串的减法操作 # '123456' - '123' = '456' # '123456'.replace('34','') class Str01(str): def __sub__(self, other): return self.replace(other, "") # str(1234)--> '1234' s1 = Str01(123456) s2 = Str01(123) print(s1 - s2)
7f262c239659a7bc67048b7d88ad9890d6592260
9aa9/tabling
/tabling.py
730
3.5625
4
''' $ Email : huav2002@gmail.com' $ Fb : 99xx99' $ PageFB : aa1bb2 ''' def TABLING(lines): num = len(max(lines)) nums = [0 for i in range(num)] for line in lines: for a in range(len(line)): if len(line[a]) > nums[a]:nums[a] = len(line[a]) for a in range(len(lines)): lines[a]...
50f6f88b619a073b607be18c6fa404aaa70333de
moncadajohn/python
/excepciones_III.py
798
4.03125
4
import math """def evaluaEdad(edad): if edad<0: raise typeError("No se permiten edades negativas")##está saliendo error if edad<20: return "you are very young" elif edad<40: return "you are young" elif edad<65: return "eres maduro" elif edad<100: return "cuida...
a85dfdfa15b71a94913ba949f0eb5f5034f45378
amadev/dojo
/single-number-ii.py
769
3.515625
4
def bin2(x): return bin(x)[2:].zfill(8) class Solution: # @param A : tuple of integers # @return an integer def singleNumber(self, A): ones = twos = threes = 0 n = len(A) for i in range(n): print 'A[i]', bin2(A[i]), A[i] twos |= ones & A[i] p...
321da9ba1dd0a434fa7a4d190ec2b9ba9b2cfa8b
raulcedres/ranked-based-voting
/VotingResultsUtility.py
1,586
3.703125
4
import random import csv class VotingResultsUtility: def generate_voting_results_csv(self, voters_amount, options): if voters_amount > 1 and options is not None and len(options) == 6: votes = [] for voter in range(voters_amount): result = random.sample(options, len...
babeaaab405d674a55c81e123595e07a4137ab5f
xVilandx/my_hillel
/HW11/HW11.py
889
3.546875
4
import json def read_file(file_json): with open(file_json, 'r') as json_file: return json.load(json_file) def sort_by_surname(list_authors): surname = list_authors['name'] if len(surname) > 1: surname = surname.split(' ') surname = surname[len(surname)-1] return surname def...
fba3af0cbea6bb4aa7b1fb0b5399bfb391d1d575
aolkin/splitgame
/tools/toollib/get.py
5,168
4.09375
4
import os QUESTION_ENDING = "? " FILLIN_ENDING = ": " DEFAULT_FORMAT = "{} [{}]" ## Holds a string for display and data class MenuChoice: def __init__(self, name, data): self.name = name self.data = data def __str__(self): return self.name class Top(Exception): pass class Ca...
644f02a3baf59d0ad63fc57b22bb277498f41a04
paolo-c/turing-arena
/04-higly_divisible_triangular/solution.py
415
3.65625
4
#w/o prime table def tri(n): return int(n*(n+1)/2) def add(v,n): for i in v: if n==i: return v v+=[n] return v def num_div(N,d=None): if d is None: d=[1] if N==1: return len(d) new=2 while N%new!=0: new+=1 newd=[] for i in d: newd+=[i] for i in d: add(newd,i*new) return num_div(N...
ad030dd9f322b772fa2c0e79712076699d56794d
karthi689/ML-Python
/Numpy/Vectors_matrices.py
1,360
3.859375
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 16 14:38:34 2020 @author: KarthikMummidisetti NumPy Operations """ """ Vectors and matrices """ my_list = [1,2,3] import numpy as np arr = np.array(my_list) print("Type/Class of this object: ", type(arr)) print("Here is the vector\n--------------------\n", arr) my_ma...
87754d706f3bac7cde0be9821ca86fd684ccd79b
rechelletandog/hello.python
/hello.python/hello.py
252
3.515625
4
print ("I am {}." .format("Rechelle Tandog")) print ("My spirit animal is {},because ." .format("Cat","they are so sweet")) print ("When not in school, I love to {}." .format("watch horror films")) print ("I dream being a {} in my future ." .format("Nurse"))
f5380083c8a01fc2ebaabc8b9542df56af1f6c52
zoheers/atm-solution1
/atm.py
972
3.5625
4
# allowed papers: 100, 50, 10, 5, and rest of request money = 500 request = 277 def ATM(request,money): if request <=0: print "shoud be positive number " elif money > request : money -= request while request > 0: if request>100 : ...
b84bd6f394f0fcf91e763d3be202bd8d99f2d942
crossmarien/TIL
/03weak3/day_7/choidegongyaksu.py
391
3.53125
4
#최대공약수 1 num1 = 20 num2 = 8 yaksu=0 number=[] while yaksu != min(num1,num2): yaksu= yaksu + 1 number.append(yaksu) cd1=[] cd2=[] assemblecd=[] for i in number: if num1 % i ==0: cd1.append(i) for i in number: if num2 % i == 0: cd2.append(i) for i in cd1: if i in cd2 : ...
edd9b8b1f15497f1dc1c246027a5c294cf9d0566
kevinmolina-io/GrokkingInterview
/Two_Pointer/tripletSumCloseToTarget.py
1,834
4.09375
4
def triplet_sum_close_to_target(arr, target_sum): """ HIGH LEVEL: This is a similar approach to triplet sum, with a little twist. You want to use a two pointer approach to solve it efficiently. Here's how it goes: Variables: closest_sum global_difference left, right...
c0b2a8f989dba3db19b85e0a66738f038fcb8f8a
Soundwavepilot1969/Udemy_Art_of_Doing
/Basics/buttons and grids.py
978
3.796875
4
#Buttons and Grids #Grid system for placement of widgets. Better than pack import tkinter root = tkinter.Tk() root.title('Buttons and Grids') root.geometry('500x500') root.resizable(0,0) name_button = tkinter.Button(root, text='Name') name_button.grid(row=0, column=0) #Rows and columns are defined on the fly time_b...
5931dd9a4234a1a5ed29bae87c2cd89623316b92
dartleader/Learning
/Python/How to Think Like A Computer Scientist/5/exercises/turtle_bar_chart_filler.py
1,099
3.953125
4
import turtle #Draw canvas, set attributes wn = turtle.Screen() wn.bgcolor("lightgreen") #Declare tess, set attributes tess = turtle.Turtle() tess.color("blue") tess.pensize(2) def draw_bar(t,h): """Draw a bar of height h using turtle t."""#Docstring t.pendown() #Put pen on canvas set_fill_colour(t,h) t.begin_fi...
fa3f53153a03d735671488bfa0ce85cf8718122b
akankshreddy/Kaustav-CSE-LABS-and-Projects
/Sem06-Distributed-Systems-LAB/WEEK 04/lab_exercises/q2_udp_client.py
469
3.5
4
#!/usr/bin/env python3 import socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) udp_host = socket.gethostname() udp_port = 12345 # msg = "My First UDP Client message !!" print("UDP target IP:", udp_host) print("UDP target Port:", udp_port) while True: msg = str(input("Enter message to send to serv...
85d62cdc372613ee5713aab5dc9761888b14edcb
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_135/3723.py
1,005
3.703125
4
def main(): T = int(raw_input()) i = 1 while T: arr_1 = [] arr_2 = [] ans_1 = int(raw_input()) insert_arr(arr_1) ans_2 = int(raw_input()) insert_arr(arr_2) answer = find_num(arr_1[ans_1 - 1], arr_2[ans_2 - 1]) if answer[0] == 0: ...
a360f233b868a100217b9fc7220839840f48a915
praveennagaraj97/Python
/File I_O/fileSystem.py
740
3.625
4
''' r - read w - write ''' ''' #Open sample_file = open('sample.txt') #opening file and assign to variable print(sample_file.read()) ''' ''' #Seek sample_file = open('sample.txt') #opening file and assign to variable print(sample_file.read()) sample_file.seek(0) print(sample_file.read()) print(sample_file.read()) # ...
548d08115f11fc5600e0432176e9e1ac85d40096
AnthonyJamez12/Web-Portfolio-
/Programming Principles I/2 Week/Wednesday (Seconds Converter).py
433
3.8125
4
# [%] equal divide # [//] equal remainder #sph = seconds per hour #spm = seconds per minute sph = 3600 spm = 60 total_seconds = int(input("Enter the total number of seconds: ")) hours = total_seconds % sph minutes = (total_seconds % sph) // spm seconds_left = total_seconds % spm print(str(total_seco...
aa0a14b2f9bcb81be6ba44df71b8b2776a371fde
KyoungSoo1996/python-coding-practice
/python project/programers/biggerNum.py
1,047
3.609375
4
# itertools를 사용한 방식 : 시간 초과가 걸린다 # from itertools import permutations # def solution(numbers): # answer = 0 # numbersToStr = list(map(str, numbers)) # allCase = list(permutations(numbersToStr, len(numbersToStr))) # for i in range(len(allCase)): # if answer <= int("".join(allCase[i])): # ...
716c24f7e2981743678e8eeedb096258e0a0f0fd
dwattles/connect4
/Connect4.py
5,784
3.859375
4
from enum import Enum class Piece_State(Enum): EMPTY = 0 RED = 1 YELLOW = 2 class Piece: def __init__(self, piece_status = Piece_State.EMPTY): self.state = piece_status # Defaults to empty, helpful when initializing the board class Board: # board coordinates: (0,0) is bottom l...
0403f68db6fb2ba7eb378d07ae5e55dcc5495d1a
idont111/python-laboratory
/laboratory1/task3.py
711
3.765625
4
print("""Черниш Аліна Андріївна\nКМ-93\nЛабораторна робота№1 \nВаріант 22 F(x)={9-x, якщо х > 1.1, sin(3x)/(x**4+1), якщо х < -1.1}\n""") import re import math re_float = re.compile("^[-+]{0,1}\d+[.]?\d*$") def validator(pattern, promt): text = input(promt) while not bool(pattern.match(text)): t...
bce1b1b47fa0d548e9b037a01e09a01878235aea
asimeena/python6
/Fibo.py
158
4.0625
4
def fibonacci(n): if(n<=1): return n else: return(fibonacci(n-1)+fibonacci(n-2)) n=int(input('')) print('') for i in range(1,n+1): print fibonacci(i),
de144dd6ce68109a8defae0cb7c278003fc8edaa
MuhammadSyaugi13/Experient-Learning
/Dasar Python/continue.py
189
3.59375
4
# continue for i in range(1, 30): if i % 2 == 0: continue print(i) # break while True: data = input("Masukan Data : ") if data == "x": break print(data)
53d5ab1f98571eb5e960f6947c3f916af3ee995f
aquafilly/operation-code-examples
/python-intro/ex04-strings.py
370
4.1875
4
# python types - Strings greeting = "Hello World!" print(greeting) # prints complete string print(greeting[0]) # prints first character print(greeting[2:5]) # prints starting from 3rd to 5th print(greeting[2:]) # prints string starting from 3rd character print(greeting * 2) # prints string two times print(greeti...
a21003a86393a39beeeb13efd5ded9b6d324602c
akimi-yano/algorithm-practice
/lc/review_1305.AllElementsInTwoBinarySearc.py
1,680
3.90625
4
# 1305. All Elements in Two Binary Search Trees # Medium # 1419 # 48 # Add to List # Share # Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order. # Example 1: # Input: root1 = [2,1,4], root2 = [1,0,3] # Output: [0,1,1,2,3,4] # Exam...
423cca1951d6bdb1747368c620340b4f7e838279
nickklaskala/checkio
/Alice In Wonderland/long_non_repeat.py
1,400
3.5
4
#!/usr/bin/env checkio --domain=py run long-non-repeat # There are four substring missionsthat were born all in one day and you shouldn’t be needed more than one day to solve them. All of those mission can be simply solved by brute force, but is it always the best way to go? (you might not have access to all of those ...
78569b660abd0ff2e3f873295c07c338f19ddd2e
cgarbin/seed-python
/seed-command-line-file-processing.py
2,611
3.5625
4
""" A seed for processing files in Python. Covers: * Process more than one file with file globbing * Working with pipes (redirect stdin and stdout) * Accepting command line options with file names * Mutually exclusive command line options with a default option Does NOT cover: * Non-text (binary) files Sources for ...
8204ac1b12c324e0ddbbe12b874ddb420eeac9f5
leoloo0510/Enterprise
/2-work/iterator_s.py
517
3.859375
4
# -*- coding: utf-8 -*- #class Bank(object): # crisis = False # def create_atm(self): # while not self.crisis: # yield '100' # #hsbc = Bank() #atm1 = hsbc.create_atm() #print(atm1.next()) class Bank(): # 让我们建个银行,生产许多ATM crisis = False def create_atm(self): while no...
747de272459ee8d829491d1af157d83cf9f57735
Majician13/magic-man
/pythonExercise46.py
257
3.90625
4
#Write a program which can map() and filter() to make a list #whose elements are square of even number in [1,2,3,4,5,6,7,8,9,10]. li = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] evenNumbers = map(lambda x: x**2, filter(lambda x: x%2 == 0, li)) print(evenNumbers)
6c5dbbf765deef5ab9b33d59a2ecbe7964d1005f
PacoCampuzanoB/Python-Course
/programacion-orientada-a-objetos/ejercicio6.py
410
3.859375
4
x = int(input("Ingresa las horas que estuviste estacionado: ")) pagar = x*8 print("Total a pagar: ",pagar, " pesos") while(pagar > 0): pago = int(input("Ingresa una moneda: ")) if(pago == 2 or pago == 5 or pago == 10): pagar -= pago if(pagar <= 0): print("Tu cambio es de ", -1*pagar, " pesos") else: pr...
e2e0dbf913fe12776ac1aa7a4d7477fefa3c80a9
rishabh-22/Problem-Solving
/leader_board.py
1,096
3.859375
4
import copy def climbing_leader_board(scores, alice): ans = [] for score in alice: mock = copy.copy(scores) mock.append(score) a = set(mock) mock = list(a) mock.sort(reverse=True) b = mock.index(score) ans.append(b+1) return ans scores = [100, 100,...
313031366d361069c434da073546989a17e1970a
rebbapragada-GH/Data-Analytics-Projects-1
/Python/PyBank/pybank.py
1,523
3.875
4
import csv import os with open(r'C:\Users\thela\OneDrive\UCB Data Bootcamp\Homework #3\budget_data_1.csv',newline='') as csvfile: csvreader = csv.reader(csvfile, delimiter=",") next(csvreader,None) num_months = list(csvreader) row_count = len(num_months) print("Financial Analysis") print("------...
5735506bf690b6c7bea467a51688a3986d941dbc
Qusay114/Graphs
/Test_Graph.py
7,304
4
4
# -------------------------------------------------------- # This file is used to test all the algorithms performed # on the graph's # -------------------------------------------------------- from Graph import * from colorama import Fore, Style print("Depth First Search") print(Fore.BLUE) print("-------------------...
3c7fd45060f00ee4b6df43034c0c47954ef4b4f7
dos09/PythonTest
/reference_code/miscellaneous/misc01.py
914
3.984375
4
a = 4 if(1 < a < 5): # chained conditions print("1 < %s < 5" % (a)) # logical operators: and, or, not if(a > 1 and a < 5): print("%s > 1 and %s < 5" % (a, a)) def printFibonacci(howMany=0): a, b = 1, 1 print(a) howMany -= 1 for count in range(0, howMany): a, b = b, a + b print(...
38fa9a21f03c3c6e0f4d6fd0a93da447b1809730
Madhav2108/Python-
/loop/nestedloop1.py
362
4.09375
4
print("Loop Type 4") for i in range(1,6): for j in range(1,6): print(i,end="") print() print("Loop Type 5") for i in range(1,6): for j in range(1,6): print(j,end="") print() print("Loop Type 6") for i in range(1,6): n=i for j in range(1,6): print(n,end="") ...
0ab427bce4cad9d3e3ea10d73ebef149916ab89a
Heeirun/courseraPython
/PR4E/ass4.6.py
323
3.953125
4
hrs = raw_input("What is the number of hours you worked?: ") rate= raw_input("What is the hourly rate?: ") hrs= float(hrs) rate=float(rate) if hrs <= 40: grosspay= hrs*rate if hrs >40: exhrs=hrs-40 exrate=rate*1.5 grosspay= (40*rate) + (exhrs*exrate) print "Your pay is : ", gross...
4f2f851748825c2ecc19293f05bd3d14a215d7c7
stefan-training-projects/freecodecamp_projects
/arithmetic_formater.py
844
3.953125
4
numbers= ["32 + 698", "3801 - 2", "45 + 43", "123 + 49"] def arithmetic_arranger(problems): #create a functions for errors def errors(): #limit is 5 problems: if len(problems)>5: return "Error: Too many problems" errors() arranged_problems = " " #create a for loop to separate the elements in the...
ed84acc021b940e3adb4382a7733a7de1ac9cd0d
yuanxu1990/studyday
/day37/day37e.py
1,732
3.640625
4
''' 生产者和消费则模型 买包子 包子笼 买包子 生产数据快-----------容器-----------处理数据慢 ''' from multiprocessing import Process,Queue import time,random def product(name,food,q): for i in range(10): foods='%s生产了%s%s'%(name,food,i) print(foods) q.put(foods) time.sleep(2) def commu(q,...
d43a4725626e87c0253dc9eb5847c0bc7579b6df
maxerogers/Dev
/Python/hw3/test4.py
3,941
3.984375
4
##Author:Max Rogers ##ID: 107979405 ##Class: CSE307 - Spring 2013 - Paul Fodor ##Assignment: Hw3 ##Problem: Build a 6x6 sudoku solving program that returns a solved game after taking ##in a path parameter for the input txt file ## ##The format for the input txt file should be ## ##2 1 - - 4 3 ##- - - - - - ##- - 6 2 ...
9093392b2679e4cc3aa4315e222cb75b05d52f88
emplam27/Python-Algorithm
/프로그래머스/카카오 2019 인턴쉽 - 크레인 인형뽑기 게임.py
983
3.546875
4
def solution(board, moves): answer = 0 # 인형 꺼내기. 0을 제외하고 가장 위쪽에 있는 숫자 고르기 # stack에 인형 넣기. 만약 마지막 인형이 본인의 숫자와 같다면 마지막 숫자를 pop, answer += 2 stack = [] for move in moves: # 가로 for depth in range(len(board)): # 세로 if board[depth][move - 1] != 0: # 제일 위 인형을 꺼낸다 pi...
c0d5e1ebc5aa7a3feac22d141d2224cde456749f
dfki-ric/pytransform3d
/examples/plots/plot_matrix_from_two_vectors.py
843
4.0625
4
""" ========================================== Construct Rotation Matrix from Two Vectors ========================================== We compute rotation matrix from two vectors that form a plane. The x-axis will point in the same direction as the first vector, the y-axis corresponds to the normalized vector rejection ...
5ce52a9c87fd0bab033d3e5805fdc2c0eeaa514b
PuffedRiceCrackers/algorithmChallenge
/1 191113 Merge Two Sorted Lists pm.py
1,665
3.78125
4
class ListNode: def __init__(self, x): self.val = x self.next = None def mergeTwoLists(l1, l2): # l1, l2 중 하나가 None 인 경우 진행이 안되므로 미리 탈출 if l1 == None and l2 == None: return None elif l1 == None or l2 == None: return l1 == None and l2 or l1 iter1 = l1 iter2 = l2...
f01bbf3f65ff2dfdb9467c06f809154137379317
joeynosharefood/estudos
/Python/Exercicios/40.py
294
3.921875
4
x = float(input('Insira a primeira nota: ')) y = float(input('Insira a segunda nota : ')) z = (x+y)/2 print(z) if z < 5: print('Está reprovado') elif 5 == z < 7: print('Está de recuperação') elif z == 6.9: print('Está de recuperação') elif z >= 7: print('Está aprovado')
a440b77d30fbfaa9c9b845ad0f82239247d825fc
Shin1203/Unit3--comsci-shin
/week28/CodingPractiseQ3.py
222
4.1875
4
# this program will recieve an input of words seperated by comma, and reorganize them in alphabetical order. words = input("Enter words seperated by commas, e.g- bird,dog,cat") ind = words.split(",") ind.sort() print(ind)
cd8f5187ebcbc908b78dd45d35c2b6ab9b437179
lpython2006e/python-samples
/Unit 05 Lists & Dictionaries/01 Python Lists and Dictionaries/Lists Capabilities and Functions/9-More with for.py
292
4.03125
4
start_list = [5, 3, 1, 2, 4] square_list = [] # for loop number is ambiguous variable for number in start_list: square = number ** 2 # calculate square to add later square_list.append(square) # add the calculation square_list.sort() print(square_list # print sorted version)
87b4f12485d834f440b51ef2023f0e26d5146357
amigodornot666/PD10k
/PDplayerClass.py
3,111
3.703125
4
# PDplayerClass.py // Player class file for pyDice10k # by: aMigod666(KyleJRoux) import random import PDrollClass import PDmenu class Player(object): '''Players interact with the game while keeping track of individual Users data(per instance), and keeps track of the current player as well as the number of...
999912462411447ed2a4979dd30f421116b38c4f
patchen/battleship
/src/BattleShip.py
18,110
3.578125
4
""" Created on Feb 15, 2012 """ import Board import ship import random import AI import Tkinter def draw_game(window, b1, b2, player): """Draw b1 and b2 (Boards) on window (Tk).""" window.grid() size = 750 / b1.size * b1.size board = Tkinter.Canvas(window, bg='black', height=size + 3...
c67ae6064ed345ce7b325af4e81ab7ef8e207739
aaqibgouher/python
/pandas_eg/sorting.py
627
4.125
4
import pandas as pd import numpy as np # Sorting by Label (Index) : Only Index will be sorted and according to the index the actual values will be shown. unsorted_df = pd.DataFrame(np.random.randn(3,2),index=[3,2,1],columns=['x','y']) sorted_df = unsorted_df.sort_index() # sort_index : by default it sorts in asc orde...
c57e0affb6224562bbab3c4623401d19f9c0264f
idlelearner/interview_qns
/coding_practice/leetcode/code/algos/bitoperations/complement.py
378
3.5
4
class Solution(object): def findComplement(self, num): """ :type num: int :rtype: int """ bin_str = bin(num)[2:] print bin_str comp_str = ''.join(['1' if c=='0' else '0' for c in bin_str]) print comp_str return int(comp_str, 2) if __name__=='_...
0cc6ea82a61ed3c4550ca4c71b5965dd3e40ba3d
Pinecone628/Leetcodes
/26. Remove Duplicates from Sorted Array.py
968
3.546875
4
class Solution: def removeDuplicates1(self, nums: List[int]) -> int: if len(nums) == 0: return len(nums) count = 0 prev = None for num in nums: if num != prev: prev = num nums[count] = num count += 1 ret...
7e94b1989c51b8077f0f0618d2349f3c6cb931fd
amanalex1804/ML_using_python
/data_preprocessing/importdataset.py
446
3.75
4
import pandas as pd import matplotlib.pyplot as plot import numpy as np dataset=pd.read_csv('Data.csv') #save the file where there is dataset #index in python starts with 0 X=dataset.iloc[:,:-1].values #gives output of independent variables i.e # last column is dependent co...
57ad1acaaa0967d30b6e6c4b7161aa2e761e8897
joaovlev/estudos-python
/Desafios/Mundo 1/desafio007.py
192
3.875
4
nota1 = float(input('Digite sua nota em matemática: ')) nota2 = float(input('Digite sua nota em português: ')) media = (nota1+nota2)/2 print('A média entre suas notas é {}'.format(media))
dd35fe0afce83da7ff82b81cc8cfd9479c7701b9
ktekchan/DSR
/degree.py
2,839
3.65625
4
#------------------------------------------------------------------------------ # Author: Khushboo Tekchandani # Calculate the average degree of the network based on the mobility patterns. # This calculation is done periodically and the average is calculated over the # entire simulation time. #-----------------------...
f408d0b015bbd91d63476d1ce91063d43052d5e8
monish7108/PythonProg2
/fileWordReversing.py
812
4.5
4
"""This program takes existing filename as input and creates a new file by data=open(filename) s of old file in reverse order [words]. ============================================================""" def file_printing(filename,outputFilename="output.txt"): """This function writes from one file to another in r...
b8323827aef38b5df223a2ca8e5b9c4ecbe5a11b
llcawthorne/old-python-learning-play
/scripts/random-features.py
386
3.703125
4
#!/usr/bin/env python3 # A simple introduction to random functions import random print( random.choice(['apple', 'pear', 'banana']) ) samps = random.sample(range(100), 10) # 10 samples w/o replacement print(samps) print( random.random() ) # a random float die = random.randrange(6) # rando...
c76b43744c03f0eeb1f7353708acd7c6db25ccdc
waynephill/Python
/01String.py
117
3.734375
4
yourName = input("Please enter your name: ") mood = "Good" timeofDay = "day" print (mood, timeofDay, yourName)
134e3fef638c3eea8e8ccba584f0b3b94e518971
Terrenceybt/tensorflow
/basic_learn/pandas_basic.py
388
3.71875
4
#! /usr/bin/env python import pandas as pd city_names = pd.Series(['shang hai', 'nan jing', 'su zhou']) population = pd.Series([1000, 2000, 3000]) population = population/1000 city_population = pd.DataFrame({'City Name':city_names, 'Population': population}) print(city_population.describe()) print(city_names) print(p...
01e56ff0bc0951ae049012868ccde3b5c459e23a
phrodrigue/URI-problems
/iniciante/1011/main.py
101
3.640625
4
raio = float(input()) pi = 3.14159 vol = (4.0 / 3) * pi * (raio ** 3) print(f"VOLUME = {vol:0.3f}")
d55598efe38b564dd205be68ec6ce1db33a36843
EdwaRen/Competitve-Programming
/Leetcode/208-Implement_Trie.py
1,237
3.859375
4
class Node: def __init__(self): self.next = [None] * 26 self.end = False def containsVal(self, val): return self.next[val] != None class Trie: def __init__(self, value=""): self.root = Node() self.insert (value) def insert(self, word): cur = self.roo...
0e71f1bddf4a237830515682162be2e77a682cba
wbjordammen98/PyGame-Project
/alien.py
1,536
3.765625
4
import pygame as py from pygame.sprite import Sprite class Alien(Sprite): # A class to represent a single alien in the fleet. def __init__(self,ai_game): # Initializes the alien and set its starting postion. super().__init__() self.screen = ai_game.screen self.settings = ai_ga...
9d6300169a8c2c8e90cae1c77400fa52ed08fbaf
alexoreiro/Python
/factorial_recursion.py
252
4.375
4
#!/usr/bin/python3 factorial = input("Enter the number to factorize: ") def factorial(num): if num <= 1: return 1 else: result = num * factorial(num -1) return result fact = result print("This is the result", fact)
6f4040e2d291a5a4420ca3c58ee0b8e4d6434a39
Enhory/practicas
/programacion2/ejercicio1_Introducción/ejercicio02.py
150
3.609375
4
a = 10 b = -5 c = "Hola " d = [1, 2, 3] print(a * 5) print(a - b) print(c + "Mundo") print(c * 2) print(c[-1]) print(c[1:]) print(d + d)
8f8bac87cd3628dc46773037e6c12de6e3f20437
bhattvishal/programming-learning-python
/3.Object.Oriented.Programming/10.callableObjects.py
627
3.84375
4
# in Callable object you can actually call an object as a function to change the values class Book: def __init__(self, title, price, author): super().__init__() self.title = title self.price = price self.author = author def __str__(self): return f"Book {self.ti...
c6bd678af4300543feccccde06823edb2318860b
Wen0420/COMP9021_Principles-of-Programming
/quiz_6.py
7,248
4.25
4
# DO *NOT* WRITE YOUR NAME TO MAINTAIN ANONYMITY FOR PLAGIARISM DETECTION # # Randomly generates a grid with 0s and 1s, whose dimension is controlled # by user input, as well as the density of 1s in the grid, and finds out, # for given step_number >= 1 and step_size >= 2, the number of stairs of # step_number many step...
594831ce86a63b66a1b2841a2098939c145dba73
quickheaven/ltp-the-fund-by-uot
/time.py
477
4.25
4
def convert_to_minutes(num_hours): """ (int) -> int Return the number of minutes there are in num_hours hours. >>> convert_to_minutes(2) 120 """ result = num_hours * 60 return result def convert_to_seconds(num_hours): """ (int) -> int Return the number of seconds there are in num_...
16dbd02df60f1e2648f094ba1b301ac99b2e6a83
sookoor/PythonInterviewPrep
/compute_circus_tower.py
1,027
3.5625
4
# Given the heights and weights of people, computes the largest possible number of people in a tower such that each peron is both shorter and lighter than the person below him or her. # Input: [(ht_0, wt_0), (ht_1, wt_1), ... (ht_n, wt_n)] def compute_circus_tower(people): sorted_people = sorted(people, key=lambd...
cc849933ac40c6ba76e53f1a9d15ad3404e0c257
pzabauski/Homework
/Homework2/#4.py
587
4.1875
4
# Модуль random # Программа загадывает целое число в промежутке [1; 10] (от 1 до 10 включительно) и просит пользователя отгадать его. # Программа не завершается, пока число не будет отгадано. import random x = random.randint(1, 10) while int(input("Введи число от 1 до 10?")) != x: print("Не угадал") continue...
b32e1d0cac53b2a9d0398b1ba63b234002b94889
JasonLiu798/leetcode
/python/Str-Substring-withConcatenation-ofAllWords.py
4,504
4.03125
4
#!/bin/env python #-*- coding:utf-8 -*- ''' @questions 30. Substring with Concatenation of All Words @Difficulty Hard @Pass 20.4% @link https://leetcode.com/problems/substring-with-concatenation-of-all-words/ @introduction You are given a string, s, and a list of words, words, that are all of the same length. F...
e42a8727759035cec01ab735c56f013b64b4a76d
jiayu-daemon/python_ai
/baseGrammer/example.py
709
3.765625
4
"""对上面例子的一个扩展""" print("=======欢迎进入狗狗年龄对比系统========") while True: try: age = int(input("请输入您家狗的年龄:")) print(" ") age = float(age) if age < 0: print("您在逗我?") elif age == 1: print("相当于人类14岁") break elif age == 2: ...
56915bcfdf358ffc4944df5bfc80896a81847703
green-fox-academy/sepgab
/Week-04/day-01/blog_post.py
1,728
3.625
4
# Create a BlogPost class that has # an authorName # a title # a text # a publicationDate # Create a few blog post objects: # "Lorem Ipsum" titled by John Doe posted at "2000.05.04." # Lorem ipsum dolor sit amet. # "Wait but why" titled by Tim Urban posted at "2010.10.10." # A popular long-form, stick-figure-illustrat...
12f6ce4ed2aa98876c21dfdbc353c1e656cb4703
vadympopovych24/Learning_code
/Lab9_1.py
677
3.578125
4
def gameBlackJack(cards: str) -> int: kartu = cards.split() card_table = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 10, 'Q': 10, "K": 10, 'A': 0} amount = sum([card_table[_] for _ in kartu]) if 'A' in cards: ace = 21 - amount if ace < 11: ...
18838f2c1f377727de12fa731674e2df3ca4b49f
danielsunzhongyuan/python_practice
/hackerrank/plus-minus.py
633
3.859375
4
#!/usr/bin/python # -*- coding:utf-8 -*- # author: zsun # @Time : 2018/11/07 18:53 # @Author : Zhongyuan Sun # Complete the plusMinus function below. def plusMinus(arr): positive, negative, zero = 0, 0, 0 for n in arr: if n > 0: positive += 1 elif n < 0: negative...
69ed980b8aad758cd2e75ff3bba697db18538765
sahithi2316/python
/Assignment 12_tuple_to_string.py
126
3.71875
4
def convertTuple(tup): str=' '.join(tup) return str tuple=('p','y','t','h','o','n') str=convertTuple(tuple) print(str)
76613428c83908b96ca3a89085579a8abbfce8df
A-ZGJ/Hilbert
/hilbert/preprocess.py
3,564
3.734375
4
""" Module for preprocessing of signals """ import numpy as np def _make_pad_window(signal_len, pad_len): """Returns a window (vector) that identifies (True) the original portion of the signal prior to padding. Parameters ---------- signal_len : int Length of original signal along axis to...
7b4a270989163449fc9feaa7e2b83c37b7645f4c
philipblee/Pyramid-Poker-v1
/test_folder/test_create_card_images_1deck.py
1,398
3.546875
4
""" test_create_card_images is a class that displays six hands on Canvas """ import tkinter as tk from src.Deck import * from src.create_card_images import create_card_images class test_create_card_images(): """ test_create_card_images """ def __init__(self): self.cardlist = [] self....
d5e4cd6150c4889d34711e551ed19d8957bc9967
a-kontorius/GeekBrains
/Python1/Lesson2/hw02_hard.py
6,026
4.0625
4
# Задание-1: уравнение прямой вида y = kx + b задано в виде строки. # Определить координату y точки с заданной координатой x. equation = 'y = -12x + 11111140.2121' x = 2.5 t = list(equation.split(" ")) k = t[2] # получаем k (-12х). k = k[:len(k)-1] # избавляемся от х. k = float(k) # Преобразовыв...