blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c63ccfe9c85115d36590347dca277ec3032054a7
Halldor-Hrafn/PythonShenanigans
/Forrit40.py
332
3.515625
4
file = open('nofn.txt') eList = [] aList = [] for line in file: word = line.strip() if 'e' in word: eList.append(word) if word[2] == 'a': aList.append(word) print('the names with an "e" in them are:', len(eList)) print(aList) print('The amount of names with "a" as the thrid letter are:', ...
a4fb7bad59202e2adf3879b24036d9f6ed36ce97
Davebreaux/Class
/Python/Day1/functionBasics.py
2,128
4.03125
4
#1 def number_of_food_groups(): return 5 print(number_of_food_groups()) # 5 #2 def number_of_military_branches(): return 5 print(number_of_days_in_a_week_silicon_or_triangle_sides() + number_of_military_branches()) # error function not defined #3 def number_of_books_on_hold(): return 5 return 10 pr...
1664ad9f7047c4c6fa0834b663f1169ceb590ff8
Thamaraikannan-R/Condition_Statement
/Div_by_3.py
177
4.15625
4
low=int(input("Enter the low number:")) high=int(input("Enter the highest number:")) while(low<=high): print(low) if(low%3==0): print("div3") low=low+1
ec8b6d2d38474be282b0b52c512af546d7a4e321
NOY10/pyproject
/myalgo/binarysearch2.py
1,914
3.703125
4
class User: def __init__(self, username, name, email): self.username = username self.name = name self.email = email def __repr__(self): return "User(username='{}', name='{}', email='{}')".format(self.username, self.name, self.email) def __str__(self): re...
2b931e71b94e197cd2af5bb78e0d1b2d55f6e011
BishuPoonia/coding
/Python/list_addition.py
160
3.671875
4
def array_sum(ar): return sum(ar) ar = list(map(int, input("Enter list items: ").rstrip().split())) print("Addition on list items:", array_sum(ar))
269bf0415e49ce62057ad989ca3e598af3bfd248
Yue-Xiong/ri_li_cha_xun
/main_code.py
557
4.09375
4
year = int (raw_input('year:\n')) month = int (raw_input('month:\n')) day = int (raw_input('day:\n')) months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334] if 0<month<=12: xuhao = months[month-1] xuhao +=day leap = 0 if (year % 4 == 0): leap = 1 days = [31, 28+leap, 31, 30, 31, ...
87eb6d7ed653f603a457ec790fc94ccf7ddc39ce
pingao2019/DS-Unit-3-Sprint-2-SQL-and-Databases
/module1-introduction-to-sql/buddymove_holidayiq.py
1,850
3.71875
4
# module1-introduction-to-sql/buddymove_holidyiq.py #- Count how many rows you have - it should be 249! #- How many users who reviewed at least 100 `Nature` in the category also # reviewed at least 100 in the `Shopping` category? #- (*Stretch*) What are the average number of reviews for each category? import pandas a...
6e7797562ae56947d39c26f2eeaabf52dc3a7bc8
amazingcodeLYL/Crawler-practice
/crawler_practice/numpy/numpy5.py
465
3.703125
4
import numpy as np A=np.arange(12).reshape((3,4)) print(A) # [[ 0 1 2 3] # [ 4 5 6 7] # [ 8 9 10 11]] B=A.copy() print("B=",B) # B= [[ 0 1 2 3] # [ 4 5 6 7] # [ 8 9 10 11]] #纵向分割 print(np.split(A,2,axis=1)) # [array([[0, 1], # [4, 5], # [8, 9]]), array([[ 2, 3], # [ 6, 7], # ...
2e81cbee2da6e44d9397037cf28e3f69a1ff57f9
sarvparteek/Scientific_computation_2
/romberg_integration2.py
592
3.71875
4
#script: ex-romberg-todo.py #author: Luis Paris import math import _plot, _numinteq def f(x): return (x + 1/x) **2 ; #true integral of f(x) def Itf(x): return (1/3 * x**3) - 1/x + 2*x; #evaluation range x0 = 1 xn = 2 #plot function _plot.graph(f, xl=x0, xu=xn, title="f(x) = (x + 1/x)^2 ") #true value of integral ...
06b8e1c318e23d6aa360303d8e9fa220baea3f0d
G30RG3PAK/Python_Practice
/RoPaSc.py
878
3.9375
4
import sys userone = raw_input("What's your name?") usertwo = raw_input("And...?") userone_answer = raw_input("%s, choose rock, paper or scissors?" % userone) usertwo_answer = raw_input("%s, choose rock, paper, or scissors?" % usertwo) def compare(u1, u2): if u1 == u2: return("It's a tie!") elif u1 =...
aced2878f93addeb3c887135844ba7c1bd991955
suprviserpy632157/zdy
/ZDY/Jan_all/pythonbase/January0107/afternoon.py
1,714
3.828125
4
# 写程序,实现以下要求 # 用户输入一个整数代表这个季度,打印这个 # 季度的信息,用户输入的信息不在字典内打印不存在 # seasons={ # 1:'pring has 1,2,3month', # 2:'summer has 4,5,6month', # 3:'automn has 7,8,9month', # 4:'winter has 10,11,12month' # } # print(seasons) # x=int(input("Please input a number(1-4):")) # d={} # d[1]='spring has 1,2,3month' # d[2...
aa6b6396af980c6e0d571b39afefbccc5532301e
BarelyMiSSeD/PUBG
/calc_rank.py
19,247
3.5
4
#!/usr/bin/env python3 RANKING_FILE = "current_rankings.txt" # The name of the file holding the current tournament standings NQ_FILE = "not_qualified.txt" # The file to hold the players without enough games to qualify GAME_FILE = "game_{}.txt" # The name structure for the file saved for each ...
e51d5701868edaea6763157116f5bd8c2488f5f8
buddy-israel/pyships_parser
/MyDatabase.py
287
3.53125
4
import sqlite3 import os import json conn = sqlite3.connect('WoWs_DB') c = conn.cursor() def ship_tbl_select_name_type(ship_id): c.execute(""" SELECT ship_name, type FROM tbl_ships WHERE ship_id=? """, (ship_id,) ) rows = c.fetchall() for row in rows: return(row)
ea00d83da32c5eb2fa435a4fab7cc3791c4fccbb
arnabs542/Competitive-Programming
/Codelearn.io/Code Practice/maxPoint.py
246
3.546875
4
# https://codelearn.io/training/detail?id=632023 def maxPoint(a, b): ans = [] mark_max = [a[0]] for i in range(1,len(a)): mark_max.append(max(a[i],mark_max[i-1])) for i in b: ans.append(mark_max[i]) return ans
f571a3698b380d7cb56f20138ba5efa6848ab58e
This-is-NB/CodeChef
/JUN21_CodeChef/Optimal_Xor_Set.py
367
3.546875
4
import math def invertBits(num): x = int(math.log(num, 2.0) + 1) for i in range(0, x): num = (num ^ (1 << i)); return num ; def optimal_xor_set(n,k): if k ==1:return [n] if k ==2:return [n,invertBits(n)] return -1 for i in range(int(input())): n,k = map(int,input().split())...
7c1caf588db912e3fb2bf2b268002e6d617ebb8f
romcra/romcrap
/romcrap/Extension.py
2,392
4.46875
4
######################### EXTENSION ###################################### # 1. Write a function that will simulate numbers from a given distribution. # The function should take one argument for the number of samples and # a second argument which specifies the distribution # (Normal, Poisson or Binomial). The funct...
a4ac87cf3b5d8ba54a649b617eb9628b1c26f67d
jaymz95/ThompsonsPython
/regex.py
2,561
3.546875
4
# Matching Regular Expressions with Strings using Thompsons Construction and Shunting Yard Algorithm # James Mullarkey # Importing functions from other python files from shunt import toPostfix from thompsons import compile def followes(state): """Return the set of states that can be reached from state following e...
67692d328ae67d39f1700ede3cf7bc09640e8baa
zhy0313/children-python
/教孩子学编程++PYTHON语言版/6.1 GuessingGame.py
378
4.09375
4
import random # random integer,随机数 the_number = random.randint(1,10) guess = int(input("Guess a number between 1 and 10: ")) while guess != the_number: if guess > the_number: print(guess,"was too high. Try again.") else: print(guess,"was too low. Try again.") guess = int(input("Gues...
fcc8bf549473510e137686e403dd228a688b36a9
road-to-koshien/kevin-leetcode-challenge
/LEETCODE/205. Isomorphic Strings.py
1,228
4.03125
4
# https://leetcode.com/problems/isomorphic-strings/ # Given two strings s and t, determine if they are isomorphic. # Two strings are isomorphic if the characters in s can be replaced to get t. # All occurrences of a character must be replaced with another character while preserving the order of characters. No two ch...
a1301efd403562cda08ea7d78a21c236d31fa86f
yaoyu2001/LeetCode_Practice_Python
/DataStructure/dynamic_programming.py
1,918
3.5
4
# https://www.youtube.com/watch?v=Jakbj4vaIbE&t=26s # Dynamic programming Question 1 # Given an array, choose tow of them which have most sum value. These two numbers can't Adjacent # OPT = optimazition has two situation. Choose or not choose. OPI(i) = max { choose opt(i-2) + arr[i], opt(i-1)} # When i = 0, only has on...
f898ae48a631cd8093c3b388989f62de4238bd7f
N140191/Turtle-Graphics
/tkinter_test.py
301
3.75
4
from tkinter import * def main(): rt=Tk() rt.title("My first tkinter App") rt.minsize(width=300,height=300) rt.maxsize(width=300,height=300) button=Button(rt,text="Click!!",width=12,height=1) button.pack() rt.mainloop() if __name__=="__main__": main()
8d7fc03dd07185bb6e3ca78c0c1263d14067d4d4
bsonge/CodePracticeDump
/10dayStats/MeanMedianMode.py
1,150
3.734375
4
# Input N = int(input()); arr = input(); arr = list( map(lambda a: int(a) , arr.split(' ')) ) # print(N, arr) #=====[FUNCTIONS]=====# def mean(li): #add all numbers together then divide by total total = 0 for num in li: total += num return round(total/len(li) , 1) def median(li): li.sort(...
6ef753dd792cb8e11895c8461e79df5186d58b2e
patthrasher/codewars-practice
/kyu7-1.py
661
4.03125
4
# Create a function named divisors/Divisors that takes an integer n > 1 # and returns an array with all of the integer's divisors(except for 1 and # the number itself), from smallest to largest. If the number is prime return # the string '(integer) is prime' (null in C#) (use Either String a in Haskell # and Result<Vec...
f067f3c71f5437b369ac02ba3358ab1a3aa5f04e
aislinnm12/learning_python
/finalproject.py
1,860
4.1875
4
#!/usr/bin/env python3 # final project # generating random first and last names import string import random from random import randrange vowels = 'aeiou' consonants = 'bcdfghijklmnpqrstvwxz' def get_letter(last_letter=None): # Check if last letter generated was a consonant if last_letter: last_lette...
3c1d0d70a7b6d1b1d99001f1084e2a51a464ee67
peltierchip/the_python_workbook_exercises
/chapter_1/exercise_20.py
483
4.34375
4
## #Compute the amount of gas in moles R=8.314 #Read the value of the pressure, volume and temperature from the user pressure=float(input("Enter the value of the pressure in Pascal:\n")) volume=float(input("Enter the value of the volume in liters:\n")) temperature=float(input("Enter the value of the temperature in degr...
35641f41ce345d4ed8032eb8ab9c8a127be08196
jabrayare/Sort-Algorithms
/selectionSort.py
472
4.1875
4
from typing import List """ Sort array A[1..n] of size n by recursively selecting the maximum element and placing it at the end of the array """ def selectionSort(arr: List[int], n: int): if n < 1: return for i in range(0, n): if arr[i] > arr[n]: arr[i], arr[n] = arr[n], arr[i] selectionSort(arr, n...
175d10548886a942c7786fe7e37142524312c9a2
victorwongth/hackerrank-solutions
/interview-preparation-kit/string-manipulation/special-string-again/special-string-again.py
1,547
3.703125
4
# https://www.hackerrank.com/challenges/special-palindrome-again/problem #!/bin/python3 import math import os import random import re import sys # Complete the substrCount function below. def substrCount(n, s): # First build a list that stores strings occurences as sets # i.e. s = "aabcdaa" would be stored a...
04f2299f286472d033497791bdd7c27d9168b1af
dikoko/practice
/6 Trees/6-07_check_bst.py
1,827
3.515625
4
import math class BTNode(object): def __init__(self, val): self.val = val self.left = None self.right = None def build_from_list(inlist): if not inlist: return root = BTNode(inlist.pop(0)) wqueue = [root] while inlist: node = wqueue.pop(0) ...
234c094967e1a77314d4ac8cebe0d39833ce8d38
isharajan/my_python_program
/avarage no in list.py
259
3.921875
4
n=int(input("enter n no:")) list1=[] for i in range(n): n=int(input("enter the no:")) list1.append(n) print(list1) sum=0 for a in list1: # print(a) sum=sum+a print("sum is",sum) avarage=sum/len(list1) print("the avarage is",avarage)
3f6a8d539e04223a175c895b82a406ef5bf26d04
martindavid/code-sandbox
/algorithm/COMP90038/comp90038-assignment2/pareto_optimal.py
1,441
3.796875
4
from __future__ import print_function point = [ (1, 11), (2, 1), (2, 6), (4, 3), (4, 8), (5,10), (6, 6), (8, 7), (10, 4), (11, 2), (11, 11), (11, 7), (11, 10), (11, 4), (12, 5) ] X = [] Y = [] sorted(point, key=lambda x: x[0]) print(point) temp_point = point[len(point) - 1] y_max = temp_point[1] pareto_optim...
8416f6e63d1d4d3a6763df0d49686f3e12910a04
beneen/nobody-likes-a-for-loop
/tests/test_check_permutation.py
823
3.703125
4
from unittest import TestCase from string_manipulation.check_permutation import check_permutation class TestCheck_permutation(TestCase): def test_check_permutation_empty(self): self.assertEqual(True, check_permutation("", "")) def test_check_permutation_empty_1(self): self.assertEqual(False,...
5523424311e61d3772d9f16eb86a496ef286358f
keasyops/BaseCode
/python/6.net/6.rpc/1.test/1.localhost.py
157
3.734375
4
def sum(a, b): """return a+b""" return a + b def main(): result = sum(1, 2) print(f"1+2={result}") if __name__ == "__main__": main()
546224b3f7a37b6cbe81799c985c8c431d30c77f
JasPass/Projects
/Project_Euler/Problem 14 script.py
1,461
3.671875
4
# Project Euler: Problem 14 # # # Which starting number, under one million, produces the longest chain? import time # Sets starting time of program startTime = time.time() # Function to run the sequence until 1 is reached def sequence(n, sequence_length=1): # Checks if (n) is even if n % 2 == 0: n /...
fb78f5f6c9f6c5bdbe24a0c63228dfc9bc7c4317
cce-bigdataintro-1160/winter2020-code
/4-python-advanced-homework/numpy-exercises.py
1,928
4.15625
4
import numpy as np # 1 - Create your first array with the elements [1,22.4,5,35,4,6.7,3,8,40] and print it. Experiment what the # following functions do: ndim, shape, size and dtype. my_array = np.array([1, 22.4, 5, 35, 4, 6.7, 3, 8, 40]) print(my_array) print(f'my_array.ndim is {my_array.ndim}') print(f'my_array.shap...
99854ce996de0606fe5a797acc32d72cd0818a5f
SatyamJindal/Competitive-Programming
/CodeChef/Chef and prime Queries.py
720
3.703125
4
from math import sqrt n=int(input()) a=list(map(int,input().split(" "))) q=int(input()) def isPrime(x): flag=0 for i in range(2,int(sqrt(x))+1): if(x%i==0): flag=1 break if(flag==1): return False else: return True def F(L,R,X,Y): result=...
1305ac39181fa5afc93c50679c9657ddf96a9b8a
lfdyf20/Leetcode
/Clone Graph.py
821
3.6875
4
# Definition for a undirected graph node class UndirectedGraphNode: def __init__(self, x): self.label = x self.neighbors = [] from collections import deque class Solution: # @param node, a undirected graph node # @return a undirected graph node def cloneGraph(self, node): if not nod...
867be1f4144834bd20914439283198fd99efbb06
Daniel-TheProgrammer/Sub-Directory-Update
/dan2.py
352
3.515625
4
from tkinter import* root=Tk() topFrame= Frame(root) top.Frame.pack() bottomFrame=Frame(root) bottomframe.pack(side=BOTTOM) button1= Button(topFrame,text="Button1",fg="red") button2= Button(topFrame,text="Button2",fg="blue") button3= Button(topFrame,text="Button3",fg="green") button4= Button(topFrame,text="Button4",...
13e01313f6b2534b0c74b0f0284565616c9c56c1
SkyNet214/WPU-INFO
/Python/Graphentheorie/graph.py
2,453
3.703125
4
# graph .py # Ein Graph ist ein Menge von Knoten und eine Menge von ungerichteten Kanten # Die Darstellung erfolgt in einer Adjazenzliste mithilfe eines Dictionary # Knotenwerte sind vorerst nur Zahlen class Graph(): def __init__ (self, graph={}) -> None : self.__graph = graph def vertex_count(self) -...
cc478b8b42776a196f3c6f081fcae6e24627bb5e
TPei/jawbone_visualizer
/plotting/LineGraph.py
1,470
3.53125
4
__author__ = 'TPei' import matplotlib.pyplot as plt from plotting.Plot import Plot class LineGraph(Plot): """ representing a line graph """ def __init__(self, data=None): """ :param data: data dict {'xdata': [...], 'ydata': [...]} sets ydata and xdata :return: ...
88a3907ee633b95bdd77e3bfef567bab4c5ca35c
shonihei/road-to-mastery
/leetcode/distribute-candies.py
575
4.125
4
""" Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these candies equally in number to brother and sister. Return the maximum number of kinds of candies the sister could gai...
6d80acd8524eecad6714e589a4cc9f40be8d35d8
ShunKaiZhang/LeetCode
/search_in_rotated_sorted_array_II.py
1,759
4.15625
4
# python3 # Follow up for "Search in Rotated Sorted Array": # What if duplicates are allowed? # Would this affect the run-time complexity? How and why? # Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. # (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). # Write...
631ea9106eccef6e883c579d91569dcbcdc2b6d5
anhnh23/PythonLearning
/src/theory/control_flow/for_loop.py
1,569
3.765625
4
''' Created on Dec 8, 2016 @author: ToOro ''' """ Behind the scene: for statement calls iter() on the container object. """ #--------- How iter() works --------- s = 'abc' it = iter(s) print(next(it)) print(next(it)) print(next(it)) # enumerate() : can be retrieved index and corresponding value for i, v in enumerate(...
b55431ded794822e76e0834f4524e918078e4739
jashidsany/Learning-Python
/LCodecademy Lesson 10 Classes/LA10.15_Exceptions.py
978
3.828125
4
# An Exception is a class that inherits from Python’s Exception class. # We can validate this ourselves using the issubclass() function. issubclass() is a Python built-in function that takes two parameters. issubclass() returns True if the first argument is a subclass of the second argument. It returns False if the f...
7a500c4181d2d4c793b3856bb84a509db361b861
Mohit-Maurya/Baisc_Interesting_programs_
/higher_lower_game/main.py
1,305
3.890625
4
from art import logo, vs from game_data import data from replit import clear import random #Choose 2 random data A = random.choice(data) B = random.choice(data) #compare A and B 'follower_count' def compare_AB(a, b): if a > b: return "a" else: return "b" #Print logo AND compare A - vs - Agai...
24c58cd85a2c825df516adc47509493981256ba2
parsanoroozi/Pythonw3schools
/src/Tutorial/variable/Variable.py
1,131
4.4375
4
# multiple variable x, y, z = "Orange", "Banana", "Cherry" print(x) print(y) print(z) x = y = z = "Orange" print(x) print(y) print(z) fruits = ["apple", "banana", "cherry"] x, y, z = fruits print(x) print(y) print(z) x = "Python is " y = "awesome" z = x + y print(z) #global variables: x = "awesome" def myfunc():...
910091988637152040d4c50cbddff2e42e092d8a
methjx/educ_de_ba_ver
/bölüm4_oop/objectorientedpro3.py
1,486
4.46875
4
#Inheritance (Kalıtım): Miras Alma #Person => name, lastname, age, eat(), run(), drink() #Student(Person), Teacher(Person) gibi class tanımlarsam üstteki görevleri bu classda olmasını isterim #Animal = > Dog(Animal), Cat(Animal) class Person(): def __init__(self, fname, lname): self.isim = fname ...
ec4b7a7cad3b21a09a3b035092467d67d3b06c03
SiddarthSingaravel/CS50
/pset6/mario/less/mario.py
368
3.890625
4
from cs50 import get_int # getting correct user input while True: h = get_int("Height: ") if h > 0 and h < 9: break # initalizing i and j to 0 i = 0 j = 0 # running two loops for printing blocks for i in range(h): for j in range(h): if i + j < h - 1: print(" ", end="") ...
ddf24a45c8542eee94779c6b89ab1fa462c005b4
Vigneshrajvr/Python-Intership-BEST-ENLIST
/day2.py
639
3.765625
4
print('30 days 30 hours challenge'); print("30 days 30 hours challenge"); Hours='thirty'; print(Hours); Days='Thirty days'; print(Days[0]); Challenge = "I will win"; print(Challenge[7:10]); print(len(Challenge)); print(Challenge.lower()); a = "30 Days"; b = "30 hours"; c = a + b; print(c); c = a + " " + b...
f12983388c8185b6c37e20c7ac62b9f363f08aa1
tbywaters/cryptopals-solutions
/cryptopalsmod/stringops.py
1,139
4
4
""" A collection of functions which are used for manipulating string when solving the cryptopals challenges""" def kequalsv_to_dict(kequalsv_str): """Splits a string into chucnks using & as separators. Builds a dictionary from each chunk using = as a separtor for keys and values. eg: 'foo=bar&baz=...
eba80c6370211b29efd21c98c9298c6385d85875
lizhihui16/aaa
/pbase/day18/shili/class_method2.py
363
3.734375
4
class A: v=0 @classmethod def get_v(cls): return cls.v #获取类变量v的值 @classmethod def set_v(cls,value): cls.v=value #设置类变量v=value a=A() #创建的实例对象 print(a.get_v()) #借助对象来调用类方法 a.set_v(100) #借助对象来设置类变量v print(a.get_v()) #100 print(A.v) #100
24a3ef2915a7dbcfff963dff82ad51429f7e5a2f
masonbot/Wave-1
/Wave 1/makingchanges.py
302
3.765625
4
Cash = int(input("Insert amount of cash in cents:")) print(Cash//200, "Toonies") Cash= Cash%200 print(Cash//100, "loonies") Cash= Cash%100 print(Cash//25, "quarters") Cash = Cash%25 print(Cash//10, "dimes") Cash = Cash%10 print(Cash//5, "nickles") Cash = Cash%5 print(Cash//1, "pennies") Cash = Cash%1
170c155ab5aa03873a78f028a2b35d92b83213e5
aravindhan2000/test
/odd and even number.py
290
4.0625
4
#!/usr/bin/env python # coding: utf-8 # In[10]: numbers=(1,2,3,4,5,6,7,8,9) count_odd=0 count_even=0 for i in numbers: if i%2: count_even+=1 else: count_odd+=1 print("Number of even numbers :",count_even) print("Number of odd numbers :",count_odd) # In[ ]:
3c47566c01205069c7403bc785f2cad463134294
AzimAstnoor/BasicPython
/5r.py
277
3.578125
4
try: i = int(input('Enter the no.')) a = [] for i in range(0, i): b = int(input('Enter the no.')) a.append(b) i = i - 1 m = [] for x in a: if x%2 != 0: m.append(x) print(m) except Exception as Z: print(Z)
9f8fd7ce49ff5bf9183fb733dd72e99e2273b9df
smartvkodi/learn-python
/4-Python_Flow_Control_Part-1/63-Finding_Smallest_and_Biggest_Number_by_using_if-elif-else.py
2,448
4.34375
4
# 63 - Finding Smallest and Biggest Number by using if-elif-else Statement msg = '63 Finding Smallest and Biggest Number by using if-elif-else Statement' tn = ' '*5 text = '#'+ tn + msg + tn + '#' i = len(text) print('#'*i) print(text) print('#'*i) print('\n') print('''Program-1: Find the biggest Number of 2 given num...
0f52957230c9ac650ffd29d24a6da26701bfc97c
whoisgvb/initial_python
/estruturaRepeticao/018.py
419
4.03125
4
""" Faça um programa que, dado um conjunto de N números, determine o menor valor, o maior valor e a soma dos valores. """ n = int(input("Digite os laços: ")) maior = 0 menor = 0 for i in range(n): x = int(input("Digite um número: ")) maior = (maior if maior != 0 and maior > x else x) menor = (menor if menor ...
740aec520fd9e276b6c88177adc00d2749895033
kesihain/python-challenges
/binary_search.py
368
3.78125
4
def binary_search(target, my_list): # your code low = 0 high = len(my_list) while low <= high: i = (low+high)//2 if my_list[i] < target: low = i+1 continue if my_list[i] > target: high= i-1 continue return i return Non...
4473191b48b90a9576f654df44a01ac1cfbef05d
ivn-svn/Python-Advanced-SoftUni
/Exam/Problem2..py
2,053
3.78125
4
from math import floor PLAYER = "P" WALLS = "X" def create_matrix(size): return [input().split() for line in range(size)] def find_player_position(matrix, PLAYER): for row in range(len(matrix)): for col in range(len(matrix)): if matrix[row][col] == PLAYER: return (row, col...
4e6be706b2542a950565c110e79d2fafd9304b81
m3schroder/coursefiles
/AI/8-puzzle with a-star/functions.py
1,277
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Calculates total displaced tiles on the board def h1(state): displaced = 0 goal = [[0,1,2],[3,4,5],[6,7,8]] for i in range(0,3): for j in range(0,3): if goal[i][j] != state.__hash__()[i][j]: displaced += 1 return disp...
9b9e60f1b2a70826a075bc66c4989ca4277ed93e
JacobSilasBentley/EulerProject
/problem2.py
835
3.90625
4
# Problem 2 # # Each new term in the Fibonacci sequence is generated by adding the # previous two terms. # By starting with 1 and 2, the first 10 terms will be: # # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # # By considering the terms in the Fibonacci sequence whose values do # not exceed four million, fin...
d31333b29ba5ed90d3453f67056e5792163ea79e
amobdi/faseeh
/fasseh/Parser.py
2,977
3.609375
4
import itertools from textblob import Word # class Parser is responsible to parse the tags of the statement to get all nouns, verbs, questions words and generate all patterns class Parser(object): # define the tags needed to extract the nouns, the verbs, the question words. def __init__(self): self.noun_tags = ['...
9826382e86c71a3e0cef23c4d4c5b490d80f3d00
saikiranrede/Coding-challenges
/rndm_pass_gen.py
322
3.796875
4
import random chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()' def pass_char(value): password = '' for item in range(value): password += random.choice(chars) return password value = input("Enter a value for number of chars for pass: ") print(pass_char(int(value))...
22fc9af468b039cf0f101d0f662a7bdb72761a37
CribberSix/finding_earl_minigame
/src/Parser/Parser.py
4,137
4.0625
4
class Parser: def __init__(self): """ The parser is used to map the user's input to game functionality. It asks for clarification if it couldn't successfully parse the input. """ self.last_input = "" # no concrete usage so far self.directions\ = ["west"...
cb70103705d5a8e2339d84de05327dc17e9daecf
RAMKUMAR7799/Python-program
/Beginner/binaryornot.py
134
3.640625
4
n=str(input("")) flag=0 for i in n: if int(i) not in range(0,2): flag=1 break if flag>0: print("no") else: print("yes")
214d2f99f71449e8a48ac52902e1f4da7745cdb6
cafenoctua/100knock2019
/Naoto/chapter06/knock53.py
624
3.71875
4
''' 53. Tokenization Stanford Core NLPを用い,入力テキストの解析結果をXML形式で得よ.\ また,このXMLファイルを読み込み,入力テキストを1行1単語の形式で出力せよ. ''' import re def Tokenization(input_, output_): with open(input_) as f, open(output_, "w") as fw: for line in f: word = re.search("<word>([a-zA-Z0-9]{2,})</word>", line) i...
12994e12df90c5506fed6820154f820005f32dc4
BeeverFeever/Tic-Tac-Toe
/Tic_Tac_Toe-Python/Tic_Tac_Toe.py
1,804
3.84375
4
board = ["-", "-", "-", "-", "-", "-", "-", "-", "-",] winner = None def GenerateBoard(): print(f"""{board[0]}|{board[1]}|{board[2]} {board[3]}|{board[4]}|{board[5]} {board[6]}|{board[7]}|{board[8]}""") def GetInput(player): position = int(input(f"'{player}' Turn, where would you like to place your piece (0-9): "...
9a076e154a3a9e2cdb8ef2fd35c1e4c55e5b4fe1
ViniciusMadureira/python-script
/rock_paper_scissors/rock_paper_scissors.py
859
3.890625
4
### -*- coding: utf-8 -*- __author__="Vinícius Silva Madureira Pereira <viniciusmadureira@outlook.com" __date__="$Feb 2, 2017 6:33:19 AM$" import random # Main mathematical function of the algorithm: ƒ(n, m) = mⁿ def player_value(n, m): return m ** n def winner(player1, player2): if player1 == player2: ret...
3c6395629863f3426d2aa0ec298dae066cd7f798
mohitarya/python
/assignments/day2/Q2_list.py
475
4.21875
4
""" Day2, Program-2 2) Create a simple list. Can you add integers and strings in the same string? Show with example. """ #Simple List test_list = [1, 'Hello', 2, 'world'] print "List is::\n\t{0}".format(test_list) #Addition element in a list test_list.insert(2, 23) print "List after insertion at position...
6bf843837ab813bfbd2c2cbdbb3a82976a1ab91d
illu12/Company-Analysis-Overviewing-Software
/SA.py
1,478
3.546875
4
############################# #// Stock Analysis Module //# ############################# def EPS(a,b): """Netincome-dividends/outstanding shares""" """ profit / shares """ return a/b def absolutePE(a,b): """ P/E of current stock price """ """ Price/earnings """ return a/b def relativePE(): ...
d28c9ae4725f8d918163b7e893f9e3a13521978c
jsapatos/hehexD
/intercambio.py
257
4.15625
4
#Programa para intercambiar dos variables sin una tercera print "Escribe tu numero" A = int(raw_input()) print "Escribe tu segundo numero" B = int(raw_input()) A=A+B B=A-B A=A-B print "El primer numero es:" print A print "El segundo numero es:" print B
604dd25d09169ec7ac65c406dcebd193fadb13e7
lKlausl/Mision-04
/Triangulos.py
1,384
4.40625
4
#Autor Claudio Mayoral García #Descripción Dice que tipo de triángulo es dependiendo de los valores que se les asignen a los lados #Y si no cumple con las características del triángulo manda un mensaje de error #Esta función regresa el tipo de triángulo que es pero si no es un triángulo regresa un anuncio de error de...
ebc30654bc52c95e281fe19cc0a283f1ef5e0f79
vincent507cpu/Comprehensive-Algorithm-Solution
/LintCode/ladder 06 DFS/旧/816. Traveling Salesman Problem/solution_2.py
1,792
3.859375
4
# brutal DFS + pruning class Result: def __init__(self): self.min_cost = float('inf') class Solution: """ @param n: an integer,denote the number of cities @param roads: a list of three-tuples,denote the road between cities @return: return the minimum cost to travel all cities """ d...
ee842214ffef0bddb45d451c2ef2073d652cef03
xiesongzhang/learn-python-the-hard-way
/ex21sd.py
476
3.640625
4
def sd1(X): print "i get %r" % X return 5 print sd1(raw_input(">")) #a = 30 #b = 5 #c = 78 #d = 4 #e = 90 #f = 2 #i = 100 #j = 2 #print "the puzzle is? %d" % (a+b+(c-d-i/j/2*e*f)) def subtract(a, b): print "SUBTRACTING %d - %d" % (a, b) return a - b def add(a, b): print "ADDING %d...
15a925618fab77bb279a7bef349e631f8ecfac04
vietanhtran2710/projectEuler
/highlyDivisibleTriangularNumber.py
588
3.84375
4
from math import sqrt from collections import Counter def isPrime(value): for i in range(2, int(sqrt(value))): if value % i == 0: return False return True def getPrimeFactorList(value): result = [] prime = 2 while (value != 1): while not isPrime(prime) or value % prime != 0: prime += 1 result.append(...
91d57d3e18d6e8a580e824270e77fdd60d727a1d
noahsafeer/RobinHoodTradingBot
/venv/Lib/site-packages/int_date/__init__.py
4,542
3.609375
4
from datetime import datetime, timedelta, date from dateutil import rrule import six __author__ = 'Cedric Zhuang' def _from_str(date_str, format_str=None): if format_str is None: format_str = "%Y%m%d" try: ret = datetime.strptime(date_str, format_str).date() except ValueError: rai...
553ff70553e087e7326d4d29d5a19a5e05d944fa
GuglielmoS/ProjectEuler
/euler2.py
730
3.890625
4
#!/usr/bin/python # Each new term in the Fibonacci sequence is generated by adding the previous # two terms. # By starting with 1 and 2, the first 10 terms will be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # By considering the terms in the Fibonacci sequence whose values do not # exceed four million, find the sum of ...
fce119d92ece4618ac3ea01bcdde49c7b5efb6b8
greenstripes4/CodeWars
/sortbyheight.py
969
4.0625
4
""" Task Some people are standing in a row in a park. There are trees between them which cannot be moved. Your task is to rearrange the people by their heights in a non-descending order without moving the trees. Example For a = [-1, 150, 190, 170, -1, -1, 160, 180], the output should be [-1, 150, 160, 170, -1, -1, 1...
9e03b1f747e464b5eeeb6ed1e859e4f4ffb8de9f
zhaochuanshen/leetcode
/Anagrams.py
459
3.96875
4
''' Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. ''' class Solution: # @param strs, a list of strings # @return a list of strings def anagrams(self, strs): c = {} for s in strs: try: c[tuple(s...
4d1ef9cad395379a5744ed311358982b2b8a0ccd
nishio/atcoder
/hhkb2020/a.py
80
3.671875
4
S = input().strip() T = input().strip() if S == "Y": T = T.upper() print(T)
7b7a0216d9f3452f53b98ef49c9bb640d650154e
edgarshmavonyan/python_text_generator
/markov_chain/vertex.py
1,547
3.890625
4
"""Implementation of vertex of markov chain""" import numpy as np from collections import defaultdict class MarkovVertex: """A vertex of a markov chain""" def __init__(self, current_word): """Constructor :param current_word: str The word, which is represented by this vertex""" ...
a8862a6e03a312b26a84606c145f859728e89069
sharmaji27/Leetcode-Problems
/977. Squares of a Sorted Array.py
814
3.9375
4
''' Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. Example 1: Input: [-4,-1,0,3,10] Output: [0,1,9,16,100] Example 2: Input: [-7,-3,2,3,11] Output: [4,9,9,49,121] Note: 1 <= A.length <= 10000 -1...
86044ac162a15b9bf7b04cf43363e96a7e9ae626
ngpark7/deeplink_public
/1.DeepLearning/01.Multiple_Neurons/or_gate_linear_two_neurons.py
1,556
3.671875
4
from __future__ import print_function import numpy as np import random class Neuron1: def __init__(self): self.w1 = np.array([random.random(), random.random()]) # weight of one input self.b1 = random.random() # bias print("Neuron1 - Initial w1: {0}, b1: {1}".format(self.w1, self.b1)) ...
ad223210ee8796e0b09e49af9a10fa0453d6b711
Gnanender-reddy/python_program
/DataStructures/Utility1.py
5,632
4.09375
4
""" @Author : P.Gnanender Reddy @Since : Dec'2019 @Description:This code consists all utilities. """ #functions for stack #creating stack(LIFO manner) class class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.i...
bf7ad0a9b488ffa7f9b2abcc9ee583fdfb52cf9c
MMVonnSeek/Hacktoberfest-2021
/Python-Programs/ceaser_cypher_encryption.py
324
3.75
4
alphabet = "abcdefghijklmnopqrstuvwxyz" alphabet = list(alphabet) n = input("Enter the sentence to be encrypted ").lower().split(" ") s = int(input("Enter the number to be shifted by ")) shifted_alphabet = alphabet[s:] + alphabet[:s] coded = [shifted_alphabet[alphabet.index(j)] for i in n for j in i] print("".join(code...
14b3a2b56fd797479fd7b046e6fae9b64d35d11a
gmsviderski/python
/lesson_1_1.py
697
4.25
4
""" 1. Поработайте с переменными, создайте несколько, выведите на экран, запросите у пользователя несколько чисел и строк и сохраните в переменные, выведите на экран. """ var_int = 777 var_str = 'Привет, мир!' var_bool = True print('Целое число =', var_int) print('Строка =', var_str) print('Переменная bool =', var_bool...
00ef18a9e14358571919232233c25dbbd4413a43
sdamico23/Rosalind
/fibonacci_sequence.py
222
3.671875
4
def fib(n): if n == 0: return 0 terms = [] terms.append(0) terms.append(1) for i in range(2, n+1): terms.append(terms[i-1] + terms[i-2]) return terms[n] print(fib(22))
6290e1419cf760476e48960d389f097ed8388d45
castorfou/mit_600.2x
/lectures/UNIT 3 - Lecture 8 - Monte Carlo Simulations/asset-v1 MITx+6.00.2x+3T2020+type@asset+block@lecture8-segment3/exercise 4.py
1,550
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Nov 12 15:33:47 2020 @author: explore """ import random import numpy as np def drawBalls(): ''' You have a bucket with 3 red balls and 3 green balls. Assume that once you draw a ball out of the bucket, you don't replace it. Return a l...
07a98d68b565e9bb91911bba2883692db6463b28
Hu-Wenchao/leetcode
/prob122_best_time_buy_sell_stock2.py
1,261
3.796875
4
""" Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the sa...
36db4feab82f7372eb90f964f7dd9995bb79331b
Daniel-Wuthnow/python_nov_2017
/Daniel_Wuthnow/Python_fundamentals/string_lists.py
937
4.28125
4
# words = "It's thanksgiving day. It's my birthday,too!" # print words.find("day") # #.replaces(what i am replacing, what will be replacing the first index) # print words.replace("day", "month") # x = [1,324,6,3,-8,6] # #min and max are called and in the () is what is looked through to find the value wanted # print mi...
a080cbe846b86d10383ef367c2b672e393f52b19
Awonkhrais/data-structures-and-algorithms
/python/code_challenges/stack-queue-brackets/stack_queue_brackets/bracket.py
607
3.875
4
open_list = ['(','[','{'] close_list = [')',']','}'] def validate_brackets(input): char_list=[] for i in input: if i in open_list: char_list.append(i) elif i in close_list: x = close_list.index(i) if ((len(char_list) > 0) and (open_list[x] == char_list[len(ch...
00556813af1268d8a67a49cf645faaa236dc84e4
avivkiss/cs107-w16
/block_ciphers/exercise_2.py
2,377
3.734375
4
from crypto.primitives import * from crypto.tools import * from crypto.ideal.block_cipher import * import sys, itertools """ Let E be a blockcipher E:{0, 1}^8 x {0, 1}^8 --> {0, 1}^8 Define F: {0, 1}^16 x {0, 1}^16 --> {0, 1}^16 by: Notes: Derived from lecture 3 slide 40. Sizes in comments are bits, sizes in code ar...
3f965f3781356270b5b379455e7e22f34ff12d9c
OlyaVT/ClassWork
/CW_12.py
601
4.1875
4
# use map metod names = ['Sam', 'Don', 'Daniel'] names = map(hash,names) print(list(names)) # find colour red colors = ['red', 'green', 'black', 'red', 'brown', 'red', 'blue', 'red', 'red', 'yellow'] def is_red(str): return str == 'red' new_colors = filter(is_red,colors) print(list(new_colors)) #...
f855924b36ae2117cea75ffa1aac126ba15b4e6c
agvaress/algorithms
/recursion/sum_array.py
271
3.796875
4
def array_sum(arr): if len(arr) == 0: return 0 elif len(arr) == 1: return arr[0] return arr[0] + array_sum(arr[1:]) print(array_sum([3, 4, 5, 6])) def len_array(arr): if len(arr) == 1: return 1 return 1 + len_array(arr[1:])
be505e83b2f651329b84d44e5b6b04b8ff43a2e3
RickCarletti/P1---Dante
/URIs/1021.py
736
3.53125
4
def AchaNotas(val, listaA, listaB): retorno = [] for i in listaA: notas = val // i retorno.append(notas) val -= notas*i for i in listaB: notas = val // i retorno.append(notas) val -= notas * i # print(round(val, 4)) return retorno listaDeNotas = [1...
7e3c7519238dc6622e58ebe9c9643856bd01308e
gy-chen/gyjukebox
/gyjukebox/lyrics/nlp/utils.py
496
3.671875
4
def ngrams(sequence, n): """ngrams Args: sequence (iterable) n (int) Returns: yield ngrams result """ # implementation from nltk sequence = iter(sequence) history = [] for _ in range(n - 1): try: next_item = next(sequence) except Stop...
4bf74cd87ee89e7a29683ba7c1e8f1c977e8340f
NathanNNguyen/challenges
/dynamic_programming/words_sorted_according.py
901
3.640625
4
def isAlienSorted(Words, Order): Order_index = {c: i for i, c in enumerate(Order)} # c = {} # for index, val in enumerate(Order): # c[index] = val for i in range(len(Words) - 1): word1 = Words[i] word2 = Words[i + 1] # Find the first difference word1[k] != word2[k]. ...
e9b822127040ffcbe6718e31d232ce9a8f433390
PeterL64/UCDDataAnalytics
/7_Introduction_To_Data_Visualization_With_Matplotlib/2_Plotting_Time_Series/1_Read_Data_With_A_Time_Index.py
402
3.828125
4
# Read data with a time index # Import pandas as pd import pandas as pd # Read in the data from a CSV file called 'climate_change.csv' using pd.read_csv. # Use the parse_dates key-word argument to parse the "date" column as dates. # Use the index_col key-word argument to set the "date" column as the index. climate_ch...
f39778517e3d6df0cf76d36ade7556448c1d75cc
Meet953/python
/pyrhon/Crucial Info/Exception Handling/to_handle_mulyiple_exceptions.py
419
3.734375
4
# TO HANDLE MULTIPLE EXCEPTIONS.. try: f=open("myfile.txt") line=f.readline() Int=int(s.strip()) calculated_value=101/Int except IOError: print"I/O error occured" except ValueError: print"Could not convert data to integer" except ZeroDivisionError: print"Zero Divisio...
24a5cdcaafe2992f198813b15a1a7faeeaaf9180
soldierloko/Curso-em-Video
/Ex_86.py
428
4.34375
4
#Crie um programa que crie uma matriz de dimensão 3x3 e preencha com valores lidos do teclado #No final mostre a matriz na tela, com a formatação correta matriz = [[0,0,0],[0,0,0],[0,0,0]] for l in range(0,3): for c in range(0,3): matriz[l][c] = int(input(f'Digite um Valor para [{l}, {c}]: ')) print('-=' ...
8fb36c9231b48cf3b9ab77b43394d85f3830c08d
LidaRevtova/project4
/project4.py
1,904
3.96875
4
# У пользователя есть дв варианта, ак зашифровать текст, он сам # выбирает код и вводит текст print('Выберите, каким кодом вы хотите зашифровать свой текст: ' '1 - код цезаря, 2 - код выводит текст в обратном порядке' '') choice = int(input()) if choice == 1: ALPH = ['а', 'б', 'в', 'г', 'д', 'е', 'ё',...
93b4d6ab8f947ef70c234fa08cf30b348b835424
Yasin-4030/Assignment-1--Music-Playlist
/Playlist.py
2,172
4.0625
4
from Song import Song class Playlist: #this class is a linked list def __init__(self): self.__first_song = None # TODO: Create a method called add_song that creates a Song object and adds it to the playlist. This method has one parameter called title. def add_song(self, title): node = self.__first_so...