blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8117de66b8b0efbce5f7f39a7e9e997d01b10c5a
benwei/Learnings
/pySamples/testMultipleHerit.py
480
3.75
4
#!/usr/bin/env python # source: http://stackoverflow.com/questions/3277367/how-does-pythons-super-work-with-multiple-inheritance class First(object): def __init__(self): print "first" class Second(First): def __init__(self): print "second" """ TypeError: Error when calling the metaclass bases...
55b1d917c479a9fe07ad93d4d366cb5bf78d737d
carcuz789/EDD_1S2019_P1_201700633
/venv/Scripts/REPORTES.py
1,644
3.828125
4
import os import curses from curses import KEY_RIGHT, KEY_LEFT, KEY_DOWN, KEY_UP from random import randint from Scripts import Menu from Scripts import Pila_Score_Report def pedirNumeroEntero(): correcto = False num = 0 while (not correcto): try: num = int(input("Introduce un numero en...
c38914e813c6134d2ed06ad6066073db0f6c1224
nbeirne/aoc-2020
/4/4.py
3,111
3.796875
4
import re f = open("input", "r") lines = f.readlines() def validate1(dict): return \ "byr" in dict and \ "iyr" in dict and \ "eyr" in dict and \ "hgt" in dict and \ "hcl" in dict and \ "ecl" in dict and \ "pid" in dict def validate2(dict): print("----...
5a6c2f1523ee5207fdaa510310c42b0887ae5c23
conrad760/EPI
/expo_4_7.py
992
4.25
4
''' a program that raises a a number by another number ''' def raised_to(x, y): """ Brute Force take x multi by itself y times time: O(2^n) """ """ recursive algorithm even: [(x^y/2)^2] odd: [x*(x^y/2)^2] time: O(n) """ result, power = 1.0, y if y < 0: power, x = -...
ba89c650e5d0ce06dce3d085b0dbabfd83f9e4dd
exploring-curiosity/DesignAndAnalysisOfAlgorithms
/Assignment2/q1_6matpower.py
999
4
4
class MyError(Exception): def __str__(self): return repr("Exception : if matrix 1 is m*n then matrix 2 should be n*o") def mat_power(a, n): if (n == 1): return a elif n % 2 == 1: return mat_mul(a,mat_power(a, n - 1)) else: x = mat_power(a, n / 2) return mat_mul(...
f9219b7264d16b822f7748174cda6b5be1b91d88
HaoWangSir/Incomplete_Morelli_F16_6DoF_model
/post_process.py
2,289
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Sep 27 15:14:06 2020 @author: johnviljoen """ ''' This is to rotate angles in 3D around 3 axes like euler angles I think, equations are taken from wikipedia https://en.wikipedia.org/wiki/Rotation_matrix ''' import numpy as np from numpy import cos, si...
9b9a4b55ce1ee3e13adb114abea37edf2351f394
oubush/algorithms
/Grokking_Algorithms/01_binary_search.py
460
4.03125
4
# binary search def binary_search(a_list, item): """ Binary search returns an index of item in a_list (first index is 0) returns None if item is not in a_list """ low = 0 high = len(a_list)- 1 while low <= high: mid = (low + high) // 2 guess = a_list[mid] if guess =...
047c1c5c0040b7b7b7c2c330622e0752a5381316
hobg0blin/ganterbury-tales
/scripts/clean.py
1,571
3.59375
4
import argparse import re parser = argparse.ArgumentParser() parser.add_argument('filename') args = parser.parse_args() with open(args.filename, "r") as file: # this script contains a bunch of individual regexes for common footnote/non-corpus patterns and deletes lines that contain them clean_name = ("_clean....
d674c20ebf648b44170b16de8dec2fe6ffdfeef9
StarCoder09/PythonTkinter
/App's/sliders.py
973
4.21875
4
''' This App illustrates the use of Sliders to set window size in Tkinter ''' #Packages from tkinter import * from PIL import ImageTk,Image from tkinter import messagebox from tkinter import filedialog window = Tk() window.title("Sliders") window.iconbitmap('D:/e-Learning/Tkinter/Images/India-flag.ico') window.geometr...
c567693ddb605e5cd5e554c6a670eaef0c789c30
Carmenuski/savy
/proj06/proj06.py
2,728
4.25
4
# Name: # Date: # proj06: Hangman # ----------------------------------- # Helper code # (you don't need to understand this helper code) import random import string WORDLIST_FILENAME = "words.txt" def load_words(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending on the si...
c43e3af22f7739aa0e9e48162498f2663ea000ec
GaneshDesk/Python-Programs
/Object_Oriented_Programming/typecheck.py
741
4.25
4
# In python every class is subclass of object class. i.e object class is parent class of all classes. class Book: def __init__(self, title): self.title = title class Newspaper: def __init__(self, name): self.name = name # Create some instance of the classes. b1 = Book("the cacher") b2 = B...
949f3c750fed44eda77f4960ead95a7b4e908b10
AmitBaroi/Data-Visualization-Lessons
/Sentdex/2_BarCharts.py
826
4.25
4
import matplotlib.pyplot as plt ''' Bar charts show the comparison of different variable, they are discrete. ex: Number of speakers of different languages While Histograms show the distribution of variables, they are continuous. ex: GPD of a Country by Year ''' # Data for Bar_1 x = [2, 4, ...
404422ba1b270c1e5791108544cd997d75360930
johnnyshi1225/leetcode
/problems/118_Pascals_Triangle.py
917
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ######################################################################### # Author: Johnny Shi # Created Time: 2018-08-27 17:38:42 # File Name: 118_pascal_s_triangle.py # Description: ######################################################################### class Solution...
77d1e99d9e2a56b87498d41b024331cd7660db4c
Hanu-Homework/SS1
/week02/hw_ex02_date_printer.py
882
4.46875
4
def formatted(date_str: str) -> str: # Split the month, day and year from the string month, day, year = map(int, date_str.split("/")) # A translator to convert the numeric month to a named one month_translator = { 1: "January", 2: "February", 3: "March", 4: "April", ...
0939f2b7ff6128cf68bd0673c74c48b8fb6735c0
egarris/loan_calculator
/loan_calculator.py
5,396
3.75
4
import argparse import math import sys class Loan: def __init__(self, principal=0, monthly_pay=0, diff_pay=[], num_months=0, interest=0): self.principal = principal self.monthly_pay = monthly_pay self.diff_pay = diff_pay self.num_months = num_months self.i...
a9ceb4b5b4470c4a3a21fafeb1663a0add1abe37
flyfire/Programming-Notes-Code
/Python/Python3-Base/03_Container/list.py
1,914
3.984375
4
######################### # 演示列表 ######################### # 定义列表 listA = [1, 2, 3, 4, 5, 6, 7, 8, 9] # 遍历 for a in listA: print("%d " % a, end="") print() # 创建一个枚举,以支持带索引的遍历 chars = ['a', 'b', 'c', 'd'] for i, ch in enumerate(chars): print(i, ch) # 插入操作 listA.append(11) # 添加到末尾 listA.insert(len(listA), 12...
0930780302b74f95af151b923ca597a3402a1aa9
dgw15/PYNET
/Lesson1/ex2.py
576
3.515625
4
# exercise 2 ip_addr1 = input ("input ip address") oct1 = "Octet1" oct2 = "Octet2" oct3 = "Octet3" oct4 = "Octet4" octets = ip_addr1.split(".") print ("\n") print ("{:^15}{:^15}{:^15}{:^15}".format (oct1, oct2, oct3, oct4)) print ("-"*60) print ("\n") print ("{:^15}{:^15}{:^15}{:^15}".format (*octets)) print ("{:^15...
b74771f9c3f399c7ef87d4b2936105a3ee402d7b
vinaykumar7686/Leetcode-Monthly_Challenges
/December/Week4/Jump Game IV.py
6,268
3.859375
4
# Jump Game IV ''' Given an array of integers arr, you are initially positioned at the first index of the array. In one step you can jump from index i to index: i + 1 where: i + 1 < arr.length. i - 1 where: i - 1 >= 0. j where: arr[i] == arr[j] and i != j. Return the minimum number of steps to reach the last index o...
3e1f9953253f986f84f926d2db6e2b965affc0d3
djm4686/Heroes-of-Teleria
/line.py
549
3.859375
4
class Line: def __init__(self, point1, point2): self.p1 = point1 self.p2 = point2 self.slope = (self.p1[1] - self.p2[1])/(self.p1[0]-self.p2[0]) self.b = -((self.p1[0] * self.slope) - self.p1[1]) def isPointGreaterThan(self, point): if point[1] < (point[0] * self.slope) +...
c61cfcf826f7332776eb757ad8001c0d1df062c6
liu-yuxin98/Python
/chapter10/10.19.py
615
3.5625
4
# -*- coding: utf-8 -*- # 2020-02-08 # author Liu,Yuxin # eight queen import random num = eval(input('enter number of balls:')) positionlist = [] for i in range(8): positionlist.append(0) print(positionlist) for i in range(num): turnlist = [] for j in range(7): turnlist.append(random.randint(0, 1...
1ead6678ee3ba05d662582a04ab4d8b70b0da9b7
Paztelin/Curso-intensivo
/problema.py
1,357
4.21875
4
"""Realiza una funcion llamada relacion con 2 parametros (a,b) que apartir de 2 numeros cumpla lo sig: *Si el primer numero es mayor que el segundo debe devolver 1* *Si el primer numero es menor que el segundo debe devolver -1* *Si ambos numeros son iguales debe devolver un 0* num1=int(input('Dame un numero: ')) num2=...
727a8868b76a1cd458068e46c3914ac6c8337ad3
Joke-Dk/CodeTrain
/Leetcode/longsequence.py
701
3.609375
4
class pairs: def __init__(self, id, step): self.id = id self.step = step class Solution: # @param num, a list of integer # @return an integer def longestConsecutive(self, num): print "this num is ", num dict0 = {} dict_num = {} for i in range(len(num)): val = num[i] if val in dict0: tmp = dict...
38eaf2876b6aaec5b3d3fa39722bee69a7f64583
saeidp/Data-Structure-Algorithm
/Stack and Queue/StackDecimalToMultipleBase.py
821
3.90625
4
class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self.items[len(self.items) - 1] def...
ba9743aa9020a8b551a16a2e6c61bb70bee34720
Silentsoul04/FTSP_2020
/Knowledge Shelf/Series_Object_Pandas_1_ML.py
3,107
3.859375
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 27 18:34:47 2020 @author: Rajesh """ """ Extract Values by Index Label in Pandas :- ----------------------------------------- """ NOTE :- Here we want change the index by some of the column name then we can use the index_col = 'Column name' like see in the below lines. ...
c988c93cd1a39f529460fb4145814002aad0a9b3
AlphaAlpacaa/Project-Euler-s-Solutions
/Project Euler's Solutions/Integer_right_triangles.py
479
3.5625
4
"""DİK Açılı bir üçgen olacak şekilde p üçgenin çevresiyse hangi p değeri için çözüm sayısı maximumdur (p<1000) örnek: p = 120 için 3 tane (20,48,52) (24,45,51) (30,40,50)""" result = 0 number = 0 for p in range(1,1000): sayac= 0 for a in range(1,999): for b in range(1,a): c = (a**2 + b**2)*...
b76f784ab125f0bbeadf7b54ffe6e81c56e67f54
tutanck/Learning
/py/step2/pendu/fonctions.py
947
3.515625
4
from random import randrange import donnees import pickle f_name = donnees.f_name def choisir_mot(): mots = donnees.mots r = randrange(len(mots)) return mots[r] def saisir_lettre(): lettre = "" alphabet = donnees.alphabet while lettre not in alphabet: lettre = input('Entrez une lett...
a1e550948758b7038048e236ed0eccf016dce8e9
sabrikrdnz/LYK-17-Python-Examples
/26sudokugibi.py
334
3.84375
4
#9x9 tahtadaki verilen bir koordinatın nerede olduğunu bulan fonksiyon. #Öncelikle 9 kare içerisinde arama yapsın, daha sonra o kare içerisinde arama yapsın. def sudoku(): x = int(input("x'i giriniz:")) y = int(input("y'yi giriniz:")) a = x/3 b = y/3 z = x%3 t = y%3 print("(%s,%s) içerisinde (%s,%s)" %(a, b, ...
4b886000691f7fccfd07f0462e42f8efc5c7d0f0
Scrainer/Ayudantias-F.Programacion
/Ejercicios/Calificaciones.py
553
3.734375
4
list = [] cont = 1 while cont == 1: alumno = input("Nombre del alumno: ") calificaciones=[] notas=input("Ingrese notas ") calificaciones=notas.split(",") for i in range(len(calificaciones)): calificaciones[i]=float(calificaciones[i]) prom=sum(calificaciones)/len(calificaciones) prin...
a41447ee753954560fd2b920ef8783712e04077c
lastbyte/dsa-python
/problems/easy/is_palindrome.py
1,149
3.96875
4
import functools def is_palindrome(s: str) -> bool: formatted_string = ''.join(c for c in s if c.isalnum()).lower() itr = 0 while itr < len(formatted_string) // 2: if formatted_string[itr] != formatted_string[len(formatted_string) - itr - 1]: ...
7ddb8bd82fbb25b4df0c3286e6ae43f666be7244
caideyang/python2018
/Python全栈学习/第三模块/practise/学生对象,计数.py
529
3.703125
4
#!/usr/bin/python3 #@Author:CaiDeyang #@Time: 2018/9/13 6:54 class Student(object): count = 0 def __init__(self, name, age): Student.count += 1 self.name = name self.age = age @classmethod def get_count(cls): print("当前创建了 %s 个Student对象" % cls.count) if __name__ == "__m...
75a13bc7db88213a525a1dfa8efbbb56c741a28c
Nick-Feldman/PythonExamples
/exercise6_10.py
656
3.71875
4
''' Write a program to solve a classic ancient Chinese puzzle: We count 35 heads and 94 legs among the chickens and rabbits in a farm. How many rabbits and how many chickens do we have? ''' legs = 94 heads = 35 chickenLegs = 2 * 35 #count the number of legs accounted by the two legged animal - chickens r...
b5a8af3b344697721d953653464c08bd20c8a099
ALShum/leetcode
/0020-valid_parentheses.py
439
3.734375
4
## use a stack class Solution: def isValid(self, s: str) -> bool: st = [] match = {'}': '{', ']': '[', ')': '('} for c in s: if c in ('(', '{', '['): st.append(c) else: other = match.get(c) if len(st) > 0 and st[-1] == ...
b102e472aab8e90259d47b3d6e4171ead86375f2
tdwong/leetcode
/hackerrank/day-6-lets-review.py
2,608
4.21875
4
#!/bin/python #https://www.hackerrank.com/challenges/30-review-loop """ # Day 6: Let's Review # # Objective # # Today we're expanding our knowledge of Strings and combining it with what we've already learned # about loops. Check out the Tutorial tab for learning materials and an instructional video! # #...
0cbf78a9b8d0203b5f7edb4d9603751586187f63
SambhuRajendran/thepythons
/Basics/List/for_loop_list.py
203
4.375
4
thislist = ["Cat", "Dog", "Goose"] for animals in thislist: print(animals) #A list can be also printed by refering their index number for animal in range(len(thislist)): print(thislist[animal])
6d551f973ad42fd4e99d397b323fbe5690c09c56
MayowaFunmi/Algorithm-Problem-Solutions
/string_validator.py
1,862
3.953125
4
''' s = input() def func(s): for i in range(len(s)): if s[i].isalnum(): return True break return False def func2(s): for i in range(len(s)): if s[i].isalpha(): return True break return False def func3(s): for i in range(len(s)...
5f192532e0027d60f18f5015db2c9c69de83d5f5
thirumurthis/pythonLearning
/BasicLessons/ListOperations.py
2,340
3.90625
4
listval = [1,2,3,4,5,6] print ("value at idx 1 %d " % listval[1]) somenum =2**4 lst = [1, [20,21,somenum],3,4] print(lst[1][2]) #16 lst[1][2] = somenum**2 print(lst[1][2]) #256 (16^2) frstList = [4,3,2,1] secondList = [10,9,8] print (frstList + secondList) # adds both the list print (secondList *2) # prints the...
b5c0569c024a2c99346b923f4d6cab18b317dca7
panarnold/python-projects
/python-theory/generators.py
1,134
3.859375
4
# Iterator - obiekt, który umozliwia poruszanie się przez container # iterator umozliwia podroz i dostep do daty, ale nie wykonuje on uteracji, dlatego są: Iterable, Iterator, Iteration # ITERABLE # każdy obiekty pytona który ma __iter__ lub __getitem__ metode, która zwraca iterator albo może brać indeksy. Innymi słow...
ce32e49a3898a085cfcc7195fbd38225bf50d4b1
mike006322/HammingEncoderDecoder
/Decoder/decoder.py
2,775
3.890625
4
#!/bin/python3 # Hamming code is a linear block code of length 2^r - 1 for some natural number r # The dimension, k, of a Hamming code is 2^r - 1 - r and contains 2^k codewords # implemented as function and then as a class import numpy as np from Encoder.encoder import number_to_binary_array from Encoder.encoder impo...
b68f12215c5c5ec313913d3f82cc23d0df8e2c0d
stewSquared/project-euler
/p052.py
527
3.734375
4
"""It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. """ def shuffleCheck(n): digits = sorted(str(n)) return all(sorted(str(m * n)) == dig...
09f2dfefc54c71d1b8d1dd6b2d8e9bf1706b27e8
jin09/python_scripts
/draw_flower.py
1,007
4.03125
4
import turtle def draw_square(some_turtle): some_turtle.color("yellow") some_turtle.shape("turtle") import turtle def draw_square(some_turtle): some_turtle.color("yellow") some_turtle.shape("turtle") some_turtle.speed(30) for i in range(1,5): some_turtle.forward(150) ...
ed4d34c8cea1cb27c9adc542e782cf01d18d4041
Elijahbp/myThesis
/src/lib/MethodsForWords.py
702
3.6875
4
def get_count_word(list_words: list, type_operation: str): count_words = 0 if type_operation == 'max': max_count_word = 0 for x in list_words: count_words = len(x.split(' ')) if max_count_word < count_words: max_count_word = count_words return max...
ee8badde8060d80c50e30a83c15dc25a207fd378
ro6ley/MyPy
/algorithms/searching/linear-search/linear_search.py
481
4.125
4
def linear_search(array, item): """ Given an array and an item, this function traverses the array to locate the item. Parameters: array, item Returns: index if item is found, -1 if the item is not found """ for i in range(len(array)): if array[i] == item: return i ret...
e445c0e380322d6746ea6cb77cdb69391b66f52a
McNibbler/networks
/simultaneous users probability/probability.py
853
3.53125
4
#Calculate probability of more than N users being online from math import factorial testUsersSimultaneous = 10 testUsers = 35 testProbPerUser = 0.1 #nCr helper function for prob function def nCr(n,r): return ((factorial(n))//(factorial(r) * factorial( n - r ))) #uses binomial distribution to find the pro...
359ce093eb779430ba3850e06ab21c6bd571b56e
rishky1997/Python-Practice
/Day 2/Q1.py
149
3.921875
4
no=int(input("Enter a number:")) sum=0 for i in range(1,no): sum=sum+i print(str(i),'+ ',end='') print(str(no),end=' = ') print(str(sum+no))
37d73b80e3d9d2d57ea1061167b8cec48e7491e4
shanemcdo/pixel_heart
/pygame_tools.py
19,981
3.703125
4
"""Basic classes for creating a pygame application""" import pygame, math, sys from glob import glob from pygame.locals import * from recordclass import RecordClass class TrueEvery: """This is a functor that creates a function that returns true once every {self.count} calls""" def __init__(self, count: int, ...
8c7a656ab041624e801545a0acbe2c1ecd93b9c7
libangchui/pyhtonProject
/TkinterPython基础/Tkinter学习之旅/字符串连接器.py
1,264
3.65625
4
# -*- coding: utf-8 -*- # @Time : 2020/3/27 12:16 # @Author : 富贵 # @FileName: 字符串连接器.py # 导入模块 import tkinter as tk # 创建窗口 win = tk.Tk() # 设置标题 win.title("字符串连接器1.1") # 设置窗口大小 win.geometry("400x300") # 标题 title = tk.Label(win,text="Concatenation of Two Strings\n---------------------------------------...
51347371392749108935c6e6861262a6a03a968d
bradford-smith94/cs347_project
/src/main.py
4,306
3.625
4
# Bradford Smith and David Ott # CS 347 Project # AbsenceCheck main.py # "I pledge my honor that I have abided by the Stevens Honor System." ##################################################################### #all the imports from ac_config import ac_config from ac_attendance import ac_attendance from ac_notify impor...
133d40a1e5435b8d38973f8da8a5be1384a0c150
Korpusha/module3python
/exceptions.py
1,831
3.75
4
import sys class GameOver(Exception): @staticmethod def append_lines(my_result): """Appends score in file.""" with open('scores.txt', 'a') as f: f.write(my_result+'\n') @staticmethod def check_lines(): """Returns stored scores.""" with open('scores.txt', 'r...
64b67995d78ccb1411eb04d45f66674b7ad5da19
dumasr3265/cti110
/P4T2_DumasRyan.py
637
4
4
# CTI-110 # P4T2 - Bug Collector # Ryan Dumas # 6/28/2018 def main(): # This program keeps a running total of bugs caught in a week print("This program will calculate how many bugs you have caught this week.") print() # Initialize accumlator to zero total = 0 # Get the number of days w...
e15922bdfaeaf56974251e908598add34e02bdea
masakiaota/kyoupuro
/practice/B_ARC/arc020_2/arc020_2.py
1,964
3.59375
4
# https://atcoder.jp/contests/arc020/tasks/arc020_2 # 一行飛ばしでカウントしておけば良い # もし同色だったら次のいろを使うことにする import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv)) # 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと def read_a_int(): ...
f7e5be431181f14fccf1eb41ec29106dbad7a46a
luix/aws-deep-racer-league
/empire-city/YaVoy.py
1,817
3.5
4
def reward_function(params): import math import json print(json.dumps(params)) # Read input parameters track_width = params['track_width'] distance_from_center = params['distance_from_center'] speed = params['speed'] steering_angle = abs(params['steering_angle']) closest_waypoints ...
0c09fd17dede62fc00c93f453edf12c91190bdb2
sarahclarke-skc/week_02-day_2_bus_stop_lab
/src/bus.py
1,313
3.609375
4
from src.bus_stop import BusStop class Bus: def __init__(self, route_number, destination, price, capacity): self.route_number = route_number self.capacity = capacity self.destination = destination self.price = price self.passengers =[] self.takings = 0 def driv...
a9dc2084273fb94c3d5d31fb6a4b066608b0eee0
elenabarreto/Repositorio
/Situacion-S5.py
519
3.734375
4
print "___________________" print "-*- EJERCICIO 5 -*-" print "___________________" print " " print " " print " " print "_______________________________________________________________________________" print " " dinero = int (input('Ingrese la cantidad de dinero que va a llegar al hospital: ')) odon = (dinero*40)/100 ...
07cf3429ae0a0ee1fb08c0e35683c1b5136a51d1
karafont/Python-Programs
/6.11.py
553
3.53125
4
def getName(): userName = input ( "Enter your name: " ) return userName def getBio(): userBio = input ( "Please enter a sentence or two that describes yourself: " ) return userBio def webPage(userName, userBio): web = "biopage.html" openFile = open(web, "w+") openFile.write("<html>\n<head>\n</head>\n...
f6444a23f9a1489c5e0508e0b85764eb647cf70c
andylampi/esercizi_workbook_python
/capitolo_4/esercizio_97.py
375
4.0625
4
#!/bin/python3 def precedence(number): if number.startswith("+"): return 1 elif number.startswith("-"): return 2 elif number.startswith("*"): return 3 elif number.startswith("/"): return 4 def main(): number = input("Enter the number: ") first = precedence(number)...
2bd4f7f14ba0c317fdd455727cb81ac4acd7acc7
FinnBuick/CtCI-Python-Solutions
/Chapter1/2_Is_Permutation/IsPermutation.py
631
3.84375
4
import unittest from collections import Counter def isPermutation(a, b): return Counter(a) == Counter(b) class Test(unittest.TestCase): dataT = [("aaaa", "aaaa"), ("hello", "olelh"), ("", "")] dataF = [("abcds", "safsdf"), ("hello finn", "hello finneas"), (" ", "")] def test_isPermutation(self): ...
64ac390259c057f46d6373cbbf6ee90c2849797c
Jays88/practicepython.org_exercises
/Exercise_13.py
235
4.125
4
number = int(input("Please specify how many long do you want your Fibonacci sequence to be: ")) count = 1 a = 0 b = 1 fib = [1] while count < number: c = a + b fib.append(c) a = b b = c count = count + 1 print(fib)
83956544a3fe5981461a37534f9daab22fa3398f
chendebiao/Network_Analysis
/coefficient_analysis/coefficient_analysis.py
5,873
3.65625
4
import numpy as np import networkx as nx import matplotlib.pyplot as plt # initialize erdos_renyi_graphs = None air_traffic_graph = None acad_collab_graph = None num_nodes = 1226 edge_probs = [0.001, 0.003, 0.01, 0.05, 0.1] def generate_erdos_renyi_graph(n=1226, p=0.003): """ Return an instance of Erdos-Re...
b10046d9a4a6c0fc612b6fa38fb34a86d796bcf2
z-sector/stepik_snakemake
/scripts/copy_files.py
750
3.53125
4
import argparse import re def parse_args(): parser = argparse.ArgumentParser(description='Word counting utility!') parser.add_argument('input', type=argparse.FileType('r'), help='Input path file for count.') parser.add_argument('output', type=argparse.FileType('w'), help='Output path file after count.') ...
996f3a678005aa5831de22ec205ecb82d4d598dd
meda123/Hb_weekend_assessments
/w2_object_orientation/assessment.py
5,998
4.03125
4
""" Part 1: Discussion 1. What are the three main design advantages that object orientation can provide? Explain each concept. The three main design advantages of object orientation include abstraction, polymorphism, and encapsulation. Abstraction affords programmers the ability to hide certain pieces ...
6ef4e7d3784202034377c6901d2c43cf8b522d00
chriswill88/holbertonschool-machine_learning
/math/0x05-advanced_linear_algebra/5-definiteness.py
2,333
3.921875
4
#!/usr/bin/env python3 """This module contains the function for how to solve a determinant""" import numpy as np def definiteness(matrix): """ @matrix is a numpy.ndarray of shape (n, n) whose definiteness should be calculated If matrix is not a numpy.ndarray, raise a TypeError with the message ...
b77e3bb5795deb2d54e905fb1f0cb266097efc75
byung-u/HackerRank
/Cracking_the_Coding_Interview/time_complexity_primality.py
319
4.0625
4
#!/usr/bin/env python3 import sys def is_prime(n): if n == 2: return True if not n & 1: return False return pow(n - 2, n - 1, n) == 1 p = int(input().strip()) for a0 in range(p): n = int(input().strip()) if is_prime(n): print('Prime') else: print('Not prime')
9cfa69bb830f01c40070f11174adf90c694aca7e
guxal/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/6-print_sorted_dictionary.py
154
3.96875
4
#!/usr/bin/python3 def print_sorted_dictionary(a_dictionary): for idx in sorted(a_dictionary.items()): print("{}: {}".format(idx[0], idx[1]))
e5b560c1066f56d7a77d3e8302326dbab8d63129
dungtuanha/hatuandung-fundamental-c4e24
/session03/Homeworks/extra_1.py
389
4.0625
4
import random word = str(input("enter a word: ")) charlst = list(word) random.shuffle(charlst) new_word = ''.join(charlst) print("guess what word is this: ", end ="") print(new_word) your_word = str(input("your answer: ")) while your_word != (word): your_word = str(input("wrong answer, try again:...
d24b48b819f64be1f3799e60cfdc2fac7eb825a7
Nukalakrupani12345/pythonProblems
/distinct.py
269
3.65625
4
def distinctPowers(): liste = [] count = 0 liste = [] for i in range(2, 101): for j in range(2, 101): if (i ** j) not in liste: liste.append(i ** j) count += 1 return count print(distinctPowers())
0ef05cae977f5e61aa35f4fc4c47cdcbebcd4e99
QikTech/TkinterExercise
/open.py
1,033
3.59375
4
from tkinter import * from tkinter import filedialog from PIL import ImageTk, Image root = Tk() root.title('Convert Image to text') #Favicon root.iconbitmap('E:\Programming 0.1\MLai\Image to text\Qik5.ico') # # # fileLabel =Label(root, text=root.filename).pack() # #Getting selected image path # selected_image = I...
0537344b467e5da7487b5f1b6c7f102e87dc4254
greencodespace/code_data
/py_scipy/엔지니어를위한_파이썬/chapter05/class3.py
1,277
4.1875
4
# (1) 전역 네임스페이스에 x를 정의 x = 100 class MyClass: # (2) 이 클래스의 변수 i와 x를 정의 i = 10 # 메소드 price() 안에서 참조 x += 2 # 전역 네임스페이스 상의 x에 2를 더함 xx = x + 2 # (3) MyClass 안의 x를 참조 print('xx = ', xx) def price(self): y = self.i * x # (4) 전역 네임스페이스의 객체 x를 참조 z = self.i * self.x # (5) 인스턴스 속성 -...
f67cb3a81430a9c52785f171826f0affb7146f07
VinhMaiVy/ds
/src/ds/SinglyLinkedList.py
479
3.546875
4
''' Created on Sep 21, 2020 @author: vinhm ''' class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None class SinglyLinkedList: def __init__(self): self.head = None self.tail = None def insert(self, node_data): node = Sin...
a528e550df90f4d1c206a2fd8a912523aa58e71e
Mjayendr/My-Python-Learnings
/paycalc.py
809
4.09375
4
# This program calculates the pay based on rate and working hours. def main(): print invalid = True while invalid: print hours = raw_input("Enter number of hours worked : ") h = float(hours) if h <= 0: print "Working hours can not be less than 0" continue invalid = False print invali...
aed26f0a8677362eb63e6ab2a2efadb113c980e8
scls19fr/openphysic
/python/tk/test/main.py
622
3.6875
4
from Tkinter import * class App: def __init__(self, master): frame = Frame(master) frame.pack() self.button = Button(frame, text="ADD", command=self.job) self.button.pack(side=LEFT) #self.buttonquit = Button(frame, text="QUIT", command=frame.quit) self.buttonquit = B...
c216b0e0b1d15c39900487ddb95ba95ca4dd6166
sneh0304/Data-Intensive-Computing
/p2/mapper_5.py
838
3.5625
4
import numpy as np import pandas as pd import sys #method for normalizing dataset #start: def normalize(x): x_norm = np.zeros(x.shape) mean = np.mean(x, axis = 0) sd = np.std(x, axis = 0) x_norm = (x - mean) / sd return x_norm #end test_x = np.array(pd.read_csv('Test.csv'), dtype = np.float32) # r...
0f5d5d055f4d0e341607d46aa60f370c3b1cc149
SMMO0/testMancio
/main.py
51
3.546875
4
print("Hello") print("Simone sei gay") x = 10 print(x**2)
a4f841275beaf8cdfde13425f7001cee52a24505
dddbuji/hello
/小海龟基础作图2.py
441
3.953125
4
#设置小海龟的形状和颜色 import turtle as T #定义重复函数 def drawstar(x,y,color): T.up() T.goto(x,y) T.down() T.color(color) T.begin_fill() for i in [0, 1, 2, 3, 4]: T.right(144) T.forward(100) T.end_fill() drawstar(-200,200,"blue") drawstar(-200,-200,"red") drawstar(300,200,"gree...
fde42f54bdc3fa0a002d82fed9ba002d4ab894d3
imtiazaadar/Sudoku---Imtiaz-Adar
/Sudoku Python.py
5,652
4.28125
4
# Imtiaz Adar # Sudoku Solve # Date : 27/06/2021 # Email : imtiaz-adar@hotmail.com, imtiazadarofficial@gmail.com ####################### # # # ...
52cbad64c9f77c423f21ae6a8f066b3aac5b56a4
AndreaCeolin/Functionalism_Contrast_Change
/Chapter3/Cantonese/minipair-can.py
2,349
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' This script is used to retrieve the number of minimal pairs associated to each phoneme for the English (UK) CHILDES data. author: Andrea Ceolin date: February 2021 ''' from collections import Counter, defaultdict def minimal_pairs(wordlist, phoneme): ...
0c0101c7cc6ca0ef4ed0382cd854bf290a987311
djFatNerd/leetcode_python3
/swapNodesInPairs_24.py
458
3.75
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def swapPairs(self, head: ListNode) -> ListNode: p1 = head # base case if not p1 or not p1.next: return p1 ...
6c3e464900a5bd8ee3ddefa9c648e17747ef6c72
abhicse32/SPOJ_codes
/NHAY.py
282
3.625
4
counter =0; n = -1 #print while True: num = raw_input() try: num = int(num) except ValueError: break num = int(num) #if(!num) : # break needle = raw_input(); haystack= raw_input(); for i in range(len(haystack)+1): if haystack[i:i+num] == needle: print "\n",i,
988b20756db3f68b6ebf7d4ab315d0e1bc051cea
madhusivaraj/maze-runner
/map_maker.py
811
3.71875
4
import random def map_maker(dim=None, p=None): # Takes a positive, nonzero integer (dim), and a number between 1 and 0 # (p). # Returns a dim X dim matrix, where the value of each element is randomly # decided, with a probability p of being 1, or else being 0. Exceptions are # the upper left elemen...
470a2a5a34811a9303243354866e601539cac752
sayoojtmc/TarentoInternship
/validstring.py
1,433
4.1875
4
""" Question - Accept a String input - Accept a String of valid chars - Remove all the characters that are not present in the valid chars from the input string - Print the cleansed String and the count of characters removed Eg. If the String input is The name of my dog is #2#Tiger and the valid chars is abcdefghijklmno...
3e9757bb1a436fdcab5da0448b7da08795bedf75
mabearnews/leaderboard.py
/user_utils.py
1,806
3.75
4
"""User class and offline helper functions""" import csv class User: """Holds like, comment and post stats for a student.""" def __init__(self, userobject): self.userid = userobject['id'] self.name = userobject['name'] # No data yet self.likes = 0 self.comments = 0 ...
dcaaea6c6d4772ec3322c0e81caf8ef69db87928
sikander27/Techgig-python
/30 Days Coding Challenge/day19_binarryToDecimal.py
380
4.09375
4
''' Write a function to take an input and convert binary into decimal form. ''' def binToDec(n): decimal,i = 0, 0 while n!=0: dec = n % 10 decimal = decimal + dec * pow(2,i) n = n // 10 i += 1 print(decimal) def main(): n = int(input(),2) #using build in function # ...
3afc3ba4f4c0cdf767ce751e529b182a9759464d
hayabalasmeh/data-structures-and-algorithms.
/tests/test_hashtable.py
1,469
3.90625
4
from data_structures_algorth.challenge_hashtable.hashtable import HashTable # Testing if Adding a key/value to your hashtable results in the value being in the data structure def test_adding(): #Arrange test_obj = HashTable() index = test_obj.hash('test') #Act test_obj.add('test',5) #Assert ...
6d051efaa623527758ebdda896f4ce09b6332330
pithecuse527/python-practice
/Ch.1 - Ch.2/abs.py
358
3.5625
4
## # 18.03.08 # 20152262 Hong Geun Ji # # Implemnetation of absolute user_input = int(input("임의의 정수를 입력하시오 :")) num_type = "양수" if user_input < 0: user_input = -user_input num_type = "음수" elif user_input == 0: num_type = "0" print("입력하신 수는", num_type,"이고 절댓값은",user_input,"입니다.")
b82b218156d219b2ae4de5543e6aff81499b4d05
Vieiraork/Python-Learn
/Ex042.py
647
4.0625
4
l = [0] * 3 for i in range(3): l[i] = float(input('Digite o {}º lado: '.format(i+1))) if l[0] < l[1] + l[2] and l[1] < l[2] + l[0] and l[2] < l[1] + l[0]: if l[0] == l[1] and l[0] == l[2]: print('Todos as medidas são iguais, por isso o triângulo formado é o Equilátero.') elif l[0] == l[1] or l[1] ...
7ffc5d76dee3c4c818af05d69b2cebc6ccc1833f
paramchoksi/task-management
/Database.py
5,191
3.515625
4
import mysql.connector from mysql.connector import Error import pandas as pd def createServerConnection(): """ This function create a connection with the mySQL server """ server_connection = None try: server_connection = mysql.connector.connect( host='localhost', ...
2411dc4fc5288cf8bfed113ef535bb6bbdf97315
rchen00/Python-for-AI
/hw1-1.py
535
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Dec 28 11:32:15 2020 @author: robertchen """ print("How old are you?" , end='') age=input() print("How old are you?" , end='') print(age) print("How tall are you?" , end='') height = input() print("How tall are you?" ,end='') print(height) print(...
683a9db708c7460fc92a173a35480f98a3a308b5
Derfador1/fdr
/fdr.py
3,793
3.671875
4
#! /usr/bin/env python3 import socket import os import threading import math #class to create my threads and socket connections class myThread(threading.Thread): def __init__(self, host, port): threading.Thread.__init__(self) self.host = host self.port = port self.server_socket = socket.socket(socket.AF_INET...
89d7f5d93f58b7d3d8cd71bc75e80cb69cd4dfba
i-zuzu/IntroToProg-Python-Mod07
/Assignment07_StructuredError.py
1,354
4.0625
4
# ------------------------------------------------------------------------ # # Title: Assignment 07 Structured Error (Demo) # Description: This script calculates the speed and # demonstrates how Structured error handling works # ChangeLog (Who,When,What): # Irina Zubova,2-27-2020, Created the script ...
ba593cd332e6a3765f45d9d976153863f4b9c4ab
Cecilia520/algorithmic-learning-leetcode
/cecilia-python/greedy-thinking/CutRope.py
1,232
3.625
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ @File : CutRope-1.py @Contact : 70904372cecilia@gmail.com @License : (C)Copyright 2019-2020 @Modify Time @Author @Version @Desciption ------------ ------- -------- ----------- 2020/4/5 15:53 cecilia 1.0 剪绳子 问题描述: 给你一根长度为n...
db8318c82c22170ec6e362e3d15636dc97a5cfc5
Savely-Prokhorov/DifferentPythonSolutions
/AlgorithmsAndDataStructures/AlgorithmicToolbox/hw/week2_algorithmic_warmup/2_last_digit_of_fibonacci_number/fibonacci_last_digit.py
303
3.6875
4
# Uses python3 import sys def get_fibonacci_last_digit_naive(n): arr = [0 for i in range(n)] arr[0], arr[1] = 1, 1 for i in range(2, n): arr[i] = (arr[i - 2] + arr[i - 1]) % 10 return arr[-1] #input = sys.stdin.read() n = int(input()) print(get_fibonacci_last_digit_naive(n))
48c72da14c5feedc16c2c80432b9fcbafd7c5a46
eg319/Simulation
/Main/Star.py
2,342
3.671875
4
class Star(object): global G G=6.67*10**(0) def __init__(self, xpos, ypos,velx=0, mass=1): # Object constructor self.pos = PVector(xpos,ypos) self.mass = mass self.acc = PVector(0,0) self.vel = PVector(velx,0) self.siz = 5 def show(self): # Display the s...
4cdb7e1693b8e5d73aeab0b115a38a36d4d2df58
himanshu2801/hackerrank_code
/filling jars.py
703
3.578125
4
""" Link of the question... https://www.hackerrank.com/challenges/filling-jars/problem Solution... """ #!/bin/python3 import os import sys # Complete the solve function below. def solve(n, operations): sum=0 for i in range(len(operations)): sum=sum + (operations[i][1] - operations[i][0] + 1)*operation...
bf065bc13cef724761588c0583180191b3ca1fb2
kmsnyde/SP_Online_Course2_2018
/students/JerryH/Lesson02/generator.py
434
3.625
4
#!/usr/bin/env python3 import pandas as pd music = pd.read_csv("featuresdf.csv") # Get all Ed Sheeran's tracks from the dataset data = [m for m in sorted(zip(music.name, music.artists, music.danceability, music.loudness), key=lambda m: m[2], reverse=True) if m[1] == 'Ed Sheeran'] def track_generato...
638e7a50e8127e561940ade2d6edb78d8c80b62c
glyif/holbertonschool-higher_level_programming
/0x03-python-data_structures/0-print_list_integer.py
117
3.984375
4
#!/usr/bin/python3 def print_list_integer(my_list=[]): for thing in my_list: print("{:d}".format(thing))
4dbac9098615bbbbb443499d7e03d3cfaa0582aa
tinkle1129/Leetcode_Solution
/LinkedList/23. Merge k Sorted Lists.py
1,636
4
4
# - * - coding:utf8 - * - - ########################################### # Author: Tinkle # E-mail: shutingnjupt@gmail.com # Name: Merge k Sorted Lists.py # Creation Time: 2018/2/17 ########################################### ''' Merge k sorted linked lists and return it as one sorted list. Analyze and describe its com...
be3adf3c76c7e7c4611c836a10ed2fe80055c4fd
mik30s/CS4086
/dec2bin.py
451
4.0625
4
#st1 = raw_input('Enter a string, no delimiters: ') #print st1 #for c in st1: print ord(c), #str = 'never odd or even' #for c in reversed(str): # st1 += c #st = 'Python\'s string class' # index will crash it is just to mimic the index function for lists #print st1.index('t', 5, 11) #print st1.find(...
d537d0dead4a497581b54f424831530490bec5a9
piketan/pike-s-python
/Python/ex21/ex21.py
528
4
4
def add(a,b): print(f"相加{a}+{b}") return a+b def subtract(a,b): print(f"相减{a}-{b}") return a-b def multiply(a,b): print(f"相乘{a}*{b}") return a*b def divide(a,b): print(f"相除{a}/{b}") return a/b print("函数做一些简单的计算") age = add(30,5) height = subtract(78,4) weight = multiply(90,2) iq = d...
bf25a02ab41207dd8feb812a4203a409e26185fe
chenjiahuan262821/LearnPy
/python_100_day/day5_exercise/craps.py
984
3.53125
4
import random counter = 0 gambler = 0 maker = 0 rounds = 100000 while counter < rounds: counter += 1 x = random.randint(1, 6) y = random.randint(1, 6) sum0 = x + y if (sum0 == 7) | (sum0 == 11): gambler += 1 #The gambler wins the game elif (sum0 == 2) | (sum0 == 3) | (sum0 == 12): ...
e76e1572cb8bb3474cd1ff402a2e0b1b5e6edfe9
sidneyalex/Desafios-do-Curso
/Desafio062.py
653
3.734375
4
#Melhore o Desafio061, perguntando para o usuario se ele quer mostrar mais alguns termos. O pgm encerra quando ele disser que quer mostrar 0 termos. from time import sleep c = 0 fim = False print('{:=^50}'.format(' Prograssão Aritmética ')) num = int(input('\nDigite o 1º termo da P.A.: ')) quant = int(input('Quantos te...
ca9564becee709e64714119569daa3e4d59bec3e
f-fathurrahman/ffr-MetodeNumerik
/chapra_7th/ch06/chapra_example_6_10.py
1,721
3.75
4
def f(x): return x**3 - 5*x**2 + 7*x - 3 def df(x): return 3*x**2 - 10*x + 7 def d2f(x): return 6*x - 10 # m is root multiplicity def root_newton_raphson(f, df, x0, NiterMax=100, TOL=1e-10, m=1): x = x0 for i in range(1,NiterMax+1): xnew = x - m*f(x)/df(x) # Newton-Raphson formula ...