blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
27b0b0069b44272f4c950d1c5ecffcfe77c3e1cc
EmreCenk/Breaking_Polygons
/Storing_High_Scores/handling_csv.py
1,652
3.8125
4
def add_to_csv(name, score,pre_path=""): folder = open(pre_path+"/high_scores.csv", "a+") folder.write(name + "," + str(score) + "\n") folder.close() def read_csv(pre_path=""): folder = open(f"{pre_path}/high_scores.csv", "r") information = folder.read() folder.close() # pr...
ceac412b95ddfc03f70b09946ee5ddd20c38d124
VivakaNand/COMPLETE_PYTHON_3
/COMPLETE PYTHON-3 COURSE/Chapter-07-DICTIONARY/data_entry_project.py
355
4.15625
4
for i in range(1, 3): name = input("Enter Name : ") age = input("Enter age : ") gender = input("Enter gender : ") marks = input("Enter marks : ") school = input("Enter school : ") data = {} data["name"] = name data["age"] = age data["gemder"] = gender data["marks"] = marks ...
d3e0b7b9bc8d41203d988bc14d5101024fd51fe8
jainvardhman/HackerRank
/python/maximize-xor.py
768
3.53125
4
totalLanes = 0 testCases = 0 lanesWidth = [] def initializeGlobals(): global totalLanes,testCases,lanesWidth totalLanes,testCases = input().split() totaLanes,testCases = int(totalLanes),int(testCases) lanesWidth = input().split() for i in range(0,len(lanesWidth)): lanesWidth[i] = int(lanesW...
a28e1fb1a8c5a24acfead91ceeca0a7ac1d8e2fb
sharadbhat/Competitive-Coding
/LeetCode/Calculate_Money_In_Leetcode_Bank.py
420
3.59375
4
# leetcode # https://leetcode.com/problems/calculate-money-in-leetcode-bank class Solution: def totalMoney(self, n: int) -> int: total = 0 for i in range((n // 7) + 1): days_in_week = 7 if n >= 7 else n n -= 7 total += self.calcSum(days_in_week + i) - self.calcS...
27a69edb744fbfdbe07ed4700c2a99ef05915ae9
MCaldwell-42/Prep
/something.py
1,160
3.6875
4
import sys name = sys.stdin def FizzBuzz(T, *args): i = 0 while i < T + 1: for instances in args: instance = list(range(1, instances+1)) for number in instance: if number % 3 == 0 and number % 5 == 0: print('FizzBuzz') elif nu...
0dd9b13f3f42ebb4929ba93efb919ded4a40b3fe
azunic/pyhton-tasks
/vjezba_6_ponovno/zad_6_1.py
590
3.609375
4
# -*- coding: utf-8 -*- """ Created on Thu Aug 13 15:40:16 2020 @author: Ana """ #Napišite program u kojem korisnik unosi broj N. Program # tražiti od korisnika da unese N cijelih brojeva i ispisati #njihovu aritmetičku sredinu. #Koristite funkciju „ArtimetickaSredina” koja prima broj i vraća rezultat. def aritme...
ab1ac0b217a00b9f8e9cf312e18a326a70e6ec17
Shaheen0611/UiA-Work
/assignment_2_1/main.py
825
3.796875
4
count = 0 num = [] sum = 0 avg = 0 sort = [] result = [] med = 0 j = 0 while num != 0: j = int(input())#FUNCTION TO CALCULATE AVERAGE if j == 0: break num = j sort.append(num) sum += num count += 1 avg = sum / count for x in range(len(sort)): #FUNCTION TO S...
61cb58a86e6fea647fd2651a55871d4b1aa6829b
anannya03/zip-file-cracker
/ab.py
773
3.859375
4
import zipfile wordlist = 'rockyou.txt' zip_file = 'secret.zip' flag = False # initialize the Zip File object zip_file = zipfile.ZipFile(zip_file) # count the number of words in this wordlist num_words = len(list(open(wordlist, "rb"))) # print the total number of passwords print "Total passwords to tes...
48d9b449d6f330b23627207238ae8395d7bc37bc
farmkate/asciichan
/test.py
274
3.671875
4
#def testEqual(fuctionResult, expected): # if functionResult == expected: # result = 'Pass' # else: # result = 'Fail' # return result def testEqual(a, b): if a == b: print('Pass:', a, '==', b) else: print('Fail:', a, '!=', b)
0d389c71122fd2e8e98ef5bed6dcf1d4599571e1
kjspgd/aoc2020
/21/aoc21_part1.py
2,481
3.65625
4
#!/usr/local/bin/python3 ingredients = {} allergyMap = {} tempList = [] debug = 0 allergenCulprits = {} inverseAllergenCulprits = {} allCulprits = [] allIngredients = [] for line in open('input.txt'): tempList.append(line.rstrip()) for i in range(0,len(tempList)): ingredients.update({int(i):tempList[i].split(...
43e7007ffaef8677fc4be0cf33758f4e2d134c58
Zahidsqldba07/python_course_exercises
/TEMA 5_FICHEROS/Ficheros_2/escribe_csv.py
1,015
3.78125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import lee_csv def dicacsv(fichero,lista): """Recibe un fichero y una lista de diccionarios que fue creada a partir de un CSV en dicho fichero se escribirán los datos de todos los diccionarios""" with open(fichero,'w') as fman: # con la primer...
9435c4fbefec4e546bb43173535945beafad6543
grkheart/Python-class-homework
/homework_3_task_6.py
440
4.0625
4
# Реализовать функцию int_func(), принимающую слово из маленьких латинских букв и возвращающую его же, # но с прописной первой буквой. Например, print(int_func(‘text’)) -> Text. word = input("Введите слово в строчном формате: ") def int_func(word): return word.title() print (int_func(word))
e4d73e8ac451265838a878d516e47382d1a212a6
leotalorac/SpidersAndFlies
/main.py
2,850
3.515625
4
from graphics import * import spider as sp import fly as fl import random as random import time import matplotlib.pyplot as plt height = 600 wight = 1000 def main(): # setup series = list() s =0 spy =list() fli = list() nspiders = 80 nflies = 170 #import the points flyform = open("./...
943e410dd308e561a8fba82f696c4a4994998688
vikramzsingh/Python
/for_loop3.py
146
4.25
4
#Display table of a given number by user n=int(input("Enter the number: ")) for i in range(1,11,1): t=n*i print(n,"*",i,"=",t)
0e5a74b168b2d587c6ef94e5ccae46bc019566d8
TJMcButters/workspace-vscode
/Python/Personal/cardGames/99/Player.py
1,025
3.625
4
import ninetynine as nn class Player: def __init__(self, hand, p_num): self.hand = hand self.p_num = p_num def play_card(self): x = '' keep_going = True while keep_going: print("Player {}: what would you like to play: ".format(self.p_num)) prin...
6a3b65b8e42a135f435151b90b5f413eb41a4a4c
rauljordan/PythonInterviewPractice
/interviewquestions.py
18,870
4.03125
4
def binary_search(l, value): low = 0 high = len(l)-1 while low <= high: mid = (low+high)//2 if l[mid] > value: high = mid-1 elif l[mid] < value: low = mid+1 else: return mid return -1 #======================================================================= # Author: Isa...
b09eaf732235660df644474829ad62d30cda20b5
Louvani/holbertonschool-higher_level_programming
/0x0B-python-input_output/100-append_after.py
561
4.0625
4
#!/usr/bin/python3 """Module learn how to Search and update in a file""" def append_after(filename="", search_string="", new_string=""): """function to inserts a line of text to a file, after each line containing a specific string """ cp_line = [] with open(filename, encoding='utf-8') as f: f...
77d77de31824605f5fad5e4b756696d84bd4a31d
XianYX/Python-
/Snake game with frame.py
2,368
3.734375
4
from Tkinter import * import random class SnakeGame: def __init__(self): # moving step for snake and food self.step=15 # game score self.gamescore=0 # to initialize the snake in the range of (x1,y1,x2,y1) r=random.randrange() se...
835ebccf51c229885b577cb81095e695095d54fe
gsudarshan1990/Training_Projects
/Classes/class_example134.py
416
3.78125
4
#This is python program on Multiple Inheritance class GrandParent: def height(self): print('I have inherited height from Grand Parent') class Parent(GrandParent): def intelligence(self): print('I have inherited intelligence from Parent') class Child(Parent): def experience(self): ...
c515d2b428fabbcebbbfc37d85ffcb7ebbdda34c
WIC-ING/AllPython
/IntroductiontoAlgorithms/dynamicProgramming/Fibonacci sequence.py
936
4.25
4
# -*- coding: utf-8 -*- import time # 函数名称:fibonacciSequence # 函数功能:自底向上 -- 产生斐波切纳数列中的某一位 # 输入参数:int # 返回参数:int def fibonacciSequence(n): if n<=2: return 1 seq = [1, 1] for i in range(2, n): seq.append(seq[-1] + seq[-2]) return seq[-1] # 函数名称:fibonacciSequence_up_to_buttom # 函数功能:自顶向下 -- 产生...
3b0c7c590154dd6fface0f9b3930ffe3a44b824b
foxtype/python
/wiki_scraper/wiki_scraper.py
2,430
3.59375
4
#import Dependencies #BS helps with parsing data from the web. from bs4 import BeautifulSoup #python Lybrary, used for deailing with HTML CSS and other web technologies import requests # Helps us perform regular expressions import re #a wrapper around functions that already exist in python ie. addition subtraction impo...
d50ee114e5abc13a3579a4f609f186720216f9aa
idloea/manfred-jobs
/web_scrapping.py
520
3.515625
4
from bs4 import BeautifulSoup import requests def get_href_to_list(url): """ Get all the href elements of a URL to a list :param url: URL of the website to extract the href elements :return: list of href elements """ page = requests.get(url) soup = BeautifulSoup(page.content, 'html.parser'...
336de1cf555630e4b375801fc543b3d440712e5b
gururajks/algos
/check_permutation.py
650
3.75
4
import unittest from collections import Counter def check_permutation(input1, input2): c1 = Counter(input1) c2 = Counter(input2) for k, v in c1.items(): if c2[k] != v: return False return True class check_permutation_unit_test(unittest.TestCase): def test_check_permutation(...
156a8186cff7973b1532bd0adf7ef863512085eb
ShubhamJha21/python-rough-work
/Object Introspection.py
761
3.765625
4
class Mobiephones(): def __init__(self): self.brand = ["mi","nokiya","lenovo"] self.battery_capacity =["3000mhz","4000mhz","6000mhz"] def rint_details(self): return f"mobile brands {self.brand} have {self.battery_capacity} battery capacity" def ispe(self,str,classstr): ...
17080120ff48422589779a7970b8f2c418bdab02
eepgwde/godel-program-converter
/src/encode_program/encode_program.py
3,182
3.859375
4
from typing import Generator, Tuple from src.godel_utils import encode_pair, sequence_to_godel_number from .constants import ADD_REGEX, GOTO_REGEX, MINUS_REGEX, NOOP_REGEX def encode_label(label: str) -> int: """ Encodes a label into a number If there is no label, the number is 0. Othewise, the number is the ...
f0cef96d25892e261438ff813eb0ed5cf0712b53
JaimeyHolm/Programming
/Opdracht 9.1.py
324
3.65625
4
def sum(): total = 0 aantalKeer = 0 while True: nextInt = (input('next int: ')) if nextInt == '0': break else: total += int(nextInt) aantalKeer += 1 return aantalKeer, total x, y = sum() print('Er zijn', x, 'getallen ingevoerd, de som is:'...
95909bec400f2a893038405ed1115d4cc8843045
holsky/stralg12
/stralgsearch.py
2,532
3.546875
4
#!bin/python from __future__ import print_function import sys import random import time def calc_border_array(string): """ >>> calc_border_array("aaba") [0, 1, 0, 1] >>> calc_border_array("bbba") [0, 1, 2, 0] >>> calc_border_array("abaabaab") [0, 0, 1, 1,...
9e7e03df37bd8be14ad1b826dc2fea46455e63bf
Parker609/leetcode
/ptoffer58_2.py
521
4.125
4
""" 剑指 Offer 58 - II. 左旋转字符串 字符串的左旋转操作是把字符串前面的若干个字符转移到字符串的尾部。请定义一个函数实现字符串左旋转操作的功能。比如,输入字符串"abcdefg"和数字2,该函数 将返回左旋转两位得到的结果"cdefgab"。 """ """ 其实还是栈堆的知识,就不赘述了。 """ def reverseLeftWords(s: str, n: int) -> str: return s[n:] +s[:n] if __name__ == '__main__': res = reverseLeftWords("abcde",1) print(res)
e968f87951840d6f088c0b4ef87dbed2141a602b
daizutabi/machine-learning
/docs/tensorflow/b1_チュートリアル/p1_初級/c01_KerasによるMLの基本/s05_過学習と学習不足.py
5,123
3.65625
4
# # 過学習と学習不足 # # (https://www.tensorflow.org/tutorials/keras/overfit_and_underfit) import matplotlib.pyplot as plt import numpy as np from tensorflow import keras # ## IMDBデータセットのダウンロード NUM_WORDS = 10000 (train_data, train_labels), (test_data, test_labels) = keras.datasets.imdb.load_data( num_words=NUM_WORDS ) ...
bb8d535cf65dcf71a0b83b533ccbf8999b0878aa
PeterSchell11/Python---Beginnings
/#Two Dimensional Lists.py
692
4.0625
4
#Two Dimensional Lists students=[['Joe', 'Kim'],['Sam','Sue'],['Kelly','Chris']] print(students) print(students[0]) print(students[1]) print(students[2]) def main(): #Create a two dimensional list values=[[1,2,3], [10,20,30], [100,200,300]] for row in values: for element in row: print(element) main()...
502781ec19a7c858460dc52afa9461e801462d10
davidyuanyue/Mars-Rover
/model/Rover.py
2,587
3.515625
4
from .Plateau import Plateau from constants import INSTRUCTION_LEFT_TURN, INSTRUCTION_RIGHT_TURN, INSTRUCTION_MOVE, NORTH, WEST, SOUTH, EAST _DIRECTIONS_TURN_LEFT = {NORTH: WEST, SOUTH: EAST, WEST: SOUTH, EAST: NORTH} _DIRECTIONS_TURN_RIGHT = {NORTH: EAST, SOUTH: WEST, WEST: NORTH, EAST: SOUTH} _DELTA = {NORTH: (0, ...
6ec1bee818b74f8641e4c4e93edf4cbc735785fb
k-r-jain/misc
/algorithms_assignment_1/multiplication.py
4,838
3.75
4
from random import randint from timeit import timeit # from memory_profiler import profile import matplotlib.pyplot as plt from sys import getsizeof def gen_rand_ints(digit_size = 8, list_size = 1000): '''Returns a list of m integers each of n digits where m = list_size and n = digit_size''' list_of_ints = [] ...
45a85781f95c5f5dae59740ef1b254e42834a7ee
junyechen/Basic-level
/1009 说反话.py
706
4.34375
4
#给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。 #输入格式: #测试输入包含一个测试用例,在一行内给出总长度不超过 80 #的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用 1 个空格分开,输入保证句子末尾没有多余的空格。 #输出格式: #每个测试用例的输出占一行,输出倒序后的句子。 #输入样例: #Hello World Here I Come #输出样例: #Come I Here World Hello sentence = str(input()) sentence = sentence.split(' ') sentence = list(...
960a52f2941291206cfe9f2a659b84849008e975
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/meetup/521a9e43970a4d4f99807829cb74ac18.py
1,191
3.65625
4
import datetime import calendar WEEKLIST = list(calendar.day_name) def meetup_day(year, month, dayOfWeek, dayType): weekday_index = WEEKLIST.index(dayOfWeek.title()) num_days = calendar.monthrange(year, month)[1] days = [] for day in range(1, num_days + 1): if datetime.date(year, month, day).w...
61a58875482fafc9e606efa729b7f1a23819247e
JoshBasham/Cosc499GithubGroup
/scripts/median.py
234
3.734375
4
##the median of the array def median(nums): n = len(nums) if n%2 == 0: median1 = nums[n//2] median2 = nums[n//2-1] median = (median1 + median2)/2 else: median = nums[n//2] return median
806d1fa8c6b57b9d01460a496ab06b003c9cbef8
gus-an/algorithm
/2020/05-3/recursive_13699.py
539
3.65625
4
my_hash = {} def rec(n): if n == 0: return 1 else: a = 0 for i in range(n): if i in my_hash: l = my_hash[i] else: l = rec(i) my_hash[i] = l if (n-1-i) in my_hash: r = my_hash[n-1-i] ...
5f1690caa34b6ddeb1c7a2020b6b307f1b97717c
BerlinTokyo/Python_new
/nvod_while.py
11,725
4.15625
4
#Для получения данных в программах используется функция input(). #Цикл while в языке Python позволяет выполнять программу, пока некоторое условие остается истинным. prompt = "If you tell us who you are, we can personalize the messages you see." prompt += "\nWhat is your first name? " name = input(prompt) print("\nHell...
873dc9aa5fb75cf4954ed6c21f766b7ed4b964bd
buzsb/PythonExample
/HundredYears.py
654
4.09375
4
# Simple program that ask you age and show year that you will turn 100 # years old from datetime import date def calculate_years(age): if not isinstance(age, int): return False if age <= 0 or age >= 100: return False now = date.today().year calculate = (now - age) + 100 return c...
f677760fc4426aa4612e48a0a587ac3e33b08aaf
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4174/codes/1752_3090.py
241
3.96875
4
N = int(input("movimentos da lagartixa:")) cont = 0 while(0 < N < 7): somatorio = N + 7 if(somatorio = 0): mensagem = ("Abaixo") cont = cont + 1 else:(somatorio < 0) mensagem = ("Acima") cont = 1 *(-1) print(mensagem)
2149ecdbfd0fd32b6288be3f702ad1eaf65e12e2
bharat-kadchha/tutorials
/python-pandas/Python_Pandas/dataframe/CreateDfFromDictofTuples.py
434
3.65625
4
import pandas as pd d = {('a', 'b'): {('A', 'B'): 1, ('A', 'C'): 2}, ('a', 'a'): {('A', 'C'): 3, ('A', 'B'): 4}, ('a', 'c'): {('A', 'B'): 5, ('A', 'C'): 6}, ('b', 'a'): {('A', 'C'): 7, ('A', 'B'): 8}, ('b', 'b'): {('A', 'D'): 9, ('A', 'B'): 10} } df = pd.DataFrame(data=d) # You can automatical...
7c0cef370aac4a94b1dd0926655f495a3bd59cbc
jaychsu/algorithm
/lintcode/600_smallest_rectangle_enclosing_black_pixels.py
1,356
3.5625
4
class Solution: def minArea(self, image, x, y): """ :type image: list[str] :type x: int :type y: int :rtype: int """ if not image or not image[0]: return 0 m, n = len(image), len(image[0]) top = self.binary_search(image, 0, x, sel...
22f295a737603420ed849c25ddce576e7ca07f46
saumonarticho/Project-Euler
/Problem 2.py
404
4.09375
4
#finds the sum of even-valued terms from the Fibonacci sequence whose values do #not exceed "n" def fibo(n): x = 1 y = 2 liste = [x,y] z = x+y while z < n: z = x+y if z % 2 == 0: liste.append(z) x = y y = z else: ...
aa848c9083552aa7ccfe07e85ed366cbc65ace4d
gabriellaec/desoft-analise-exercicios
/backup/user_004/ch75_2019_06_06_18_52_27_826626.py
690
3.515625
4
def primo(n): if n == 1: return False elif n == 2: return True elif n == 5: return False elif n == 3: return True elif n % n == 0 and n % 1 == 0 and n % 2 == 0: return False elif n % n == 0 and n % 1 == 0 and n % 5 == 0: return False elif n % n...
e6b9ad39d889d48b1e68c22586074b7ed0a29515
Yaya7/hornets-scrape
/hornets-scrape.py
1,717
3.546875
4
import urllib2 import re import sys from bs4 import BeautifulSoup import csv import os import itertools from itertools import izip import datetime from datetime import datetime from datetime import date my_url = "http://www.nba.com/hornets/schedule/" scheduleHTML = urllib2.urlopen(my_url) # Now we create a beautiful...
4807df700a19023b3498b9b5756e62704a8c49f2
collin-yamada/UVa
/Super Easy/hajj/hajj.py
445
3.671875
4
from sys import stdin case = 0 while True: hajj = stdin.readline() hajj = hajj.strip() case += 1 if hajj == "Hajj": print("Case ", end = "") print(case, end = "") print(": ", end = "") print("Hajj-e-Akbar") elif hajj == "Umrah": print("Case ", end ...
77f565f2a37aa3e6d46b60c396334edcf20c73dc
GabrielaVilaro/Ejercicios_Programacion
/POO_2.py
931
3.859375
4
#coding=UTF-8 #Ejercicio de objetos Python, del curso de "Pildoras Informáticas." class vehiculos(): #herencia def __init__(self, marca, modelo): self.marca = marca self.modelo = modelo self.enMarcha = False self.acelera = False self.frena = False def arrancar (self): self.en...
173a0b5f6b11ab7b2b3430d4d5695de3f83ee233
GalyaBorislavova/SoftUni_Python_Fundamentals_January_2021
/10_Exams/Exam03.04.2021/Third.py
1,477
3.859375
4
mail = {} capacity = int(input()) command = input() while not command == "Statistics": command = command.split("=") action = command[0] if action == "Add": username = command[1] sent = int(command[2]) received = int(command[3]) if username not in mail: mail[usern...
f90d926fb7c1f0523e77a2d263d42058766c5d1c
guanfuchen/CodeTrain
/SwordOffer/Algorithm/Python/link_list_copy.py
1,022
3.609375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- class RandomListNode: def __init__(self, x): self.label = x self.next = None self.random = None class Solution: # 返回 RandomListNode def Clone(self, pHead): # write code here if pHead is None: return None p...
38d999eef7c9eeece480368abcdf3ad8acb24761
lumbduck/euler-py
/archive/p046.py
2,150
3.59375
4
""" Goldbach's Other Conjecture It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 2×1^2 15 = 7 + 2×2^2 21 = 3 + 2×3^2 25 = 7 + 2×3^2 27 = 19 + 2×2^2 33 = 31 + 2×1^2 It turns out that the conjecture was false. What is the smallest o...
bb56d5c67f3c1b4ba84fd67b8ff14004fb36fa31
minnonong/Codecademy_Python
/17.Advanced Topics in Python/17_05.py
176
3.578125
4
# 17_05 # 리스트 내포(list comprehension): new_list = [x for x in range() if 조건문] even_squares = [i ** 2 for i in range(1, 11) if i % 2 == 0] print even_squares
7251cde04154919a03ac74cabc6ad09039b258f8
xiangcao/Leetcode
/python_leetcode_2020/Python_Leetcode_2020/241_differents_ways_to_add_parentheses.py
1,376
4.0625
4
""" Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 2: Input: "2*3-4*5" Output: [-34, -14, -10, -10, 10] Explanation: (2*(3-(4*5))) = -34 ((2*3)-(4*5)) = -14 ((2*(3-4))*5)...
b638deb5ca9eca81c6af7bad8a5dcb9d57cd4b02
haanguyenn/python_learning
/simple_coffee_chatbot/utils.py
1,483
4.28125
4
def print_message(): print('We\'re sorry, we did not understand your selection. Please enter the corresponding letter for your response.') def get_drink_type(): res = input('What type of drink would you like?\n[a] Brewed Coffee \n[b] Mocha \n[c] Latte \n>') if res.lower() == 'a': return 'Brewed Coffee' el...
8b1ae241b9555318cd904f83515e913e4c88dba0
tochukwuokafor/my_chapter_7_solution_gaddis_book_python
/driver_license_exam.py
1,085
3.578125
4
def main(): correct_answers = ['A', 'C', 'A', 'A', 'D', 'B', 'C', 'A', 'C', 'B', 'A', 'D', 'C', 'A', 'D', 'C', 'B', 'B', 'D', 'A'] open_file = open('driver_license_exam.txt', 'r') student_answers = [] for answer in open_file: answer = answer[:-1] student_answers.append(answer) ...
9d4948c3f6d958da0e6eca9e72a801bb87ff8740
vumeshkumarraju/class
/strings activity assesment 2/code7.py
263
4.3125
4
#converting to title case print("\n\t<<<....WELCOME TO THE PROGRAM....>>>") print("converting your entered string into title mode.\n") string=input("enter the string :- ") print("showing you the entered string in title mode ",end=":- ") print(string.title())
22460ac6a8359e67184906fe4e925ac1bc599c14
arbalest339/myLeetCodeRecords
/main43strMultiply.py
478
3.78125
4
class Solution: def multiply(self, num1: str, num2: str) -> str: num1 = [int(n) for n in num1] num2 = [int(n) for n in num2] multi = 0 for n1 in range(1, len(num1)+1): for n2 in range(1, len(num2)+1): multi += num1[-n1]*num2[-n2]*pow(10, n1-1)*pow(10, n2-1...
f6dd75bc3bf434f21494b4511f673be19ae805b1
XiangSugar/Python
/verification/verf_cli.py
1,314
3.5
4
# coding = utf-8 '''This is a cilent program to test the comunication which is encrypted''' import rsa import socket import time HOST = '127.0.0.1' PORT = 9997 BUFSIZE = 2048 ADDR = (HOST, PORT) key = rsa.newkeys(1024) #生成随机秘钥 privateKey = key[1] #私钥 publicKey = key[0] #公钥 n = publicKey.n ...
2ae7942e916b76da8baca8da487ad755015a1ab5
SpiceGhost/telegram-csgo-server-status-bot
/apps/timer.py
1,159
3.578125
4
import datetime import time class DropReset: def get_time(self): wanted_day = 'wednesday' wanted_time = 00 list = [['monday', 0],['tuesday', 1],['wednesday', 2],['thursday', 3],['friday', 4],['saturday', 5],['sunday', 6]] for i in list: if wanted_day == i[0]: ...
06866720c30f1e9cc2e875da50b9ddc9ca4ddc06
JarryChung/Python-Learn
/python_1.py
229
4.125
4
# -*- coding: utf-8 -*- name = input("Enter you name:") print("hello",name,".") height = input("Enter your height:") weight = input("Enter your weight:") print("Height: %s, Weight: %s" % (height,weight)) print("Number: %d" % 5)
f1102f2291cc6414ec2f1ce97b3984e0d0333fb6
SkotarenkoEvgeny/Softformance_scool
/Modul_3_1/Task_3_1_max.py
4,165
3.90625
4
import random # 1 Створити програму для вгадування числа. Програма запитує користувача число, # яке він повинен відгадати. Якщо користувач відповів не вірно, програма виводить # підказку, повідомляє чи число є більшим чи меншим за те, яке потрібно вгадати і # запитує ще раз. Програма повинна працювати доки користувач н...
aaace78556f84b94af0304fd6ff839d37b9906ed
seweissman/advent_of_code_2017
/day2_corruption_checksum.py
987
3.625
4
""" Day 2: Corruption Checksum """ def string_to_spreadsheet(s): rows = [[int(s) for s in row.split()] for row in s.split("\n")] return rows def checksum(ss): rows = string_to_spreadsheet(ss) checksum = sum(max(row) - min(row) for row in rows) return checksum s1 = """5 1 9 5 7 5 3 2 4 6 8""" # p...
0b335abb5a0aa332bcb27bd4f3705bb5ae607ada
joaothomaz23/Basic_Python_Journey
/verificador_notas.py
539
3.75
4
v = [] aux = 1 acima = 0 sete = 0 while aux > 0: nota = float(input('Entre com o valor da nota: ')) aux = nota v.append(nota) v.pop() print('Número de valores lidos: ',len(v)) print(v) v.reverse() print(v) print('Soma dos valores: ',sum(v)) print('Media dos valores: ',sum(v)/len(v)) for i in ...
7694b0ff31d33818d151294a03437a5b28e8634e
andywillcock/political-analysis-cc
/src/donation-analytics.py
3,376
3.515625
4
from data_checks import * from extract_repeat_donors import * import argparse import numpy as np import pandas as pd def find_repeat_donors(input_file,percentile_file,output_file): """ Uses the provided files to pull relevant data from pipe-delimited file of FEC donation records. Writes out rows containing...
f4582db26d49786722a6e9d51a62ebbcdef52f3d
BaeKyoungYoung/education-automation-robot
/robotEnv/DegreeLibrary.py
512
3.578125
4
from Degree import Degree, DegreeChangeError class DegreeLibrary(object): def __init__(self): self._deg = Degree() self._result = 0 def degree_change_C(self, degree): self._result = self._deg._change_C(degree) def degree_change_F(self, degree): self._result = ...
5116e717b0981e9f4c00b1a16e5800099678cd7a
RodolfoSocrepa/projetos_LetsCode
/projeto_1_JogoDaForca/Projeto_JogoDaForca.py
5,301
3.8125
4
import random # Biblioteca para usar o 'choice' para selecionar a palavra aleatória import os #Biblioteca para ulitizar o comando cls para limpar o terminal #Função para ilustrar a forca #Imprime na tela o boneco conforme os erros def forca(erro): os.system('cls') print('---------- JOGO DA FORCA ----------') ...
680643a392a615408ba8079d433566543d767c5a
gabriellaec/desoft-analise-exercicios
/backup/user_091/ch121_2020_10_06_00_24_28_049671.py
105
3.65625
4
def subtracao_de_listas(lista1,lista2): lista=[x for x in lista1 if x not in lista2] return lista
f2e2788fbf086d53967fc07741cf56ad54627ae1
sotomaque/Cracking-the-Coding-Interview
/Chapter 1/stringRotation.py
641
4.03125
4
''' problem: 1.9 - string rotation assume you have a method 'isSubstring' which checks if a word is a substring of another. given two strings, s1 and s2, write a function that checks if s2 is a rotation of s1 using only one call to isSubstring i.e. 'waterbottle' is a rotation of erbottlewat ''' def isSubstring(st...
2af4a0e0ad67159a05fe5cb023aa2c7aa866bec2
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_95/1588.py
616
3.625
4
#!/usr/bin/python # google code jam - c.durr - 2012 # Speaking in Tongues # trouver un couplage sur {a...z} from string import * def readint(): return int(raw_input()) clear = """a zoo our language is impossible to understand there are twenty six factorial possibilities so it is okay if you want to just give u...
bb51910f2f8118fd6aea1e92ad3faeb9f889fea6
J-RAG/DTEC501-Python-Files
/Lab 4-1-3 Challenge Lab.py
2,095
4.125
4
# Lab 4-1-3 Challenge Lab # By Julan Ray Avila Gutierrez, jra0108@arastudent.ac. EQUAL_RESULT = "an equilateral" ISO_RESULT = "an isosceles" SCALENE_RESULT = "a scalene" INVALID_INPUT_MSG = "One or more of the sides was not valid." ZERO_INPUT_MSG = "You can't have a triangle with a side of 0." ZERO_INPUT = 0 ...
7309de992f9cc77d7196c5f94320d1693bab0903
fagan2888/leetcode-6
/solutions/647-palindromic-substrings/palindromic-substrings.py
1,009
4.125
4
# -*- coding:utf-8 -*- # Given a string, your task is to count how many palindromic substrings in this string. # # The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. # # Example 1: # # # Input: "abc" # Output: 3 # Explanation: Thre...
da62b68e9ff378f5c79c515bf613f5ea5b26d2a2
kellysan/learn
/python/day4/homework10_打印菱形.py
192
3.765625
4
#! /usr/bin/env python # @Author : sanyapeng i = 1 while i <= 9: j = 1 while j <= i: print("{} * {} = {}".format(j, i, i * j), end='\t') j += 1 print() i += 1
44ee4d8dad44570e7a379e2ef81eff05de072ed5
vineel2014/Pythonfiles
/python_exercises/17exercises/16_search.py
677
4
4
# Search element in a sorted list def search(list1,elem): return bsearch(list1,elem,0,len(list1)-1) def bsearch(list1,elem,low,high): if (high - low) < 2: if list1[high] == elem: print 'position = ',high+1 elif list1[low] == elem: print 'position = ',low+1 ...
95afa0448ff53b67261a04bb4378f87772638fad
alijangjoo/rpi-course
/session7/Stepper_Motor.py
1,358
3.5625
4
###################################################################### # Stepper_Motor.py # # This program control the speed and direction of a stepper motor # that connected to gpio ###################################################################### import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM...
0315e63470993b4158d5549358ccd318b7888609
lungen/algorithms
/chapter-3/349_01_InfixToPostfixConversion.py
1,980
4.09375
4
""" 1. Create an empty stack called op_stack for keeping operators. Create an empty list for output. 2. Convert the input infix string to a list by using the string method split. 3. Scan the token list from left to right. • If the token is an operand, append it to the end of the output list. • If the token is a left pa...
1207418ea3ef4e123c136d9e621b707b0d7ed0e7
Allen-Maharjan/Sudoku_Queens
/queen_1.py
264
3.640625
4
import numpy as np grid = [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]] num = 4 def main (): point = [] for i in range (0,4): point.append([0,i]) point.append([i,0]) m = grid.diagonal() print (m) main()
c9c1d307005fcf3cc2f9e899f1e6a821dd134941
schouten76/raspberrypi_workshop
/python/simonIncomplete.py
1,732
3.609375
4
import RPi.GPIO as GPIO # importeer de GPIO bibliotheek. import time # importeer de 'time' bibliotheek. import random # Import 'random' bibliotheek # Constanten declaratie leds = [20,16,12,7] # array met pinnummers van de leds buttons = [21,6,13,19] # array met pinnummers van de buttons aantal = len(leds) # t...
1848d132b2e8ab1851455e501447ffbb46e80a9f
matthaigh27/python-challenges
/primes.py
340
3.828125
4
def isprime(x): for i in range(2, int((x ** 0.5)) + 1): if x % i == 0: return False return True def isgprime(real,imag): return ( (real == 0 and imag % 4 == 3) or (imag == 0 and real % 4 == 3) or isprime(real ** 2 + imag ** 2) ) if __name__ == "__main__": ...
70406cc678ae57c81fd269211cbd9f22b7ea6aba
Israa-Saleh/hackerrank
/Diagonal_Difference.py
781
4.0625
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'diagonalDifference' function below. # # The function is expected to return an INTEGER. # The function accepts 2D_INTEGER_ARRAY arr as parameter. # def diagonalDifference(arr): # Write your code here sum1,sum2=0,0 j=...
67d0aff8ecfe93a6a200447989566ecd675f69d9
asperaa/back_to_grind
/Heap/k_nearly_sorted_array.py
853
3.765625
4
"""We are the captains of our ships, and we stay 'till the end. We see our stories through. """ """https://practice.geeksforgeeks.org/problems/nearly-sorted-algorithm/0 """ from heapq import heapify, heappop, heappush def k_nearly_sorted(nums, k): min_heap = [] heapify(min_heap) sorted_arr = [] for n...
5678c4cc738d442a749822805f0bcf09315104fe
ndiekema/CPE202
/Labs/lab1/location_tests.py
715
3.5625
4
import unittest from location import * class TestLab1(unittest.TestCase): def test_repr(self): loc = Location("SLO", 35.3, -120.7) self.assertEqual(repr(loc),"Location('SLO', 35.3, -120.7)") def test_eq(self): loc1 = Location("SLO", 35, -120) loc2 = Location("SL...
bfd9aa024962448e409b318fbce340735bba4b91
Huymemee/genetics
/sudoku/positions.py
6,136
3.71875
4
""" This package is used to compute positions of elements in grids depending on grid size obviously. Created on 15/11/2018 @author: nidragedd """ from random import shuffle def retrieve_row_id_from_position_and_size(position, size): """ Given a position in the objects values, determine the id of the row (sta...
27917945244de8a9fab3686f1f9fd6f75452233c
SocioProphet/CodeGraph
/kaggle/python_files/sample987.py
8,341
3.671875
4
#!/usr/bin/env python # coding: utf-8 # <table> # <tr> # <td> # <center> # <font size="+1">If you haven't used BigQuery datasets on Kaggle previously, check out the <a href = "https://www.kaggle.com/rtatman/sql-scavenger-hunt-handbook/">Scavenger Hunt Handbook</a> kernel to get started.</fo...
ee5529f234f5ad4f088620a01dda105fd2d44160
appdutao/python
/python/com/dutao/spider/sigle_thread.py
460
3.53125
4
''' Created on 2015-12-18 @author: dutao ''' from time import ctime,sleep def music(music_name): for i in range(2): print("I was listening to %s. %s" % (music_name,ctime())) sleep(1) def move(movie_name): for i in range(2): print("I was at the %s! %s" % (movie_name,ctime...
c30ef29642aad3ba26ad140dcd81883ed0a75dc4
mdziubin/leet
/22.py
499
3.515625
4
class Solution: def generateParenthesis(self, n: int) -> List[str]: res = [] # Backtracking? def helper(left, right, tempStr): if right < left: return if not right and not left: res.append(tempStr) return if...
cb726ee71c81ef694e364fd019efb66f32b6b5e3
jan-nemec/LPTHW
/ex42_objects_and_classes.py
5,951
4.15625
4
# Is-A, Has-A, Objects, and Classes # An important concept that you have to understand is the difference between a class and an object. # The problem is, there is no real "difference" between a class and an object. # They are actually the same thing at different points in time. # What is the difference between a fish...
72651e56e608d9fd25f0cfd5908c08647d2382d8
valgerdur-asgeirsdottir/Python_verkefni_git
/numbers.py
301
3.515625
4
for i in range(10, 100): num1 = i // 10 num2 = i % 10 sum_num = num1 + num2 if (sum_num ** 2) == i: print(i) count_div = 0 for i in range(10,100): for b in range(1,100): if i % b == 0: count_div = count_div +1 if count_div == 10: print(i)
c8fbfa72135f465358196b6a8b912a105e95de1d
TiredOfThisAll/SmartCalculator
/main.py
1,460
4.03125
4
from calculator import calculate from parse_brackets import parse_brackets from my_dictionary import show_variable_value, add_variable_to_dictionary HELP_MESSAGE = """Type your expression in the next format: x + y * ( c + ( s + z ) ) Calculator supports addition, subtraction, multiplicatio...
f9eba7fc6357e4fb32a52de80e63722baafd35d7
lilyhuong/TD3-S1-Info-2018-2019
/EX1.1.TD3.Nguyen Thi Huong.py
176
3.78125
4
def function(x): print ("F(x) = 1 / (x * x)") Fx = 1 / (x * x) return Fx Fx = function(5) print(Fx) def f(x): return 1/ x ** 2 print(f(2))
2bdc4e84ae9f968ad447a5dd2b52d353372c7e90
kannanmavila/coding-interview-questions
/interview_cake/5_ways_to_make_change.py
714
4.0625
4
def ways_to_make_change_bottom_up(n, denominations): """O(Nk) solution - uses the coins bottom-up. Start with a particular coin, update all amounts up till n, and never come back to that coin again. """ ways = [1] + [0] * n for coin in denominations: # For amounts higher than coin for amount in xran...
c7144342329fb1ce3c1ee7b0a416905e56331907
dhlife09/pyschool
/20201130_환전.py
442
3.625
4
def exchange(c, m): m = m/1000 if c == 1: m = str(m*0.9) + '$(달러)' elif c == 2: m = str(m*0.8) + '€(유로)' elif c == 3: m = str(m*5.6) + '¥(위안)' elif c == 4: m = str(m*91.8) + '¥(엔)' else: m = 'ERROR' return m print('[1] 달러 [2] 유로 [3] 위안 [4] 엔') c = int...
d4c65034f48c4c69d1eff001d41780247d49fcc3
tcsfremont/curriculum
/python/pygame/maze/maze_generator.py
1,782
3.65625
4
import random import time mx = 12; my = 12 # width and height of the maze maze = [[0 for x in range(mx)] for y in range(my)] dx = [0, 1, 0, -1]; dy = [-1, 0, 1, 0] # 4 directions to move in the maze color = [(0,0, 0), (255, 255, 255)] # RGB colors of the maze # start the maze from a random cell cx = random.randint(0, m...
78b48e86a00128fad0c82900d358f30feb97e2f3
daniel-reich/turbo-robot
/dBBhtQqKZb2eDERHg_5.py
841
4.25
4
""" Write a **recursive** function that accepts an integer `n` and return a sequence of `n` integers as a string, descending from `n` to 1 and then ascending back from 1 to `n` as in the examples below: ### Examples number_sequence(1) ➞ "1" number_sequence(2) ➞ "1 1" number_sequence(3) ➞ "2 1...
9af43523b581d7cdb6764156585e497c7c7565a9
VVKot/coding-competitions
/leetcode/python/101_symmetric_tree.py
918
4.0625
4
""" T: O(N) S: O(N) Start with left and right children of the root. For a tree to be symmetric both of them should either have same value or both be emptry. If that condition holds, check their children in mirrored fashion - first left with second right and first right with second left. """ class TreeNode: def ...
bf2a9ae252fb937ebcd9dfdac3a4ee2fc8651e1a
gtripti/PythonBasics
/Decorators/Sample.py
891
4.09375
4
def func(): return 1 func() def hello(): return 'Hello!!!' hello() greet = hello greet() # Return Functions def hello1(name = 'Jose'): print('The hello1() function is executed') def greet(): return '\t This is the greet function inside hello' def welcome(): return '\t this is welco...
f5603aa68a8a4d7bb85acb024bd3046024d3006a
antariandel/eliq
/common.py
15,739
3.609375
4
import platform import types from typing import Union from abc import ABC, abstractmethod import tkinter as tk from tkinter import ttk from images import icons def float_or_zero(value) -> float: try: return float(value) except ValueError: return float(0) def center_toplevel(toplevel: tk.To...
287420ddfbb5cfb1dfdda1aeadc5da74c9f8a7c2
aravind1910/Algorithmic-Toolkit-Course-UC-SanDiego
/Algorithmic toolkit/week4_divide_and_conquer/2_majority_element/majority_element.py
930
3.9375
4
# Uses python3 import sys def findCandidate(A): maj_index = 0 count = 1 for i in range(len(A)): if A[maj_index] == A[i]: count += 1 else: count -= 1 if count == 0: maj_index = i count = 1 return A[maj_index] # Function to ...
de3212366871ec7ca1842e1ea2854c4099141a69
MaximOksiuta/for-dz
/dz3/5.py
890
3.8125
4
def splitter(u_str): u_str = u_str.split() for i in range(0, len(u_str)): u_str[i] = int(u_str[i]) return u_str def summer(u_str): result = sum(u_str) print(result) return result itog_sum = 0 while True: u_str = input("Для сложения введите числа через пробел для выхода введите '...
db2c7c0a09ab89ef321901c8ea7667e75af23003
ursstaud/PCC-Basics
/ada_lovelace.py
477
3.921875
4
#name = 'ada lovelace' #print(name) #print(name.title()) #name_upper = name.upper() #print(name_upper) #print(name_upper.lower()) first_name = 'ada' last_name = 'lovelace' full_name = f"{first_name} {last_name}" #print(full_name) #print(full_name.title()) print(f"Hello, " + full_name.title() +"! How are you ...
d190ead0af51f82dbd5746e8ade4a83d360d4f56
Apurva-10/Python-Basics
/swapno.py
121
3.8125
4
a = 100 b = 157 print(a,b) #It will give output as: 10 15 a,b = b,a print(a,b) #It will give output as: 15 10
c6630e815b33a3a733fbdfb66be6cf0a8a858e04
mrpsharp/comp-phys
/turtle1.py
825
4.03125
4
import math from turtle import * dt = 0.0 class Particle(Turtle): """Subclass of Turtle representing a body. Extra attributes: mass : mass in kg ax, ay: x, y accelerations in m/s^2 vx, vy: x, y velocities in m/s px, py: x, y positions in m """ mass = None vx = vy = 0 px = 0. ...
9170eb406b6b048c0bf2c86d3138d73edfc131b0
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/strings/pangrams.py
1,153
4.375
4
def pangrams(s): """Hackerrank Problem: https://www.hackerrank.com/challenges/pangrams/problem Roy wanted to increase his typing speed for programming contests. His friend suggested that he type the sentence "The quick brown fox jumps over the lazy dog" repeatedly. This sentence is known as a pangram becau...