blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d4940aba594178c67a075c8d419c4f9923ee3ac2
siddharth15121998/python-programs
/squareroot.py
173
3.78125
4
n1=int(input("enter a number:")) n2=int(input("enter a number:")) n3=int(input("enter a number:")) list1=[n1,n2,n3] def sqr(a): return a**2 print(list(map(sqr,list1)))
aeb13848fcff9e22d1b541d559c3dd76198b8aeb
ResearchInMotion/CloudForce-Python-
/UnboxQuestions/sample.py
615
3.875
4
emp = [] # emp = [[],[][,[]] emp = [['id', 'name', 'Gender', "Sal"]] f = True while f: ch = input('do you want to add datat then press y and exist press n:') if ch == 'n': f = False elif ch == 'y': row = [] i = input('enter id :') name = input('enter name :') g =...
fb303846e73f0a2ab5be9110c2c45c4b23681aa5
ParkerCS/ch15-searches-bernhardtjj
/ch15Lab.py
1,452
4.15625
4
""" Complete the chapter lab at http://programarcadegames.com/index.php?chapter=lab_spell_check """ import re # This function takes in a file of text and returns # a list of words in the file. def split_file(file): return [x for line in file for x in re.findall('[A-Za-z]+(?:\'[A-Za-z]+)?', line.strip())] dict_...
a2cf7d8969902bbbd93799a64ad7cbd863c1f4e5
ThomasCarstens/SelfStudyIRM
/Data_structures/graph.py
4,049
3.546875
4
import numpy as np import math import test import matplotlib.pyplot as plt from collections import deque graph = {'A': ['B', 'C'], 'B': ['C', 'D'], 'C': ['D'], 'D': ['C'], 'E': ['F'], 'F': ['C']} ##file:///home/txa/SelfStudyIRM/Data%20Structure%20and%20Algorithms%20--%20Ouc...
2333cb5815961ac0f5416da4a6ee0de8d5311d5c
roshan2M/edX--mitX--introduction-to-computer-science-and-programming-with-python
/Week 2/Lecture 4 - Functions/In-Video Problems/Lec4.3Slide1.py
504
4.6875
5
# Lecture 4.3, slide 1 # Here, we are taking a number x and raising it to the power p via successive multiplication. # Takes the values of the base and exponent from the user. x = float(raw_input('Enter a number: ')) p = int(raw_input('Enter an integer power: ')) # Sets an intermediate result variable to find the res...
e79184bcd4f378d666baa19eecd1ccd0379772e6
Artarin/Python-Trashbox
/test_new_commands.py
496
3.671875
4
UserInfo = input('введите известные данные пользователя без пробелов: ') UserInversed = UserInfo.swapcase() UserInfo+=UserInversed UserInfo= ''.join(sorted(''.join(set(UserInfo)))) print (UserInfo) FullAlphabet = '0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()' print (set(FullAlphabet)) Difference = ...
8af22689444e7c09a17923e60c314da2129fe7c6
aparecida-gui/learning-python
/exercicios/bolaMagica.py
845
3.984375
4
import random print('Seja bem vindo a bola magica') print() bolaMagica = ['sim', 'provavelmente sim', 'não', 'sem duvida que sim', 'talvez', 'concentre-se e pergunte novamente', 'estou sentindo que sim', 'não crie espectativas'] continuaJogando = True while continuaJogando == True: print('Digite s...
d7c06414f2470076512542745430578f703d26a4
ssolanki/algorithms
/c files/paran.py
945
3.84375
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 isPairMatched( ch1, ch2): if (ch1 == '(' and ch2 == ')'): return 1 els...
1d7fc15007ef57b03a3f836d42f31d0e33a75018
wjpe/EjemplosPython-Cisco
/ej20.py
1,068
3.875
4
# bloques = int(input("Ingrese el número de bloques:")) # # # # Escribe tu código aquí. # # # altura = 0 # base = 0 # while bloques > 0: # if base == 0: # base = base +1 # altura = altura +1 # else: # if bloques > base: # base = base + 1 # bloques = bloques ...
2476406f27835f3c56e17116093bdbfc8409e488
rafalcode/pwtables
/simpmpl0.py
434
3.78125
4
#!/usr/bin/env python import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2*np.pi, 400) y = np.sin(x**2) # Creates just a figure and only one subplot fig, ax = plt.subplots() ax.plot(x, y) ax.set_title('Simple plot') # Creates two subplots and unpacks the output array immediately # f, (ax1, ax2) = ...
0c40990cb123b2649165d295b5788f648c0a79b4
fatihaydnn/Python
/Barbut.py
2,123
3.953125
4
# Oyuncu classı oluşturun # Her oyuncunun bakiyesi olacak. # Para yatırma fonksiyonu olacak # Zar at fonksiyonu olacak # Bilgisayar da yatırılan parayı karşılayacak # Yüksek zar atan tüm parayı alacak from random import randint as r import time class Oyuncu: bakiye = 500 def __init__(sel...
74dbb6db8dc5fcd6727bf1179ffd673db76a6ad0
sstadick/pygrep
/pygrep/pygrep.py
3,464
3.953125
4
#!/usr/bin/env python # Skip Loop # Match Loop # Shift # class BoyerMooreSearch: """Boyer Moore search implememtation""" from string class BoyerMoyer: """ Good general pupose searching algorithm for natural language. made to behave like fgrep -i """ def __init__(self, pattern: str) -> str: ...
2fefb0b82b86c6486b1f78c24ace02104c325602
aumc-bscs5th/Lab-Submissions
/Lab Test -17 Nov 2017/153193/Q4.py
499
3.578125
4
inputString = str(input("Please type a sentence: ")) a = "a" A = "A" e = "e" E = "E" i = "i" I = "I" o = "o" O = "O" u = "u" U = "U" acount = 0 ecount = 0 icount = 0 ocount = 0 ucount = 0 if A or a in stri : acount = acount + 1 if E or e in stri : ecount = ecount + 1 if I or i in str...
410a8c324506d0fc441a3ebcac20753c9dd9277a
lamhuynhb779/xla_ud
/object_detection/myobject.py
493
3.53125
4
class MyObject: def __init__(self): self.id = 0 self.name = "" self.prob = 0 print('Khoi tao doi tuong object') def getId(self): return self.id def setId(self, myid): self.id = myid def getTenDoiTuong(self): return self.name def setTenDoiTuong(self, name): self.name = name def getXacSuat(self...
dbdcbed435a71d33a8d13f0810ea908110731e47
thormeier-fhnw-repos/ip619bb-i4ds02-audio-text-alignment
/lib/test/test_utils/TempFile.py
976
3.734375
4
from tempfile import NamedTemporaryFile import os class TempFile: """ Temporary file for convenience in tests that include opening and reading files. """ def __init__(self, content: str) -> None: """ Initializes a temporary file :param content: File content """ ...
74f34766170c574b594a245cbc51d67677bf830c
estebango/coding-skills-sample-code
/coding205-writing-file-ga/write-file.py
1,924
3.59375
4
# Most basic example of writing to a file # amwhaley@cisco.com # twitter: @mandywhaley # http://developer.cisco.com # http://developer.cisco.com/learning # Jan 15, 2015 # * THIS SAMPLE APPLICATION AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY # * OF ANY KIND BY CISCO, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT...
09ae5f6922ea3b9a61adeaf7226fcd1c7e61f134
neethu567/examplePyth
/dict.py
122
3.53125
4
d={"name":"neethu","age":33,"subjet":['python','maths','physics']} print(d.keys()) print(d.values()) print(d["subjet"][1])
9cafb5b8bf7c088631179ba1f80522d25d2a1205
khangvtran/SeatingChart_OOP
/chart.py
4,214
3.625
4
from seat import * class Chart(): def __init__(self): self._chart = [ ] # initate the List (of lists) keepReading = True while(keepReading): try: fileName = input("Enter a file name or hit Enter to use lab7input2.txt: ") ...
c9d46802f7b8b8538cbedfa9bb8ea54030c84992
getChan/algorithm
/greedy/1339_단어수학.py
210
3.625
4
from collections import defaultdict n = int(input()) # 자릿수의 빈도를 구하자 alphabet = defaultdict([0 for _ in range(10)]) for _ in range(n): word = input() for ch in word[::-1]:
76b7d8c8f0e2c14045b70bb0c843c748398080f2
MintuKrishnan/subrahmanyam-batch
/python_lectures/1. introduction/2.typecast.py
459
4.6875
5
""" This code will show you how to do typecasting Whenever you want a specific type to be converted to another type we say it as typecasting it is simple ;) just wrap data in int() or str() or float() >>> a = "5" a = int("5") """ print("Typecasting from str to int") a = "5" print("before: ", type(a)) a = int("5...
ce85f79aecc95c09bc0f410cc498af41af6c32cc
JamCh01/porter-stemmer
/porter-stemmer/api.py
6,424
3.828125
4
from static import static class Stemmer(object): def __init__(self): self.vowels = 'aeiou' self.cvc_ignore = 'wxy' def is_consonant(self, letter: str) -> bool: # 判断字母是否为辅音 if letter not in self.vowels: return True return False def is_vowel(self, letter...
8ea1e4a728d57dad91858a0119a850a832406a0f
carlosbarcelos/CS4341
/astar.py
24,694
3.625
4
# -*- coding: utf-8 -*- ''' A* Link: https://codeshare.io/alobxj a* ref: http://web.mit.edu/eranki/www/tutorials/search/ a* tutorial: http://www.policyalmanac.org/games/aStarTutorial.htm steps: 1) Begin at the starting point A and add it to an “open list” of squares to be considered. The open list is kind of like a ...
dd4b7dee3cd96a5d7f993199953fca6dcca2ff9d
9929eric/9-24hwd5
/hw5problem1.py
707
3.734375
4
romantic_movie1 = ("The Princess Bride", 1987, 98, "The story of a man and a woman who lived happily ever after.", ["Buttercup", "Westley", "Fezzik", "Inigo Montoya", "Vizzini"]) romantic_movie2 = ("Groundhog Day", 1993, 101, "He's having the day of his life… over and over again.", ["Phil Connors"]) romantic_movie3 = (...
69874fb51329984840a0db97c158ed735916c90e
vlkonageski/Logica
/Python/Exercicio02.py
377
4
4
""" Faça um programa que calcule o estoque medio de uma peça, sendo que: estoque medio = quantidade minima + quantidade maxima / 2 """ qtd_minima = int(input("Informe a quantidade minima da peça: ")) qtd_maxima = int(input("Informe a quantidade maxima da peça: ")) media_estoque = (qtd_minima + qtd_maxima) / 2 p...
460a24b694e41ad51e8f006eedabda2b7fa2dcd3
zhansoft/pythoncourseh200
/Assignment4/moreloops.py
3,403
3.765625
4
# Input Parameter: a list of, possibly empty, numbers x # Returns: the max number in list x (does not have to be unique) def maxFor(xlst): if xlst: maxNumber = xlst[0] for i in xlst: if i > maxNumber: maxNumber = i return maxNumber else: return xlst #T...
97c3ca5990be167c9dea8f73cf61d31804f18bfc
AbnerZhangZN/PythonLearning
/003_advanced characteristics/day004_02.py
683
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #setup 14 高级特性-列表生成式 #单层循环 print([x * x for x in range(1, 11)]) #单层循环后加判断 print([x * x for x in range(1, 11) if x % 2 == 0]) #两层循环 全排列 print([m + n for m in 'ABC' for n in 'XYZ']) import os print([d for d in os.listdir('.')])# os.listdir可以列出文件和目录 d = {'a':'1','b':'2','c...
9d394339d929d92b50bfb26552f0a1d27b02544e
ritikagupta25051998/FSDP2019
/day10/random.py
494
3.8125
4
# -*- coding: utf-8 -*- """ Created on Tue May 14 07:48:06 2019 @author: HP WORLD """ result=eval(input("enter the chara")) print(result) if True: print("qwe") else: print("zxc") import random names=['Mary','Isla','Sem'] code_names=['Mr.Pink','Mr.Orange','Mr.Blonde'] list3=list(map(lambda x: random....
83340646c493ff0d927822fb330bb58fc9e42704
ppen/basicPython
/test.py
215
3.6875
4
# test number = 5 p1 = 5 p2 = 10 if number == 10: print(p1 + p2) else: print(p1*p2) # test print(sum(range(1, 10))) print("Hello World!") # test data = ['physics', 'chemistry', 1997, 2000]; # print(data)
5880d51df4e753d7fa58c5ac246c515439fe4a7d
thedabs91/Scrabble
/WordListUpdater.py
1,097
3.5625
4
# A file to update a word list with additions and deletions # Importing the original word List words_orig = file.open('Words/words_orig', 'r') list_orig = [] for line in words_orig: word = line.strip('\n\r') word = word.upper() list_orig.append(word) words_orig.close() # Additions words_add = file.open('Words/w...
83a82ba825cbba8c7780cabaa48e478b5c3ef144
sashakrasnov/datacamp
/13-introduction-to-data-visualization-with-python/4-analyzing-time-series-and-images/05-plotting-moving-averages.py
1,970
3.84375
4
''' Plotting moving averages In this exercise, you will plot pre-computed moving averages of AAPL stock prices in distinct subplots. * The time series aapl is overlayed in black in each subplot for comparison. * The time series mean_30, mean_75, mean_125, and mean_250 have been computed for you (containing the wi...
3d87c95db1d5cbfe0e31c166a56f29fcfa52941a
diegoaleman/ciu-old
/leet-problems/053-maximum-subarray.py
578
3.5
4
# Kadane's algorithm class Solution: def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ max_value = None prev_max = None for index, val in enumerate(nums): if index == 0: max_value = nums[0] prev...
e5584e56f70a12d004a9100d653cbc267152622e
dsergiyenko/pyneng-examples-exercises
/exercises/18_db/task_18_4/get_data.py
1,223
3.578125
4
# -*- coding: utf-8 -*- import sqlite3 import sys from tabulate import tabulate db_filename = 'dhcp_snooping.db' if len(sys.argv) == 3: key, value = sys.argv[1:] keys = ['vlan', 'mac', 'ip', 'interface', 'switch'] if not key in keys: print('Enter key from {}'.format(', '.join(keys))) else: ...
cf382d4decb18759516e2d8df6bb588890ea8f50
soledadvega/Ingenieria
/testing_varios/test_sut.py
1,736
3.796875
4
import unittest import sut class TestSut(unittest.TestCase): def test_area(self): area = sut.area(3, 2) self.assertTrue(area==6) def test_sumar(self): resultado = sut.sumar(2, 3) self.assertTrue(resultado==5) def test_saludar(self): resultado = sut.saludar("Luz")...
3e4f04d3844a08f3c0f0ed1e9235f807af7c49a6
Samsogo/MachineLearning
/Alex_lei/ML/Numpy/get_elements_from_array.py
507
3.703125
4
import numpy as np arr = np.array(np.arange(12).reshape(3,4)) print(arr) print(arr[0]) #获取二维数组的第一行 print(arr[1]) #获取二维数组的第二行 print(arr[:3]) #获取二维数组的前三行 print(arr[[0,2]]) #获取二维数组的第1行和第三行 print(arr[:,1]) #获取二维数组的第二列 print(arr[:,-2:]) #获取二维数组的后两列 print(arr[:,[0,2]]) #获取二维数组的第一列和第三列 print(arr[1,3]) #获取二维数组的第二行第四列的元...
f0e29227ecd2f68921bc81ceb16f5a1bdd767a75
phlalx/algorithms
/leetcode/542.01-matrix.py
2,440
3.546875
4
# # @lc app=leetcode id=542 lang=python3 # # [542] 01 Matrix # # https://leetcode.com/problems/01-matrix/description/ # # algorithms # Medium (36.68%) # Likes: 804 # Dislikes: 82 # Total Accepted: 52.3K # Total Submissions: 142.7K # Testcase Example: '[[0,0,0],[0,1,0],[0,0,0]]' # # Given a matrix consists of 0 a...
a4ec936c880998078120ad6e0106d5bb07e32159
wangerde/codewars
/python2/kyu_6/mkdir_p.py
762
3.9375
4
# coding=utf-8 """mkdir -p http://www.codewars.com/kata/mkdir-p Write a synchronous function that makes a directory and recursively makes all of its parent directories as necessary. A directory is specified via a sequence of arguments which specify the path. For example: mkdirp('/','tmp','made','some','dir') ....
612c768046467780b665ed234a89c23d4c1532a0
andrew-yt-wong/ITP115
/ITP 115 .py/Labs/ITP115_L10_1_Wong_Andrew.py
1,578
3.90625
4
# Andrew Wong, awong827@usc.edu # ITP 115, Spring 2020 # Lab 10-1 # ---- readDictionaryFile ------------------------------- # # Input: string # Output: list of strings # # Side Effect: None # Description: Read in each word and store it in a list # ------------------------------------------------------- def readDictio...
d3e4990432892386ff8463adbb24977fcc5a0c5f
kvetab/BioinfoToolbox
/Hamming.py
851
3.8125
4
import FASTAparser class HammingDist: # calculates the Hamming distance of two sequences of equal length def Hamming(self, seq1, seq2): dist = 0 str1 = str(seq1) str2 = str(seq2) for i in range(len(str1)): if str1[i] != str2[i]: dist += 1 ret...
3607652c43f915852f3c8449740514bd1b145f6a
zanderobert/GROUP-ASSIGNENT
/banking.py
5,051
3.53125
4
import random class Bank: def __init__(self, BankId, Name, Location): self.bank_id = BankId self.name = Name self.location = Location self.customers = {} self.tellers = {} self.loan = {} self.accounts = {} def add_accounts_info(self, customer_id, account...
39a40cf206f1e258ad5d2ef81b20488cf4d3e4df
luisfe12/desarrollo
/URIPT1/puntos.py
240
3.765625
4
import math x1, y1 = [float(x1,y1) for x1 in raw_input().split()] x2, y2 =[float(x2,y2) for x2 in raw_input().split()] val1 = x2 - x1 val2 = y2 -y1 Distancia = math.sqrt(pow(x2-x1, 2) + pow(y2-y1, 2)) print("{:.4f}".format(Distancia))
ce4221453ce1c9e0d90fee7151486c73ab01daad
scls19fr/openphysic
/python/oreilly/cours_python/solutions/exercice_10_29.py
475
3.90625
4
#! /usr/bin/env python # -*- coding: Latin-1 -*- # Affichage de tables de multiplication nt = [2, 3, 5, 7, 9, 11, 13, 17, 19] def tableMulti(m, n): "renvoie n termes de la table de multiplication par m" ch ="" for i in range(n): v = m * (i+1) # calcul d'un des termes ...
82f752147f144d731de92040ea7aa3479f672863
OhsterTohster/Project-Euler
/Python/q7.py
878
3.859375
4
# What is the 10 001st prime number? #idk whats wrong with the code but something is wrong somewhere because 10001st prime number would mean 10001 elements in the list and thus # primeNumbers[10000] right? import math def checkPrime(num): isPrime = True if (num % 2 == 0): isPrime = False return...
0b7bb66baa9e52dfa4660725addb699b5549394a
minthf/Parseltang
/lab3/koch_curve.py
1,785
3.515625
4
from PIL import Image, ImageColor from PIL import ImageDraw import math as m image = Image.new("RGB", (400, 300)) draw = ImageDraw.Draw(image) class Point: def __init__(self, x, y): self.x = x self.y = y def find_part_of_line(start: Point, end: Point, part): y = (start.y + (part * end.y)) / (1 + part) x = (...
55bf46a98532d956f442bab5c7d1715f9bfaa0eb
priestd09/project_euler
/e_47.py
855
3.640625
4
#!/usr/bin/env python ''' Created on 10 feb. 2012 @author: Julien Lengrand-Lambert DESCRIPTION: Solves problem 47 of Project Euler The first two consecutive numbers to have two distinct prime factors are: 14 = 2*7 15 = 3*5 The first three consecutive numbers to have three distinct prime factors are: 644 = 2^2 * 7 ...
d6637a9b9a288a46c82afbe8ce6014b05fd89e82
vbabushkin/NaoRoboticProject
/relatedPythonProjectsFromDellLaptop/visionOptimization/Shape.py
1,320
3.578125
4
__author__ = 'vahan' class Shape: # color="" # shape="" # centers=[] # contours=[] def __init__(self,color=None,shape=None): if color!=None: self.color=color if shape!=None: self.shape=shape self.centers=[] self.contours=[] def setColor...
0fa14f42b2170ba6bcbd68a1d600464ae3c0b5f3
fulviocanducci/python
/primitives.py
237
3.953125
4
n1 = input('Digite o número: ') n2 = input('Digite o número: ') re = int(n1) + int(n2) print('O resultado é {}'.format(re)) print('O resultado entre', n1, 'e', n2, 'é', re) print('O resultado entre {} e {} é {}'.format(n1, n2, re))
86647bd5c31f2c4dae20e9c9e9ddac40634be9d5
anj339/dtf
/lists.py
448
3.984375
4
import random list = [] for i in range (10) : list.append(random.randrange(1, 999)) print (list) question= input("pick a number from the list") number= int(question) question2= input("Pick another number from the list") number2= int(question2) x= number y= number2 def Maximum_Number(number, num...
d378aa40caf2243958c7b9541ef6dc1c8544b3e3
mitchelloliveira/python-pdti
/Aula01_03082020/aula01_exe08.py
521
4.0625
4
# Curso de Python - PDTI-SENAC/RN # Profº Weskley Bezerra # Mitchell Oliveira # 04/08/2020 # -------------------------------------------------------------- # Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. # Calcule e mostre o total do seu salário no referido mês. val_h...
320c43fadde8753baf6dda74bb934629154f3777
Archanciel/Pygame_2d_Cartesian_coordinates_system
/twodcartesiancoordsystem.py
8,049
3.5
4
import math from constants import * class TwoDCartesianCoordSystem: """ This class has no dependency on Pygame. So, it can be unit tested more efficiently. It hosts the Cartesian axes computation logic used by its subclass PygameTwoDCartesianCoordSystem. """ def __init__(self, origin, xLength, yLength, xRange,...
d92e985b1b01a053cfbf7d976b97d5d6f318dc37
beautiousmax/hint_game
/hint_game.py
2,432
4.1875
4
import random #This is HINT. Like "CLUE", but not copyright infringing. #Here we have a list of options for a murder. Char = ["Mrs. Scarlet", "Col. Mustard", "Ms. White", "Mr. Green", "Rebecca Black", "Blue Man Group"] Weapon = ["Gun", "Candle Stick", "Lead Pipe", "Antifreeze", "Wrench", "Rope", "Ar...
dd85a717ed1243c5cb7ff1b1e10ef9f8ae1fcbdf
s-surineni/atice
/code_chef/covid_run.py
555
3.609375
4
# https://www.codechef.com/OCT20B/problems/CVDRUN tc = int(input().strip()) def solve(): city_count, hop_dist, start, melive = [int(i) for i in input().strip().split()] # <!TODO> see why this is a failure # if city_count % 2: # return 'YES' curr_city ...
2daef6ed8e06557301821c03e0a98ab4ba699c2d
arjunkorandla/automationlearning
/arjun2/forloop.py
1,078
3.71875
4
for i in range(1,12): print("the counting value of: {:4}".format(i)) num= "123,156,23,86561,846" for i in range(0,len(num)): print(num[i]) for i in range(0,len(num)): if num[i] in '0123456789': print(num[i]) for i in range(0,len(num)): if num[i] in '0123456789': print(num[i],end='') c...
2bf957987e06a418b5c5988280e8720abe610135
HeithRobbins/python_notes
/replace-function.py
290
3.921875
4
sentence = 'The quick brown fox jumped over the lazy dog' sentence = sentence.replace('quick', 'slow') print(sentence) sentence = 'The quick brown fox jumped over the lazy dog.' sentence = sentence.replace('quick', 'slow') sentence = sentence.replace('slow', 'fast') print(sentence)
6a51badb0ab0b679fa4b1a783768ca8f160a4b40
wangsiyang68/Coding-Pains
/Content Notes/Problem Solving/Algorithms/Sorting/Self Learn Sorting Exercise.py
2,812
4.21875
4
##sorting exercise import random import time ##implement bubble, insertion and quick sort def bubble_sort(my_list): for i in range(0, len(my_list)): for j in range(0, len(my_list)-i-1): if my_list[j] > my_list[j+1]: my_list[j], my_list[j+1] = my_list[j+1],my_list[j] return ...
a01b5121cc8788d17c3fe07052616480a4d529de
iqram1337/komputasi_geofisika
/exercise 3.2 (pert 2).py
108
3.625
4
ans = 0 for i in range(2, 12, 2): print(i, end =' ') ans = ans + i print('') print(ans)
1c64fb54cd7e8bffa89060790db648e5e309d643
oucler/DLND-Bike-Sharing-Project
/multipleLayers.py
9,246
3.859375
4
import numpy as np np.random.seed(21) class NeuralNetworkMultiLayers(object): def __init__(self, input_nodes, hidden1_nodes, hidden2_nodes,hidden3_nodes, output_nodes, learning_rate): # Set number of nodes in input, hidden and output layers. self.input_nodes = input_nodes self.hidden1_n...
ab1a83ffb91909966c799cde082c52a1dfc4d5dc
bFraley/python-examples
/TRAVIS_BAUMANN.py
752
4.40625
4
""" # Number one will be a random number generator using the "random" function. In the print section I get to choose my chosen integer range, dissected by commas. This program basically simulates a 6-sided dice """ from random import randint print (randint(1,6)) """ # HEX function this will convert any number int...
193784c22f38b819e3ec57e91ceceb309a16d9c4
pontushojer/rosalind
/tree.py
1,463
3.71875
4
#!/usr/bin/env python3 """ Problem: Completing a Tree url: http://rosalind.info/problems/tree/ Given: A positive integer nn (n≤1000n≤1000) and an adjacency list corresponding to a graph on nn nodes that contains no cycles. Return: The minimum number of edges that can be added to the graph to produce a tree. """ def...
6ce72bf638e319d62acd972ed3ddfda559246f4d
salamba-eric/BMI-calculator
/BMI_calculator.py
3,118
3.59375
4
import sign_up import pymongo from tkinter import * from pymongo import * window = Tk() client = MongoClient() Data_Base = client.BMI users_data = Data_Base.users_data #def calculate_bmi(): # Calculating function # def metric_calculator(): # Clear what's on the space # BMI_display_entry.delete(0, 'end') #Get...
cc12b2e4ba04e4a82b02a3b0c76f26331e7f9009
NikhilaBanukumar/GeeksForGeeks-and-Leetcode
/strings16.py
1,030
3.546875
4
def pallindrome(strings,k,l): m=k for n in range(l,k,-1): if strings[m]!=strings[n]: return False m+=1 return True def find_pallindrome_substrings(strings,i,j): count=0 for k in range(i,j+1,1): count+=1 for l in range(j,k,-1): pallin=pallindr...
58a62b3469fcebcfa331df5bb01dc6201f04c889
Srishti20022/Python-basics
/numpy/array3.py
700
3.671875
4
# to compare time and space took by array and list import numpy as np import time import sys list_1 = list(range(1000)) # get size functions used to get size of any function print("size of lst : ", end = ' ') print(sys.getsizeof(list_1)) array_1 = np.array(list(range(1000))) array_2 = np.array(list(range(1000)...
38ab336fff18c2525a48eccfcff3d45eb01b6977
aliceturino/learning-python-projects
/bmi-calculator.py
621
4.375
4
# 🚨 Don't change the code below 👇 height = input("enter your height in m: ") weight = input("enter your weight in kg: ") # 🚨 Don't change the code above 👆 #Write your code below this line 👇 height = float(height) weight = float(weight) BMI = weight / height ** 2 print("Your BMI is " + str(int(BMI))) #extra que e...
6a87a72becf7ed4a55b25dacdf48e6d88157ed93
Yuto-kimura/data-management
/datamanagement.py
576
3.796875
4
import random class MenuItem: def road(self): print("Rolling the dice...") def dais(self,daisA,daisB): print("Die:"+str(daisA)) print("Die:"+str(daisB)) def hello(self): print("Hello,"+self.name+"!") menu_item1 = MenuItem() print("What is your name?") menu_item1.name = inp...
e4fa6bc6a1eea3c84519e91fc284667ac83919d6
BobIT37/Python3Programming
/venv/03-Methods and Functions/04-Function Level 1 Solutions.py
319
4.0625
4
# Level 1 Problems' solution def old_macdonald(name): if len(name) > 3: return name[:3].capitalize() + name[3:].capitalize() else: return "name is too short!" print(old_macdonald('macdonald')) def master_yoda(text): return ' '.join(text.split()[::-1]) print(master_yoda('We are ready'))
4e2732888bd2d6440a808f505a4c5782747d120f
mdk44/OtherProjects
/Avalon/Avalon.py
836
3.65625
4
# Avalon Test import random character_list = { 0: 'Merlin', # Knows all evil except Mordred 1: 'Percival', # Knows who Merlin is 2: 'Loyal Servant of Arthur', 3: 'Loyal Servant of Arthur', 4: 'Loyal Servant of Arthur', 5: 'Loyal Servant of Arthur', 6: 'Loyal Servant of Arthur', ...
e80bf29a01d65ee42a2b383809eebed9a2d57ce6
Infra1515/Automate-the-boring-stuff
/CH5_Fantasy_game_inventory.py
735
3.84375
4
#! python 3 # Fantasy game inventory + list_to_dict function stuff = {'Arrows': 2, 'Belt': 1, 'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'Arrows': 12} dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby'] def displayInventory(inventory): print ('Inventory: ') item_total = 0 for ...
b6dd84d51b0bacac1a604cdf72156aa0343365f5
Wu22e/JUNGLE_DS_ALGO
/WEEK01/B4[2588] 곱셈.py
208
3.578125
4
a=input() b=input() a=int(a) b=int(b) location100=b//100 location10=(b-location100*100)//10 location1=b-location100*100-location10*10 print(a*location1) print(a*location10) print(a*location100) print(a*b)
aec7a69ede6151eaa36af402b1f563d972ccdeaf
Muhammad-Hozefa-Haider/Probability-Statistics-Project
/task5.py
1,632
3.578125
4
import turtle import random import matplotlib.pyplot as plt # t = turtle.Turtle() t.speed(0) t.penup() t.setposition(0,-100) t.pendown() t.pensize(3) t.fillcolor("green") t.begin_fill() t.circle(100) t.end_fill() t.penup() t.setposition(0,0) t.pendown() t.hideturtle() t.color("yellow") # t.penup(...
811634a9a923ad4f329619a62cd880ccd6d5f5ef
prashant-subedi/Ellastic-Collision-Game
/graphics_final.py
8,240
3.8125
4
import numpy as np import pygame class Ball: """Define physics of elastic collision.""" def __init__(self, mass, radius, position, velocity): """Initialize a Ball object mass the mass of ball radius the radius of ball position the position vector of ball velocity the v...
e396ca4d51c42c278ef6a6c517d380bc8dd4bcb1
faradayyg/data-structures-python
/linked_list.py
436
3.8125
4
#!/usr/bin/python3 from LinkedList.LinkedList import LinkedList linked_list = LinkedList() linked_list.insert_start(23) linked_list.insert_start(33) linked_list.insert_start(36) linked_list.traverse() print('\n\n ==== ') linked_list.remove(23) print(linked_list.size()) linked_list.traverse() print('\n\n ==== ') l...
78cf6d6ad0d0e5fd8a0f1dbae14ce870bae37ac2
DhilipBinny/Python_for_everybody
/Python Data Structures/week 4/Assignment 8.4.py
251
4.0625
4
fname = input("Enter file name: ") fh = open(fname) list = [] for line in fh: line = line.rstrip() words = line.split(' ') for word in words: if word not in list: list.append(word) list.sort() print (list)
5040332e6103d3d69fcbc276a335c66e85fe53a5
syurskyi/Algorithms_and_Data_Structure
/_algorithms_challenges/leetcode/LeetCode/670 Maximum Swap.py
1,173
3.828125
4
#!/usr/bin/python3 """ Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get. Example 1: Input: 2736 Output: 7236 Explanation: Swap the number 2 and the number 7. Example 2: Input: 9973 Output: 9973 Explanation: No swap. No...
0c9caf4322140428c3437cd3663c4943f01bea5c
martinearlz/PSB-Quiz-Application
/logic.py
5,325
3.640625
4
"""This script stores the train logic class that contains all the program-related functions.""" from variables import Variables variables = Variables() class Logic: def __init__(self): self.username = "" def login(self, username, password): # Load the users dictionary, users = variab...
544f1775e6fb234fd26f439da84c37961f76522b
wjjameslee/ATMController
/account.py
691
3.703125
4
class Account: def __init__(self, balance=0, limit=0): self.balance = balance self.limit = limit def deposit(self, amount): self.balance += amount print("Successfully deposited $" + str(amount) + ".") def withdraw(self, amount): if amount > self.limit: ...
35a7ffdf07c41e67d128e6205b1b3772ee0db3d1
bedros-bzdigian/intro-to-python
/week 4/homework/problem7.py
159
3.6875
4
list4 = [[10,20,40], [40,50,60] , [70,80,90] ] list5 = list4.copy() for x in range (0,3): list5[x][2] = 100 print ("list4 ", list4) print ("list5 ", list5)
e458218b8170dd2174a8961b4b37462a6d2dc72b
Lancelot1106/HU_AI_Blok_C
/Structured Programming/Simple Algorithm.py
1,909
3.734375
4
from random import randint from itertools import * code = "ABCD" def Allcombos(): """creates a list with all options for the AI to choose from the first time around""" global allcombos allcombos = [] results = product("ABCDEF", repeat=4) allcombos = resulttolist(results) return AIpicks(...
d0f73b1a92c80e39f2e5c7d09d5163c9d18e2316
charlesfranciscodev/codingame
/clash-of-code/fastest/calc-weight/calc_weight.py
713
4
4
def calculate_actual_weight(body_weight, repetitions, exercise_type, added_weight): if exercise_type == 'bp': actual_weight = (added_weight + 20) * repetitions elif exercise_type == 'lp': actual_weight = (added_weight + 47) * repetitions elif exercise_type == 'p': actual_weight = (ad...
006074011ebe991f9728982aa7aa47cb76474aaa
Edgar-La/Machine_Learning
/Bounds_classifier_comparison/FFNN_module.py
5,147
3.9375
4
#Feed Forward Neural Network import numpy as np import pandas as pd #This is for avoid future warning: RuntimeWarning: overflow encountered in exp from scipy.special import expit def sigmoid(s): # Activation function return 1 / (1 + np.exp(-s)) def sigmoid_prime(s): # Derivative of the sigmoid retur...
812f9e8540e14921b96fc088c09b399458ef7158
dwangproof/1337c0d3
/33_Search_in_Rotated_Sorted_Array/solution.py
1,707
3.984375
4
""" Problem: 33. Search in Rotated Sorted Array Url: https://leetcode.com/problems/search-in-rotated-sorted-array/ Author: David Wang Date: 09/05/2019 """ class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ ...
7f603f7f5a4adc4adf29202997b9aac554583b38
irobbwu/Python-3.7-Study-Note
/basic Grammar/09. 序列.py
1,600
3.859375
4
# 10.1 作业 # 序列 1)list():把一个可迭代的对象转换为列表 2)tuple([iterable]):把一个可迭代的对象转化为元组 3)str(obj):把obj对象转化为字符串 4)max(),min():返回序列或者参数集合中的最大或最小值 5)sum(iterable[,start=0]):返回序列iterable和可选参数start的总和 6)sorted():返回排序的列表,默认从小到大 7)reversed():翻转 8)enumerate():枚举,生成由每个元素索引值和元素组成的元组 9)zip():返回各个参数的序列组成的元组 # 1.猜想一下 min() 这个BIF的实现...
48adb6d155e12f1c328975f5e49b52ead71a8993
Sergey-Laznenko/Stepik
/Generation Python - A Beginner's Course/13_Functions/13.4(return)/9.py
574
4.15625
4
""" Напишите функцию number_of_factors(num), принимающую в качестве аргумента число и возвращающую количество делителей данного числа. """ # 1 вариант def get_factors(num): score = 0 for i in range(1, num + 1): if num % i == 0: score += 1 return score n = int(input()) print(get_facto...
a1e6f671c20c752acc89d6150e89d414b3dbbc76
nesen2019/everyday
/ctasks/year_2021/month_07/day_20210702/L00100304.py
1,052
3.59375
4
''' 剑指 Offer 42.连续子数组的最大和 LCOF 剑指 Offer 42.连续子数组的最大和 https://leetcode-cn.com/problems/ lian-xu-zi-shu-zu-de-zui-da-he-lcof 输入一个整型数组,数组中的一个或连续多个整数组成一个子数组。求所有子数组的和的最大值。 要求时间复杂度为O(n)。   示例1: 输入: nums = [-2,1,-3,4,-1,2,1,-5,4] 输出: 6 解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。   提示: 1 <= arr.length <= 10^5 -100 <= arr[i] <= 100 注意:本...
b4e01a92c1c5a7256c607f50be52fac6b193222b
architarora/TowerDefenseGame
/Enemy.py
5,161
3.71875
4
""" Enemy.py Creates and moves the enemy (balloons) throughout the screen """ import pygame import sys import random import math from random import uniform from os import path from settings import * class Enemy(pygame.sprite.Sprite): def __init__(self,game): self.groups = game.all_sprites, game.enemy ...
25827995c5edd8dced9f808e610e3176015d7971
zero1hac/cp-practice
/spoj/CANDY3.py
176
3.5
4
T = int(raw_input()) while T>0: N = int(raw_input()) K = N sumi=0 while N>0: x = int(raw_input()) sumi+=x N-=1 if sumi%K==0: print "YES" else: print "NO" T-=1
54fe11fafa60259a5699c31ad9de2c0c6317aa95
Mr-alan9693/cursoemvideopython
/Tinta para pintar parede.py
255
3.875
4
altura = float(input('Digite a altura da parede: ')) largura = float(input('Digite a largura da parede: ')) area = altura * largura litros = area / 2 print('Para pintar uma parede de {:.2f}m2, você vai precisar de {:.1f} l de tinta'.format(area, litros))
873593a04b62a80e765eabed5f65dda791c40d99
wenlins/Python-Self-study
/2.第二节课.py
552
3.59375
4
good = str(input('您感觉怎么样:')) print('I\'m a student') print(good) print("您好最近怎么样,我想你有一个",good,'的一天') print("您好\n最近怎么样,我想你有一个",good,'的一天') print("\v祝你好运\t\v每天开心") print('%s\n'*2 %('祝你好运','每天开心')) print('%d\n'*2 %(3.14,1.414)) print('%.3f\n'*2 %(3.14,1.414)) print('%s%.3f\n'*2 %('祝你好运',3.14,'每天开心',1.414)) A=1 A...
0b2b674abbba7374ff239b8dc73ecb2e8e5b0abb
HorseSF/pp_Python
/sample/05_set_dictionary.py
1,088
4.03125
4
s1={3,4,5} # 判断对象是否在集合里 print("判断3是否在集合中") print(3 in s1) print("判断10是否不在集合中") print(10 not in s1) print("------------") s2={4,5,6,7} # 交集 print("交集") s3=s1&s2 print(s3) print("------------") # 连集 print("连集") s3=s1|s2 print(s3) print("------------") # 差集 print("差集") s3=s1-s2 print(s3) print("------------") # 反交集 ...
1f77092d2fd20920b5a31e800edc950e1f1caad2
gptech/python
/investment.py
471
3.8125
4
from __future__ import division from decimal import Decimal def invest(amount, rate, time): print "Principle amount: $%d " %amount print "annual rate of return: %r " %rate #Take the amount of years and use it in a range and print out that corresponding year #The year is based off of this total formula $1,00...
f09304f93d018cda2d9234d5b5d3abbaf432719a
NiamV/SortingAlgorithms
/quick.py
604
3.875
4
def quickIter(xs, steps): if xs == []: return [], steps pivot = xs[0] less, same, more = [], [], [] for x in xs: nextstep = [] for y in xs: nextstep.append(y) steps.append(nextstep) print(less, same, more, xs) if x < pivot: ...
625a34ab6d4eed80b35f40a787b54e99b24eb78a
Shyzay/Solutions-to-Problem-3-and-4-Algorithm-and-data-structure-
/problem4/SearchingAndSortingD.py
4,931
3.875
4
#------------------------------------------------------------------------------- # Name: Implementing the in method (__contains__) for the hash table Map ADT # Two contain methods one to check for keys and the other for the value # Purpose:Education # # Author: mmk and emeka # # Created: 07/09/201...
8f45971d766dd5dea450c9b9802e49551121fe84
erikkaplun/tmp-proxy
/rain-proxy.py
3,940
3.625
4
#!/usr/bin/python # coding: utf-8 import socket import select import sys import os if sys.version_info > (3, 0, 0): #print "This version of python is not supported!\nPlease download python 2.x" sys.exit(1) def console_write(text): if os.name == 'nt': with open("dump.txt", "a+") as f: ...
b8acdc3ca577e1c469c1aab67135059bc025b2e7
VirtualMe64/jeopardy-sim
/player.py
1,380
3.75
4
import random class Player: def __init__(self, p_know, p_correct, buzzer_skill, daily_double_strat, final_jeopardy_strat, pick_question_strat): ''' param p_know: Probability of 'knowing' question - deciding to buzz in\n param p_correct: Probability of getting question correct after buzzing ...
44418d41b360bb17d4540d96c648c7078734f633
kenberman/NextGen
/Problems_Conditionals_Set1.py
1,574
4.0625
4
import random # won = False # # Win = random.randint(1, 5) # while won == False: # guess = int(input('Guess the Number: ')) # message = 'You Win.' # if guess > Win: # print('Number is too high.') # elif guess < Win: # print('Number is too low.') # elif guess == Win: # print(...
105640121098a722ca18f509a828a5e7dfdb1d6f
rodrigotoro/Rosalind
/exercises/lia.py
1,000
3.640625
4
import argparse from math import factorial sample_dataset = "2 1" sample_output = "0.684" def heterozygous_organisms_prob(k, n): prob_double_het = 0.25 prob_other = 1 - prob_double_het num_organisms = 2 ** k prob = 0 for i in range(n, num_organisms + 1): k_combinations = factorial(num_...
82ad3c3928b623fdb4931bada45bd299e2c1b887
ong-ekken/nlp100knocks-rev2
/03_pi.py
443
4.15625
4
#!/usr/bin/env python3 """ 03. pi Split the sentence “Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics”. into words, and create a list whose element presents the number of alphabetical letters in the corresponding word. """ S = ("Now I need a drink, alcoholic of course...
36971fa2e3b2e68bc1fc99c49066c0d0a66ea29f
kookminYeji/SW-Proj2-class1-3
/Byeongjo/Byeongjo_week4/assignment4_factorial_combination_recursive_20171593.py
352
4
4
def factorial(n) : if n == 1 or n == 0 or n == -1: return 1 else : return n * factorial(n-1) n = int(input("Enter n : ")) m = int(input("Enter m : ")) c = factorial(n-1) d = factorial(m) e = factorial((n-1)-m) f = int(c/(d*e)) d = factorial(m-1) e = factorial((n-1)-(m-1)) g = int(c/(d*e)) pri...
9774fcc0ae93a565ff16c3426e8f8a70bad5251f
phantomrush/untitled
/client2.py
1,170
4.0625
4
# Import socket module import socket # Create a socket object class client: def __init__(self,username,port): # Create a socket object self.s = socket.socket() # Define the port on which you want to connect self.port = port self.username = username self.connecting_m...
fce109e13934270ee5392f3b3644caff8e4e6142
lbordino/unipy
/es1.py
285
3.640625
4
V_UNO = input("inserisci il valore 1 :") V_DUE = input("inserisci il valore 2: ") def somma(a,b): return a + b def prodotto(a,b): return a * b def v_medio(a,b): return (a + b)/2 def dist(a,b): return abs(somma(a,b)) print(max(V_UNO,V_DUE)) print(min(V_UNO,V_DUE))
2695ccf531a9c4403c540a5f98e4911841344ee5
Musa6630/my_program
/hackerrank.py
96
3.765625
4
Input = input() Answer = '' for i in range(1,Input+1): Answer += str(i) print(Answer)
ea102dda35073b7b4f900164fe604f45994d6f49
lichen911/adventofcode
/2018/day2.py
2,656
3.5625
4
<<<<<<< HEAD from collections import Counter input_file = 'day2_input.txt' box_counts = { 'twice': 0, 'thrice': 0 } def char_appears_twice(box_code): char_counts = Counter(box_code) for value in char_counts.values(): if value == 2: return True return False d...