blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
395896b47a59051b3749ac89db72d22441f46104
cpsolano/Nivelacion-Programaci-n
/23082019/000959.py
411
3.59375
4
given_list2 = [5,4,4,3,1,-2,-3,-5] #se genera lista total5 = 0 #variable i = 0 #variable contador while True: #se pone condicion que siempre es verdad total5 += given_list2[i] #se le suman los valores de la lista uno por uno a la variable i += 1 #se le suma 1 al contador if given_list2[i] <= 0: #condicion p...
9c6eb778cfc20002ae7aafb850e216e1f16e4a6c
kunzhang1110/COMP9021-Principles-of-Programming
/Quiz/Quiz 3/quiz_3.py
1,700
4.03125
4
# Prompts the user for a word and outputs the list of # all subwords of the word of height 1. # # Written by Kun Zhang for COMP9021 def extract_subwords(word): i = 0 # start index pointer out = [] # elminate redundant whitespace word = word.split() word = "".join(word) last_index = len(wo...
c279136191fdde56581f148859ad1b808438d676
charlesmtz1/Python
/Ejercicios/Ejercicio30.py
302
4
4
#Ejercicio 30 #Para un número N imprimir su tabla de multiplicar. def tabla_multiplicar(numero): for valor in range(1,11): print(f"{numero} x {valor} = {numero * valor}") numero = int(input("Escribe un numero: ")) print("Se muestra su tabla de multiplicar:") tabla_multiplicar(numero)
8e002898088f6b6c336967b73d0608b5c7239767
JAntonioMarin/PythonBootcamp
/Section12/81.py
1,567
3.984375
4
def func(): return 1 print(func()) def hello(): return "Hello!" print(hello()) print(hello) greet = hello print(greet()) # del hello # print(hello()) # # Traceback (most recent call last): # File "81.py", line 18, in <module> # print(hello()) # NameError: name 'hello' is not defined def hello2(...
1baa2a86164bd18979758e596b5cb8701f04c2f9
EraSilv/day2
/class1/class.py
498
4.03125
4
class Person: def __init__(self, name, age): self.__name = name self.__age = age def printmy(self): print("I am ", self.__name, "I am", self.__age) class Person2: def __init__(self, name, age): self.name = name self.age = age def printmy(self): print("I ...
e9f9c92e43e6856f571e46671dedd378585975d0
Erick-ViBe/Platzi
/PythonPlatzi/busquedaBinaria.py
738
4.0625
4
# -*- coding: utf-8 -*- def run(): list_of_numbers = [2, 5, 8, 1, 6, 9, 3, 10, 4, 7] number = int(raw_input('Numero a buscar: ')) result = binary_search(list_of_numbers, number) if result is True: print('Si esta en la lista') else: print('No esta en la lista') def binary_search...
abf9144ab13fe4a821808079fb20d3555e7d414d
hoangnym/Python_project
/python_intermediate/secret_auction/main.py
598
3.84375
4
from art import logo print(logo) # Create empty dictionary biddings = {} keep_bidding = True while keep_bidding: name = input("What is your name?: ") bid = int(input("What is your bid? €")) biddings[name] = bid additional = input("Are there other users who want to bid (yes / no)?: ").lower() ...
a78c1c4b38a78d10a38df86607ed216650dd0015
ruinanzhang/Leetcode_Solution
/70-Restore IP Address.py
1,962
3.609375
4
# Tag:Backtracking # 93. Restore IP Addresses # ----------------------------------------------------------------------------------- # Description: # Given a string containing only digits, restore it by returning all possible valid # IP address combinations. # A valid IP address consists of exactly four integers (each ...
7bcde5627ed004ff68db242d88af1d8d5db05954
licmnn/driving
/driving.py
371
3.984375
4
country = input('请问您是哪国人: ') age = input('请输入您的年龄: ') age = int(age) if country == '台湾': if age >= 18: print('你可以考驾照') else: print('你还不能考驾照') elif country == '美国': if age >= 16: print('你可以考驾照') else: print('你不可以考驾照') else: print('你只能输入台湾或者美国')
dfec94e674fd73fb4c64edd53c78b341dfb49082
nikhilgurram97/CS490PythonFall2017
/PythonLab2/task4.py
594
4.03125
4
import numpy as n a=n.random.rand(15) #random function to generate 15 random values into a list print("Previous Vector: ") print(a) b=max(a) #finding max value in the generated vector for i in range(15): ...
95604cc9e863327ef75d04cc0e09b27498caebf8
FanJiang718/Courses-Exercises
/MAP556/TP1/MAP556_PC1_Exo1_2.py
633
3.640625
4
import numpy as np import matplotlib.pyplot as plt N = 1000 U = np.random.rand(N) a = 1. ######## # Stocker dans X des simulations de la loi de Cauchy de parametre a # en utilisant l'inverse de la fct de repartition # X = a*np.tan(np.pi*(U-0.5)) # ######## integers1toN = np.arange(1,N+1) ########...
e4021908627f1d0b9ad6d1cbcc8179214a040bfd
chasemp/sup
/suplib/durations.py
789
3.5
4
import os import time class Timer(object): def __enter__(self): self.start = time.clock() return self def __exit__(self, *args): self.end = time.clock() self.interval = self.end - self.start def ftimeout(func, args=(), kwargs={}, timeout_duration=1, default=None): """http...
b6cbbca196ab6d3274f8e2940d584b7b17fa8146
Gabrielatb/Interview-Prep
/elements_of_programming/Heaps/sort_nearly_sorted_array.py
2,668
4.125
4
# Sort a nearly sorted (or K sorted) array # Given an array of n elements, where each element is at most k away from its target position, # devise an algorithm that sorts in O(n log k) time. For example, let us consider k is 2, # an element at index 7 in the sorted array, can be at indexes 5, 6, 7, 8, 9 in the given a...
03096cec7da3e4ef5f6c09fb3132c1fe7bf62a4b
THADEUSH123/python-noobs-programming-challenge
/prog-challenges/boxes.py
890
3.671875
4
"""Bython Challenge.""" my_rectangle1 = { # coordinates of bottom-left corner 'left_x': 1, 'bottom_y': 2, # width and height 'width': 3, 'height': 4, } my_rectangle2 = { # coordinates of bottom-left corner 'left_x': 1, 'bottom_y': 5, # width and height 'width': 2, '...
eea0dd0a4750d8b0c535cbd3b9774be5863a6a19
lukelee1220/Python
/zhishu2.py
365
4.0625
4
def isprime(y): isprime=True #print(y) if y == 0: return False if y == 1: return True for a in range(2,y): if y%a==0: isprime=False break return isprime #x=int(input("input a number")) y=int(input("input a number")) for a in range(y): ...
0b02ae6ebb9904199d280c27307e47f4377cf341
maih1/DAA
/PrimeFactor.py
1,051
3.75
4
import time import math a = [] prime = 2 def isPrime(n): if n < 2: return False else: for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def intPrime_1(n): global prime, a if n == 1: return a elif n % pri...
413036d9d27f69d021f33c1f3877206268c2b353
wangyunge/algorithmpractice
/int/63_Search_in_Rotated_Sorted_Array_II.py
1,352
3.9375
4
''' Follow up for Search in Rotated Sorted Array: What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a function to determine if a given target is in the array. Have you met this question in a real interview? Yes Example Given [1, 1, 0, 1, 1, 1] and target = 0, return true....
347fdd373f491c8976ed48afc79d4b67f8940707
Ming-H/leetcode
/438.find-all-anagrams-in-a-string.py
774
3.734375
4
# # @lc app=leetcode id=438 lang=python3 # # [438] Find All Anagrams in a String # # @lc code=start class Solution: def findAnagrams(self, s: str, p: str) -> List[int]: """ The time complexity of this solution is O(n), where n is the length of s. """ pCount = [0] * 26 ...
442ed6429cde676f837e17ea24709dedbc3d7154
TilletJ/ProjetInfo_TerrainFractal
/NEW/cours_eau.py
1,054
3.65625
4
# -*- coding: utf-8 -*- class CoursEau(): def __init__(self, start, paysage): self.points = [start] self.paysage = paysage def coule(self): if self.points[0].est_3D : pass else : #2D tolerance = 0.0 #Provoque des erreurs de dépassement de limite de ré...
3f084dba4683bb142a0ff378dd743a2f09ac3ce5
julianfrancor/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-number_of_lines.py
1,015
4.34375
4
#!/usr/bin/python3 """ function that returns the number of lines of a text file """ def number_of_lines(filename=""): """ with: It is good practice to use the "with" keyword when dealing with file objects. This has the advantage that the file is properly closed after its suite finishe...
04c65f0df52be3b0fb3cca8e43a59703adf5f135
MitsurugiMeiya/Leetcoding
/leetcode/Tree/构造二叉树/105. 从前序和中序遍历序列构造二叉树.py
1,086
3.96875
4
""" 前序遍历 preorder = [3,9,20,15,7] root left right 中序遍历 inorder = [9,3,15,20,7] left root right """ # 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 buildTree(self, preord...
17a2e220da73d701e33de04a77443dd65617b0e4
AlvisonHunterArnuero/EinstiegPythonProgrammierung-
/PYTHON NOTEBOOKS/8.8_dictionary_questions_&_solutions.py
3,462
4.0625
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 23 17:32:12 2019 @author: giles """ ''' Question 1 Can you remember how to check if a key exists in a dictionary? Using the capitals dictionary below write some code to ask the user to input a country, then check to see if that country is in the dictionary and...
517f3f2e292248c2938781258e0dcc833a362908
soh200/PYTHON
/t9.py
176
3.78125
4
a=[1,2,3,4,5,6,7,8,9] b=0 c=0 for n in a: if(n%2==0): b=b+1 else: c=c+1 print("Number of even numbers: ",b) print("Number of odd numbers: ",c)
11f7e2a05172e491e2dfdbfe42cd6677254c56a1
aRivieraDream/Learning-Python
/ex21.py
1,339
3.9375
4
print "Let's practice everything." print 'You\'d need to know \'bout escapes with \\ that do \n newline and \t tabs.' poem = """ \tThe lovely world with logic so firmly planted cannot discern \n the needs of love nor comprehend passion from intuition and requires explanation \n\t\twhere there is none. """ print "____...
f4ee1a2c6beb24257c016f10f974555950feec78
akshatakulkarni98/ProblemSolving
/DataStructures/arrays/pairs_are_divisible_by_k.py
849
3.5625
4
# https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k/ # TC: # SC: class Solution: def helper(self, arr, k): """ This will not work for many test cases """ s=sum(arr) if s%k==0: return True else: return False def helper2(...
ef6d29777a2d60d9cbe15d20a803f06ffa04e870
pirhoo/python-course-fr
/teaching-demos/16.py
185
3.90625
4
# coding: utf-8 name = "Jens Finnäs" length = len(name) small_name = name.lower() english_name = name.replace("ä", "a") small_english_name = name.lower().replace("ä", "a") print(length)
b93c2ff8b60cca00f81c1b0bd0a6cb1c2c44a1b6
mkodekar/PyOOPS
/square.py
1,077
4.03125
4
class Square: def __init__(self, height=0, width=0): self.height = height self.width = width @property def height(self): return self.__height @property def width(self): return self.__width def getArea(self): return int(self.width) * int(self.height) ...
a107264e45278f411f91f3b23f7f27445b02b481
cho010012/PyAI_Learning
/02_Pandas_DataFrame.py
658
3.609375
4
import pandas as pd import numpy as np df1 = pd.DataFrame(np.random.rand(6,4),columns=list('ABCD')) # 數值在 0 到 1 之間 , 6 列 4 行的資料 print(df1) print('') #Random Normal distr 隨機常態 分配 , 6 列 4 行的資料 df2 = pd.DataFrame(np.random.randn(6,4),columns=list('ABCD')) print(df2) print('') df1 = df1.append(df2,ignore_index=Tr...
c14ef57a4c07a5984f6f8575411a84c898b09d36
carlysonviana/AulasPython
/nome_senha.py
265
3.984375
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: while True: nome = input("Digite o nome do usuario: ") senha = input("Digite a senha do usuario: ") if nome != senha and len(nome) >= 5 and len(senha) >= 5: print("VÁLIDOS") break
65f2b53b16e4272780e1e34b6924a6e57f63e832
nikist97/CodingChallenge
/DataModel.py
10,059
3.578125
4
from DataRandomizer import DataGenerator from CustomErrors import InvalidPriceError, InvalidPositionError, DuplicateIdentifierError from collections import deque from math import log class Event(object): """ this class represents the model of an Event with a unique identifier and 0 or more positive ticket pri...
d3680771932c7f39bb8255281e3b05aea8bbad06
Frankiee/leetcode
/union_find/547_friend_circles.py
3,629
4.3125
4
# [Union-Find] # https://leetcode.com/problems/friend-circles/ # 547. Friend Circles # History: # 1. # Apr 28, 2019 # 2. # Nov 13, 2019 # 3. # May 4, 2020 # There are N students in a class. Some of them are friends, while some are # not. Their friendship is transitive in nature. For example, if A is a # direct friend...
bdf55571c5a92d1e02ad71b889cdd22a52e96ad6
fishisnow/leetcode
/2.py
1,447
3.609375
4
#coding:utf-8 """ #给你两个链表表示两个非负数字。数字存储在相反的顺序和每个节点包含一个数字。添加两个数字并返回一个链表。 #Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) #Output: 7 -> 0 -> 8 # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None """ 设x为l1节点值, y为l2节点值, 若为空则为0 sum = x ...
bebf2b0ead87c4baa0e695b322e22b13d72d1d8a
Deepaksinghmadan/MITx-6.00.1x-Computer-Science-and-Programming-Using-Python
/both program.py
505
3.546875
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 19 20:47:32 2018 @author: deepak """ n=int(input("Enter a number: ")) a=[] for i in range(1,n+1): print(i,sep=" ",end=" ") if(i<n): print("+",sep=" ",end=" ") a.append(i) print("=",sum(a)) n=int(input("Enter a number: ")) for j in ra...
f822ead8f75f5cd8d8b4a3e619c320ac2612bfca
Noba1anc3/Machine_Learning
/numpy/5.numpy的索引.py
728
3.546875
4
# coding: utf-8 # In[1]: import numpy as np # In[2]: arr1 = np.arange(2,14) print(arr1) # In[3]: print(arr1[2])#第二个位置的数据 # In[4]: print(arr1[1:4])#第一到第四个位置的数据 # In[5]: print(arr1[2:-1])#第二到倒数第一个位置的数据 # In[6]: print(arr1[:5])#前五个数据 # In[7]: print(arr1[-2:])#最后两个数据 # In[8]: arr2 = arr1.reshape(3,4...
f8ecd3d4b9f1272e89dbd397fb5905a4f3e95edf
doedotdev/uc-data-mining
/untitled/hello.py
1,420
3.5
4
def get_integer_part(pre_decimal_string): # special case of negative 0 being a prefix "-0.6" if pre_decimal_string == "-0": return "-0" else: num = int(pre_decimal_string) return "{0:b}".format(num) def get_decimal_part(post_decimal_string, string_builder, recurse): recurse += ...
f588a4c0c324ac5dbf34cf87d60a7e8a7c3dac52
pacewski/Bubblesort
/bubblesort.py
613
4.15625
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 14 11:42:00 2019 @author: pacew """ # A bubble sort app import numpy as np import random def bubblesort(array): lenght = len(array) - 1 for i in range(lenght): for j in range(lenght): if array[j] > array[j + 1]: array[j], a...
332291c6387f9bf1bf25a20243c5508b38def7bf
ghamerly/nondeterminism
/prime.py
431
3.859375
4
from nondeterminism import * @nondeterministic def composite(n): d = guess(range(2, n)) if n % d == 0: accept() else: reject() def prime(n): if n < 2: return False else: return not composite(n) numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] for n in numbers: if p...
d84b74457c7c5a3a9c08257c64d6cc5dbbd2eb9e
haekyu/python_tutoring_kh
/1029/0926hw.py
5,321
3.890625
4
# 1. list 연습1 # list 내 최대값 구하기. # lst = [2, 3, 6, 2, -1, 0, 6, 2, 3] 이 주어져 있을 때 최대값인 6을 출력해보세요. # 힌트1) 간단하게 max(lst) 로도 구할 수 있지만, max()를 쓰지 않고 loop로 해결해 보세요. # 힌트2) skeleton code를 이용해도 좋습니다. ??? 을 채워 넣으면 됩니다. # Target list lst = [2, 3, 6, 2, -1, 0, 6, 2, 3] def get_max_of_lst(lst): # Initialize max_val max_val...
76c24d757b8b28e26d053c22a6fa730e49659bce
rom-k/topcoder
/python/15.py
256
3.921875
4
#!/usr/bin/python # -*- coding: utf-8 -*- for element in [1, 2, 3]: print element for element in (1, 2, 3): print element for key in {'one': 1, 'two': 2}: print key for char in "123": print char for line in open("tmp2"): print line
7a9aa4e44c821e042f43e07f824de3899fa01692
snackjunio/jun
/Ex01.py
423
3.71875
4
def main(): try: a = int(input('nを入力ください:')) for r in range(1,a+1,1): for b in range(1,(a-r)+1,1): print('\t',end='') for c in range(1,(2*r-1)+1,1): print(' ',c,end='') print('\n') except: raise if __name__...
e65b37be8bc3d1813cd85d1ff0297bdecbf146ae
JohannSaratka/AdventOfCode
/AoC_2016/Day05/Day05.py
3,937
4.0625
4
''' --- Day 5: How About a Nice Game of Chess? --- You are faced with a security door designed by Easter Bunny engineers that seem to have acquired most of their security knowledge by watching hacking movies. The eight-character password for the door is generated one character at a time by finding the MD5 hash o...
2f8218ab0b36ff01afc17584587f4095ca95b854
DorotejaMazej/11-OOP
/age_years.py
215
3.6875
4
import time from datetime import date today = date.today() le = 1979 my_birthday = date(1979, 2, 6) time_to_brth = today.year - my_birthday.year l = str(time_to_brth) + " " + "years" + " " + "old" print l
f731d5ba918be2f1aa8a57a95a58c6cd94ddfcc4
Talk-To-Code/TalkToCode
/AST/output/program expected outputs/P Progs/isPrimeNumber.py
272
3.953125
4
import sys def main(): n, c = 0, 2 print("Enter an integer\n") n = input() if(n == 2): print("Prime number.\n") else: for c in range(2, n): if(n % c == 0): break if(c != n): print("Not prime.\n") else: print("Prime number.\n") return
106585ee67b25d153714fad3ae8b9101bee88a0a
devinitpy/devinitpy.github.io
/mid/dictionaries.py
809
4.125
4
my_dictionary = { "name":"allan","school":"Makerere","physics":100,"biology":130} #returns dictionry values dictionary_values = my_dictionary.values() my_school=my_dictionary["school"] print my_school value_list = [] for value in my_dictionary.values() : value_list.append(value) print value_list for key ...
04879146b7f5e523d7b462ec890b1ce049480e5e
micaiahparker/python-utils
/flip.py
205
3.59375
4
def flip(): """A fair coin simulator""" from random import choice while True: r1, r2 = choice([0,1]), choice([0,1]) if bool(r1) ^ bool(r2): # exclusive or yield r1
6a1bfebf7c42f8a94745da0474e2826cd0a1a6f4
yashkha3/Exercises
/test/ans10_b.py
333
4.03125
4
x = int(input("Enter x value: ")) y = int(input("Enter y value: ")) if(x > 0 and y > 0): print("It is in First Quadrant") elif(x < 0 and y > 0): print("It is in Second Quadrant") elif(x < 0 and y < 0): print("It is in Third Quadrant") elif(x > 0 and y < 0): print("It is in Fourth Quadrant") else: print("Kindl...
9abcfadd7a4de11dbd810443260c000d7b1f6df7
goyal-aman/codeforces
/Hit the Lottery.py
346
3.734375
4
""" by goyal-aman https://codeforces.com/problemset/problem/996/A """ def notes(money): currency = [1 , 5, 10, 20, 100] notes = 0 for val in currency[::-1]: notes += n//val n = n%val print(notes) #solution 2 n = int(input) def notes2(money): print( (money//100) + (money%100)//20 + (money%20)//10 + ...
933b3b97999120708626e1a34deb8334fe195bc6
saranya1999/sara
/20.py
59
3.6875
4
s=int(input()) for x in range(1,6): print(s*x,end=" ")
9aeac075fb8f7c1ba8e61f9d7025f87672fed6b8
ankitkparashar/python
/Bootcamp/CofeeMachine/main.py
2,672
4.1875
4
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, "c...
a0f0c6ea5a4a7ea38efd0a3fd010d14f7a52d25b
sachihiko/illumio-coding-challenge
/main/attributes.py
2,127
3.78125
4
''' Classes for a firewall rule ''' # Specifies the range of ports accepted for a rule class Port(): def __init__(self, port_str: str): if '-' in port_str: self.start, self.end = (int(x) for x in port_str.split('-')) else: self.start, self.end = int(port_str), int(port_str...
fa2cc4f60b8ce3f2dd2384f938f983b8778a14e2
xuefeihexue/Nanodegree
/project3.py
5,666
4.34375
4
# IPND Stage 2 Final Project # You've built a Mad-Libs game with some help from Sean. # Now you'll work on your own game to practice your skills and demonstrate what you've learned. # For this project, you'll be building a Fill-in-the-Blanks quiz. # Your quiz will prompt a user with a paragraph containing several bla...
3956156cf04cb71dcae9d421ae1b439f6bbbeebb
marykamau2/katas
/python kata/birthday_count/birthday.py
221
4.0625
4
def main(): bdays={"newt":"18/12/1802","diana":"13/02/2005"} print(bdays.keys) name=input("enter a username") if bdays[name]: print(bdays[name]) else: print("there is no such username")
d8c5e0bd5a290223b17ae6e4d7b136800af0e54e
jpdown/twitch-mod-log
/utils/humanReadableTime.py
532
4.1875
4
def time(seconds): """Function to convert seconds to human readable time""" days = seconds // 86400 hours = seconds // 3600 % 24 minutes = seconds // 60 % 60 seconds = seconds % 60 #Create message string message = "" if days != 0: message += "{0} Days ".format(days) if hours ...
aad7745ec5438f18a3d99649de0d922e0e0a9740
ChandanaBasavaraj/python_assignment2
/pgrm7.py
158
4.34375
4
#implement a program to reverse a string without using standard library function string="enter the string" print("reverse string is:") print(string[::-1])
1e963851834d95a51210034435a616a8229c9a4b
benzoa/pythonStudy
/libraries/standard/dataclass.py
519
3.671875
4
from dataclasses import dataclass from datetime import date @dataclass class User: id: int name: str birthdate: date admin: bool = False __age: int = 0 @property def get_name(self): return self.name @property def age(self): return self.__age @age.setter ...
8c41b0c401b2c14d35f425893656df41ab20b8a5
anzhihe/learning
/python/practise/learn-python/python_basic/none_and_range.py
2,381
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @FileName: none_and_range.py @Function: python None & range @Author: Zhihe An @Site: https://chegva.com @Time: 2021/6/21 """ """一、对象None""" """ 1、什么是对象None 对象None用于表示数据值的不存在 对象None是占据一定的内存空间的,它并不意味着"空"或"没有定义" 也就是说,None是"somet...
341514cb47ba8012139dc42fdbdb4c8f02f90a23
DeyanGrigorov/Python-Advanced
/Multidimensional_lists./matrix_shuffle.py
1,117
3.6875
4
def print_matrix(matrix): for i in range(m): print(' '.join(matrix[i])) def print_not_valid(): print('Invalid input!') def valid_input(matrix, commands): if command != 'swap': print_not_valid() elif len(args) != 4: print_not_valid() row_one, col_one, row_two, col_two = li...
fae31e26f1be30947ed9d378146f84e7f2ed907d
pulum03/ML
/Practice/step_function.py
475
3.65625
4
""" def step_function(x): if x > 0: return 1 else: return 0 print(step_function(2)) """ """ import numpy as np def step_function(x): y = x > 0 return y.astype(np.int) x = np.array([-1.0, 1.0, 2.0]) print(step_function(x)) """ import numpy as np import matplotlib.pylab as plt def st...
de709c32e41c47e0ca2d2e8705d07c117df77089
nasolim/ksp_mission_helper
/targetLanding.py
1,898
3.578125
4
# Script Name: targetLanding.py # Author: Milo Sanu # Created: 10/3/15 # Last Modified: # Version: 1.0 # Modifications: # Description: Script which provides the user with coordinates that are a predetermined # distance from the original landing site. from math import sin,cos,radians,pi,degrees from kerbalformulae i...
fe3ad6c7be5530d99e5cebae04fe1b9c1bbefe32
heyb7/python_crash_course
/ch09/ex9-3.py
779
3.578125
4
class User(): def __init__(self, first_name, last_name, username, email, location): self.first_name = first_name self.last_name = last_name self.username = username self.email = email self.location = location def dcscribe_user(self): print("\n" + self.first_name...
9142aa2d93073d7143c590a82d8234dc7e8e786c
gabisala/Kattis
/Closing_the_Loop/closing_the_loop.py
1,952
3.828125
4
# -*- coding:utf-8 -*- import sys # Read data data = [line.split() for line in sys.stdin] def sort_segments(case): """ Sort the segments in blue and red :param case: a list of test cases :return: a tuple with blue and red segments lists sorted from big to small """ blue = [] red = [] ...
f4587f01a4badccd49f73f49a03eddffbd52e08b
joestalker1/leetcode
/src/main/scala/DeleteNodeLinkedList.py
421
3.578125
4
class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def deleteNode(self, node): last = None while node.next: node.val = node.next.val last = node node = node.next last.next = None ...
64052766b17e72615ffe4a6ec91b8625d3213582
saqeeb360/FSDP2019
/Day 11/area_of_state.py
1,522
3.671875
4
# -*- coding: utf-8 -*- """ Created on Tue May 21 12:09:30 2019 @author: Windows Code Challenge https://en.wikipedia.org/wiki/List_of_states_and_union_territories_of_India_by_area Scrap the data from State/Territory and National Share (%) columns for top 6 states basis on National Share (%). Create a Pie Chart usin...
fa8bb582d0df56754d483f956f9d022f0c0b6e8a
1UnboundedSentience/PythonTweeting
/request.py
1,709
3.546875
4
import oauth2 as oauth import time import random import json import math import sys import pprint def grab_tweet(): query = '%20'.join(sys.argv[1:]) # Set the API endpoint url = "https://api.twitter.com/1.1/search/tweets.json?q=" + query token = oauth.Token("1035256117-JEcbtW3741GwyB820PmCHLCvq0Us18FhNSZdDBH",...
d7606902c6e76501c7a941a4381a8122f5cabdb6
suhasreddy123/python_learning
/example programs/find square root of numbers.py
58
3.625
4
num=int(input()) square_root=num**0.5 print((square_root))
64c67d8c0d0765f1e73db81c8a20d4cade5dfd53
WKDavid/python_quiz_game
/ProjectQuizNew.py
5,380
3.921875
4
data = { 'easy': { 'text': '''\nGenerally, every ___1___ has to be within single or double quotes. A ___1___ can be assigned to a ___2___. It is a convention not to use capital letters in ___2___ naming. A ___1___ can not be added to an ___3___, but they can be multiplied. However, it is possible to add ...
521f1e7e6b99400a297b7d7366bc9094f3e02f0b
dannythorne/CSC115_SP16
/dthorne0/09_Loops/main.py
217
4.1875
4
print("Danny Thorne") print("Loops Example") listOfNumbers = [0,1,2,3,4,5,6,7,9] for number in listOfNumbers: print(number,end=" ") print(number*number,end=" ") print(number**3) print("Bye, bye!")
25f6278d4ebe19957fbb685ee35e4e79c4634def
alexandraseg/appInPython
/sort_fruits.py
603
3.859375
4
#Read the file f=open('unsorted_fruits.txt','r') #Create an empty list fruit_list=[] #For every line in file for fruit in f.readlines(): #Remove whitespace from the begin or end of the string fruit=fruit.strip() if len(fruit)==0: continue #Append to the list fruit_list.append(fruit) #Sort th...
aa812db5f10c4281693030aa7b729bda75d46dda
PVyukov/GB_HW
/Lesson3_func/29012020.py
2,017
3.734375
4
# print(max(1, 2, 3, 4, 8)) # print(max('zz', 'aaa', key=len)) # print(round(7.5)) # for index, letter in enumerate(['a', 'b', 'c'], start=5): # print(index, letter) # def say_hello(name): # print(f'Hello {name}!') # # # say_hello('Ivan') # say_hello('Petr') # def average(numbers): # count = len(numbers...
50f737a4eebeb639fb053b75042f2882a575e1d1
joaopaulopires/teste3
/python/exe079.py
1,201
3.671875
4
print('\33[4;35m{:^40}\33[m'.format(' ANÁLISE DE LISTAS II')) valor =[] while True: cont = 0 valor.append(int(input('\33[1;30mDigite um valor: \33[m'))) for num in valor: if valor.count(num) == 2: valor.pop() cont = 1 if cont == 1: print('\33[1;31mValor duplicado!...
7aa50a8dd2bbaed5881a752f464f1770bac733ee
Gedanke/StudyNote
/Math/codes/module_3/l_14_1.py
207
3.9375
4
# -*- coding: utf-8 -*- left = 0 left_temp = 0 right = 0 for k in range(1, 100): left_temp = 2 * k - 1 left += left_temp right = k * k if left == right: print(str(k) + " is right!")
a338fe4e29d8a51a79118e51897f60fdb141ee98
sindhu-thanikonda/Assignment--1_Python-
/18.py
728
3.90625
4
""" Write a program create a random list of length 10 and print all the elements except the elements which are divisible by 4. """ list1 = [ ] val = 0 for str1 in range(10): str1 = raw_input("Enter Random List: ") print "Random String: ", str1 val = len(str1) print "Length...
d4c6672f27cdf0792883ae52a3a5d733a536335e
AntonMir/Stepik
/Калькулятор в диапазоне.py
259
3.609375
4
a = int(input()) b = int(input()) c = int(input()) d = int(input()) for z in range(c,(d+1)): print('\t',z, end='') print() for x in range(a,(b+1)): print(x, end='') for y in range(c,(d+1)): print ('\t',x * y, end='') print()
763a66828954066db9942d24349ccf32e2625377
krishnakatyal/philosophy
/ethics/utiltrolley.py
1,296
4.34375
4
""" We implement a basic, simplified utilitarian method of reasoning to solve the trolley problem. The problem consists of deciding whether to pull a lever that would change the track of an incoming train such that it would kill fewer people tied to the tracks. Given a directed graph as an input file and a nonnegativ...
8367b534569a8312e6203fdc2a3650b5662b6b94
habroptilus/atcoder-src
/abc/077/python/code_b.py
260
4.0625
4
N = int(input()) def max_square(n): """ >>> max_square(10) 9 >>> max_square(81) 81 >>> max_square(271828182) 271821169 """ base = 0 while (base + 1)**2 <= n: base += 1 return base**2 print(max_square(N))
4dfd2f4dc915d0ba611ea2dfc59ef3eb738b9cc6
ZHHJemotion/algorithm008-class01
/Week_03/47.Permutations_II.py
1,219
3.546875
4
# Given a collection of numbers that might contain duplicates, return all possib # le unique permutations. # # Example: # # # Input: [1,1,2] # Output: # [ # [1,1,2], # [1,2,1], # [2,1,1] # ] # # Related Topics Backtracking # leetcode submit region begin(Prohibit modification and deletion) class Solution: ...
0839c0e2c12f02fae003319ff5bc0e2e45572adc
haticeaydinn/Hello-World-with-Python
/GuessingGame.py
273
3.84375
4
guess_count = 0 magic_number = 9 guess_limit = 3 while guess_count < guess_limit: guessed_number = int(input("Guess: ")) guess_count += 1 if guessed_number == magic_number: print("You won!!!") break else: print("You failed...")
0881febb52c8bac019042c99a56943a22ef93ab8
stani95/stani95
/CS166_final.py
25,498
3.921875
4
from matplotlib import pyplot as plt import networkx as nx import numpy as np import math np.random.seed(0) #Each package has on origin, a destination, and a current position (a city or a road) class Package: def __init__(self, origin_index, destination_index, current_position): self.destination_index = de...
ae8017e645946884ec49cb2d72e0f55b87de9686
burakonal89/edu-projects
/pycharm_projects/HackerRank/10 Days of Statistics/1_0.py
1,276
4
4
def find_median(number_list): "Assuming that number_list is sorted" if len(number_list)%2 == 0: return (number_list[len(number_list)/2]+number_list[len(number_list)/2-1])/2.0 else: return number_list[(len(number_list)-1)/2] def findQuantile(input_numbers): if len(input_numbers)%2 == 0: ...
30deb5a82c95a6bfd098829d1f72386df351c448
DonghaoQiao/Python
/0Leetcode Solutions/0006 ZigZag Conversion.py
1,932
4.3125
4
''' https://leetcode.com/problems/zigzag-conversion/ 6. ZigZag Conversion Medium The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read l...
a12f705b6c35e09f4945d09462efdb36c2c85108
martinbaros/competitive
/CodeJam/2019/solution.py
447
3.953125
4
# input() reads a string with a line of input, stripping the '\n' (newline) at the end. # This is all you need for most Kickstart problems. t = int(input()) # read a line with a single integer for i in range(1, t + 1): case = str([int(s) for s in input().split(" ")][0] )# read a list of integers, 2 in this case ...
615d95b80358c3042cc1c9a325ce4efb4c42b56b
vladi837/tms-21
/hw05/task_5_5.py
1,438
3.890625
4
''' В массиве целых чисел с количеством элементов 19 определить максимальное число и заменить им все четные по значению элементы. [02-4.1-BL19]''' from random import randint maximum1 = 0 def is_even_let(_x): # Вложенная функция проверки числа х на чётность global maximum1 # Чтение внешней переменной if _x...
e34b01e79fb4b799d2a41d50912c95c428d64f4a
geekysid/Python-Projects
/Rock, Paper Scissor/RPS Version 1.1.py
2,209
4.40625
4
# author: Siddhant Shah # Desc: An update to basic version of RPS. This program converts inout text to upper case and does all testing # using upper case. This removes any ambiguity about lower and upper case import random print("Welcome to the Rock, Paper, Scissors Game") user_input = input("Please choose one of the...
0f8c3ca15e7a0379ce53fab5a1aa4997a951985c
Syzygy05/CS435-Project2
/thankUVertext/main.py
1,222
3.609375
4
import node import directedGraph import topSort import random def createRandomDAG(n): dag = directedGraph.DirectedGraph() randomNums = [] for i in range(n): while True: val = random.randint(0, n * 10) if val not in randomNums: randomNums.append(val) ...
97e46b5d680b0fe287856ff72096ae3671a2d87b
eebmagic/python_turtle_art
/pattern_spirograph/patternSpirograph.py
345
3.515625
4
import turtle t = turtle.Turtle() # t.speed("fastest") angle = 45 / 2 iterations = 25 adjust_angle = 5 turts = 360 // adjust_angle for x in range(turts): t = turtle.Turtle() t.speed("fastest") t.left(x * adjust_angle) for i in range(iterations): t.fd(100) t.left(i * angle) t.hide...
2fae836dc606d29f5aa12ba1087680209983f43e
amineHY/video2audio
/video2audio.py
1,025
3.546875
4
import youtube_dl import os print('[Info] Simple video-to-audio converter \n') video_url = input('Enter the youtube URL of the video or playlist: ') print('[Info] You have entered:', video_url) def createFolder(dirName): try: # Create target Directory os.mkdir(dirName) print("Directory...
56c14f1a4217be9e3d260816d839151364f80e55
ryanmcg86/Euler_Answers
/053_Combinatoric_selections.py
1,265
3.609375
4
'''There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In combinatorics, we use the notation, 5C3 = 10 5C3 = 10. In general, nCr = n! / r!(n−r)!, where r ≤ n, n! = n × (n−1) × ... × 3 × 2 × 1, and 0! = 1. It is not until n = 23, that a value exceeds o...
c55e82849ba44d1d46fb02a772e8af1dbba1df04
calebpalmer/pypgbackup
/pypgbackup.py
3,921
3.59375
4
import argparse import subprocess import datetime import os import getpass import tempfile import sys def get_dt_format(): """ Gets the datetime format string. Returns: str: The datetime format string. """ return '%Y%m%d-%H%M%S' def create_arg_parser(): """ Creates an argument pa...
5c99ff057ec235421354a01771172cc87e695490
keolam/Project-Euler
/p005.py
508
3.53125
4
# This Python file uses the following encoding: utf-8 """ 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? """ import functools as ft import fractions def lcm(a...
1c02bad3c6d9d3a1e687bdf01aa3f1ac5d3160f0
diopch/stock_prediction
/stock_prediction/tradding_app.py
13,388
3.890625
4
import pandas as pd import numpy as np from stock_prediction.params import company_list import pdb from datetime import datetime, timedelta def best_stocks(df, sell=True, eq_weight=False) : '''This function allows us to select the best 10 stocks in our predictions of returns for each day of the tradding expe...
5b53e5fdc0534a3e813764c607c4fb61717f59d7
bestchenwu/PythonStudy
/Unit18/ProducerConsumerTest.py
1,199
3.796875
4
import threading from time import ctime, sleep from random import randint from queue import Queue def write(queue): # print("Producer produce start:%s" % ctime()) value = randint(1, 99) queue.put(value) print("Producer put value %d " % value) # print("Producer produce end:%s" % ctime()) sleep(...
43cba49f72330ea1ad5de3fae55c50895b97950d
Ash25x/PythonClass
/p.py
1,711
4.09375
4
# #write a function that takes an array of integers # # and returns if it has more even numbers or more odd numbers? # # l =[2,4,6,8,7] # # def array1(l): # countodd = 0 # counteven = 0 # for i in l: # if i % 2 == 0: # counteven += 1 # print(counteven) # else: # ...
fd3ca38ba86efdd3401129f19329ed5e8578563a
halflogic/learn-python
/rps-game.py
2,062
4.375
4
# A game of rock, paper, scissors against the computer import sys import random print("Welcome to Rock, Paper, Scissors game!") win = 0 lose = 0 tie = 0 # use dictionary for the choices choice_dict = {'r':'Rock', 'p':'Paper', 's':'Scissors'} while True: print("-----------------------------") print("Score: ...
0443c4c129fb47ebea24e145131a0fd494e321bb
rjorth/Algorithms-and-Data-Structures
/LHS.py
340
3.890625
4
import collections def findLHS(nums): #counter counts the number of times that an element appears in the list #you constantly confuse this with enumerate count = collections.Counter(nums) #store result arr = 0 for i in count: if i+1 in count: arr = max(arr, count[i] + count[i+1]) return arr print(findL...
54be3853f398bf9b8e26e095a2ddc6ef4e7b9092
rbiswas4/utils
/binningutils.py
2,816
3.953125
4
#!/usr/bin/env python import numpy as np import math as pm verbose = False def nbinarray(numpyarray , binningcol , binsize , binmin , binmax ): """ bins a numpy array in equal bins in the variable in the column of the array indexed by the integer binningcol. args: binningcol: integer, manda...
51b499e33a8ed175b89381d1786ac2daeb0399b9
gabriellaec/desoft-analise-exercicios
/backup/user_256/ch131_2020_04_01_18_25_49_144668.py
884
3.953125
4
#Fase1: import random dado1= random.randint(1, 10) dado2= random.randint(1, 10) sorteio = dado1+dado2 print("Voce tem 10 dinheiros") dinheiro = 10 #Fase de dicas nmr1 = int(input("Digite um numero: ")) if sorteio < nmr1: print("Soma menor") nmr2 = int(input("Digite outro numero: ")) if sorteio > nmr2: print("S...
a14454728f2a8ec6430341a2e921b38a6c4ff505
Gowtham-cit/Python
/Guvi/int-to-bin-count-of-1s.py
200
3.5625
4
def int_bin(n): x = "{0:b}".format(n) x = str(x) count = 0 for i in x: if i == '1': count += 1 print(count) n = int(input()) int_bin(n)
b9656eed835a4a701822af05c69312db01869424
woernerm/cucoloris
/cucoloris/_colorlabel.py
5,452
3.75
4
"""Defines a label that can change color. The color shift is animated. This can be used for link-style text. """ from os.path import dirname as _dirname from math import modf as _modf from typing import Optional as _Optional from kivy.animation import Animation as _Animation from kivy.graphics import Color as _Color...
07d9bb8c501270ea93a950cd7fdc9a54b01be99d
timkaing/spd-2-4
/leetcode/14.py
390
3.765625
4
# Write a function to find the longest common prefix string amongst an array of strings. # If there is no common prefix, return an empty string "". def longestCommonPrefix(self, strs): if not strs: return "" for index, letter in enumerate(zip(*strs)): if len(set(letter)) > 1: ret...
a96d5e960611a308638263d25c619b67112cc664
Toyin5/HacktoberfestAlgorithmsExercices
/exercicies/medium.py
1,386
3.84375
4
class Medium: # description: paste the description here # enter parameters: paste the enter parameters examples here # return: paste the return expected here def nameOfFunction(self, value1, value2): # script here return None # description: Create a function to return sorted array...