blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
18f396d6cab808f43723e80981b90fef011898bd
jaiswalIT02/pythonprograms
/Chapter-3 Loop/series.py
125
3.703125
4
x1=range(1,11) print (x1) for item in x1: if item % 2==0: print(item) else: print(-item)
6de8cc6eff5d84304b883dd0990c56aa761ebfd3
lavindiuss/OnicaAssignment
/orm.py
3,280
3.984375
4
import sqlite3 as sq # this function create a database with all required tables and pass if its already exist """ database for : database connection database_cursor for : the cursor that controls the structure that enables traversal over the records in the database """ database = sq.connect("Books.db") database_curs...
1dfb56c8d3698deca428411bc6c5774a739d5241
beccadsouza/System-Programming-and-Compiler-Construction
/ICG/infix.py
1,441
3.703125
4
infix = input("Enter infix expression : ").replace(' ','') result = input("Enter resultant variable : ") temp,string,operators = {},[],['+','-','*','/'] count,cp = 1,0 for i in range(len(infix)): if infix[i] in operators: string.append(infix[cp:i]) string.append(infix[i]) cp = i+1 string.a...
d135bef0e2867c43ac4b429033e6f06d6c43d2a8
mvondracek/VUT-FIT-POVa-2018-Pedestrian-Tracking
/camera.py
1,426
3.546875
4
""" Pedestrian Tracking 2018 POVa - Computer Vision FIT - Faculty of Information Technology BUT - Brno University of Technology """ from typing import Tuple import numpy as np class Camera: def __init__(self, name: str, focal_length: float, position: Tuple[int, int, int], orientation: Tuple[int,...
013ecfc959125154250731c0d5df74f2a7849548
ianmunoznunezudg/Particula
/mainclass.py
451
3.546875
4
from particula import Particula class MainClass: def __init__(self): self.__particulas = [] def agregar_inicio(self, particula: Particula): self.__particulas.insert(0, particula) def agregar_final(self, particula: Particula): self.__particulas.append(particula) def imprimir(self...
386696a7e854e5ca447e3032dacea9e7686d0485
rbuhler/codigobasico
/Codigo_Python/e_par.py
224
3.578125
4
def e_par(valor): resultado = True resto = valor % 2 if resto > 0: resultado = False else: resultado = True return resultado if e_par( 3 ): print("E par") else: print("E Impar")
c37d12eab7ccf6dd8caa974bc22e47f98ec5cc36
shaman2527/Practicando-DNI
/js/python3/practica.py
358
3.96875
4
# n = int (input ("Enter an integer:")) # sum = n * (n + 1) / 2 # print ("The sum of the first interger from 1 to" + str (n) + " is" + str (sum) ) # print(type(sum)) #Modulo Horas de Trabajos y Paga hours = float (input("Horas de Trabajo:")) cost = float (input("Introduce lo que cobras por hora:")) pay = hou...
436e5365c686922f6cc775cb441d6cb014a6103c
naveen882/mysample-programs
/last_day_quarter.py
473
3.59375
4
import datetime as dt import calendar month_quarter = [3,6,9,12] user_date = dt.datetime.strptime('2017-12-31', "%Y-%m-%d").date() if user_date.month in month_quarter: last_day = calendar.monthrange(user_date.year,user_date.month)[1] actual_date = dt.date(user_date.year,user_date.month, last_day) if user_...
335f5f0a83fb2c433d706e2b4640d408752508cf
naveen882/mysample-programs
/#longest_substring_in_a_given_string.py
379
3.71875
4
#longest substring in a given string def longSubstring(s): charSet = [] l=0 li = [] ss = '' for r in range(len(s)): if s[r] not in ss: ss+= s[r] else: li.append(ss) ss = '' return li ret = longSub...
1deb78c1b1af35d46bf3fef07643a25ba7a1c5f1
naveen882/mysample-programs
/classandstaticmethod.py
2,569
4.75
5
""" Suppose we have a class called Math then nobody will want to create object of class Math and then invoke methods like ceil and floor and fabs on it.( >> Math.floor(3.14)) So we make them static. One would use @classmethod when he/she would want to change the behaviour of the method based on which subclass is call...
9bee868b22f8f2077bdcc3e13e3edb333e0a6ab4
CHemaxi/python
/001-python-core-language/005_tuples.py
3,322
3.859375
4
## >--- ## >YamlDesc: CONTENT-ARTICLE ## >Title: python tuples ## >MetaDescription: python tuples creating tuple, retrive elements, Operators example code, tutorials ## >MetaKeywords: python tuples creating tuple, retrive elements, Operators example code, tutorials tuple Methods,find,index example code, tutorials ## >A...
fc8bde15b9c00120cb4d5b19920a58e288100686
CHemaxi/python
/003-python-modules/008-python-regexp.py
2,984
4.34375
4
""" MARKDOWN --- Title: python iterators and generators MetaDescription: python regular, expressions, code, tutorials Author: Hemaxi ContentName: python-regular-expressions --- MARKDOWN """ """ MARKDOWN # PYTHON REGULAR EXPRESSIONS BASICS * Regular Expressions are string patterns to search in other strings * PYTHON Re...
5b4b6d7602f2161ba8c400a6452067a729029f08
CHemaxi/python
/001-python-core-language/003_strings.py
7,001
3.859375
4
## >--- ## >YamlDesc: CONTENT-ARTICLE ## >Title: python strings ## >MetaDescription: python string, Strings as arrays,Slicing Strings,String Methods,find,index example code, tutorials ## >MetaKeywords: python string, Strings as arrays,Slicing Strings,String Methods,find,index example code, tutorials ## >Author: Hemaxi ...
85b893d3d8e664dd898e615e77adbcafc7a46938
CHemaxi/python
/003-python-modules/016-python-json-files.py
1,701
3.8125
4
""" MARKDOWN --- Title: Python JSON Tags: Python JSON, Read Json, write Json, Nested json Author: Hemaxi | www.github.com/learnpython ContentName: python-json --- MARKDOWN """ """ MARKDOWN # Python JSON Module * JSON is a data format widely used in REST web services, It stands for javascript Object Notation. * Here...
e6516fb6c875b55303f5098988eb876d1749c739
lucifersasi/pythondemo
/TELUSKO/selectionsort(min).py
345
3.90625
4
def sort(nums): for i in range(5): minpos=i for j in range(i,6): if nums[j]<nums[minpos]: minpos=j temp=nums[i] nums[i]=nums[minpos] nums[minpos]=temp print(nums) #to see the sorting process step by step nums=[5,3,8,6,7,2] sort(nums) pri...
6c82a4dd7590e0faac8b65e9011f621e44a01486
lucifersasi/pythondemo
/AndreiNeagoi/testing/game_test/guess_game_test.py
649
3.578125
4
import unittest from unittest import result import guess_game class TestMain(unittest.TestCase): def test_guess_val(self): answer = 1 guess = 1 result = guess_game.guess_run(guess, answer) self.assertTrue(result) def test_guess_wrongguess(self): result = guess_game....
2ab350c02e54f7a4677eaa5b9b20b82a0fb1ec41
garciazapiain/euler
/euler 5.py
297
3.703125
4
i=1 counter=1 x=300000000 divisible=0 while (counter<x): while (i<21): if counter%i==0: divisible=divisible+0 else: divisible=1 break i=i+1 if divisible==0: print ("Number divisible by",counter) counter=counter+1 divisible=0 i=1
b530137226c3edb0245d2ccb10564baa0f4a78fa
peterbekins/MIT_OCW_6.00SC-Introduction-to-Computer-Science-and-Programming
/PS11/shortest_path.py
11,174
4
4
# PS 11: Graph optimization, Finding shortest paths through MIT buildings # # Name: Peter Bekins # Date: 5/12/20 # import string from graph import * # # Problem 2: Building up the Campus Map # # Write a couple of sentences describing how you will model the # problem as a graph) # def load_map(mapFilename): """ ...
128d708db97a5073cd55a968fd83a78c7149d89f
denisdenisenko/Python_proj_1
/Project_1/Q1.py
668
3.6875
4
import re def number_of_messages_in_inbox(given_file): """ Counting the number of messages in the inbox :param given_file: .txt :return: void """ file_to_handle = None try: file_to_handle = open(given_file) except: print('File cannot be opened:', given_file) exi...
91f1b436f1ef43d14ace8e53cabec0ab202c1b45
hussein343455/Code-wars
/kyu 6/Split Strings.py
612
4.09375
4
# Complete the solution so that it splits the string into pairs of two characters. # If the string contains an odd number of characters then it should replace # the missing second character of the final pair with an underscore ('_'). # Examples: # solution('abc') # should return ['ab', 'c_'] # solution('abcdef...
1ea08b041a6b98de6c0a5c55e9ffb411bdd6d3bc
hussein343455/Code-wars
/kyu 5/Best travel.py
2,218
4.03125
4
# John and Mary want to travel between a few towns A, B, C ... Mary has on a sheet of paper a list of distances between these towns. ls = [50, 55, 57, 58, 60]. John is tired of driving and he says to Mary that he doesn't want to drive more than t = 174 miles and he will visit only 3 towns. # # Which distances, hence ...
bcd7c3ee14dd3af063a6fea74089b02bade44a1c
hussein343455/Code-wars
/kyu 6/Uncollapse Digits.py
729
4.125
4
# ask # You will be given a string of English digits "stuck" together, like this: # "zeronineoneoneeighttwoseventhreesixfourtwofive" # Your task is to split the string into separate digits: # "zero nine one one eight two seven three six four two five" # Examples # "three" --> "three" # "eightsix" ...
e73d1193b1cb911c3681103d0ce3db4f44340176
hussein343455/Code-wars
/kyu 4/Roman Numerals Helper.py
2,229
3.796875
4
# Create a RomanNumerals class that can convert a roman numeral to and # from an integer value. It should follow the API demonstrated in the examples below. # Multiple roman numeral values will be tested for each helper method. # # Modern Roman numerals are written by expressing each digit separately # starting wi...
d9684a8c4fcdc5d846fb8e83ba8a9d9adf6c79e9
hussein343455/Code-wars
/kyu 7/Holiday III - Fire on the boat.py
373
3.5
4
# njoying your holiday, you head out on a scuba diving trip! # Disaster!! The boat has caught fire!! # You will be provided a string that lists many boat related items. If any of these items are "Fire" you must spring into action. Change any instance of "Fire" into "~~". Then return the string. # Go to work! ...
7d688699d912214c003e718f918a530d2acb637b
hussein343455/Code-wars
/kyu 7/Simple letter removal.py
913
3.828125
4
# In this Kata, you will be given a lower case string and your task will be to remove k characters from that string using the following rule: # # - first remove all letter 'a', followed by letter 'b', then 'c', etc... # - remove the leftmost character first. # For example: # solve('abracadabra', 1) = 'bracadabra' ...
fc6a2e2351529daf107a2996b8fc8052fe4a4384
colson1111/Other-Python-Code
/Random-Code/bubble_sort.py
446
3.640625
4
import numpy as np import time lst = np.random.randint(low = 1, high = 100, size = 10000).tolist() lst1 = lst # bubble sort def bubble_sort(lst): for i in range(len(lst)-1,0,-1): for j in range(i): if lst[j] > lst[j + 1]: c = lst[j] lst[j] = lst[j + 1] ...
967970e8265ab10e4677188c1a5fb54a3007faf2
pchegancas/slabwork
/MySlabs.py
875
3.578125
4
""" Classes for slab reinforcement calculations """ class Slab(): """ Model of a slab """ def __init__ (self, name: str, thk: float, concrete: float): self.name = name self.thk = thk self.concrete = concrete def __repr__ (self): print(f'Slab({self.name}, {self.thk}, {self.concrete})') class Band(): ""...
ab31c3e1a33bbe9ec2eb8ef5235b2206c022a8d7
kritikhullar/Python_Training
/day1/factorial.py
288
4.25
4
#Fibonacci print("-----FIBONACCI-----") a= int(input("Enter no of terms : ")) def fibonacci (num): if num<=1: return num else: return (fibonacci(num-1)+fibonacci(num-2)) if a<=0: print("Enter positive") else: for i in range(a): print (fibonacci(i), end = "\t")
097662ada6fcf8db91c68ee4d6e44a883ec3662e
kritikhullar/Python_Training
/day1/fibonacci.py
364
4.0625
4
#Factorial print("-----FACTORIAL-----") a= int(input("Enter range lower limit : ")) b= int(input("Enter range upper limit : ")) fact=1 def factorial (number): if number==0: return 1 if number==1: return number if number!=0: return number*factorial(number-1) for i in range(a,b+1,1): pri...
77ceb0bc9596aa7d367d99a57e0ccb1552bdbfc6
kngavl/my-first-blog
/python_intro.py
274
4.0625
4
#this is a comment print("Hello, Django girls") if -2>2: print("Eat dirt") elif 2>1: print("hooman") else: print("y9o") def hi(name): print("hello " + name) print("hi") hi("frank") girls = ["shelly", "anja", "terry"] for name in girls: print(name)
a32357b7aabf7fd28844f10ed46e4c2517e94006
ningmengmumuzhi/ningmengzhi
/练习/1.py
113
3.8125
4
num=123.456 print(num) num='hello' print('who do you think i am') you=input() print('oh yes! i am a' )(you)
77cbc21b55152a47401ca785f411064581fa6225
ladsmund/msp_group_project
/koshka/scales/pythag_modes.py
1,384
3.515625
4
#!/usr/bin/python from pythag_series import PythagSeries class PythagMode: def __init__(self, mode, frequency): self.name = mode.lower() self.freq = frequency # An empty string does not transform to a different mode if self.name == "": self.tonic = 1 self...
64e73cb395d25b53a166a6e491e70a7834c96aee
sajjadm624/Bongo_Python_Code_Test_Solutions
/Bongo_Python_Code_Test_Q_3.py
2,330
4.1875
4
# Data structure to store a Binary Tree node class Node: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right # Function to check if given node is present in binary tree or not def isNodePresent(root, node): # base case 1 ...
5c0555e29053979c65911d74f52aa7c39af15d37
bucho666/pyrl
/test/testdice.py
643
3.59375
4
import unittest from dice import Dice class TestDice(unittest.TestCase): def testRoll(self): self.rollTest(Dice('2d6'), 2, 12) self.rollTest(Dice('2d6+2'), 4, 14) self.rollTest(Dice('2d6-3'), -1, 9) def testString(self): self.stringTest('2d6') self.stringTest('2d6+2') self.stringTest('2d6-...
85749fe8ab6730a4505eaf14e2c5cbca7d92e655
CIick/Week9
/print(“Cost Calculation Program for Fibe.py
373
3.78125
4
import os costPerFoot = .87 print(" Cost Calculation Program for Fiber Optics") compName= input("Please enter the company name: ") feet = input("Please enter the feet of fiber optics to install: ") Val = (costPerFoot * int (feet)) print( "Cost calucation for the company", compName, "Fiber Optics per foot at", f...
222798a5d6081bd5ef04addcc5e31e550c3f38f2
Jacob1225/cs50
/pset7/houses/import.py
1,175
3.9375
4
from sys import argv, exit import csv import cs50 # Verify user has passed in proper number of args if len(argv) != 2: print("Must provide one and only one file") exit(1) # Open file for SQLite db = cs50.SQL("sqlite:///students.db") # Open file and read it if argument check was passed with open(argv[1], "r")...
92156b23818ebacfa3138e3e451e0ed11c0dd343
brianspiering/project-euler
/python/problem_025.py
1,139
4.375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Solution to "1000-digit Fibonacci number", Problem 25 http://projecteuler.net/problem=25 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6...
2ce7fc6a3a166efdbb4f87ddb75c827d9c805dd7
brianspiering/project-euler
/python/problem_003.py
863
3.875
4
#!/usr/bin/env python """ Solution to "Largest prime factor", aka Problem 3 http://projecteuler.net/problem=3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? """ n = 600851475143 # 13195 | 600851475143 def find_factors(n): "My attempt" return ...
5448d28db97a609cafd01e68c875affe1f97723c
brianspiering/project-euler
/python/problem_004.py
992
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Solution to "Largest palindrome product", aka Problem 4 http://projecteuler.net/problem=4 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the...
bd009da4e937a9cfc1c5f2e7940ca056c1969ae5
brianspiering/project-euler
/python/problem_024.py
1,489
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Solution to "Lexicographic permutations", Problem 24 http://projecteuler.net/problem=24 A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or...
5e2ae02f6553cbe7c31995ba76abf564c596d346
serenechen/Py103
/ex6.py
767
4.28125
4
# Assign a string to x x = "There are %d types of people." % 10 # Assign a string to binary binary = "binary" # Assign a string to do_not do_not = "don't" # Assign a string to y y = "Those who knows %s and those who %s." % (binary, do_not) # Print x print x # Print y print y # Print a string + value of x print "I sai...
3a3717209ab762e0a98678a58553014a16e0ec3b
Allen-Maharjan/Assignment-II-Control-Statement
/No_10.py
741
4.03125
4
#changing camelcase to snake case and kebab case1 def transformer(sample,seperator): final_answer = '' if seperator == 1: for i in sample: if i.isupper() == True: final_answer += "_" final_answer += i.lower() print(f'Snakecase = {final_answer[1::]}') ...
bf98158d76a44a21dee04e7de1f54047b8b35184
Allen-Maharjan/Assignment-II-Control-Statement
/No_18.py
284
3.59375
4
import json class Person(): def __init__(self, name, age): self.name = name self.age = age person_string = '{"name": "Allen", "age": 21}' person_dict = json.loads(person_string) print(person_dict) person_object = Person(**person_dict) print(person_object.name)
690bffde0d59c3593879d1b7ea1bef2cd2c37301
Naminenisravani/guvi
/positive.py
133
4.15625
4
x=int(input('INPUT')) if x>0: print("x is positive") elif (x==0): print("x is equal to zero") else: print("x is neative")
23f9d9fc5134daddae2aa9bc7c15853370b464ae
EddyScript/Git-With-Eddy
/Calculator.py
1,092
4.28125
4
# Assignment 1--------------------------------------------- def calculator(): first_number = int(input("Enter a number: ")) operator = input("Enter an operator: ") ops = ["+","-","*","/"] if operator in ops: second_number = int(input("Enter another number: ")) else: print("Sorry," + ...
87b1700a53f458dc06fd245bcb4d041f45d1d969
BronyPhysicist/BaseballSim
/player_pkg/bats_and_throws.py
803
3.59375
4
''' Created on Apr 03, 2017 @author: Brendan Hassler ''' from enum import Enum from random import random class Bats(Enum): LEFT = "Left" RIGHT = "Right" SWITCH = "Switch" def __str__(self): return str(self.value) class Throws(Enum): LEFT = "Left" RIGHT ...
6d70d520f69c0a7e7109a14410f7eaca60e52e36
nhantrithong/Sandbox
/prac3 - scratch exer 2.py
482
4
4
def main(): score = get_score() while score < 0 or score > 100: print("Invalid score, please re-enter an appropriate value") score = float(input("Enter your score: ")) if score < 50: print("This is a bad score") elif score > 50 and score < 90: print("This is a passable sc...
bd91b70078d5e7ea12a584d83f9a16071806ed04
AaronShabanian/PythonPrograms
/friends.py
1,248
3.953125
4
file=open("people.txt",'r') while True: dict={} finalList=[] for line in file: line=line.rstrip("\n") list=line.split(",") name=list[0] del list[0] values=list values=set(values) dict.update({name:values}) for key in dict: prin...
eb1491b0d3efc61f2462d17e314244fe5c95a352
charliechoong/sudoku_solver
/CS3243_P2_Sudoku_25.py
10,478
3.546875
4
import sys import copy import time from Queue import PriorityQueue # Running script: given code can be run with the command: # python file.py, ./path/to/init_state.txt ./output/output.txt class Sudoku(object): def __init__(self, puzzle): self.puzzle = puzzle # all empty squares in input p...
6dee0f8aff74d29aed5f6384ad958dae27ba3a52
ALaDyn/Smilei
/validation/easi/__init__.py
29,631
3.609375
4
class Display(object): """ Class that contains printing functions with adapted style """ def __init__(self): self.terminal_mode_ = True # terminal properties for custom display try: from os import get_terminal_size self.term_size_ = get_t...
272f71dcc72f166a4bf938c7d24c2fcfc156fef3
amshapriyaramadass/learnings
/Hackerrank/numpy/array.py
250
3.609375
4
import numpy as np def arrays(arr): # complete this function # use numpy.array a = np.array(arr,dtype='f') return(a[::-1]) if __name__ =="__main__": arr = input().strip().split(' ') result = arrays(arr) print(result)
14c8a6e8dbdb673d146e92f1d3812523ce1b556f
amshapriyaramadass/learnings
/Python/Exercise Files/Ch2/classes_start.py
565
3.96875
4
# # Example file for working with classes # class myWheels(): def wheel1(self): print("wheel is alloy") def wheel2(self,SomeString): print("this is steel rim" + SomeString) class myCar(myWheels): def wheel1(self): myWheels.wheel1(self) print("this is car wheel dia 30inch") def wheel2(self,so...
dc66d84ad39fb2fe87895ca376652e9d95781326
amshapriyaramadass/learnings
/Hackerrank/Interviewkit/counting_valley.py
789
4.25
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'countingValleys' function below. # # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. INTEGER steps # 2. STRING path #Sample Input # #8 #UDDDUDUU #Sample Output #1 # def cou...
b003a3afa4758e8696090f05bdba608f5ea5f10b
mazalkov/Python-Principles-Solutions
/Online status.py
278
3.625
4
# https://pythonprinciples.com/challenges/Online-status/ def online_count(dictionary): number_online = 0 for i, (key, value) in enumerate(dictionary.items()): if value == 'online': number_online += 1 return number_online
d8fa7c098496d84e58e0a49577c7c866f1f60f2c
flyfish1029/pythontest
/studytext/while_mj.py
235
4
4
#-*- coding: UTF-8 -*- numbers = [12,37,5,42,8,3] event = [] odd = [] while len(numbers)>0: number = numbers.pop() if(number % 2 == 0): event.append(number) else: odd.append(number) print(event) print(odd)
de5d15d0b7c4c9c8e4113c2abaf3463af7a368af
andremourato/travian_bot
/utils.py
256
3.59375
4
from datetime import datetime, timedelta def add_seconds_to_datetime_now(seconds): """Add seconds to current timestamp and return it.""" future_date = datetime.now() + timedelta(seconds=seconds) return future_date.strftime('%H:%M %d-%m-%Y')
b51bed97a9cb40110ca0d7a897f4e2d27b1e1d5e
bobosod/From_0_learnPython
/chapter4_2.py
226
3.921875
4
list = ["apple", "banana", "grape", "orange", "grape"] print(list) print(list[2]) list.append("watermelon") list.insert(1,"grapefruit") print(list) list.remove("grape") print(list) print(range(len(list))) help(list)
e634301ac092a01c6cfc61fcd9215d66f65d4deb
tutorials-4newbies/testing101
/test_phone_validator.py
1,088
3.5625
4
import unittest from lib import CellPhoneValidator # This is the spec! class PhoneValidatorTestCase(unittest.TestCase): def test_phone_validator_regular_number(self): value = "0546734469" expected_true_result = CellPhoneValidator(value).is_valid() self.assertTrue(expected_true_result) ...
543832a8bac0de76fc71f18de41e352d2893860f
basseld21-meet/meet2019y1lab3
/debugging.py
965
3.5
4
Python 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux Type "help", "copyright", "credits" or "license()" for more information. >>> ##In order complete this challenge you need to debug the following code. ##It may be easier to do so if you improve the code qu...
f834c6ebc4442b3e4c945003704b4ec15f353289
lin-compchem/qmmm_neuralnets
/qmmm_neuralnets/input/filter.py
3,268
3.53125
4
""" This file contains methods for selecting feature from input vectors """ import numpy as np def do_pca(bfs, n_components): """ This is the code from my PCA experiment. Should do again and report results in the manual Params ------ bfs: list of ndarrays The basis function arrays ...
795d5db9f77b07f2680468da5694dfd8c37bf234
klinok9/learning_python
/Глава4.py
1,361
3.53125
4
# char = ['w', 'a', 's', 'i', 't', 'a', 'r'] # out = '' # length = len(char) # i = 0 # while (i< length): # out = out +char[i] # i= i+1 # length = length * -1 # i=-2 # while (i >= length): # out = out + char[i] # i = i-1 # print(out) # smothies = [1,2,3,4,5] # length = len(smothies) # for i in range(len...
ee3ec39130ee54a0cfa72eb81d158a027840f222
anuriq/parallels-fibonacci
/src/fibonacci.py
182
4.1875
4
def fibonacci_number(n): n = int(n) if n == 1 or n == 2: return 1 else: result = fibonacci_number(n - 1) + fibonacci_number(n - 2) return result
35775689bab1469a42bae842e38963842bf54016
scottherold/python_refresher_8
/ExceptionHandling/examples.py
731
4.21875
4
# practice with exceptions # user input for testing num = int(input("Please enter a number ")) # example of recursion error def factorial(n): # n! can also be defined as n * (n-1)! """ Calculates n! recursively """ if n <= 1: return 1 else: return n * factorial(n-1) # try/except (if ...
293770c85b55ca8be91305a5d6a005962dddee4a
CelvinBraun/human_life_py
/life_turtle.py
1,217
3.6875
4
from turtle import Turtle START_X_CORR = -450 START_Y_CORR = 220 STEPS = 8 SIZE = 0.3 class Life: def __init__(self, age, years): self.start_x = START_X_CORR self.start_y = START_Y_CORR self.steps = STEPS self.size = SIZE self.weeks = round(years * 52.1786) self.ag...
a4721adc85bf2e62d8cd37cf97f1dc2ef9e4ffff
inaju/thoughtsapi
/test_api.py
2,010
3.578125
4
import requests class TestApi: def __init__(self): self.user_url = "http://127.0.0.1:8000/auth/" self.user_profile_url = "http://127.0.0.1:8000/auth/users/" self.user_profile_data = "http://127.0.0.1:8000/api/accounts/" self.user_data = { 'username': 'ibrahim', ...
5548acf94dcf476343655ef2947fb9b6d5e5968c
Philippe-Boddaert/Philippe-Boddaert.github.io
/premiere/bloc1/chapitre-06/corrige.py
6,984
3.8125
4
#!/usr/bin/env python3 # Author : Philippe BODDAERT # Date : 19/12/2020 # License : CC-BY-NC-SA from enquete import Enquete def est_anagramme(mot1, mot2): ''' Indique si 2 mots sont anagrammes l'un de l'autre ;param mot1: (str) un mot :param mot2: (str) un mot ;return: (bool) True si les 2 mots so...
5d11169ca662b27c93169fe9c48338b339ed9f33
Allykazam/algorithms_tools
/list_manip.py
678
4.03125
4
def oddNumbers(l, r): # Write your code here odd_arr = [] for num in range(l, r + 1): if num % 2 != 0: #even numbers would be == instead of != odd_arr.append(num) return odd_arr print(oddNumbers(0, 12)) def rotLeft(a, d): for _ in range (d): front_val = a.pop(0) ...
7106bb0336835310ea40ecaf3cd4a29f1f231269
HemlockBane/simple-banking-system
/card_db.py
3,360
3.5
4
import sqlite3 as sq3 class Db: def __init__(self): self.table_name = "card" self.db_name = "card.s3db" self.connection = self.init_db() def init_db(self): create_table_query = f'''create table if not exists {self.table_name} ( id INTEGER PRIMARY K...
52c84ab4101801d394c4c8ee1dc3621e54b8285c
Reyes2777/100_days_code
/python_class/exercise_1.py
515
4.15625
4
#Write a Python program to convert an integer to a roman numeral. class Numbers: def int_to_roman(self, number_i): value = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] roman_numbers = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"] roman_num = [] f...
13578b6a7bdcfe4fede9f52f79b48f5044285299
Alessandro100/x-puzzle-solver
/xpuzzle.py
7,651
3.640625
4
class XPuzzle: #sample input: 1 0 3 7 5 2 6 4 def __init__(self, rows, cols, input): self.rows = rows self.cols = cols self.arr = [] # we keep track of the 0 position to increase the performance of our algorithm self.zero_position = (0,0) #row, column self.__init...
9aeb414b897c3948dfe4313d40b30bd7471a3d49
priyal-jain-84/Projects
/sudoku project.py
2,429
4.25
4
# Sudoku project using backtracking method # board=[ [7,3,0,9,5,0,0,0,0], [2,0,0,6,7,0,5,8,0], [0,0,5,0,1,0,4,0,0], [1,9,0,0,6,3,2,0,5], [0,4,0,0,0,0,6,0,0], [5,6,8,2,0,7,0,0,0], [0,2,0,0,8,1,3,0,0], [0,0,1,0,0,9,7,6,0], [0,7,0,5,2,0,8,0,9] ...
dd466737b8abb26679212eceabda0ae7114c2495
stevenbrand99/holbertonschool-higher_level_programming
/0x05-python-exceptions/3-safe_print_division.py
260
3.5625
4
#!/usr/bin/python3 def safe_print_division(a, b): try: inside_result = a / b except (ZeroDivisionError, TypeError): inside_result = None finally: print("Inside result: {}".format(inside_result)) return inside_result
8923477b47a2c2d283c5c4aba9ac797c589fbf7e
nobin50/Corey-Schafer
/video_6.py
1,548
4.15625
4
if True: print('Condition is true') if False: print('Condition is False') language = 'Python' if language == 'Python': print('It is true') language = 'Java' if language == 'Python': print('It is true') else: print('No Match') language = 'Java' if language == 'Python': print('It is Python') ...
645074e3b2e1274fb0380182c95124df18ce2a89
liamliwanagburke/ispeakregex
/politer.py
8,060
4
4
'''Provides a 'polite' iterator object which can be sent back values and which allows sequence operations to be performed on it. exported: Politer -- the eponymous generator/sequence class @polite -- decorator that makes a generator function return a Politer ''' import functools import itertools import collec...
6a22f2e3cd18309c2b74becebafa184467ce9b87
Piper-Rains/cp1404practicals
/prac_05/hex_colours.py
591
4.375
4
COLOUR_CODES = {"royalblue": "#4169e1", "skyblue": "#87ceeb", "slateblue": "#6a5acd", "slategray1": "#c6e2ff", "springgreen1": "#00ff7f", "thistle": "#d8bfd8", "tomato1": "#ff6347", "turquoise3": "#00c5cd", "violet": "#ee82ee", "black": "#000000"} print(COLOUR_CODES) colour_name = inpu...
e8893f7e629dede4302b21efee92ff9030fe7db2
Piper-Rains/cp1404practicals
/prac_05/word_occurrences.py
468
4.25
4
word_to_frequency = {} text = input("Text: ") words = text.split() for word in words: frequency = word_to_frequency.get(word, 0) word_to_frequency[word] = frequency + 1 # for word, count in frequency_of_word.items(): # print("{0} : {1}".format(word, count)) words = list(word_to_frequency.keys()) words.s...
0f6e1b50046506c97b52e79e6108bef72b64aa9f
siva237/python_classes
/numpys.py
990
3.75
4
# Numpy is the core library for scientific computing in Python. # It provides a high-performance multidimensional array object, and tools for working with these arrays. import numpy # a=numpy.array([1,2,3]) # rank 1 array # print(a.shape) # (3,) # print(type(a)) # <class 'numpy.ndarray'> # b=numpy....
93aff832710c79b6a88e20cdd1e6f8d0c50b1e81
siva237/python_classes
/copy_ex.py
343
3.6875
4
import copy # s={1,2,3,4} # s1=copy.deepcopy(s) # print(s1 is s) # s.add(10) # print(s) # print(s1) # s={1,2,3,4} # s1=copy.copy(s) # print(s1 is s) # s.add(10) # print(s) # print(s1) # l=[1,2,3,4] # l1=copy.copy(l) # print(l1 is l) # l.insert(1,22) # print(l) # print(l1) l=[1,2,3,4] l1=l print(l1 is l) l.insert(1...
a7554b02548c913fcf50cb1a1b7c621a646cf06a
siva237/python_classes
/read_write_append/most_occuring_words.py
198
3.78125
4
# file = open("doc.txt", 'w') import collections words = open("doc.txt", 'r').read() list_of_words = str(words).split(" ") words1 = collections.Counter(list_of_words).most_common(10) print(words1)
6abf00b079ceab321244dbe606f05bac9a347be0
siva237/python_classes
/Decorators/func_without_args.py
1,331
4.28125
4
# Decorators: # ---------- # * Functions are first class objects in python. # * Decorators are Higher order Functions in python # * The function which accepts 'function' as an arguments and return a function itslef is called Decorator. # * Functions and classes are callables as the can be called explicitly. # def hel...
14aa5e941cd3aedfb807822ba2cbea9ee3989711
LarisaSam/python_lesson2
/homework2.py
524
3.859375
4
my_list = [] n = int(input("Введите количество элементов списка")) for i in range(0, n): elements = int(input("Введите элемент списка, после ввода каждого элемента - enter")) my_list.append(elements) print(my_list) j = 0 for i in range(int(len(my_list)/2)): my_list[j], my_list[j + 1] = my_list[j + 1],...
c265111d4365097f2fed0727033af3604c8fb1f4
mantrarush/InterviewPrep
/InterviewQuestions/DynamicProgramming/BalancedBrackerGenerator.py
1,409
3.515625
4
# Given an integer: n generate all possible combinations of balanced brackets containing n pairs of brackets. def generate(pairs: int, stream: str, stack: str, answers: [str]): if pairs == 0 and len(stack) == 0 and stream not in answers: answers.append(stream) return if len(stack) > pairs: ...
39a9ed0ca6f8ce9095194deb21f2c685cfcb079c
mantrarush/InterviewPrep
/InterviewQuestions/SortingSearching/IntersectionArray.py
1,037
4.21875
4
""" Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each element in the result should appear as many times as it shows in both arrays. The result can be in any order. Follow up: What if the given array is already sorted? How w...
b9564579442a6b50cc3c79aea47c571d857dfed4
cyndyishida/MergeLinkedLists
/Grading/LinkedList.py
1,409
3.9375
4
class LinkedListNode: def __init__(self, val = None): """ :param val of node :return None Constructor for Linked List Node, initialize next to None object """ self.val = val self.next = None def __le__(self, other): ''' :param other: Link...
8119708cd5274f07265c91a686e1b3b1e7c7d11d
linal3650/automate
/organize_files/deleteBigFiles.py
815
4.03125
4
#! python3 # Write a program that walks through a folder tree and searches for exceptionally large files or folders # File size of more than 100 MB, print these files with their absolute path to the screen import os, send2trash maxSize = 100 # Convert bytes to megabytes def mb(size): return size / (3036) path =...
ea4c9af2f36bb8d737d50c4d8233d01c4e1387c0
linal3650/automate
/dictionaries/fantasyGame.py
807
3.75
4
equipment = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12} inv = {'gold coin': 42, 'rope': 1} dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby'] def displayInventory(inventory): print('Inventory:') num_items = ...
2152d9ab2cf627d41450032acbb9ab0079d23b48
msomi22/Python
/my_tests/assignments/pro/tax.py
3,947
3.859375
4
def calculate_tax(peoplelist = {}): while True: try: iterating_peoplelist = peoplelist.keys() for key in iterating_peoplelist: earning = peoplelist[key] mytax = 0 if earning <= 1000: ...
bd4ff04f9ebce8b4ad505e34012c80cca1cefcb9
msomi22/Python
/my_tests/more/peter.py
2,138
3.796875
4
def calculate_tax(dict): try: iterating_dict = dict.keys() yearlyTax = 0 for key in iterating_dict: income = dict[key] if income <= 1000: dict[key] = 0 elif income in range(10...
45572a5b9903129a8cd4ba370da4a4ec0802a116
msomi22/Python
/my_tests/assignments/datastructure.py
1,154
3.765625
4
#!/usr/bin/python def manipulate_data(mylist=[]): try: if type(mylist) is list: newlist = [] sums = 0 count = 0 for ints in mylist: if ints >= 0: count += 1 if ints < 0: sums += ints ...
4a81b3f14a778f7db90f588f71e7e1f49c471f50
jskim0406/Study
/1.Study/2. with computer/4.Programming/2.Python/8. Python_intermediate/p_chapter03_02.py
1,524
4.125
4
# 클래스 예제 2 # 벡터 계산 클래스 생성 # ex) (5,2) + (3,4) = (8,6) 이 되도록 # (10,3)*5 = (50,15) # max((5,10)) = 10 class Vector(): def __init__(self, *args): '''Create vector. ex) v = Vector(1,2,3,4,5) ==>> v = (1,2,3,4,5)''' self.v = args print("vector created : {}, {}".format(self.v, type(self.v))) ...
5d77d11119fac9045c09cec9f0cc0d73891b2dbb
jskim0406/Study
/1.Study/2. with computer/4.Programming/2.Python/8. Python_intermediate/p_chapter05_02.py
1,645
4.03125
4
# Chapter 05-02 # 일급 함수 (일급 객체) # 클로저 기초 # 파이썬의 변수 범위(scope) # ex1 b = 10 def temp_func1(a): print("ex1") print(a) print(b) temp_func1(20) print('\n') # ex2 b = 10 def temp_func2(a): print("ex2") b = 5 print(a) print(b) temp_func2(20) print('\n') # ex3 # b = 10 # def temp_func3(a): ...
6aa1ad22a6d9004e5179a7653b8d74201eb8759f
LURKS02/pythonBasic
/ex01.py
607
3.6875
4
# print ============================ print('출력문 - 홀따옴표') print("출력문 - 쌍따옴표") print(0) print("문자 ", "연결") print("%d" % 10) print("%.2f" % 10.0) print("%c" % "a") print("%s" % "string") print("%d, %c" % (10, "a")) # 연산자 ============================ # +, -, *, /, //(몫), %(나머지) # >, <, ==, !=, >=, <= # and, or # 변수 =...
aac17e924e89267aac3d0bac6308a66c38f7f03a
grmvvr/sampaga
/sampaga/data.py
341
3.625
4
import numpy as np def calc_one(): """ Return 1 Returns: """ return np.array(1) def print_this(name="Sampaga"): """Print the word sampaga. Print the word sampaga (https://tl.wikipedia.org/wiki/Sampaga). Args: name (str): string to print. """ print(f"{name}") pr...
92364501d62884d592a7f34504b896e50d366896
liuwang203/CPSC437-Database-System-Project
/Process_data/process1.py
1,826
3.515625
4
# Process raw data scraped for yale dining # to input file for database #input_file = 'Berkeley_Fri_Breakfast.txt' #output_file = 'BFB.txt' #input_file = 'Berkeley_Fri_Lunch.txt' #output_file = 'BFL.txt' input_file = 'Berkeley_Fri_Dinner.txt' output_file = 'BFD.txt' if __name__ == '__main__': out...
37f14c9ea36d9a3e9c430bb0bbeeb1b6bf9ac634
quanb1997/CS585
/perplexity.py
7,071
3.78125
4
import sys import json import string import random import csv import math POPULAR_NGRAM_COUNT = 10000 #Population is all the possible items that can be generated population = ' ' + string.ascii_lowercase def preprocess_frequencies(frequencies, order): '''Compile simple mapping from N-grams to frequenc...
025db2acb88ba3ee0072227d3e9f71f7172c0669
hsg-covid-engage/covid-engage
/app/models.py
2,118
3.640625
4
"""Data Models""" from . import db class User(db.Model): """Class that constructs the user database""" __tablename__ = "user9" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password =...
7f8aee9d19e67d433704cfc6d864c2626404f164
AnanthiD/codekata
/guvis81.py
84
3.5
4
k=list(str(input())) l=k[::-1] if(l==k): print("yes") else: print("no")
bc8974f049a33d537c278137bd5231bbcbd0f288
AnanthiD/codekata
/guvis61.py
83
3.5
4
a=input() m=len(a) for i in range(0,m-1): print(a[i],end=" ") print(a[m-1])
4c1f1bb5c4f53f2a7f724a03468152e3ae67eca1
CRAZYShimakaze/python3_algorithm
/根据字符出现频率排序.py
662
3.75
4
# -*- coding: utf-8 -*- ''' @Description: 给定一个字符串,请将字符串里的字符按照出现的频率降序排列。 @Date: 2019-09-14 19:35:01 @Author: typingMonkey ''' from collections import Counter def frequencySort(s: str) -> str: ct = Counter(s) return ''.join([c * t for c, t in sorted(ct.items(), key=lambda x: -x[1])]) def frequencySort1(self, ...
63eb763b01e453c9c329f40a0a49276389d7eb16
CRAZYShimakaze/python3_algorithm
/背包问题2.py
1,180
3.703125
4
# -*- coding: utf-8 -*- ''' @Description: 在n个物品中挑选若干物品装入背包,最多能装多大价值?假设背包的大小为m,每个物品的大小为A[i],价值分别为B[i] @Date: 2019-09-10 14:06:55 @Author: CRAZYShimakaze ''' class Solution1: """ @param m: An integer m denotes the size of a backpack @param A: Given n items with size A[i] @return: The maximum size """ ...