blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d15bb3527b56c86f6d0c2eba77fcab675a66fa24
modcomlearning/advanced_web
/Lesson1Recap.py
339
3.984375
4
# Create a simple program to find body mass index # int - whole numbers # float - is number that is whole number but it can have decimal # string - alphanumeric - letters and number, symbols weight = 50.5 # float height = 1.5 # float age = 20 # int name = 'Joseph' # string answer = weight/height**2 print('Your BM...
1382343b7ff3ad99ea6692739a41b573f2ad9ad2
saumak/AI-projects
/image-classification/orient.py
6,889
3.8125
4
#!/usr/bin/python2 ############################# # **REPORT** # # 1. # We formulate the task as a classification problem of images into different # orientations based on given features of 8x8 pixels, each of 3 colors, red, # green, and blue. Given a data set, we use 3 different hypotheses, i.e. # K-Nea...
e9b267abad404913141e000fbf1f5987867ec6f3
choi-jae-hyuck/Script_learning
/script_03.py
3,334
3.59375
4
def equation(): lst=eval(input("Input A b c :")) a=lst[0] b=lst[1] c=lst[2] judge=(b**2)-(4*a*c) r1= (-b+((b**2)-4*a*c)**0.5) / (2*a) r2= (-b-((b**2)-4*a*c)**0.5) / (2*a) if judge < 0: print("No real root") elif judge > 0: print("Real root is {0:.6f} , {1:.5f}".forma...
59b6e1c1592153994dd2415f8e922a2ee39ba873
anabelenmiranda/ClasesParadigmasIFTS
/ejercicios_clase1.py
3,533
4.03125
4
#Ejercicio 1 # # Crear un programa que imprima por pantalla el mensaje “Hello World!”. # # Nota: se puede imprimir el dato puro o el dato almacenado en una variable, siempre es una buena práctica usar variables. # Ejercicio 2 # # Crear un programa que imprima por pantalla todos los números pares del 0 al 100. # Ejerc...
8eaef922616f3f4a1a023837a2bd1ff7ae421d2f
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/hamming/903da8d5eeb1479687eb299ced3f892d.py
183
3.609375
4
def hamming(dna1,dna2): hamming = abs(len(dna1) - len(dna2)) for i,n in enumerate(dna1): try: if not n == dna2[i]: hamming +=1 except IndexError: pass return hamming
2e8c4abaa87be49c3b43f16b2ec2a654d568d2e7
reddington123/HackerRank_Python_Solutions
/Basic Data Types/nested_list.py
930
3.703125
4
""" Title : Nested Lists Subdomain : Basic Data Types Domain : Python Author : Sachin Kumar Tiwari Problem : https://www.hackerrank.com/challenges/nested-list/problem """ def sort_second(val): return val[1]; if __name__ == '__main__': list_arr=[]; for _ in range(int(input())): name = i...
f4d0e8d7f996e0691d520d0c024471030ba13509
MikkelPaulson/advent-of-code-2020
/day11/__init__.py
4,610
3.59375
4
"""https://adventofcode.com/2020/day/11""" import io def part1(stdin: io.TextIOWrapper, stderr: io.TextIOWrapper) -> int: """ Simulate your seating area by applying the seating rules repeatedly until no seats change state. How many seats end up occupied? """ def get_adjacency(layout: dict, row: ...
b0f030390a6e1b13dc711237f9a194c55677ab1b
rsauhta/ProjectEuler
/p231.py
1,235
3.703125
4
# https://projecteuler.net/problem=231 # prime factorisation of binomial coefficient # import math # Use a sieve approach where for each prime figure out the prime factors def findSum(n,m): # find prime factorisation of mCn. # mCn = n!/m! /m! # so we want to find the sum of prime factors for two numbers : ...
69c7b3ff0933167c2e8f53d70a0d40ecb1b0f9c4
napoleonwxu/ProjectEuler
/031.py
326
3.671875
4
def coinSums(money, coinList): count = 0 for i in xrange(len(coinList)): moneyLeft = money - coinList[i] if moneyLeft == 0: count += 1 elif moneyLeft > 0: count += coinSums(moneyLeft, coinList[:i+1]) return count print coinSums(200, [1, 2, 5, 10, 20, 50, 100,...
3d65fc67be24158f52601b8ebdc08b5220bc19f4
Hoja1/amali_ishlarim
/royhatlar/royhat.py
1,026
3.640625
4
""" Created on Sat Jul 24 12:12:10 2021 @author: user """ def ishchiliar_uz(ism,familiya,otasni_ismi,tel_raqami,): ishchi = {'ism':ism, 'familiya':familiya, 'otasni_ismi':otasni_ismi, 'tel_raqami':tel_raqami, } return ishchi print("\nishchlar rohati") ...
ffa0d23caa05f05138f17cc59f76ed311a4a75c6
Aswini2001/case
/caps.py
246
3.890625
4
letter = input ("write a string") count=0 lcount=0 for x in letter: if(x.islower()): count=count+1 elif(x.isupper()): lcount=lcount+1 print("NO.OF.UPPERCASE: "+str(lcount)) print("NO.OF LOWERCASE:: "+str(count))
a01ffe2983430b8dab3273a6f13ae4e64c69035a
qnomon/Python-Studies
/ex032.py
270
3.9375
4
from datetime import date ano = int(input('Digite um ano para verificar se ele é bissexto: ')) if ano == 0: ano = date.today().year if ano % 4 == 0 and ano % 100 != 0 or ano %400 == 0: print('Esse ano é bissexto.') else: print('Esse ano NÃO é bissexto.')
55da29dc6644187cdaf4cef4d4b5d3003c143f40
libarra0/Python
/logic/branched_program.py
857
4.03125
4
def run(): # num_1 = int(input('Pick a integer: ')) # num_2 = int(input('Pick another integer: ')) # if num_1 > num_2: # print('The first number is greater than the second') # elif num_1 < num_2: # print('The second number is greater than the first') # else: # print('Bot...
19f1be81151654368b8645052f32b8f71a0609c0
impateljay7480/Python-program
/sort_without_method.py
223
3.71875
4
l = [5,3,6,4,2] for i in range(len(l)): # print(i) for j in range(i,len(l)): # print(l[i]) # print(l[j]) if l[i] > l[j]: l[i],l[j] = l[j],l[i] print(l)
5b190332bb9838f0db65975c09ebae6d38810ad1
Flame753/Numeric-Matrix-Processor
/Problems/Straight A's/task.py
185
3.890625
4
# put your python code here grades = str(input()) list_of_grades = grades.split() number_of_A = list_of_grades.count('A') ratio = number_of_A/len(list_of_grades) print(round(ratio, 2))
87d1c757147e9c664df2ffcd6d9487ab07b3102f
berdoezt/codility
/ChocolatesByNumbers.py
176
3.53125
4
#!/usr/bin/python def gcd(N, M): if N % M == 0: return M else: return gcd(M, N % M) def solution(N, M): pembagi = gcd(N, M) return N / pembagi print solution(15,75)
a76c97619adbee5c47440ecd78e295c31616fe5c
haifeng94/Python-Algorithm
/剑指offer/案例/数组/Duplicate.py
884
3.75
4
#coding = utf -8 ''' 题目:在一个长度为n的数组里的所有数字都在0到n-1的范围内。 数组中某些数字是重复的,但不知道有几个数字是重复的。 也不知道每个数字重复几次。请找出数组中任意一个重复的数字。 例如,如果输入长度为7的数组{2,3,1,0,2,5,3}, 那么对应的输出是第一个重复的数字2。 ''' ''' 思路一:直接遍历 ''' class Solution: #这里要特别注意~找到任意重复的一个值并赋值到duplication[0] #函数返回True/False def duplicate(self, numbers, duplicatio...
90ea1c3680b03ea4a3647f7df50ea177f209227c
mohamedfazilk/Qickskill-Flask
/test/sample2.py
2,888
4.0625
4
# numlist = [1,2,3,4,50,4] # # for i in numlist: # # print(i) # print(numlist[2]) # print(numlist[-1]) # print(numlist[::]) # # print(1 not in numlist) # numlist2 = [1,2,3,4,50,4] # name1 = "abc" # name2 = "abc" # print(name1 is name2) # numlist2.append('esasd') # numlist2.insert(1,"name") # print(numlist2) # numli...
57036f09334da17b9d59ae9a6d302993ba7f583f
Dkodsy/Practical-minimum
/task_3.py
1,153
3.890625
4
""" Пользователь вводит дату и время в формате ДД.ММ.ГГГГ ЧЧ:ММ. Обрежьте секунды. Замените час на 10. """ from datetime import datetime import time def date_check(input_str): try: return datetime.strptime(input_str, '%d.%m.%Y %H:%M') except: print('Неверная дата или время!') return da...
6ecc492c4ef5370bcbb75c1ecee58f10353d3e21
here0009/LeetCode
/5715_MinimumNumberofOperationstoReinitializeaPermutation.py
1,678
3.953125
4
""" You are given an even integer n​​​​​​. You initially have a permutation perm of size n​​ where perm[i] == i​ (0-indexed)​​​​. In one operation, you will create a new array arr, and for each i: If i % 2 == 0, then arr[i] = perm[i / 2]. If i % 2 == 1, then arr[i] = perm[n / 2 + (i - 1) / 2]. You will then assign ar...
f4e7d4b735e7c16472468bdb5049cac75178de47
Charl86/kb-image-shuffler
/shufflealgos/command/command.py
8,357
3.71875
4
"""Module that contains the Command pattern implementations. Module that contains the Command pattern abstraction and implementations. Implementations --------------- CmdlCommand DisplayImgCommand SaveScramImgCommand SaveUnscramImgCommand ScrambleImgCommand UnscrambleImgCommand """ import abc import pathlib import s...
6117c8e71d3ff211156d765230ffb4d52e807397
SurfTheRepo/Otto-Comp9321
/week3/Activity1.py
1,356
3.875
4
import pandas as pd import numpy as np def print_dataframe(dataframe, print_column=True, print_rows=True): if print_column: print(", ".join([column for column in dataframe])) if print_rows: for row in dataframe.iterrows(): print(", ".join([str(row[column]) for column in datafra...
daa8c48fec6e9727eabe04a9796c424c612bb6c9
ravikr126/Hacktober
/python/game_of_stones.py
527
3.609375
4
#python3 import math import os import random import re import sys # gameOfStones function. def gameOfStones(n): if n==1: return 'Second' elif n>=2 and n<7: return 'First' elif n>=7: if n%7<2: return 'Second' else: return 'First' if __name__ == '__main__': ...
96f13461dabf24f070b51a0d1896da59e5378b71
ChangxingJiang/LeetCode
/未完成题目/0951-1000/1000/1000_Python_1.py
346
3.640625
4
from typing import List class Solution: def mergeStones(self, stones: List[int], K: int) -> int: pass if __name__ == "__main__": print(Solution().mergeStones(stones=[3, 2, 4, 1], K=2)) # 20 print(Solution().mergeStones(stones=[3, 2, 4, 1], K=3)) # -1 print(Solution().mergeStones(stones=[3,...
6da6a28b59921d9be45aa6d302101bd6cba2a974
AlexisAndresGarcia/Programacion-grupo-2
/bixiesto tarea 3. - copia.py
924
3.578125
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 9 16:12:54 2020 @author: Alexis Garcia """ def diasyFecha(año): if año % 4 == 0: return False elif año % 100!= 0 : return True elif año % 400!= 0: return False else: return True def diasymenes(añ...
9664082a2142142401b69ef0de1c17ed2bb6a881
canismajoris7/beklemishevs-worm
/bek worm.py
1,706
3.765625
4
print('welcome to the beklemishev worm game') cl = [int(input('pick size of worm'))] def clprinter(x): r1 = '' r2 = '' r3 = '' r4 = '' r5 = '' for i in x: r1 += " _,.--. " r2 += " " + str(i) + " .'` -" r3 += ".'. .'.'` '``' " r4...
29c89fc51566f11be13b8bd8dfe742340cbcc9af
9394974/PAT
/PAT1005.py
495
3.609375
4
def main(): text = list(input()) res = sum([int(_) for _ in text]) res = str(res) map_data = { '0': 'zero', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nin...
157e60c51c8d75eeea31eaa7d9ce3c9d38b53580
Madhura-Manwadkar/Python_Basic
/DATATYPE_DEMO2.py
1,499
4.25
4
values = [1,2,"rahul",4,5] #List is a datatype that allows multiple values and can be with different datatypes. print(values[0]) #1 print(values[3]) #4 print(values[-1]) #returns the last element print(values[-2]) #returns the last second element print(values[1:4]) #returns the element from 1 and 4 in...
48e833cd9e4d84c666c20fd02530a1c84ec2adb2
buaykap/my-first-blog
/djangogirls/test1.py
110
3.890625
4
print("Burcu") year=2017 info="This is year" print(info+str(year)+"previos year"+str(year)+ " and this year")
4c5be27b77b6fbc490c2263532cbcf70cf8a160a
Datnguyen267/Python
/character_input.py
524
3.953125
4
""" - The Goal: Ask and print user info - Author: Dat Nguyen - Create date: 2018-02-09 """ def character_input(): name = input("What's your name, sir? ") age = int(input("And how old are you? ")) year_to_100 = 100 - age message = "Hello %s, you'll turn 100 in %s years." %(name, year_to_100) print(message) ...
0e56f881dca80838dc8cdb4bbb424b57828d50cf
amogchandrashekar/Leetcode
/Medium/Construct Binary Tree from Preorder and Inorder Traversal.py
1,127
4.09375
4
""" Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given preorder = [3,9,20,15,7] inorder = [9,3,15,20,7] Return the following binary tree: 3 / \ 9 20 / \ 15 7 """ from typing import List #...
0b34cb90933a3c75d6b3137c2812ced492033b13
tayoogunbiyi/30DaysOfAlgos
/Day25.py
499
3.609375
4
def add_to_array(arr,k): j = len(arr)-1 carry = k while j >= 0: total = arr[j] + carry arr[j] = total % 10 carry = total // 10 if total < 10: break j-=1 if carry: return [1] + arr return arr print(add_to_array([1,9,9],1)) print(add_to_...
f97dac7e9d03013202f9ac2b80245588fc5aad17
JoshuaBevers/madlib-creation
/madlib-creation.py
4,430
3.640625
4
# Asks user to submit words for a Michael Bay themed madlib, # then returns the completed madlib #installs import sys def create_madlib(): # Blank madlib blank_madlib = """ __(mans_name)__ is a normal __(occupation)__. Then, one day, a __(noun)__ explodes, causing a __(noun)__ to blow up, and a nearb...
7759cff42fea0d1678234e598f73a7069cb11a6c
krisio/programming_0
/week1/While-Loop-Problems/count_to_user.py
190
3.875
4
n = input("enter a number:") n = int(n) start = 1 end = n while start<=end: print(start) start+=1 start = n end = 1 while start >= end: print(start) start = start - 1
3391b598798e4fae776c8e6283979dda6b5a70a6
tomalley4/rPi-pygame
/game_window.py
797
3.671875
4
import pygame pygame.init() def daylight(time): '''Takes an input of military time e.g. 800 = 8am, 1400 = 2pm and uses that number to select a blue value that varies between 0 (midnight) and 255 (noon). Returns a RGB tuple.''' blue_value = 255 * (1200 - abs(time - 1200)) // 1200 return (0, 0, blue...
46953a11a91618091a24b3042d2fee705f09a3e6
GiovannaK/ecommerce-paypal-payment-method
/utils/utils.py
400
3.609375
4
""" format the price to Real standard """ def formatting_price(val): return f'R$ {val:.2f}'.replace('.', ',') """ Sum the quantity of products in the cart """ def cart_total_qt(cart): return sum([item['quantity'] for item in cart.values()]) """ calculates the total price in the cart """ def cart_totals(c...
eefc63b82be0c480862768ab408c18926c8a3bea
akimi-yano/algorithm-practice
/lc/79.WordSearch.py
2,697
4
4
# 79. Word Search # Medium # 3885 # 190 # Add to List # Share # Given a 2D board and a word, find if the word exists in the grid. # The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used m...
4b6ee8eb08c00a5fd16213c66bd830f53908a21f
lucioferreira/QuestionsCsr
/q1/replace.py
639
3.609375
4
# -*- coding: utf-8 -*- def charCounter( text ): resp = 0 for c in text: if c != " ": resp = resp + 1 return resp if __name__ == '__main__': text = "User is not allowed "; counter = charCounter(text) numSpaces = len(text.split()) - 1 indexLastChar = counter +...
8575e5b43dcf18925332378f778d1c940277da89
yyxiao/pythonDemo
/demo/iterator_demo.py
1,369
3.859375
4
#!/usr/bin/env python3.5 # -*- coding: utf-8 -*- """ 迭代器 __author__ = xyy __mtime__ = 2016/10/31 """ class Account(): def __init__(self, account_name, account_type, account_cost, return_amount=0): self.account_name = account_name self.account_type = account_type self.account_cost = account_...
59612b8da4346ea63c03acfb2930c3a1c7e82810
nick-hu/pyintermediate
/oop/oopintro.py
1,906
4.03125
4
#!/usr/bin/env python class Dog(object): alive = 0 # Class variable def __init__(self, color="white", breed="mutt"): self.color = color # Instance variable self.breed = breed self.__class__.alive += 1 # Or Dog.alive += 1 def __del__(self): self.__class__.alive -= 1 #...
396c9514556ab33c44b0cb25fd07a2c49f01320e
naokiwifruit/lets-start-algorithm
/ch06/1_hash_table.py
380
3.671875
4
def hash_table(arrayD): """ :type arrayD: List[int] :rtype arrayH List[int] """ length = len(arrayD) length = int(1.5 * length) arrayH = [0 for _ in range(length)] i = 0 while i < length: k = arrayD[i] % length while arrayH[k] != 0: k = (k + 1) % length ...
8699f99e474cabbd6e795d2312b56ba09a91fb5f
sebassdc/think-python-practices
/thinkpython/cap10/reversepairs.py
198
3.625
4
__author__ = 'sebassdc' from list import * list = ['amor', 'roma', 'cosa', 'pato', 'olakase', 'otap'] aux = [] for i in list: if reverse_string(i) in list: aux.append(i) print(aux)
89db196dfb5282b3228028b5ee343703d7299953
Chillpudde/studier
/in1000/host2020/uke2/oblig2/fahrenheit_celcius.py
234
3.71875
4
# Oppgave 2. Konvertering temp_f = float(input("Oppgi temperaturen i fahrenheit: ")) # fahrenheit print(f"Temperaturen er {temp_f}F") omregning = "{:.2f}".format((temp_f-32)*(5/9)) print(f"Temperaturen i celcius er: {omregning}C")
7a2c41c2c13e09ce8fbbd92023bb1bd7d9d75673
ravikant95/Ginger
/GAddress/Group.py
990
3.671875
4
from . import Model import logging class Group: def __init__(self): self.group ='' def create_group(self, group_name): """ this is for creating group :param group_name: name of the group :return: instance of group """ try: return Group.get_o...
8f00b405b33ad054c94fad3ad628b94f545a3846
mikelei8291/LearnPython
/exam/stringValidation.py
457
3.609375
4
from sys import argv script, namelist = argv # namelist = "**ali#thomas#ghadi#akmar#smith#barija**" indicator = namelist.startswith("**") and namelist.endswith("**") names = namelist.replace("##", "#").strip("**") hashmarknum = namelist.count("#") + 1 namenum = len(names.split("#")) print(names, hashmarknum, namenum, ...
c592cdd7e216adea87f25fc246a30406cb1db128
meisterk/alg-mergesort
/mergesort.py
3,501
3.8125
4
import unittest # Function mergesort: # Parameter: unsortiertes Array mit Zahlen # Result: sortiertes Array def merge(sortiert1, sortiert2): finger1 = 0 finger2 = 0 laenge1 = len(sortiert1) laenge2 = len(sortiert2) result = [] # beide Finger sind noch in der Liste? while finger1 < laenge1...
680d0b4938be9cbb91a7ea0fe17cf0fb1ea3cfb3
fathimashibila/pythonluminar
/luminarpythonprograms/collections/set/methods.py
1,612
3.59375
4
s={4,6,6,7,8,1,2,2,5,3,"car"} print(s) st={4,6,6,7,8,1,2,2,5,3,"car"} a=st.copy() print(a) st={4,6,6,7,8,1,2,2,5,3,"car"} st.add(9) print(st) st={4,6,6,7,8,1,2,2,5,3,"car"} st.clear() print(st) st={4,6,6,7,8,1,2,2,5,3,"car"} st2={1,2,4,10} st3=st.difference(st2) print(st3) st={4,6,6,7,8,1,2,2,5,3,"car"} st2={1,2,4...
a72ca6aa4f44902427b9a9855741d0c6c21c038c
sholsapp/powertools
/powertools/__init__.py
1,400
4.5
4
import inspect def tree(node, _depth=1): """Print a tree. Sometimes it's useful to print datastructures as a tree. This function prints out a pretty tree with root `node`. A tree is represented as a :class:`dict`, whose keys are node names and values are :class:`dict` objects for sub-trees and :class:`None...
ea4d855d721f78fbfe56db0ca035e8a0da862e15
firmanrizaldi/vitraining
/no.1/liftArraySort.py
1,524
4.15625
4
# No. 1 # ambil tujuan lantai terdekat terlebih dahulu # Misalnya: # Jumlah Orang: 4 # Tujuan Orang 1: Lantai 14 # Tujuan Orang 2: Lantai 20 # Tujuan Orang 3: Lantai 5 # Tujuan Orang 4: Lantai 1 # Posisi Lift sekarang: 10 # Maka: # Lift bergerak turun ke lantai 5, 1 # Lalu...
adbd782257c1a7c63e73bd36dc60ea5ff6b382e1
AntoineAugusti/katas
/codingame/easy/the_chasm.py
702
3.90625
4
R = int(raw_input()) # the length of the road before the gap. G = int(raw_input()) # the length of the gap. L = int(raw_input()) # the length of the landing platform. # game loop while 1: S = int(raw_input()) # the motorbike's speed. X = int(raw_input()) # the position on the road of the motorbike. result = "WAIT"...
fef9ae66dac580c76ffb7592886fd86ab72cd4b4
xietalent/work_code
/spiders/tools/test3.py
174
3.75
4
# import time # # time.clock() # # for i in range(1000000): # i+=1 # # s = time.clock() # print(s) # # res = round(s,2) # print(res) for i in range(1,10): print(i)
33c8d38585ccbd2426ec2368c9de890e28dde65d
yuan-kaixuan-2002/4pm-Python-Class
/Classes/Gradebook/Student.py
359
3.625
4
class Student: def __init__(self,name): self.name = name self.grades = [] def addGrade(self,grade): self.grades.append((int)(grade)) def getAvg(self): sum =0 for x in self.grades: sum += x sum /= len(self.grades) return sum def g...
e7a4ab59c83bbb3dfbf31e8ec76bcf3683c13aa2
joesavak/learn-python
/euler10.py
445
3.515625
4
#using sieve of eratosthenes http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes def primes_sieve(index,limit): limitn = limit+1 not_prime = [False] * limitn primes = [] sumN=0 for i in range(2, limitn): if not_prime[i]: continue for f in range(i*2, limitn, i): ...
5943f2d7dc5f484af4f4285b7c31c34cd3bfc2c7
yejiin/Python-Study
/algorithm/Programmers/Lv1/짝수와 홀수.py
173
3.875
4
def solution(num): return "Odd" if num % 2 == 1 else "Even" # if num % 2 == 0: # answer = "Odd" # else: # answer = "Even" # return answer
8e46e42bc6eaa40826c8076498d7c0fac91fa4cc
iamkissg/leetcode
/interview/拼多多/顺时针螺旋顺序打印二维数组.py
2,232
3.53125
4
from typing import List class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: ''' 20191004 白璧微瑕 ''' if not matrix or not matrix[0]: return [] row, col = len(matrix), len(matrix[0]) i = 0 ans = [] while col ...
193c9d863c7246276c5e24df9cf674cbad279979
Leah1723/OnlineMathSolverExample
/equationsolvers.py
29,403
3.859375
4
#!/usr/bin/env python3 from sympy import Eq, latex, E, symbols, simplify, ln from sympy.parsing.sympy_parser import (parse_expr, convert_equals_signs, implicit_multiplication, standard_transformations, convert_xor) from textwrap import dedent # Linear Equation Solver def linear_solver(sub): r"""Linear Equati...
76f386227521c02cdf62009df1a0298a72d6d0e0
nidhi2802/18IT033_IT374_PythonProgramming_Practical_Tasks
/Week_5/Prac4.py
171
3.6875
4
d = {'British Raj': 200, ' Mughal Empire': 350, 'Delhi Sultanate': 100, 'Maurya Vansh': 150} sorted_d = sorted(d.items(), key = lambda x:x[1]) print("Sorted values:\n",sorted_d)
8d67b04c79323016dddba238ea7cc5b2eb0054c6
monkfungus/FYP
/RaspberryPi/distance_test.py
574
3.8125
4
from math import radians, sin, cos, atan2, sqrt # means lat1 = 53.27867289 lon1 = -6.144917466 # moving lat2 = 53.27859 lon2 = -6.14496 earthRadiusM = 6371000 diffLatR = radians(lat1 - lat2) diffLonR = radians(lon1 - lon2) lat1R = radians(lat1) lat2R = radians(lat2) a = sin(diffLatR/2) * sin(diffLatR/2) + sin(dif...
f22fae767e44a728bbb8695a0be0043117c9c90d
EnochEronmwonsuyiOPHS/Y11Python
/2017NEA_Task1.py
1,023
3.59375
4
#2017NEA_Task1.py #Enoch #Creating subprogram def registration(): # Obtaining detail of player print("League Registration") firstname = str(input("Enter your first name")) lastname = str(input("Enter your last name")) nickname = str(input("Enter your nickname")) emailaddress = str(input("Enter y...
1c570a4cedc530635c8dd88bc9f1cf9a76b0c396
taorea/Python-
/Python基础语法/计算本金和利息.py
258
3.75
4
def interest(money,rate): for i in range(len(money)): money[i] = money[i] * (1 + rate) return money def main(): amount = [1000,2000,3000,4000] rate = 0.01 a = interest(amount,rate) print(amount) print(a) main()
2d5251b93afe651d1da0f7094ba28dd140f5092c
benryan03/Python-Practice
/basic-part1-exercise035-sum_4.py
387
4.0625
4
#https://www.w3resource.com/python-exercises/python-basic-exercises.php #35. Write a Python program that will return true if the two given integer values are equal or their sum or difference is 5. a = int(input("Enter the first number: ")) b = int(input("Enter the second number: ")) if a == b or a + b == 5 or ...
979b9677df3c87f9b4c1a8023b2c98bc61308555
ash0x0/AUC-ProgrammingLanguagePython
/Assignment.1/Qi.py
666
4.21875
4
"""This module receives a string input from the user and counts the a, b, c and other characters and prints the count of each""" # receive user input string x = input("Input string: ") # initialize the counters a_count, b_count, c_count, other_count = 0, 0, 0, 0 # iterate over the string characters for s in x: # i...
665f320082b12109f09fd4f526c0bd99918a60ea
jason-ellis/codeabbey
/python3/002.py
633
4.03125
4
""" Sum in Loop Problem #2 http://www.codeabbey.com/index/task_view/sum-in-loop Now your goal is to learn programming loops - i.e. repeated actions. You are to find sum of several numbers (more than two). It will be useful to do this in loop. Perhaps "for" loop will suit nicely since the amount of values for summation...
80ec776a8fe6ae6d5de856c145533db86458360b
hitliyang2009/python_daily
/datastruct/20170310-Heap_Sort.py
2,611
3.71875
4
#_*_coding:utf-8_*_ __author__ = 'Alex Li' import time,random #end: the last element index of arr, len(arr) - 1 def sift_down(arr, node, end): root = node #print(root,2*root+1,end) while True: # 从root开始对最大堆调整 child = 2 * root +1 #left child if child > end: ...
15cff1e3e0fdd93dc249ac979e51d25154531c81
daviscot/DevNet-High-Cof2020
/DNH-Co2020-Challenge1.py
1,569
3.9375
4
"""DevNet High - Class of 2020 - Challenge 1""" import random import ipaddress # TODO: Write a print statement that displays both the type and value of 'ip' ip = "10.1.1.200" print("value of ip is: ",ip) print("value of str(ip) is: ",str(ip)) print("type of ip is: ",type(ip)) # TODO: Write a conditional to print ou...
d0a0210e65e33c42e2815254291b58f90bfb17a9
drkarthi/wiki-edit-analysis
/clean.py
918
3.515625
4
""" Convert given data to csv format """ import csv f = open('usersContributions_allUsers', encoding='utf-8') lines = f.readlines() csvwriter = csv.writer(open("wiki.csv","w",encoding="utf-8"), delimiter=',', lineterminator='\n') csvwriter.writerow(['Editor','Article','NumEdits']) for line in lines: unclean_flag = ...
c37b3395583accccefce9707a16ae4594166485b
hustlrr/leetcode
/accepted/Fraction to Recurring Decimal.py
999
3.5
4
# coding=utf-8 class Solution(object): def fractionToDecimal(self, numerator, denominator): """ :type numerator: int :type denominator: int :rtype: str """ res = '' # 确定符号 flag = (numerator < 0) ^ (denominator < 0) numerator, denominator = abs ...
d870f2ac223f6a4b00c4cec9fce129cf894e4a24
ilyaShevchuk/-Algorithms-and-data-structures
/Laba2/A.py
539
3.8125
4
import random def quicksort(mas): if len(mas) <= 1: return mas else: q = random.choice(mas) mas_1 = [n for n in mas if n < q] mas_2 = [q] * mas.count(q) mas_3 = [n for n in mas if n > q] return quicksort(mas_1) + mas_2 + quicksort(mas_3) with open('sort.in', 'r') as file: ...
ad6c6555569b8972242a2270e226987fb8b6d19e
god-s-perfect-idiot/Random-tests
/bot4.py
259
3.59375
4
import random hit=[] upper=9 iteration=0 def gen(): a=random.randint(0,upper) return a while(1): p=gen() while p in hit: p=gen() print(str(p)) hit.append(p) iteration+=1 if iteration==upper: upper=str(upper) upper=upper+"9" upper=int(upper)
c9c5555b0201cd8990f4aad2fc3adf38593b9e9d
jrieraster/pildoras
/ejercicio2.py
275
3.671875
4
nombre=(str(input("Introduce el nombre "))) direccion=(str(input("Introduce la direccion "))) telefono=(str(input("Introduce el telefono "))) miLista=[nombre, direccion, telefono] print("Los datos personales son: " + miLista[0] + " " + miLista[1] + " " + miLista[2])
d44da35304db1460d97a1fc5fc043a6a8c687735
anjali0306/Hangman_basic
/hangman_basic.py
224
3.921875
4
word=["hello"] y=[] for i in range (0,5): x=raw_input("Please guess the letters of the word ") print x y.append(x) print y for i in y: if i in word[0]: print("yes") else: print("no")
7043e8731151a572a4b9a6cff4c067ab6b986312
spectraguy/scratchpad
/helloworld/class_demo.py
423
3.796875
4
class Person(object): def __init__(self, name, haircolor): self.haircolor = haircolor self.name = name def say_hi(self): print('Hi, my name is ' + self.name + ' and I have ' + self.haircolor + ' hair') def dye_hair(self, newcolor): self.haircolor = newcolor ben = Person(na...
04d18fd9c873bf32f0abbbc81675f0ac40bccf52
pranesh-sp/open_lab_python
/week 5/heap.py
510
3.515625
4
import heapq N = int(input()) rating = [] top_rating = [] count = 0 while (N >= 1): n1 = input() n2 = n1.split(" ") if (int(n2[0]) == 1): rating.append(int(n2[1])) heapq.heapify(rating) count = count + 1 if (int(n2[0]) == 2): if (int(count / 3) > 0): top_rati...
24fbd46f0662b0443d378b00994d38b403f103ed
Vishad89/heyjude
/Python/interview_questions/sliding window/avg_sum_subarray.py
1,173
4.1875
4
#/usr/bin/python3 """ Given an array, find the average of all contiguous subarrays of size ‘K’ in it. Array: [1, 3, 2, 6, -1, 4, 1, 8, 2], K=5 Output: [2.2, 2.8, 2.4, 3.6, 2.8] """ def find_averages_of_subarrays(k,arr): result = [] windowSum, windowStart = 0.0, 0 for windowEnd in range(len(arr)): ...
66526d80e962fc8d01f19b17c46f678451cb7bb7
bulatnig/textsolutions
/cracking/arrays/1.4.py
615
3.75
4
ALPHABET_SIZE = 256 def is_palindrome_permutation(s: str) -> bool: "TODO document function" if len(s) == 0: return False counters = [0] * ALPHABET_SIZE for c in s: if c.isalpha(): continue idx = ord(c.lower()) counters[idx] += 1 odd_count = 0 for cou...
f98d23c3876eec5abfe6ec3ed32a46cdce7512fd
tianshufu/Leetcode_study
/283.remove0.py
437
3.71875
4
class Solution: def moveZeroes(self, nums) -> None: """ Do not return anything, modify nums in-place instead. """ #define a num to record the number of 0 num=0 for i in nums: if(i==0): nums.remove(i) num+=1 n...
0cb267d22f7baaa4dabcf7bccafa67d3c1486003
erjan/coding_exercises
/shortest_path_in_hidden_grid.py
9,145
3.828125
4
''' This is an interactive problem. There is a robot in a hidden grid, and you are trying to get it from its starting cell to the target cell in this grid. The grid is of size m x n, and each cell in the grid is either empty or blocked. It is guaranteed that the starting cell and the target cell are different, and nei...
ad43cab3b32852b5d143f77ba8ca37a2546994a8
ricknigel/machineLearningCookbook
/chapter3/recipe3-09.py
837
4.15625
4
# 3.9 欠損データの取り扱い # 問題 # DataFrame中の欠損データを特定したい。 import pandas as pd # URLを作成 url = 'https://tinyurl.com/titanic-csv' # データをロード dataframe = pd.read_csv(url) # 欠損値を選択し、2つを表示 print(dataframe[dataframe['Age'].isnull()].head(2)) # 値をNaNで置き換えることを試みる 以下エラーとなる。 # dataframe['Sex'] = dataframe['Sex'].replace('male', NaN) ...
28b2cf89b40fdf6ef32440206b26b38a72625015
dongkunchen/python
/sortedTest.py
652
4.21875
4
#排序: 冒泡 選擇 快速 插入 計數器 #普通排序 list1 = [4,7,2,6,3] list2 = sorted(list1)#默認升序 print(list1) print(list2) # #案絕對值大小排序 list3 = [4,-7,2,6,-3] # #key接受函數來實現自定義排序規則 list4 = sorted(list3, key=abs)#默認升序 print(list3) print(list4) #降序 list5 = [4,7,2,6,3] list6 = sorted(list5, reverse=True)#默認升序reverse反轉 pri...
5c9d0052478f2b9f28b50bcb5d5b3bf372b8f5cb
simsong/ctools
/procfname.py
794
3.6875
4
#!/usr/bin/env python3 """procfname: Open a process and return a filename. Implemented with pipes.""" from subprocess import Popen, PIPE def procfname(cmd, mode='r'): if 'r' in mode: p = Popen(cmd, stdout=PIPE, shell='/bin/sh') fd = p.stdout.fileno() print("fd=", fd) return f"/dev/...
b30115038ce5fe4508b38c2693ced910b4f6c92c
LookADonKill/Python
/Password.py
311
3.71875
4
nama = input("Masukkan nama anda :") Password = input("Masukkan password anda :") if nama == "JX25" and Password == "Juan2305": print("Welcome, Juan Xavier") elif nama == "Plankton" and Password == "karyabhakti82": print("Welcome, Plankton") else : print("Nama atau Passwordnya salah, silahkan coba lagi")
561c4ec28a16d5dc2b9fc3172e9d454cd609f0e5
Mnormansell/catan-start-pos-ai
/catan-spectator/catan/states.py
21,998
3.625
4
""" module states provides catan state machines which semi-correctly implement the State Pattern State Pattern: https://en.wikipedia.org/wiki/State_pattern The Game has a state whose type is one of the GameState types defined in this module. The Game has a dev card state whose type is one of the DevCardPlayabilitySta...
09e33a2a1f7db55999ff3860b28dfdd248a08901
Sobiechh/NeuralNetwork
/nnfs_dataset.py
945
3.578125
4
#from nnfs.dataset import spiral_data import numpy as np import nnfs from nnfs.datasets import spiral_data class Layer_Dense: def __init__(self, inputs, neurons): self.weights = 0.01 * np.random.randn(inputs, neurons) self.biases = np.zeros(shape=(1, neurons)) # Forward pass def forward...
727f3ec4e8caf2ba98baea6e7ab5a7ea488885bb
pombreda/comp304
/Assignment2/a2/Location.py
2,853
3.9375
4
class Location(object): def getMaintenanceEmployee(self): return self.maintenanceEmployee def setMaintenanceEmployee(self, value): self.maintenanceEmployee = value self.maintenanceCoordinates = value.getCoordinates() def getName(self): return self.name ...
510b08e730d88ac8ccc06a1b604a477e26304a2c
HeithRobbins/python_notes
/splitting-method.py
239
3.5
4
tags = 'python,coding,programming,development' list_of_tags = tags.split(',') # Turns the string into a collection print(list_of_tags) list_of_tags = tags.split() # without agruments, turns string into one element print(list_of_tags)
5d336c0017cf06273a5b1b5b683c954046ca244a
JurgenTas/Programming
/Python/Numerical Scripts/solver.py
3,136
3.546875
4
# coding=utf-8 __author__ = 'J Tas' import math as mt import matplotlib.pyplot as plt import numpy as np from scipy import optimize as opt # ===================================================================== def jacobian(x, func, eps=1.e-8): """ Computes forward-difference approximation to Jacobian. ...
4035e527fef3da4bf8f95f395e950b1a1b21035c
ShaoA182739081729371028392/Competitive-Programming
/Data Structures/Hash Tables/KarpRabinStringMatching.py
4,906
3.640625
4
class SimpleRollingHash: def __init__(self, num_buckets, base = 26): self.base = 26 self.num_buckets = num_buckets self.curSum =0 self.cur_len = 0 def reset(self): self.curSum = 0 self.cur_len = 0 def hash(self): ''' Super Simple Hashing function, mod p ''' return self.curS...
f00fc934ac4ba9a8b1186b6f66189e583a090234
CMinne/QA_Gate_V2
/module2.py
1,249
3.578125
4
from tkinter import font import tkinter as tk class SimpleGUIExample: def __init__(self, master): self.master = master self.master.title("A simple Label") self.master.bind('<Configure>', self.resize) self.label_font = font.Font(self.master, family='Arial', size=12, weight='bold') ...
d1efbc371312dcde86c26cfaaf4ce6f372510bbe
dianxiaopao/pythonpro
/test1.py
2,241
3.765625
4
# !/usr/bin/env python # -*-coding:utf-8 import os s = 'lovepython' # 输出从第5个开始至列表末尾的所有元素 print s[4:] # 从0开始计数,娶不到上限 # 输出从第2个开始第4个元素 print s[1:4] print s * 2 lists = ['runoob', 786, 2.23, 'john', 70.2] tinlist = ['test1', 88888] print lists[0] # 输出列表的第一个元素 print lists[1:3] # 输出第二个至第三个的元素 print lists * 2 # 输出列表两...
beff5784a5c208bb879c0834a4afc458c38ce880
SgtSteiner/CursoPython
/src/flower.py
878
4.0625
4
# Ejercicio para demostrar el uso de turtle. import turtle from mypolygon import arco def petalo(t, radio, angulo): """ Dibuja un pétalo con dos arcos de <radio> y <angulo> dados. t es una turtle """ for i in range(2): arco(t, radio, angulo) t.lt(180 - angulo) def flor(t, n_petalos, rad...
0d8f2a3bb2591fa50d613eeaa08c7771ae9ea031
carmonantonio/python_coursera
/regular_expresions.py
432
4.125
4
import re # This program retrieve the host on a email the traditional way data = 'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008' words = data.split() email = words[1] tmp = email.split('@') host = tmp[1] print(email) print(host) # And this lines do the same but in the regex way y = re.findall('@([^ ]*)',data...
7ab7d34622f32deb051a41e9c69249c3ecfeb1dc
Narcissus0606/Python
/class_jc.py
692
4.21875
4
#父类、基类 class Person(object): def __init__(self,name,id_1): self.__name = name self.__id_1 = id_1 def eat(self): print("Person eat!") def __str__(self): return "I'm a person!" #子类、超类、派生类 class Student(Person): def eat(self): print("Student eat!") def __str__(s...
145eb2999e2de62f06ec2b676f2e489bf5c72095
elizabeth19-meet/meet2017y1mini-proj
/snake2.py
2,813
3.65625
4
import turtle import random turtle.tracer(1,0) SIZE_X=800 SIZE_Y=500 turtle.setup(SIZE_X, SIZE_Y) turtle.penup() SQUARE_SIZE = 20 START_LENGTH = 10 pos_list = [] stamp_list = [] food_pos = [] food_stamps = [] snake = turtle.clone() snake.shape('square') turtle.hideturtle() for a in range(START_LENGTH): x_p...
81cddcf49a675a14aa860cf746b98fba9505289d
gym0569/Chinese_company_algorithm_test
/互联网公司笔试题/经典算法_八皇后问题.py
837
3.53125
4
#coding:utf-8 """ 问题描述:在8*8的棋盘上,放置8个皇后,使得8个皇后不互相攻击,一共有多少中解法 思路:显然每一行只能放置一个皇后,使用A[i] = Xi表示第i个皇后放置在Xi位置上, 假设已经将A[0] = X0,..A[i-1] = X(i-1),求A[i]可能的取值。 将A[i]可能的取值从0-7遍历,假设A[i]=Xi,判断是否会攻击,如果不会寻找下一行,如果会,寻找下一个位置 """ count = 0 def queue(A, cur): global count if(8==cur): print(A) count += 1 ret...
e8a5353f015840da0d581ea7058c69dbace1ed84
juyingnan/PythonScripts
/final_1.py
983
3.921875
4
#!/usr/bin/python # Yue Chen class BugPopulation: def __init__(self, initial_size): self.bug_number = initial_size print "Initialized. There are ", self.bug_number, " bugs in Lindley Hall now." def wait(self, time=1): self.bug_number = self.bug_number * (2 ** time) print time,...
19307081494c9b1c5939c98cc9b82c8c89b46ca2
alexanderJPV/webScarping_BeautifulSoup
/webScrapingStore/Funciones_scraping.py
1,047
3.796875
4
#Monitoriza el precio historico def Monitor_Cambios_Precio(precioActual , precioHistorico): if(precioActual < precioHistorico): print("Atención , el producto ha bajado de precio a " + str(precioActual) + "€") #avisar al usuario elif(precioActual > precioHistorico): print("Ha subido de precio a "+ ...
e71f411f2fabf903621de69c3efa0c887490d30e
vittal666/Python-Assignments
/First Assignment/Question_4-[Swapping values].py
112
3.5
4
list = [1, 2, 3, 4] var1 = list.pop(0) var2 = list.pop(2) list.insert(0, var2) list.insert(3, var1) print(list)
7a33d5096ae8a808b8939cd397fbd89c90011508
JDMullally/maze
/maze.py
4,927
3.53125
4
from node import Node import functools import operator foldr = lambda func, acc, xs: functools.reduce(lambda x, y: func(y, x), xs[::-1], acc) class Maze: """Represents the entire maze""" def __init__(self, size): """init function which""" self.maze = {} self.size = size self....
3e597b559e0896e61718db4fdff1ae9768cb9377
Hugens25/School-Projects
/Python/NestedList.py
753
3.90625
4
students = [] student_names = [] student_scores = [] second_place = [] names = ["Harsh","Beria","Varun","Kakunami","Vikas"] scores = [20,20,19,19,21] for i in range(5): name = names[i] score = scores[i] students.append([name, score]) student_names.append(name) student_scores.append(score) minimum...
efcf2afdcc70c6dcd1f62eafb4685221de6a0f64
Sairam-Yeluri/DCA
/Inbuild Functions/Strings/replace().py
136
3.59375
4
str1 = 'spirpm yeluri' str2 = str1.replace('p','a') str3 = str1.replace('k','a') print(str2,str3) str4 = str1.replace('pm','am') print(str4)