blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
61fe41aabf1d20f522aa42320a4727db89f17e0f
OrkunAvci/Codes-From-Courses
/Python/Session 3/Blackjack_Deck.py
713
3.578125
4
import random as rand class deck: cards = [{}] def __init__(self): for type in ["clubs", "diamonds", "hearts", "spades"]: for value in range(2,11): self.cards.append({ "type" : type, "name" : str(value), "value" : value }) self.cards.append({"type": type, "name": "Ace", "value": 11}) ...
7b427d3b030b9e2b6b25d4b61575edbb7d8daa03
arifaulakh/Competitive-Programming
/DMOJ/harambe/harambe.py
305
3.875
4
a = input() numupper = 0 numlower = 0 for char in a: if char.isupper(): numupper = numupper + 1 if char.islower(): numlower = numlower + 1 if numupper > numlower: a = a.upper() elif numupper < numlower: a = a.lower() elif numupper == numlower: a = a print(a)
f90e241d661829af9e7fdf053920fd5935d7c4ad
kdschlosser/python-utils
/python_utils/decorators.py
2,248
3.53125
4
import functools from . import types def set_attributes(**kwargs): '''Decorator to set attributes on functions and classes A common usage for this pattern is the Django Admin where functions can get an optional short_description. To illustrate: Example from the Django admin using this decorator: ...
cba181ed9a68d9d0ff632897434fb46525339332
FilipiRafael/web-testing-Python
/web-testing/programa_principal.py
1,191
3.9375
4
# Importando a biblioteca urllib.request # Esta biblioteca que trará a capacidade para o nosso programa de requisitar a conexão de uma URL na web import urllib.request from time import sleep def testar_website(site): try: site = urllib.request.urlopen(site) # Aqui você pode colocar qualquer URL,...
e15aa54ff52fcba41ff529f207893036e748aa8e
EpicureanHeron/DataAnalyticsBootcampSpring2018
/Week 2 - VBA/Practices/Python/exercise.py
794
4.0625
4
# create and define variables """name = input("What is your name?: ") country = input("What country are you from?: ") age = int(input("How old are you?: ")) hourly_wage = int(input("What is your hourly wage?: ")) satisfied = input("Are you satisfied?: ") daily_wage = hourly_wage * 8""" # print variables #print("My na...
fb79b0b891457b89c5fe17ce5fa3242b2873846c
jiangyoudang/python3
/algorithm/leetcode/simplify_path.py
431
3.6875
4
class Solution: # @param path, a string # @return a string def simplifyPath(self, path): path_list = path.split('/') simp_path = [] for dir in path_list: if dir == '.' or not dir: continue elif dir == '..': if simp_path: sim...
9788b15e52277022689d71440c508b5c92f9c7a0
492083363/yangchao
/python3study/爬虫/正则表达式与cookie使用/通用字符作为原子.py
146
3.5
4
#!/bin/env python #coding=utf-8 import re pattern="\w\dpython\w" string="abcdfphp345pythony_py" result1=re.search(pattern,string) print(result1)
92fe582b25b4f7f13ff6002b878a09cdecf2ad2f
lifor9/git.python.src
/PostgreSQL_Ex/postgresql_Example.py
2,395
3.640625
4
import psycopg2 # 데이터베이스에 연결 conn_string = "host='192.168.15.50' dbname = 'ontune' user = 'ontune' password = 'ontune'" #conn_string = "database='testdb', user='ontune', password='ontune', host='127.0.0.1', port='5432'" conn = psycopg2.connect(conn_string) # conn = psycopg2.connect(database="ontune", user="ontune", ...
707c13d02bb1197fbdbe0f1549276181bc46bec5
murakumo512/Alpro-Python-2019-2020
/Pertemuan 8/36.py
110
3.703125
4
text = 'abcdefg' index = 0 length = len(text) while index < length: print(text) index = index + 1
74c9fd58adad003fe60ba039e04fb7e73890ba48
nerutia/Leetcode
/Algorithm/1748.py
393
3.6875
4
# 唯一元素的和 # 给你一个整数数组 nums 。数组中唯一元素是那些只出现 恰好一次 的元素。 # 请你返回 nums 中唯一元素的 和 。 from typing import List class Solution: def sumOfUnique(self, nums: List[int]) -> int: return sum([(i if nums.count(i)==1 else 0) for i in nums]) c = Solution() print(c.sumOfUnique( nums = [1,1,1,1,1] ))
21dcac93060832022ef9180905a11ddd33968a11
shua2018ti/Coding
/rent_the_runway.py
222
4.0625
4
""" Multiply two numbers represented as lists """ def multiply_numbers(number_1, number_2): zero_pad = 0 running_sum = [] if len(number_1) < len(number_2): number_1, number_2 = number_2, number_1
9a1f75231698b7385427f8026e80d33ca856d013
SheezaShabbir/Python-files-read-and-write
/import files.py
3,310
3.78125
4
#import files from the web address #! this sign runs the command interface supporting curl #curl enables curl that can download files #https://raw.githubusercontent.com/..... is the address for the data file to import # -o tells curl write data to a file #poem1.txt name curl will give the file #Opening a Local Fi...
51c7db691b8bdce3660ae85bac6d552d554c4232
GaikwadHarshad/ML-FellowShip-Program
/WEEK_4/NumPy/NumPy Programs 11-20.py
6,790
4.1875
4
import numpy as np from myprograms.Utility.UtilityDS import validate_num # class for mathematical/logical operation using NumPy class NumPyProgram: choice = 0 def numpy_operations(self): # list of program print() print("11. find the number of elements of an array, length of one array ...
cf298b81fd70ffac69808bd5d432d2af5655c380
NickjClark1/PythonClass
/Chapter 10/Chapter10Lab2Final.py
2,211
3.84375
4
from random import shuffle class Card: def __init__(self, rank, color, suit, value): self.__rank = rank self.__color = color self.__suit = suit self.__value = 0 def getrank(self): return self.__rank def getcolor(self): return self.__color ...
7d309813f62f18eb7f764ab251253f34182b37ca
Akshatha-Udupa/AITPL2108
/database.py
1,287
3.84375
4
import sqlite3 con = sqlite3.connect('db1.db') c = con.cursor() c.execute("create table student(regno 'text' primary key, name 'text', Address 'text')") c.execute("insert into student values('A101','Akshatha','KS Layout')") c.execute("insert into student values('A102','Rakshita','BTM')") c.execute("insert int...
d40de3b4c89ff71359fc61e7efd571d42b403bd3
vorSherer/DSnA_Py
/dsna_py/challenges/cc_27_merge_sort/merge_sort.py
1,194
4.125
4
def merge_sort(arr): n = len(arr) if n > 1: mid = int(n/2) left = arr[:mid] print("Left= ", left) right = arr[mid:] print("Right= ", right) merge_sort(left) print("Sorted left= ", left) merge_sort(right) print("Sorted right= ", right) ...
898f2001d102948b23d45d403a560e1a4c3f52bb
luxuguang-leo/everyday_leetcode
/00_leetcode/2.add-two-numbers.py
1,413
3.625
4
# # @lc app=leetcode id=2 lang=python # # [2] Add Two Numbers # # @lc code=start # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: List...
e8e55bd749e7d6e26a806a655723bdbd44b3a3bc
nkgrobel/dataScience
/nG6.12.15.py
765
4.125
4
# Extend your program above. Draw five stars, # but between each, pick up the pen, move forward by 350 units, turn # right by 144, put the pen down, and draw the next star. # You’ll get something like this (note that you will need to move to the left before # drawing your first star in order to fit everything in th...
8c6ec2c259c3a5109ecc20b76de66c9fd41d3999
MMcCaffrey/Algorithms
/SortAlgos.py
736
4.03125
4
def bubblesort(input): n = len(input) for i in range(n): for j in range(0,n-i-1): if input[j] > input[j+1]: input[j], input[j+1] = input[j+1], input[j] return input def merge(left, right): result=[] while len(left)!=0 and len(right)!=0: if left[0] < right...
b0e68b57655f1342272a622c9ddd3dd023c18604
textchimp/pyth02
/day05/books-database.py
11,107
4.21875
4
# Books Database # # There's a lot of code here! Remember that in Atom you can type # cmd + k and then cmd + 1 to collapse or 'fold up' all the bodies # of functions, loops, dictionaries etc and just see the outline. # Then you can click on the '...' or the line number to expand or unfold # and see the details! # # I ...
a2e16081f6efa18805c24df04691b5b31c75ef06
justinflesch/cs362-hw5
/fizzbuzz.py
798
3.859375
4
# Cube program def avg_list(items): value = 0 value = float(value) if len(items) > 0: for i in items: try: value = value + float(i) except: print("Error: Invalid value passed") return value = value / len(items) ...
39676c27cc90a33765f849aeb8f609f8950fe6ab
changray1201/AE402-Python
/猜數字.py
347
3.84375
4
import random num = random.randrange(1,10) guess = input("請猜一個1~10的數") guess = int(guess) while guess <1 or guess > 10: print(" ") print("請重新輸入一個1~10的數") guess = input("請猜一個1~10的數") guess = int(guess) if guess == num : print("你猜對了") else : print("你猜錯了")
bfddfb471930acba66e35df8d3bdd98469f7ca91
LennyDuan/AlgorithmPython
/Hackerrank Basic 2/answer.py
315
3.8125
4
def possibleChanges(usernames): res = [] for name in usernames: sorted_name = ''.join(sorted(name)) if sorted_name < name: res.append('YES') else: res.append('NO') return res name = ['hydra'] name = ['foo'] # name = ['adb'] print(possibleChanges(name))
24b031f97798c9ed157ef33d7157e28975dc727f
MyeongJun88/homework
/180705과제/5-23.py
115
3.59375
4
i = 1 while i <= 9: j =1 while j <= 9: print("%d * %d = %d" % (i, j, i*j)) j= j+1 i = i+1
c50b61af42dd410aefbe53a11ee0b44b1d3f1e64
ajaypalsaniya/Python-plauground
/color.py
283
4
4
print("What's your favorite color from ?") color = input() if color == 'green': print("excellent choice!") elif color == 'red': print("not bad!") elif color == 'blue': print("mediocre") elif color == 'black': print("I like how you think") else: print("YOU MONSTER!")
b9c98a59fa3f19534bf74c75bcdcdfb541bfe7e0
Sovima/Google-Play-App-Rating-Prediction
/data_exploration.py
2,248
3.671875
4
import numpy as np import pandas as pd from sklearn.preprocessing import LabelEncoder app_data = pd.read_csv('googleplaystore.csv') def missing_values(df): total = df.isnull().sum().sort_values(ascending=False) percent_1 = df.isnull().sum()/df.isnull().count()*100 percent_2 = (round(percent_1, 1)).sort_v...
3c701c877e60c2d0f48f13be9c14561ab690a411
TheFoxDecoder/Algorithms
/fizz_buzz.py
820
4.46875
4
''' Algorithm:- Fizz and Buzz refer to any number that's a multiple of 3 and 5 respectively. In other words, if a number is divisible by 3, it is substituted with fizz; if a number is divisible by 5, it is substituted with buzz. If a number is simultaneously a multipl...
6fea6c50b3ceea23bc211d35d8cd35d02dfd0db2
kgarofali/machine_learning
/Homework/kristengarofali_hw1/fitdata.py
2,177
3.75
4
from __future__ import print_function import numpy as np import matplotlib.pyplot as plt import sys def least_squares(datfile): """ Function to read in N pair of points from file and fit data to y = ax + b Parameters ---------- datfile: string, csv file with x,y points Returns --...
0242db7e9cdd116094c34b45e6e1ec49ceaf9c7a
starkizard/CrudeCode
/CSES Problem Set/Introductory Problems/15-ChessboardAndQueens.py
1,268
3.640625
4
# auth: starkizard # representing the chess board as columns, diagonal 1, diagonal 2, # diagonal 1s value is r+c throughtout, diagonal 2 value is r-c+7 (check it out!) # Putting queen row by row, so i don't need to check for previous rows, that's why didn't put it # Putting all the reserved squares in a 2d array # # ...
73ee394322c2c6397d3024851c774595f1f44d73
kumargagank/pytthon
/obc1.py
253
3.765625
4
class Test: h = 0 def __init__(self): self.h = 6 def my__func(self,k): print("i am in the class") self.h = k #assigning the value print(self.h) o=Test() print(o.h) o1=Test() print(o1.h) o.my__func(4) o1.my__func(6) o3=Test() print(o3.h)
6b6227a8d3f2e071228999a5176bb04e356c3755
lxxxc/Python
/03_List/numbers.py
970
4.5
4
# 使用range()函数生成数字序列 print("使用range()函数生成数字序列") for value in range(1, 5): print(value) # 使用list()函数创建列表 print("使用list()函数创建列表") numbers = list(range(1, 6)) for number in numbers: print(number) # 使用list()函数创建列表,并指定步长 print("使用list()函数创建列表,并指定步长") even_numbers = list(range(2, 11, 2)) for even_number in even_numb...
83b2b27e42677bc1173c338359803261fd6cfd6b
JSidat/python-practice
/python_exercises/Code/conditionals.py
185
4.09375
4
num1 = int(input('Enter first number here: ')) num2 = int(input('Enter second number here: ')) num3 = num1 + num2 if num3 % 7 == 0: print(num1 + num2) else: print(num1 * num2)
b050c19a230c8a5e60b34a8082c0e439e222957c
setu4993/LeetCode
/125_valid-palindrome.py
346
3.734375
4
import re, math class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ s = re.sub(r'\W+', '', s).lower() if s[:int(len(s)/2)] == s[int((len(s) + 1)/2):][::-1]: return True else: return False print(Soluti...
ebdac5ff1b71d920337598f9bb87e2e7b64c5970
bopopescu/imfree
/venv/Lib/site-packages/base64_util/__init__.py
2,260
3.859375
4
import re def get_only_base64_characters(arg): ''' Returns only the base64 characters from the string, preserving order. Args: arg: The string that will have the non-base64 characters removed Returns: A string containing only base64 characters ''' if not ar...
3021dfe1e6256c063ce93e1e9d2bead4272e7f4e
AldieNightStar/pyparser
/pyparser/util.py
897
3.625
4
from typing import List, Tuple, cast def read_while(text: str, set: str): for i in range(len(text)): if not text[i] in set: break return text[:i] def is_next(text: str, subtext: str): return text[0:len(subtext)] == subtext def is_next_of(text: str, list: List[str]): for l in list: if is_next(text, l): ...
1f5af626290f012084e1aafe8e86a1a629835726
antomin/GB_Algorithms
/lesson_2/task_2_3.py
463
4.3125
4
""" Сформировать из введенного числа обратное по порядку входящих в него цифр и вывести на экран. Например, если введено число 3486, то надо вывести число 6843. """ def revers_func(num): res = 0 while num > 0: res = res * 10 + num % 10 num = num // 10 return res print(revers_func(nt(inpu...
4d5b0bbda962657318c4ea67153c210a7491c73c
clebsonpy/MiniTest
/SomaSerie.py
268
3.71875
4
n = int(input('')) def fatorial(numero): fat = 1 for i in range(1,numero+1): fat*=i return fat soma = 0 sinal = 1 x = 1 for i in range(1,n+1): fat = fatorial(i) soma += (fat/x)*sinal sinal *= -1 x = (x*2) + 1 print(round(soma,2))
b755405005fabaee49d87b7189deb10508178781
Parizval/CodeChefCodes
/Python/Beginner/CHEALG.py
585
3.625
4
for a in range(int(input())): string = input() num = 0 ; char = string[0] count = 0 for i in range(len(string)): if i == 0 : num += 1 char = string[0] count += 1 continue if string[i] != char: #prin...
f97e70b9b7c0b17ae7bb5f31f13c417be07884cc
ldale1/GoogleFooBar
/L3-2-BunnyEscape.py
5,681
4.0625
4
## You're awfully close to destroying the LAMBCHOP doomsday device and freeing Commander ## Lambda's bunny prisoners, but once they're free of the prison blocks, the bunnies are going ## to need to escape Lambda's space station via the escape pods as quickly as possible. ## Unfortunately, the halls of the space station...
cea1084fe74a4749983a6fb51f012ab4eaa2869e
bodhwani/machine-learning-lab-CSE4020
/PythonFiles/Decisiontree.py
1,744
3.53125
4
# coding: utf-8 # In[104]: import pandas as pd from sklearn.cross_validation import train_test_split from sklearn.tree import DecisionTreeClassifier from sklearn.metrics import accuracy_score from sklearn import tree df = pd.read_csv('dataset.csv') # In[105]: df.head() # # How to handle missing values # - use d...
7f28ed830c6c68f281bc1ccdc42a12f7d51570fb
CBKain/githubTest
/_Scripts/test.py
158
3.828125
4
print("This is a test, I'm just gonna repeat the number you inputted.") print("Enter a number: ") userNum = input() print("This is your number: " + userNum)
05f6c76af955c0421199e665bbc710e2eefb3558
HourGlss/Chess
/pieces/rook.py
2,134
3.578125
4
from pieces.piece import Piece class Rook(Piece): def __init__(self, color): super().__init__(color) self.symbol = "R" def is_valid_move(self:Piece, board, startx, starty, endx, endy, evaluate_only=True): tile_is_free = board.is_tile_free(endx,endy) opponents_piece_is_occupyin...
23f1691e17ae770a6bf3c0333cbf51d93580a0ba
Sana-mohd/functionsQuestions
/returnlisss.py
156
3.828125
4
def list_1(list=[3,5,6,9]): i=0 lis=[] while i<len(list): a=list[i] lis.append(a) i=i+1 return lis,i print(list_1())
af383f2311153bb5aa2164e6a106407f88ff4f97
coding-club-iit-jammu/Python-Programs-Hacktoberfest
/file4.py
311
3.9375
4
print("Hi") a=input("Enter a string : ") for i in range(0,len(a)): for j in range(len(a)-1,i,-1): print(" ",end='') for j in range(0,i+1): print(a[j],end='') if i == 0: print("",end='') else: for j in range(i-1,-1, -1): print(a[j],end='') print()
a60ed84b29154a7441a171385aa31e9bc66e4d2a
0525ParthPatel/Twitter-String-Manipulation
/tweets.py
11,384
3.953125
4
"""Assignment 3: Tweet Analysis""" from typing import List, Dict, TextIO, Tuple HASH_SYMBOL = '#' MENTION_SYMBOL = '@' URL_START = 'http' # Order of data in the file FILE_DATE_INDEX = 0 FILE_LOCATION_INDEX = 1 FILE_SOURCE_INDEX = 2 FILE_FAVOURITE_INDEX = 3 FILE_RETWEET_INDEX = 4 # Order of data in a tweet tuple TWE...
1ee29809034d8e8e025f1954d26ace2bc9349555
Raventhal/Class
/assert.py
292
4.03125
4
def checkvalue(valuetocheck): assert (type(valuetocheck) is int), "You must enter a number." assert (valuetocheck > 0), "Value entered must be greater than 0" if valuetocheck > 4: print("Value is greater than 4") var = int(input("Enter a number greater than 0: "))
c5f2c7ee172ff48f44ed7ea1527361d6c732b9e8
touhiduzzaman-tuhin/python-code-university-life
/University/Practice - 1/62.py
144
4
4
x = int(input("Enter A Number : ")) y = int(input("Enter Another Number : ")) for i in range(x): if(i < y): continue print(i)
168b814b09ea5eeabecd3d8c8afd316c1c0def20
divij173/Python
/Guess_the_number.py
395
3.9375
4
a=input("Enter a Number Between 1-25 = ") c=input("Enter Your Guess = ") b=0 for i in range(1,25): if a==c: print("\nYou Found it in {} times".format(b+1)) break elif c>a: print("Your Number is Higher\n") b+=1 c=input("Wrong, Enter Again = ") else: print("Your...
df1749da326489ddaa6ce5da70ecc971b20a2375
nguyendiepminh/Titanic-Kaggle
/06 - Application of Radom Forest Model to test data set.py
3,593
3.578125
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 19 16:12:00 2016 @author: s621208 """ titanic_test = pandas.read_csv("C:/Users/s621208/Downloads/data/test.csv") titanic_test.info() #Converting object type to categorical #titanic_test['Sex']=pandas.Categorical(titanic_test['Sex'],ordered=False) #titanic_test['Name']=p...
6aba22d7dc20b581697c5950b5261acaec60e354
Nazira06/first_git_lesson
/файлы цикл for/ht11.py
144
3.65625
4
number_list = [1, - 1, 2, -2, 3, -3] i = 0 while i < len(number_list): if number_list[i] > 0: print(number_list[i]) i = i + 1
92c657fdc02def7515aa4485b454654d5950ff19
edelvandro/Python
/fundamentos/exer019.py
624
4.03125
4
''' Um professor quer sortear um dos seus quatro alunos para apagar o quadro. Faça um programa que ajude ele, lendo o nome delas e escrevendo o nome do escolhido. ''' import random # ou from random import choice. primeiro_aluno = input('Primeiro aluno: ') segundo_aluno = input('Segundo aluno: ') teceiro_alun...
d21a86efbe50b81831e68a83b803cb8232918315
myalgor/HackerChallenges
/Max Min Challenge.py
253
3.609375
4
N = input() K = input() lists = [input() for _ in range(0,N)] lists.sort() print lists for i in enumerate(lists) sublist = minimum = [min(lists)] print minimum #min_diff = ## Write code here to compute the answer using (n, k, candies) print min_diff
e2386e62d3533d6f0c31ce6e746d3809224272aa
anachz19/Prueba_Python
/Dia 4/while3.py
53
3.53125
4
i =1 while i>0: print(i, end="") input("....")
7767477fad38276fe053d00a72e63b2ce14f41b0
josue270193/python_simple_chat_bot
/Topics/Else statement/Healthy sleep/main.py
203
3.609375
4
var_a = int(input()) var_b = int(input()) var_h = int(input()) if var_a <= var_h <= var_b: print("Normal") else: if var_h > var_b: print("Excess") else: print("Deficiency")
599569ffbabd27b22c5b9d49547a2b2422616639
mkierc/advent-of-code
/2017/src/day_03/part_1.py
1,204
3.609375
4
test_input_1 = 1 test_input_2 = 12 test_input_3 = 23 test_input_4 = 1024 input_data = 361527 # TODO - solution is wonky, needs refactoring def do_the_thing(n): if n == 1: return 0 level = 1 level_range = (level*2+1)**2 while n > level_range: level += 1 level_range = (level *...
173c8469a92bf2d29971b5d2f1895d4b21ce5df5
norman-c/3522_A00893016
/Labs/Lab 1/controller.py
1,417
3.90625
4
import random import time import datetime from asteroid import Asteroid def simulate(seconds): """ Simulates movement of the asteroids and displays the simulation :param seconds: an int for how many seconds to simulate :return: """ delta = datetime.datetime.now() + datetime.timedelta(seconds=1...
c3df059b7d0c5469dc14267443668097d468d1f6
iteong/comp9021-principles-of-programming
/lectures/Lecture_2/Example2.py
776
3.53125
4
from math import ceil, sqrt #ceiling rounding up to integer upper_bound = ceil(sqrt(9876532)) def ok(number, set_of_digits): while number: d = number % 10 if d not in set_of_digits: set_of_digits.add(d) else: return None number //= 10 # number = number // 1...
372a9d0635480800f1ff65bc911f0962b8deba98
tspies/Python
/Dice_Simulator/dice_simulator.py
1,452
4
4
import random import os print(" Welcome to Tower Dice simulator\n") print(" You may have up to 6 die at a time, each dice can have between 2 - 20 sides") print(" Press any key to continue . . .") def setup(): die_list = [] run = True while run: print(" How many die's would you like to use?") die_number =...
530a62c640223c829b362a55263e356a8edc1597
Ngouanfo-Gildas/GASystem
/GASystem.py
7,108
3.53125
4
import random import math import time from typing import List import matplotlib.pyplot as plt import numpy as np class Point: def __init__(self, x=0, y=0): self.x = x self.y = y def __str__(self): return "("+str(self.x)+", "+str(self.y)+")" def distance(self, point): retur...
a040310bc918e0f7fd8069231fd5d9f71d8d5088
jmarcos9/udemy
/intermediario/groupby.py
1,160
3.828125
4
from itertools import groupby, tee #tee faz copia do iterador alunos = [ {'nome': 'Marcos', 'nota': 10}, {'nome': 'Luciana', 'nota': 8}, {'nome': 'Camila', 'nota': 7}, {'nome': 'Mariana', 'nota': 7}, {'nome': 'Lorena', 'nota': 10}, {'nome': 'Igor', 'nota': 8}, {'nome': 'Flora', 'nota': 7}, ]...
9d2367195072aefe83f2588b43fd744210dcd6bd
Git-Sergio/Python3Git
/StepikPython/1.121_Heron_formula_triangle.py
2,411
3.734375
4
# В то далёкое время, когда Паша ходил в школу, ему очень не нравилась формула # Герона для вычисления площади треугольника, так как казалась слишком сложной. # В один прекрасный момент Павел решил избавить всех школьников от страданий и # написать и распространить по школам программу, вычисляющую площадь треугольни...
730f063e293a58d2793cf8eae7c591e906ef0c1f
yoga24/PythonStart
/Start/ReFuncs.py
256
3.734375
4
import re string = "This is some gibberish string just for testing the re module" pos = re.search("some", string) print(str(pos.start())) print(str(pos.end())) print(string[pos.start():pos.end()]) print("This is a {} {}".format('formatted', 'string'))
8f1d17380cb25f01c7d131aef570a0e69aa86db6
toncysara17/luminarpythonprograms
/Revision_advance/oops_pgm6.py
704
3.734375
4
#using oops class Bank: def acCreate(self,acno,acname,bname): self.acno=acno self.acname=acname self.bname=bname self.minibal=5000 self.currentbal=self.minibal def deposit(self,amt): self.minibal+=amt print("your account has been credited with amount",amt)...
2131bc98a6b14220b5f3bc0c0cb08f6f3eec7fcd
CarolRameder/Chess
/Move.py
2,411
4.46875
4
class Move: """ Class to define a move It contains all the information needed for representing a move """ def __init__(self, start, end, board, enpassant=False, castle=False): """ Constructor method for Move class :parameter start: tuple for representing coordinates o...
6929f052041676c9ae2331b0d1b3e3abdd863436
nathantau/ML
/legacy_code/statistics/mean_median_mode/mean_median_mode.py
952
3.734375
4
import numpy as np import matplotlib.pyplot as plt # Create a numpy list centered around 27000 w standard dev of 15000 with 10000 data points incomes = np.random.normal(27000,15000,10000) print(incomes) # Getting the mean of a numpy array mean = np.mean(incomes) print(f'The mean is {mean}') median = np.median(income...
71fab9717d55724d22546d96f80ad5143abb92c9
Alekselion/project-euler
/task5.py
364
3.859375
4
def gcd(a, b): while a != 0 and b != 0: if a > b: a %= b else: b %= a return a + b task = "What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?" result = 1 for i in range(11, 21): result *= i // gcd(i, result)...
3ecf0aa3d7c5a01c5373b284d73f0a1a407d8270
ukokobili/web-appliaction
/stock-price.py
866
3.578125
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 19 03:44:02 2020 @author: JACOB This is a tutorial by Data Professoer Link:https://www.youtube.com/watch?v=ZZ4B0QUHuNc&list=PLtqF5YXg7GLmCvTswG32NqQypOuYkPRUE&index=1 """ import yfinance as yf import streamlit as st st.write(""" # Simple Stock Price App Shown are the s...
ea0affee4ea62ec4a8a4208bb3e77540f4dba83b
menjaw/Python_Project
/questions.py
5,160
3.546875
4
import pandas as pd def exec_qst1(df): """Question 1 - How many products have been tested?""" total_amount = len(df.drop_duplicates(['Series_title_1'])) return total_amount def exec_qst2(data): """Question 2 - How many times have each product been tested?""" # Put columns together frame = pd.D...
f1bb238781a5db50331f3e49c0c7971fe3920835
jerinsebastian521/python
/Cycle 5/C5.3 rectangle.py
775
4.0625
4
class Rectangle: def __init__(self, b, l): self.b = b self.l = l def area(self): return self.l * self.b def perimeter(self): return 2 * (self.l + self.b) l = int(input("enter length of 1st rectangle:")) b = int(input("enter breadth of 1st rectangle:")) arr = Rectangle(l, ...
fe419f881efcdbe2fd5788fba89c2170551213f1
wojdzi1607/MiAPR_path_planning_project
/gym/pydstarlite/grid.py
1,363
3.5
4
WALL = '#' PASSABLE = '.' class SquareGrid: def __init__(self, width, height): self.width = width self.height = height self.walls = set() def in_bounds(self, id): (x, y) = id return 0 <= x < self.width and 0 <= y < self.height def cost(self, from_node, to_node): ...
da956e0fee8d74998686ceed5baf619a086316fb
grakshith/lossless-text-steganography
/src/huffman.py
1,643
3.8125
4
from priority_queue import PriorityQueue, TreeNode class HuffmanTree: def __init__(self,sym_freq_list): """sym_freq_list is a list that contains the symbols and their associated frequencies, where each list item is a tuple in the form (freq,symbol) """ self.sym_freq_list = sym_freq_...
0fe400aa1bf6498bbb37ba55e668693aa68d87cf
nemani/ProjectEuler
/Euler014.py
360
3.53125
4
def next_num(num): if num%2==0: return num/2 else: return 3*num+1 def chain_len(num): k=1 while num !=1: num = next_num(num) k+=1 return k dict={} output=[] for i in range(100000,1000000): dict[chain_len(i)] = i output.append(chain_len(i)) pr...
94823bdd97ced37b63603356ff50990d1ad8a6da
numbat77/lc101
/crypto/helpers.py
724
3.6875
4
import string def alphabet_position(letter): alpha_low = string.ascii_lowercase alpha_up = string.ascii_uppercase if letter.islower(): return alpha_low.find(letter) else: return alpha_up.find(letter) def rotate_character(char, rot): alpha_low = string.ascii_lowercase alpha_up =...
84d593eafe03f35df0b2d0fadaccea2098ed2374
tbergstrom/pythonFundamentals
/multiples_sum_average.py
723
4.21875
4
num = 1 # our number that increments every loop for num in range(1, 1000): if num % 2 != 0: # modulo operator, meaning if the number is not even, it will print. print num num = 5 for num in range(5, 1000000): # commas, like in "1,000,000" are not welcome. if num % 5 == 0: # if the number divided by 5 leave...
05a71b759851a922b6bd4b70497b1aea84d7c7c8
HuuBaa/show-me-the-code
/0004-countwords/count_words.py
728
3.90625
4
#任一个英文的纯文本文件,统计其中的单词出现的个数。 import re with open('words.txt','r') as f: text=f.read() wordlist=re.findall(r'\b[A-Za-z]+\b',text) print(wordlist) print(wordlist.__len__()) # import re # import os # from pprint import pprint # path = os.getcwd() + '/word.txt' # def wordstat(path): # f = open(path, 'r+') # ...
971bb3f64297eab041ff02f541c572608d2bf0df
RiKjess/SololearnPY
/3. Control Structures/TuitionDiscounts.py
794
3.875
4
""" Chaining Multiple Conditions The university gives students discounts on tuition fees depending on their performance: 90-100 => 50% 80-89 => 30% 70-79 => 10% 0-69 => 0% Write a program that will take the scores from the first and second semesters, then calculate the average score, and output the discount, dependin...
a8cdbeed6bec030d1572270cc94065d049423fe3
DincerDogan/Data-Science-Learning-Path
/Data Scientist Career Path/5. Data Manipulation with Pandas/1. Python Lambda Function/6. multiple of 3.py
181
3.8125
4
#Write your lambda function here multiple_of_three = lambda num: "multiple of three" if num % 3 == 0 else "not a multiple" print(multiple_of_three(9)) print(multiple_of_three(10))
98b78666d0edd6c5558b6acf96f199a450f10a12
plutmercury/OpenEduProject
/w04/task_w04e08.py
234
3.78125
4
# Выведите все четные элементы списка. # # Sample Input: # # 1 2 2 3 3 3 4 # # Sample Output: # # 2 2 4 a = list(map(int, str(input()).split())) for i in a: if i % 2 == 0: print(i, end=' ')
99aecc62b6546a9878960aa5759a91472d055588
AlexSChapman/ToolBox-WordFrequency
/frequency.py
1,780
4.4375
4
""" Analyzes the word frequencies in a book downloaded from Project Gutenberg """ import string import re def get_word_list(file_name, n): """ Reads the specified project Gutenberg book. Header comments, punctuation, and whitespace are stripped away. The function returns a list of the words used in the...
a4708acd91f19b6a34004972230541a194022f44
SimonFans/LeetCode
/Dynamic_Programming/L221_Maximal_Square.py
1,127
3.5
4
''' Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] Output: 4 Input: matrix = [["0","1"],["1","0"]] Output: 1 Input: matrix = [["0"]] Output...
345fc4c2614a20a31b4527158c654ab93e60cfa2
daniel-reich/ubiquitous-fiesta
/qwDPeZeufrHo2ejAY_7.py
498
3.578125
4
def eval_algebra(eq): list1 = eq.split() result = [] for item in list1: try: result.append(int(item)) except: result.append(item) if result[4] == 'x': if result[1] == '+': return result[0] + result[2] return result[0] - result[2] elif result[0] == 'x': if resul...
32cf0906d53b25439b546b04f50ea9c69411a058
lllinx/leetcode
/81_Search_in_Rotated_Sorted_Array_II.py
782
4.125
4
""" Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]). You are given a target value to search. If found in the array return true, otherwise return false. Example 1: Input: nums = [2,5,6,0,0,1,2], target = 0 Output: tru...
d1c4d4987f67c40e6cebd5e114885d8469bcaf82
kupad/tictactoe
/main.py
5,922
3.828125
4
# Phil Dreizen # Tic Tac Toe import random DEV = False # seed the RNG seed = 42 if DEV else None random.seed(a=seed) EMPTY = 0 X = 1 O = 2 NROWS = 3 NCOLS = 3 START_POS = 0 MAX_ROW_POS = NROWS - 1 MAX_COL_POS = NCOLS - 1 class Board: def __init__(self): self.b = [[EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, ...
74ecaed5cff76241aec7c2f55fee64a220b21235
benjaminmurphy/eccpy
/main.py
3,713
4.21875
4
#!/usr/bin/env python3 class Curve: """A class representing an elliptic curve.""" class Integer: """A class representing an integer with a given modulus.""" def __init__(self, modulus: int, value: int) -> None: self.modulus = modulus self.value = value % self.modulus ...
295eedae7cbcfd1fa67308e3002c1562547ee453
Mos7mos7/Random-projects
/DS.py
3,361
4.125
4
#implementing STACK DS with lists class Stack: def __init__(self): self.st = [] def isEmpty(self): return self.st == [] def push(self, item): self.st.append(item) def pop(self): return self.st.pop() def peek(self): return self.st[len(self.st)...
650fb11d9935e8a6e894312cb429e9fd50cc03ee
tanveermeman/Python_oops
/oops_basics1.py
880
3.671875
4
class book: def __init__(self, name, copies): self.name = name self.copies = copies print('instance created') def increase_copies(self, how_much): self.copies += how_much def decrease_copies(self, how_much): self.copies -= how_much math = book('Engineering mathema...
15ad5f1bf999b7f2af469383ff7278a2ee12c536
AndrewErmakov/PythonTrainingBasics
/Basics/Lists/rank.py
297
3.59375
4
count_elements = int(input()) list_elements = [int(i) for i in input().split()] number = int(input()) serial_number_in_rank = count_elements + 1 for i in range(count_elements): if number > list_elements[i]: serial_number_in_rank = i + 1 break print(serial_number_in_rank)
873e04eb81af16b8dc73cfdb95c7414d5457183a
ArianaLuongPham/H1st
/h1st/model/ml_model.py
1,690
3.921875
4
from typing import Any from .model import Model class MLModel(Model): """ Base class for H1st Model. To create your own Machine Learning model, inherit `MLModel` class and implement `prepare_data`, `train` and `predict` accordingly. Please refer to Tutorial for more details how to create a model. ...
b741b11266901e7890d7a8ac8a20620f39231c24
s16005/PythonTutorial
/janken/play.py
1,551
3.921875
4
HANDS = ['グー', 'チョキ', 'パー'] def select_hand(): """ コンピュータの手をランダムに決める :return: HANDSの中のいずれか。 """ import random random.choice(HANDS) pass def judgement(player, computer): """ じゃんけんの勝敗を判定する。 :param player: HANDSの」中のどれか :param computer: HANDSの中のどれか :return: プレイヤーが勝ちの場合は1...
e876d59b420b291c80298cf9c80dddb6c93d660f
BruceHi/leetcode
/binarySearch/search2.py
5,899
3.515625
4
# 33.搜索旋转排序数组, 要求时间复杂度为 O(log n) # 数组中的值互不相同 from typing import List class Solution: # def search(self, nums: List[int], target: int) -> int: # left, right = 0, len(nums) - 1 # while left <= right: # mid = left + right >> 1 # tmp = nums[mid] # ...
fcfae30fd3ffc80634f2c304bf76c95e36c27692
JianxiangWang/LeetCode
/20 Valid Parentheses/solution.py
1,070
3.8125
4
#!/usr/bin/env python #encoding: utf-8 import sys reload(sys) sys.setdefaultencoding('utf-8') class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ stack = [] for c in s: if c in "({[": stack.append(c) ...
7cd53fd9340e6105da58b1a2a39f068e6268e262
C-SIN-TC1028-002-2113/ses02-ta1-AJDJ1234
/assignments/04CalculaTiempo/src/exercise.py
275
3.734375
4
def main(): #escribe tu código abajo de esta línea edad = input("Dame tu edad: ") año = input("Dame el año actual: ") añofinal = (100-int(edad)) + int(año) print("Cumplirás 100 años en el año:",añofinal) if __name__ == '__main__': main()
a153b34d38315d25f7553f52e12caecf71102c13
sabartheman/basic-serial-recording
/serial_test/Arduino_to_text.py
2,483
3.71875
4
import time #need to install pyserial before you can use this module #which can be done by typing: # pip install pyserial #into the terminal as long as you have python installed first import serial #arch linux #programLocation = "/usr/bin/arduino" arduinoPort = "COM14" def SERIAL_TO_TEXT(): # you can also ...
7d679079eb53b0988764c4b9953ae77e96bff999
eliassim/LearnPython
/botGames.py
4,339
3.984375
4
import random def game_1(): word = input("enter your word...") show_word = '_' * len(word) print('\n' * 100) len_in_word = len(word) * 1 print(show_word) print('you have ', len_in_word, 'letter to guesses' ) guesses = 10 guesses_letters = set() while True: guess = input(f'g...
2141b3ddf88b45a361050a462f5b3d995cc6d29b
sagarsitap596/python_learnings
/StringFormatter.py
309
4.0625
4
formatter = '{} {} {} {}' text1 = formatter.format(1,2,3,4) print(text1) print(formatter.format("sads","42424",4,5,6)) text2="hi good morning" \ "hi good afternoon" \ "hi good night" text3 =""" hi good morning hi good afternoon hi good night""" print(text2) print(text3)
d69e770fd3fdbc1cbe40972cf192c9bf4ccaffc4
clarklexa/Practica-4.Py
/Modulo 3/scripts/Problemas Diversos/Modulo_Problema5/modulo_5.py
494
3.53125
4
def buscar_alumno(nombre,lista_alumnos): indices_buscados = [] for i in range(len(lista_alumnos)): count = 0 for t in range(len(nombre)): if nombre[t].lower() == lista_alumnos[i]["nombre"][t].lower(): count += 1 if count == len(nombre): ...
88fdf6e98f2511b386135315f11a6e91a5b66d9c
Ravisutha/CrimePrediction
/Code/Network/community_libraries.py
3,040
3.53125
4
#!/usr/bin/python3 #Community and library network #Author : Ravisutha Sakrepatna Srinivasamurthy #Project: Analysis of Chicago Crime Data import datetime import csv import numpy as np class Library_Network: def __init__(self, path, column=1, code=10000): """ Accepts the path of library station data an...
7812f3a1e6e4516e3906454165e80470c7e6dbfb
bashadmin/pythoncc
/pylabs/twt/twtoop03.py
1,494
4.375
4
# Inherentence """ class Cat: def __init__(self, name, age): self.name = name self.age = age def speak(self): print("Meow") class Dog: def __init__(self, name, age): self.name = name self.age = age def speak(self): print("Bark") """ # Ideally we woul...
450a27f3bcb649eabea413a7167db63db75ff8db
LambertsBikes/CapacitiveDisociationOfWater
/script.py
7,709
3.625
4
##Accepted units of measurement #imports import math #------------------------------------- # Basic Electrical Functions #------------------------------------- #Ohm's Law calculator class function class ohmsLaw: def voltage(current, resistance): volts = float(current) * float(resistance) return ...
f9a4d83624bf7b09fa004ea5dec2c97432e72195
Trillhood/Python-Boot-Camp
/passc.py
753
3.9375
4
# Author: Ian Mike # Program to generate a random password import random, string lower_case = string.ascii_lowercase upper_case = string.ascii_uppercase numbers = string.digits signs = string.punctuation def password_picker(lower, upper, numbers, signs): random_password = [] random_password.append(rando...