blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
a19b1e2645e5a65bb2176141c01cab56193f6f7c
uwcalgo/sessions
/3/easy/bliz937/Vigenere.py
1,442
3.96875
4
# Vigenre cipher def encrypt(text, key): keyLen = len(key) if(len(text) == 0 or keyLen == 0 or type(text) != str or type(key) != str): return "Not a valid key or string" arrayKey, keyIndx, encrypted = [abs(ord(i) - 97) for i in key], 0, "" for i in text: i = i.lower() ...
c857b73c627c2c02cec7124c1fb941c440c52e04
hlxwell/leetcode-ruby
/palindrome.py
385
3.84375
4
import math class Solution: def isPalindrome(self, x): """ :type x: int :rtype: bool """ x_in_str = str(x) str_size = len(x_in_str) for i in range(0, math.floor(str_size / 2)): if x_in_str[i] != x_in_str[-(i+1)]: return False return True if...
7ebba59afac0b238bfe106274f3f6b8c48cfdbf5
Quintuplin/CSCI_320
/java_OO_practice/python_postal_codes.py
952
3.8125
4
regex_integer_in_range = r"^[1-9]([0-9]){5}$" # Do not delete 'r'. regex_alternating_repetitive_digit_pair = r"(?=1[0-9]1)|(?=2[0-9]2)|(?=3[0-9]3)|(?=4[0-9]4)|(?=5[0-9]5)|(?=6[0-9]6)|(?=7[0-9]7)|(?=8[0-9]8)|(?=9[0-9]9)|(?=0[0-9]0)" # Do not delete 'r'. import re # P = "121256" # P = "110000" P = "4542867" print (boo...
e2226ca200802b68447e433e3f7069aada93c9e6
Quintuplin/CSCI_320
/hrank_problems/countingvalleys.py
489
3.703125
4
#!/bin/python3 import math import os import random import re import sys # Complete the countingValleys function below. def countingValleys(n, s): elev = 0 valleys = 0 for letter in s: prevelev = elev if(letter=='U'): elev=elev+1 elif(letter=='D'): elev=elev...
f3cc9103d11b81277039f9469dade6ebca1e9fba
Lmdudester/Python-Sandbox
/cardGames/structures/cardPlayer.py
3,325
3.96875
4
from structures.card import Card # class CardPlayer # Object: CardPlayer - represents a player in a card game # Shared class data: # N/A # Attributes: # hand - A list containing all the cards the playe currently # has in hand # name - A string holding the name of the given player # maxHandSize - Th...
161bf05d160e722dafb52092ed56e980a69641e6
rvpasari/MapReduce
/friend_count.py
640
3.65625
4
''' We implement a mapreduce to calculate the number of friends a user has. Data obtained from the friends.json file, problem given as part of assignment from a UW course. ''' # coding: utf-8 import MapReduce import sys import json mr = MapReduce.MapReduce() def mapper(record): friend1 = record[0] frien...
212eb17b3fe2be217b25c902f84d084fca9339df
dvjn/AdventOfCode2019
/Day04/part2.py
881
3.8125
4
import sys def is_valid_password(number): number_str = "0" + str(number) + "a" same_adjacent_digits = False for i in range(1, len(number_str)): if number_str[i] < number_str[i - 1]: return False if ( i > 2 and number_str[i] != number_str[i - 1] ...
335fbf6f10587917f939df825a7be813499fceff
dvjn/AdventOfCode2019
/Day01/part2.py
516
3.59375
4
import sys from part1 import calculate_fuel_requirement def main(): total_fuel_requirement = 0 with open(sys.argv[1], "r") as masses: for mass in masses: new_fuel_requirement = calculate_fuel_requirement(int(mass)) while new_fuel_requirement > 0: total_fuel_req...
35e429ba262e19e0a1e3ab109f9fac7c5490cd35
Dennissaminathan/adjust
/random_number.py
454
3.875
4
#!/usr/bin/python import random numbers =[1,2,3,4,5,6,7,8,9,10] ### List with required numbers def myfunction(): ### Function to pass floating variable for the shuffle method return 0.1 def print_random_order(): random.shuffle(numbers,myfunction) for random_number in numbers: ### Print the randomly ord...
48f63e5dfcd454d932b66604f0a60b9f94b78288
Sona-Mariyam-Sabu/aynz-anos
/anos.py
166
3.921875
4
import aynz # num1=int(input("enter number1")) # num2=int(input("enter number2")) # result=aynz.addition(num1,num2) # print(result) print(__name__) aynz.display()
c3031a099092b09cadd02bb667892d869d773706
Guillaume-Mayer/dumbchess-python
/chess/game.py
3,231
3.703125
4
from .const import * from .move import Move from .position import Position import re import winsound HELP = """ h: Show this help l: Show legal moves m: Show material score e: Show evaluation g: Show game moves c: Let computer choose for me u: Undo last move q: Quit NUMBER: Choose move by number in legal moves list ...
4780f22bdd36885b5636d1c9b8e3f3211a3e4674
pipistero/algorithms
/quick_sort.py
1,207
3.75
4
''' Written 20.09.2020 Author: Anton Kazakevich Algorithm: Quick sort (good sort if pivot is good) Language: Python 3.x ''' from random import randint max_int = 100 #Max integer that can be generated lenght = 10 #Lenght of the array arr = [] sorted_arr = [] rand_int = randint(0, max_int) #Filling the ...
a1b08206c55748a8d16a1fdfde67eca0d21372b1
JosephZYU/WSL2-Ubuntu
/move folders - Oct 17 2019.py
1,857
3.90625
4
#* SUCCEED!!! Using Python to create directories and move files # http://digitalcollections.wp.txstate.edu/2018/04/04/using-python-to-create-directories-and-move-files/ import os import shutil # C:\\Computer\\VSCode\\WIP_File_Moving\\Source_Data # dir = "1959_6x6/" dir = "C:\\Computer\\VSCode\\WIP_File_Movi...
7df1881b6fb9e4d6e2f4df82b574714383591142
Adil-Iqbal/Coding
/Ethoslab Fansite/Scripts/populate_episode_json_data.py
4,272
3.5
4
import requests import json from pprint import pprint import traceback """This script is used to populate a JSON file with formatted Episode data.""" def get_episode_num(string): """Returns the episode number as an integer.""" for i, char in enumerate(string): if char == ":": ...
ceb575c631f7ae337e64b81e699132081dbfb45d
ManuLam/Competition
/Kattis/missingNumbers.py
323
3.5
4
n = int(input()) numbers = [int(input()) for _ in range(n)] print_range = lambda x,y: [i for i in range(x+1,y)] ar = [] ar.extend(print_range(0, numbers[0])) for i in range(len(numbers)-1): ar.extend(print_range(numbers[i], numbers[i+1])) print('\n'.join(map(str, ar)) if len(ar) > 0 else 'good job'...
d1e99d3ffa45b6a26c9940a8477c5251b7437db3
ichbinjon/ProblemSolving
/src/ransom_note.py
700
3.796875
4
#https://www.hackerrank.com/challenges/ctci-ransom-note def ransom_note(magazine, ransom): magazine_dict = {} ransom_dict = {} for x in magazine: if x in magazine_dict: magazine_dict[x] +=1 else: magazine_dict[x]=1 for x in ransom: if x in ransom_dict: ransom_dict[x] += 1 else: ransom_dict[x]...
3fa8edbda50ceea877577b2cdfe2798bf7b1b7f2
Aklim21/Mini_Projects
/ATBS/tic_tac.py
620
3.9375
4
board = {'TL' : ' ', 'TM' : ' ','TR' : ' ', 'ML' : ' ', 'MM' : ' ','MR' : ' ', 'BL' : ' ', 'BM' : ' ','BR' : ' '} def printBoard(board): print(board['TL'] + '|' + board['TM'] + '|' + board['TR']) print('-+-+-') print(board['ML'] + '|' + board['MM'] + '|' + board['MR']) print('-+-+-') ...
78a501ea82dac6aab5990392f6e66a037a8c8779
Aklim21/Mini_Projects
/ATBS/stringReplacement.py
149
3.875
4
name = 'Anthony' place = 'Felpham' age = '24' print ('Hello %s, when where you last down in %s? WOW! you\'re %s years old now?!'%(name,place,age))
37ccacf9645b2e89d1eb42ce05503052f58fa54f
chenshor/Give-Take_Food_Bank
/backend.py
7,649
4.03125
4
import datetime import sqlite3 from sqlite3 import Error class DataBase: """ This class opens the connection and creates (if does not exists) a database""" def __init__(self): """Creating a connection""" self.conn = sqlite3.connect('database.db') """Creating a cursor object""" ...
761251e11c57ca3051796516b5f12d398ef67220
mschleiffarth/python-challenge
/pypoll/pypoll.py
1,989
3.625
4
import csv csvpath = "Resources/election_data.csv" totalVotes = 0 candidates = ["empty"] votes = [0] voteCast = False mostVotes = 0 winner = "nobody" with open(csvpath, newline='') as csvfile: electionData = csv.reader(csvfile, delimiter=',') csv_header = next(electionData) for row in electionDat...
dcd02ef61c6b2003024857d5132f8f4d8cf72e01
venkat284eee/DS-with-ML-Ineuron-Assignments
/Python_Assignment2.py
605
4.46875
4
#!/usr/bin/env python # coding: utf-8 # # Question 1: # Create the below pattern using nested for loop in Python. # * # * * # * * * # * * * * # * * * * * # * * * * # * * * # * * # * # In[1]: n=5; for i in range(n): for j in range(i): print ('* ', end="") print('') for i in range(n,0,-1): for j ...
e4fb103c6426e86ad07fc13d77a73b3c1207f9ce
Talk-To-Code/TalkToCode
/AST/output/program actual outputs/P Progs/Fibonacci.py
334
4.03125
4
import sys def main(): n, first, second, next, c = 0, 0, 1, 0, 0 print("Enter the number of terms\n") n = input() print("First " + n + " terms of Fibonacci series are :-\n") for c in range(n): if(c <= 1): next = c else: next = first + second first = second second = next print(next + "\n"...
00651d10a49102b04735bcbcb0572cb07128d889
kendfss/pixelwerke
/pygaming/partsim/stars.py
9,167
3.796875
4
#!/usr/bin/env python """A simple starfield example. Note you can move the 'center' of the starfield by leftclicking in the window. This example show the basics of creating a window, simple pixel plotting, and input event management""" import random, math, pygame, os from pygame.locals import * from m3ta i...
463de758d16442e714bcc6e3d05004f458bdb1ed
hobbes7878/CSV-RailSplitter
/Part II/csv_field_splitter.py
2,174
3.59375
4
from __future__ import division import csv import re import math print">>>========================== \\\\ ==========================<<<" print " __________ __ ___ _ ______ ___ __ __ " print " / ___/ __| | / / / _ \___ _(_/ / _____ / (_/ /_/ /____ ____" print "/ /___\ \ | |/ / / , _/ _ `/ /...
bf7e80f4efd903d52b154cd3e2ca8d62d238aadb
swav/udacity
/212/unit-3-hw-3.py
10,572
4.09375
4
# --------------- # User Instructions # # In this problem, you will be using many of the tools and techniques # that you developed in unit 3 to write a grammar that will allow # us to write a parser for the JSON language. # # You will have to visit json.org to see the JSON grammar. It is not # presented in the correc...
410a67b8e376978df95d4b2958e593b11cd3e92b
kaust-cs249-2020/huawen
/chapter3/3.14maximal_nonbranching_paths.py
2,599
3.71875
4
def degree_calculator_v2(graph): '''for a given graph which is a dictionary represent the edges in graph, calculate each node's outdgree and indegree as a list ''' node_degree={} for key,value in graph.items(): node_degree[key]=[len(value),0] for value in graph.values(): ...
9b494088be20b8954b6264cfc4edaeb0dae2d4ac
kaust-cs249-2020/huawen
/chapter2/2.12Distance_between_pattern_strings.py
806
3.75
4
def Distance_between_pattern_strings(Pattern,Dnas): k=len(Pattern) distance=0 for dna in Dnas: hammingdistance=float('inf') for i in range(len(dna)-k+1): pattern=dna[i:i+k] if hammingdistance>HammingDistance(Pattern,pattern): hammingdistance=Ha...
68520da1d23d7b59ad87426626270f8d945f95c7
Rens88/projectEuler
/lvl027_findns.py
2,541
3.796875
4
from functools import reduce from operator import mul import math from supportScripts.tictoc import tic, toc def dropNonPrimes(p, n_list): for n in n_list.copy(): if n %p == 0: n_list.remove(n) return n_list def findPrimes(n): n_list = set(range(2,n+1)) # Loop over all integeres primes = [] # store all p...
c82c02f3a1387a27bdda74b051532c6c21cebfaf
Cihua01/Python230221
/Ejercicios/ejercicio7.py
394
3.984375
4
import math #declarar las variables ENTRADAS print ("escribe en mc el valor de la base 1:") base1= float (input ()) print ("escribe en mc el valor de la base 2:") base2= float (input ()) print ("escribe en mc el valor de la profundidad:") profundidad= float (input ()) #operaciones PROCESO metros_cubicos=base1 * base2 *...
83a029e64c022f6f35ac0ea01b1f28818bfb093f
mrparkonline/py_basics
/solutions/desiredOuput.py
300
3.953125
4
''' Exercise 7: How would you manipulate the variable called our_number to display the following output. Desired Output: 4 34 234 1234 Instruction Set Starting Point: our_number = 1234 ''' our_number = 1234 print(our_number % 10) print(our_number % 100) print(our_number % 1000) print(our_number)
ff24a3734a3731d98556d07d7e8f8b7c21b4dece
mrparkonline/py_basics
/solutions/headTails.py
639
4.0625
4
# Create a Python program that mimics the heads or tails game. The program should output either ‘H’ for heads or ‘T’ for tails randomly on each execution of the program. from random import choice print(choice('HT')) print(choice(['Heads', 'Tails'])) ''' # Using 5 print() statements, create a tiny Python program that...
faffa16c4ee560cb5fdb32013893bbf83e947ba1
mrparkonline/py_basics
/solutions/basics1/circle.py
300
4.46875
4
# Area of a Circle import math # input radius = float(input('Enter the radius of your circle: ')) # processing area = math.pi * (radius ** 2) circumference = 2 * math.pi * radius # output print('The circle area is:', area, 'units squared.') print('The circumference is:', circumference, 'units.')
e26212cee3432b9a86f2986c98ee6d1a81536a8c
lucabecci/python-exercises2
/exercise3.py
270
3.96875
4
#search the low number in the list list = [3, 5, 2, 0, 22, -233, 233, -212] low_number = 'init' for number in list: if low_number == 'init': low_number = number else: low_number = number if number < low_number else low_number print(low_number)
12239c83a63ee007eaa9505664adce264eb6324d
GrearyGreen/learn_py
/实验6/随机小学加法题.py
161
3.5
4
import random as r x,y = input().split() r.seed(int(x)) for i in range(1,int(y)+1): a = r.randint(1,9) b = r.randint(1,9) print("{}+{}=".format(a,b))
9b65c8f2873569c9b74a6d0c86cfff16056cf795
GrearyGreen/learn_py
/实验2/人民币与美元汇率兑换程序.py
225
3.5
4
#ren min bi zhuan huan qi t = input() if t[0] in ['$']: f = eval(t[1:]) c = f*7 print("¥{:.2f}".format(c)) elif t[0] in ['¥']: c = eval(t[1:]) f = c/7 print("${:.2f}".format(f)) else: print("输入格式错误")
c1e3b72de02bb8f2ca1ed811837104213ade8852
GrearyGreen/learn_py
/实验3/计算球体积.py
81
3.734375
4
import math r = eval(input()) v = 4*math.pi*(r**3)/3 print('v={0:.3f}'.format(v))
f4d7ff78084bfb3013eb5e80c3a605e9db48a943
ulmerb/BatteryStorageManagement
/utility.py
752
3.546875
4
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np import pickle import os #Pass in data as an array of the points we want to plot def createLineGraph(data): fig,ax = plt.subplots(1) x = np.array(data) y = np.arange(len(data)) ax.plot(x,y) plt.show() sizes = [20,40,80] algorithms = ['low...
b217a43528284e2f39b5ade8f82346b145579553
tedrickzhu/exi_inpaint
/eximage/test/functest.py
140
3.671875
4
# -*- coding: utf-8 -*- # @Time : 20-3-5 上午2:57 # @Author : zhuzhengyi a = [1,2,3,4,5] for b in a: print(b) for c in a: print(c)
f39cb94b90bc3d675838918d92f4e721076b71af
ryzheboka/cities
/center.py
3,657
3.6875
4
from collections import Counter import pandas as pd import itertools from time import time def get_data(dirname, tset): """ :param dirname: name of directory with data :param tset: name of the file where to get data from :return: dictionary with city name as key and country as value """ all_d...
cfa76d8e6d8bf32387355a73b7c5d0141654c2c7
jfmalloy1/Ant-Colonies
/ants.py
12,715
3.71875
4
import sys import numpy as np import random import matplotlib.pyplot as plt #Text file containing the graph GRAPH = sys.argv[1] #Number of columns in the graph (should be 8 for sample graphs) COLS = int(sys.argv[2]) #Ending variables (two sets of coordinates) END1 = [(int(sys.argv[3]), int(sys.argv[4]))] END2 = [(int(...
99acb7594bfaa4e704b794be06845436058d2ec0
akleemans/python-library
/graph/plot.py
204
3.828125
4
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Last modified on 23.06.2012 @author: adrianus ''' import matplotlib.pyplot as plt data = [x**2 for x in range(1,20)] plt.plot(data) plt.fill() plt.show()
3929bdb207a89ea1e0606cd7172a69cacb84972c
lyb1527/depth-first-search
/subsets.py
652
3.8125
4
''' Given a set of distinct integers, return all possible subsets. *Elements in a subset must be in non-descending order. *The solution set must not contain duplicate subsets. If S = [1,2,3], a solution is: [ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], [] ] ''' class Solution: def searc...
9270a4c051358fa844d3de77a2f0c5045f50d839
Sinkrain/python_algorithm
/chapter_06/binary_tree.py
1,332
3.625
4
# -*- coding: utf-8 -*- class BinaryTree: """ 利用节点与引用创建二叉树 """ def __init__(self, rootObj): self.key = rootObj self.leftChild = None self.rightChild = None def insertLeft(self, newNode): """ 插入左节点 """ if self.leftChild is None: ...
acaf8547245186b0ace40ce940bf663abc4d55db
ElianMelo/curso-biotecnologia
/python-avancado/Reduce.py
157
3.625
4
# -*- coding: utf-8 -*- from functools import reduce def soma(x, y): return x + y lista = [1, 3, 5, 10, 20] soma = reduce(soma, lista) print(soma)
0dc37a97664481621810076ce02fb2589767f52a
ElianMelo/curso-biotecnologia
/python-intermediario/Listas.py
698
3.921875
4
# -*- coding: utf-8 -*- minha_lista = ["abacaxi", "melancia", "abacate"] minha_lista_2 = [1, 2, 3, 4, 5] minha_lista_3 = ["abacaxi", 2, 9.89, True] lista_vazia = [] tamanho = len(minha_lista) print(minha_lista) print(tamanho) print(minha_lista_2) print(minha_lista_3) print(minha_lista[2]) print(minha_lista[1]) print...
ac7202cdbafafb3c04653456e387c61c92165f96
ElianMelo/curso-biotecnologia
/python-basico/Exercicios/Exercicio4.py
1,136
4.0625
4
''' Escreva um programa que ordene uma lista numérica com três elementos. ''' valor1 = int(input("Digite o valor1: ")) valor2 = int(input("Digite o valor1: ")) valor3 = int(input("Digite o valor1: ")) maior = 0 menor = 0 medio = 0 # Caso 1 if valor3 >= valor2 and valor3 >= valor1: maior = valor3 if valor2 >=...
ede4d4d32bf1f32baf2249f1f677b08238713642
edwardyangyi/Python-hard-way
/ex34.py
261
3.625
4
animals = ['bear', 'python', 'peacock', 'kangaroo', 'whale', 'platpus'] bear = animals[0] # The third (3rd) animal. # The first (1st) animal. # The animal at 3. # The fifith (5th) animal. # The animal at 2. # The sixth (6th) animal. # The animal at 4.
0075f3db504f6f762e80a6fb7750d5400a710de8
devrijal/self-taught-python
/binary_search.py
415
3.96875
4
def binary_search(the_list, item): first = 0 last = len(the_list)-1 found = False while first <= last and not found: mid = (first + last) // 2 if the_list[mid] == item: found = True else: if item < the_list[mid]: last = mid - 1 else: first = mid + 1 return found the_list = [10, 12, 19, 1...
77483beea06a35855abf42f84a1250f89c5c6622
jolleyjames/Advent-of-Code-2019
/day15/day15.py
3,495
3.90625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Advent of Code 2019, day 15. @author: James Jolley, james@jolley.co """ from collections import deque from day05.day05 import Computer, read_program def next_output(comp, in_): '''Apply the input to the Computer, and return the next output value. Assumes the...
1321eb64211d3070782b888448a95630c1cf5de1
jolleyjames/Advent-of-Code-2019
/day03/day03.py
8,770
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 3 18:25:47 2019 @author: jim """ class Wire: def __init__(self, segments, min_x, min_y, max_x, max_y): self.segments = segments self.min_x = min_x self.min_y = min_y self.max_x = max_x self.max_y = max_y...
9dae472c7feb9cba044b6d1748d1fcf5998da3d6
jolleyjames/Advent-of-Code-2019
/day09/day09.py
848
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Advent of Code 2019, day 9. @author: James Jolley, james@jolley.co """ from day05.day05 import Computer def read_program(path): with open(path, 'r') as fobj: program = list(map(int, fobj.readline().strip().split(','))) return program def part1(path,...
d25b665f6e6cd11cb4c8b7b48d9b917d16d25dd1
KorzhMorzh/cs102
/homework03/GameOfLife.py
8,054
3.734375
4
import pygame import random from pygame.locals import * class GameOfLife: def __init__(self, width: int = 640, height: int = 480, cell_size: int = 10, speed: int = 10): self.width = width self.height = height self.cell_size = cell_size # Устанавливаем размер окна ...
0a8191c345c92e363446f5cde501c6784a7abe7d
KorzhMorzh/cs102
/homework03/GameOfLife_Classes.py
8,113
3.609375
4
import pygame from pygame.locals import * import random from copy import deepcopy class GameOfLife: def __init__(self, width: int = 640, height: int = 480, cell_size: int = 10, speed: int = 10): self.width = width self.height = height self.cell_size = cell_size #...
c914ff467f6028b7a7e9d6f7c3b710a1445d15e4
Safirah/Advent-of-Code-2020
/day-2/part2.py
975
4.125
4
#!/usr/bin/env python """part2.py: Finds the number of passwords in input.txt that don't follow the rules. Format: position_1-position_2 letter: password 1-3 a: abcde is valid: position 1 contains a and position 3 does not. 1-3 b: cdefg is invalid: neither position 1 nor position 3 contains b. 2-9 c: ccccccccc is inva...
c759ff104e8e5303ad3ef3350c4b28bad0b48e92
roniwahyu/thesis2018
/cobasastrawi/coba1.py
677
3.546875
4
import csv from Sastrawi.Stemmer.StemmerFactory import StemmerFactory # create stemmer factory = StemmerFactory() stemmer = factory.create_stemmer() # stemming process # sentence = 'Perekonomian Indonesia sedang dalam pertumbuhan yang membanggakan' # output = stemmer.stem(sentence) with open('teststem.csv') as cs...
17bca95271d269cf806decd0f1efafa05367146c
ycechungAI/yureka
/yureka/learn/data/bresenham.py
1,424
4.125
4
def get_line(start, end): """Modified Bresenham's Line Algorithm Generates a list of tuples from start and end >>> points1 = get_line((0, 0), (3, 4)) >>> points2 = get_line((3, 4), (0, 0)) >>> assert(set(points1) == set(points2)) >>> print points1 [(0, 0), (1, 1), (1, 2), (2, 3), (3, 4)] ...
bc0c773f74a99a8fd28322702f871acf823e52d1
chrisjowen/nLess
/lib/PEG_GrammarExplorer/PEG_GrammarExplorer/PegSamples/python_2_5_2/input/simple_pyprint.py
2,082
3.5625
4
#!/bin/env python # Paginate a text file, adding a header and footer import sys, time, string # If no arguments were given, print a helpful message if len(sys.argv)!=2: print 'Usage: pyprint filename' sys.exit(0) class PrinterFormatter: def __init__(self, filename, page_len=58): # Save the time of cr...
bc4f4c428035ddebb76d5663d092c9f2470f61fb
Chimilo/Kingsley
/My Assignment 1.0 (Kingsley).py
355
3.875
4
a = float(input('Enter the value of a\n: ')) b = float(input('Enter the value of b\n: ')) c = float(input('Enter the value of c\n: ')) # To take cofficient input from the users # a = float(input('Enter a: ')) # b = float(input('Enter b: ')) # c = float(input('Enter c: ')) # calculate the discriminant d = (...
f8e1fff1d3bd507e098d92704b22d15637823949
vasetousa/Python-basics
/Birthday party.py
224
3.5625
4
rent = int(input("Rent amount for the saloon: ")) cake = rent * 0.2 drinks = cake - cake * 0.45 animator = 1/3 * rent total = rent + cake + drinks + animator a = "Total amount for the BD party: " b = str(total) print(a + b)
62a127a8741f145a48c068f4eda98ef8e36e951a
vasetousa/Python-basics
/Aquarium.py
250
3.625
4
l = int(input("Length: ")) w = int(input("Width: ")) h = int(input("Height: ")) o = l * w * h / 1000 # dm3 v = float(input("Volume used space %: ")) # volume used by sand, pump, heater etc dm = o - (o * v / 100) str = "litles" print(dm)
372a4ee27449546bd3f5c1375391dc27481360c5
vasetousa/Python-basics
/C to F.py
237
3.734375
4
v = float(input("price 1 kg vegetables: ")) f = float(input("price 1 kg fruits: ")) va = float(input("kg vegetables: ")) fa = float(input("kg fruits: ")) price_v = (v * va) + (f * fa) pr_euro = price_v / 1.94 print(f"{pr_euro:.2f}")
f712fa962c06854c9706919f63b52e6a6a6002ab
vasetousa/Python-basics
/Animal type.py
263
4.21875
4
animal = input() # check and print what type animal is wit, also if it is a neither one (unknown) if animal == "crocodile" or animal == "tortoise" or animal == "snake": print("reptile") elif animal == "dog": print("mammal") else: print("unknown")
583ddc9c35b7f974c6233eaf7f196e91d837485c
Coder-010/leetcode-jan-2021
/src/Day20_ValidParentheses.py
404
3.734375
4
class Solution: def isValid(self, s: str) -> bool: if len(s) == 1: return False stack = [] brackets = {"}": "{", ")": "(", "]": "["} for b in s: if b in brackets: if len(stack) == 0 or stack.pop() != brackets[b]: return Fal...
21da3aefb75f03b93e852f0816de8e3b1fb762a9
Coder-010/leetcode-jan-2021
/src/Day1_CheckArrayFormationThroughConcatenation.py
1,926
4
4
from typing import List class Solution: # The goal is to form arr by concatenating the arrays in pieces in any order. However, you are not allowed to reorder the integers in each array pieces[i]. # Return true if it is possible to form the array arr from pieces. Otherwise, return false. def canFormArray(s...
f8558d3145d7120eb1a0f837b15695a4579de4af
priyadharsiniprabakaran/guvicode
/alpha.py
133
3.921875
4
a=input() if int(a)>=65 and int(a)<=90: print ("Alphabet") elif int(a)>=97 and int(a)<=122: print ("Alphabet") else: print ("No")
5a8dbda43a60541ddb1bf92846c7d5031522c2f1
TothZoltan2018/Giraffe
/ClassesAndObjects.py
704
3.578125
4
class Student: def __init__(self, name, major, gpa, is_on_probation): self.name = name self.major = major self.gpa = gpa self.is_on_probation = is_on_probation def on_honor_roll(self): if self.gpa >= 3.5: return True else: return False # from Classe...
619b251bfe8de979b17236f5b99c15385fdbc85d
TothZoltan2018/Giraffe
/Loops.py
942
3.828125
4
i = 1 while i <= 10: print(i) i += 1 print("Loop is done.") # Basic guessing game secret_word = "giraffe" guess = "" guess_count = 0 guess_limit = 3 out_of_guesses = False """ while guess != secret_word and not out_of_guesses: if guess_count < guess_limit: guess = input("Enter guess: ") gu...
10b55bec1497958c730c98d503d1c04083d358e8
1JohnDoe1/hello-world
/asd.py
587
3.59375
4
def elem(a): for i in range(12): print("Введите кол-во осадков в", i+1,"месяце(в мм)") x = int(input()) a.append(x) def sredn(a): sum = 0 for i in range(12): sum += a[i] sum = sum // 12 print("Среднее кол-во осадков(в мм) равно =",sum) def max(a): max ...
a982d7a630356889f66fba65e874efb37502a367
stux12/Python
/입출력.py
2,763
3.5
4
# 파이썬 함수의 구조 # def 함수명 (매개변수) : # <수행할 문장 1> # <수행할 문장 2> # return 리턴값 def sum(a,b) : result = a +b return result print(sum(1,2)) def say(): print("say") return 'Hi' print(say()) def sum_many(*args) :# 입력받은 인자들로 다받음, **kwargs key balue를 아무거나 입력받을수 있음 sum2 = 0 for i in args: ...
789866341f5e3a9fb75340b7c3997dc4abad714d
bwasmith/CS294StepSequencer
/view.py
3,581
3.609375
4
import pygame X_SIZE = 1200 Y_SIZE = 640 NUMBER_BEATS = 16 #mean to display the current state (from model) of the applicationw class View(): def __init__(self): self.model = None pass #abstract method which all View Subclasses will implement def display(self): self.model.screen.fill((0,100,0)) pygame.disp...
07c4c8285d658133ab1830407d72293838c85ccc
SamFerr/coding-dojo-projects
/python/fundamentals/math.py
835
3.734375
4
class MathDojo(object): def __init__(self, value): self.result = value def add(self, *args): for items in args: if type(items) == list or type(items) == tuple: for x in items: self.result += x else: self.result += items ...
0df004434b3c0d297d38136b61c6492b3c6ad3e2
SouBanerjee/Simple-Twitter-App
/crawler.py
2,038
3.53125
4
import tweepy import json #It may possible that the number of retrieve tweets is less than the number of tweet ids given to retrieve #this function will be used to extract tweets from twitter using tweet ids #here, api points to tweepy module def lookup_tweets(tweet_IDs, api): tweet_count = len(tweet_IDs) #counting...
dfe669425f4dbf74dd6a0db0a6fc0a912c7e9383
suhani-goel/test
/script1.py
340
3.53125
4
sl = [] temp = "val1" new = input().split(",") print(new) def fun(inp): # temp = "val2" print ("<<", temp) inp = "inp"+inp inp = inp.upper() return inp print (">>", temp) if new == "end" : print(sl) else : for i in new: t = fun(i) sl.append(t) # print (sl[0]) # sl[0].sort() # print (type(sl[0])) s...
6d3c929ffa5eb9b3085b07cf1b534dec7f0dc697
dawitys/Competitive-Programming
/week4/merge_sort.py
1,325
4.09375
4
def merge_sort(array, left_index, right_index): if left_index >= right_index: return middle = (left_index + right_index)//2 merge_sort(array, left_index, middle) merge_sort(array, middle + 1, right_index) merge(array, left_index, right_index, middle) def merge(array, left_index, right_...
5ae3fdf4e2f8ed5ebb2f2e2fe87bfe6f3587681e
congenialAnimal88/Simple-Banking-System
/LuhnAlgorithm.py
1,774
3.640625
4
import random class LuhnAlgorithm: def __init__(self): self.account_number = 0 self.card_bin = '400000' self.card_string = None self.card_list = [] def create_card_number(self): is_valid = False while is_valid ==False: self.card_string = self.genera...
6c90809be2fccd36c4f8d0da13b8f1a7836ca9c2
chenguanghuang/store
/day12/Calc.py
511
3.609375
4
class Calc: def add(self,a,b): return a + b def sub(self,a,b): return a - b def multi(self,a,b): return a*b def devi(self,a,b): return a//b #1、准备测试数据 # a = 6 # b = 5 # c = 11 # #2、调用被测程序 # c1 = Calc() # sum = c1.add(a,b) # #3、判断期望结果与实际结果是否一致 # if ...
05e63db77e088c4986fdbfaa1f8810fe2f54641d
veronica-f-reyes/python-exercises
/import_exercises.py
3,219
3.828125
4
#!/usr/bin/env python # coding: utf-8 # # Import Exercises from function_exercises import calculate_tip tip = calculate_tip(0.2, 100) print("Tip amount using imported function: $", tip) # In[30]: from function_exercises import get_letter_grade as grade # In[31]: grade(98) # ### How many different ways ca...
81e59147bf9304406776dc59378b66c5aaa5eaea
ProgramNoona/cti110
/M6T2_FeetToInches_Reaganb.py
324
4.21875
4
# Program that converts feet to inches # November 2, 2017 # CTI-110 M6T2_FeetToInches # Bethany Reagan INCHES_PER_FOOT = 12 def main(): feet = int(input("Enter a number of feet: ")) print(feet, "feet equals", feetToInches(feet), "inches.") def feetToInches(feet): return feet * INCHES_PER_FOOT...
5924743b3bf00710984f19c2f8ee9b4aac62f480
KevinKillman/Homework-5
/Instructions/Pymaceuticals/.ipynb_checkpoints/outlier_function-checkpoint.py
720
3.65625
4
def outlier(series): import pandas as pd index_counter = 0 describe_series = series.describe() q1 = describe_series['25%'] q3 = describe_series['75%'] iqr = q3-q1 lower_bound = q1 - (1.5 * iqr) upper_bound = q3 + (1.5 * iqr) outliers = [] for (value) in series: v...
53b15d2b84680eaaf9eafe1737e2f614cf67fde5
YogeshSingh1111/python_practice_1
/3_Math_Strings.py
992
4.09375
4
''' while True: try: number = int(input("Please enter number between 1 and 10 : ")) break except ValueError: print("You didn't enter a number") except: print("An unknown error occured") if (number >= 1) and (number <=10): print ("Your number is {}".format(number)) el...
388466664c11bcb0a14de7bf86f21696d90ecf66
bravo1989tango/SmartNinja-hazi-8
/számológép.py
795
3.9375
4
plusz = "+" minusz = "-" osztas = "/" szorzas = "*" while True: try: num1 = int(input("Kérem az első számot: ")) num2 = int(input("Kérem a második számot: ")) except ValueError: print("Számokat kérek!") continue muvelet = input("Kérem a műveletet: ") if muve...
7a12f9bb86a4cd0be915e678652bbbfa8f8fb38d
PrajaktaJadhav2/Implict-Explict-Data-Type-Conversions
/Implicit_Explicit_Data_Types.py
584
4
4
# Implict Type conversions integer = 2 decimal = 5.0 x = decimal + integer print("Type after adding both values :") print(type(x)) #Explict type conversion a = 2.5 b = "0101" c= "0101" print("After converting a to int with base 10 --> ", int(a)) print("After converting b to int with base 2 --> ", int(b, 2)) a = '...
6238f3aa51cd9c5981960a63d567046704aac75c
mazh661/distonslessons
/HomeWork10/main.py
948
3.796875
4
import csv import json def save_csv_to_json(csv_file,json_file): arr=[] #read from csv and convert to [{},{},{}] with open(csv_file) as csvFile: csvReader = csv.DictReader(csvFile) for i in csvReader: arr.append(i) #transform from str to int for i in range(len(arr)): ...
b73dbfe02571c5b588b18d7eb7f6056a648ab9d6
mazh661/distonslessons
/HomeWork11/main.py
1,297
3.59375
4
import csv import json def save_csv_to_json(csv_file,json_file): arr=[] #read from csv and convert to [{},{},{}] with open(csv_file) as csvFile: csvReader = csv.DictReader(csvFile) for i in csvReader: arr.append(i) #transform from str to int for i in range(len(arr)): ...
045496063fccc45e02546a3e338493dff41ce705
mazh661/distonslessons
/Lesson9/2.py
190
3.59375
4
# d1 = dict(name="Yerassyl",age=120) # d2 = dict(name="kritio",age=12) # d3 = dict(name="asdasdd",age=132) # arr = [d1,d2,d3] # print(arr) d = { i:i*2 for i in range(10) } print(d[9])
86e5f6eea9a48189779f1c555196c9d63d8f900c
mazh661/distonslessons
/Lesson4/ex4.py
249
3.859375
4
arr=["Hello","1231321","!!@#@!","1231"] numbers=[] words=[] n = len(arr) for i in range(n): try: n = int(arr[i]) numbers.append(arr[i]) except: words.append(arr[i]) print("Numbers ", numbers) print("Words", words)
e8ed954694d3c525c9e611b1164ffa793f637cba
mazh661/distonslessons
/Lesson3/seven.py
94
3.765625
4
word = "Yerassyl" count=0 for i in word: if i == "s": count = count+1 print(count)
87bc95e0791e0b49cdab629f3af350b75d9b97a5
mazh661/distonslessons
/Lesson10/main.py
422
3.96875
4
def limit(start,end,step): for i in range(start,end,step): print(i) def print_arr(array): print("Элементы массива:") for i in array: print(i) print("Максимальный элемент") getMax(array) def getMax(array): maxi=array[0] for i in array: if maxi<i: maxi = i...
a073f14cdfb5fc8b9fe9ba8bb8293f95efc7a1f4
raymondzeng/practice
/codejam/351101/A-store-credit.py
920
3.5
4
import sys def solve(credit, prices): """ Since there is only one solution, iterate through list and check that element with every other elem in the list after that elem until you get the right sum. j is always guaranteed to be >= i Runtime = n^2 """ for i, price in enumerate(prices): ...
2e311a929cb6a31fd2d33480c7be4986e7dedfde
raymondzeng/practice
/leetcode/done/string_to_integer_atoi.py
652
3.59375
4
def atoi(str): digits = list(str.strip()) print digits if len(digits) == 0: return 0 negate = False if digits[0] == '-': print "negate" negate = True digits = digits[1:] el...
7ef48a991ad95c33f11e34dfa1c4ce6618e8966d
caozxin1230/Python-Sample
/person_inheritance.py
1,328
3.640625
4
class Person: def __init__(self, name, surname, number): self.name = name self.surname = surname self.number = number class Student(Person): UNDERGRADUATE, POSTGRADUATE = range(2) def __init__(self, student_type, *args, **kwargs): self.student_type = student_typ...
82c2bcd22ef9828fe168ba266275952112772639
vvkhandekar110988/python_basics_helloworld
/string_method.py
227
4.09375
4
course = 'Python for beginners' print(course.find('o')) print(course.replace('Beginners','Absolute Beginners')) print('Python' in course) ''' print (len(course)) print(course.upper()) print(course.lower()) print(course) '''
aa755b193f2dc5738e3cc7f34edf42082fad13c5
vvkhandekar110988/python_basics_helloworld
/test1.py
181
3.5
4
sports = ['cricket', 'football', 'volleyball', 'baseball', 'softball', 'track and field', 'curling', 'ping pong', 'hockey'] a = sports.len() print(a) last = sports[6:] print(last)
430086436d6fd7866b737b33c118acbc5930b8c4
vvkhandekar110988/python_basics_helloworld
/string.py
248
3.96875
4
course = '''Python's course for "beginners"''' print(course[-2]) print(course[0]) print(course[4]) print(course[0:4]) print(course[0:]) print(course[1:4]) print(course[:4]) another = course[2:10] print (another) name = 'Jennifer' print(name[1:-1])
bc25ffa52620a3fd26e1b687452a60cb18dbf75e
Paulokens/CTI110
/P2HW2_MealTip_PaulPierre.py
968
4.375
4
# Meal and Tip calculator # 06/23/2019 # CTI-110 P2HW2 - Meal Tip calculator # Pierre Paul # # Get the charge for the food. food_charge = float(input('Enter the charge for the food: ')) # Create three variables for the tip amounts. tip_amount1 = food_charge * 0.15 tip_amount2 = food_charge * 0.18 tip_amou...
31733dbcbbc0828ec2179c3c258f2d4410e55645
dantepli/crypto_ex2
/breakcloud.py
602
3.71875
4
from cloud import * def breakcloud(cloud): """ receives 'cloud', an object of type Cloud. creates a file with the name 'plain.txt' that stores the current text that is encrypted in the cloud. you can use only the Read/Write interfaces of Cloud (do not use its internal variables.) """ with open...
08bdce0f2d75b36746c86c2ea252adaa3a19741b
michaelzh17/6001_Python
/6001_Python-michael_zhang/isIn.py
521
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 31 20:59:46 2017 @author: xinyezhang """ def isIn(char, aStr): ''' char: a single character aStr: an alphabetized string returns: True if char is in aStr; False otherwise ''' l = len(aStr) if l == 0: return ...
a9b86b8942935716681ce67a46737fab3513b1f4
michaelzh17/6001_Python
/6001_Python-michael_zhang/pset1-01.py
303
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 16 10:26:37 2017 @author: xinyezhang """ s = 'massaachuseets' count = 0 for letter in s: if letter == 'a' or letter == 'e' or letter == 'i' or letter == 'o' or letter == 'u': count += 1 print("Number of vowels:", count)
a1de48a0569407301769af6688ace732cfce8112
michaelzh17/6001_Python
/sumDigit.py
366
4.0625
4
#!/usr/bin/env python3 def sumDigits(s): """Assumes s is a string Returns the sum of the decimal digits in s For example, if s is 'a2b3c' it returns 5""" sum_digit = 0 for e in s: try: sum_digit += int(e) except ValueError: continue return sum_di...
c23f54956b3359f8aaec5d25a90bbcc41d0180c7
michaelzh17/6001_Python
/6001_Python-michael_zhang/how_many.py
495
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Feb 7 22:56:43 2017 @author: xinyezhang """ def how_many(aDict): lst = aDict.values() sum_num = 0 for i in lst: sum_num += len(i) return sum_num def biggest(aDict): lst = list(aDict.values()) lst_key = list(aDict...