blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
5e37c5b027d1268b3408c2c2029b47364e7c5b51
mohsenti/compare-programming-languages
/p.py
297
3.859375
4
# import time # start_time = time.time() pc=0 def isPrime(number): for x in range(2,number - 1): if (number % x == 0): return False return True for a in range(2,2000): if(isPrime(a)): pc=pc+1 # print("X") # print("") # print(pc,"--- %s seconds ---" % ((time.time() - start_time)*1000))
310198f1bd58e389257ba72ab57e7ef04115ff1b
SinghKaranbir/Python
/reminder.py
697
4.09375
4
names = input("Enter the name of the students seprated by comas: ").split(',') assignments = input("Enter the no of assignments left: ").split(',') grades = input("Enter current grades of the students: ").split(',') estimate_grades = input("Enter estimation of grades if assignments gets submitted: ").split(',') message...
9427d6600bbc0fed4ba2078f66cff819d9ba124a
dayoladejo/SwarmOptimization
/RandomInitializer.py
1,422
3.828125
4
# # file: RandomInitialize.py # # Initialize a swarm uniformly within the bounds. # # RTK, 07-Dec-2019 # Last update: 09-Dec-2019 # ################################################################ import numpy as np ################################################################ # RandomInitializer # class Ra...
1b00fb5fdf01aef61d44a81aa72438d7e105d41a
edfano/PycharmProjects
/List_comprehension1.py
93
3.625
4
s=["a","b","c"] #U=[print(x.upper()) for x in s] U=[(x.upper()) for x in s] print(U)
d0d118fe3a88f33f1c18d12c565e9e83620fe9f8
spettigrew/cs2-codesignal-practice-tests
/truck_tour.py
2,736
4.5
4
""" Suppose there is a circle. There are N petrol pumps on that circle. Petrol pumps are numbered 0 to (N - 1) (both inclusive). You have two pieces of information corresponding to each of the petrol pump: (1) the amount of petrol that particular petrol pump will give, and (2) the distance from that petrol pump to the ...
53ba03e8e1cbb013f566be89f6b0df2722a7319d
spettigrew/cs2-codesignal-practice-tests
/roman-to-integer.py
2,820
4.25
4
""" Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two one's added together. 12 is writt...
d9bc3016a040ecb9b68e404cf4a9244ed6ee81a6
spettigrew/cs2-codesignal-practice-tests
/anagrams.py
2,712
4.46875
4
""" A student is taking a cryptography class and has found anagrams to be very useful. Two strings are anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in the same exact frequency. For example, bacdc and dc...
e024d53bd92e5775bf8e1484ac7607b38c6bd244
spettigrew/cs2-codesignal-practice-tests
/n_integer.py
1,184
3.796875
4
""" This is a demo task. Write a function: def solution(A) that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. Given A = [1, 2, 3], the function should return 4. Given A = [−1, −3]...
7a23fa146415edbafd118056320b1859689a7dc5
thomasmcclellan/pythonfundamentals
/02.02_strings_printFormatting.py
198
4.09375
4
x = ("Insert another string here: {}".format('INSERT ME!')) print(x) y = "Item 1: {}, Item 2: {}".format('dog', 'cat') print(y) z = "Item 1: {x}, Item 2: {y}".format(x = 'dog', y = 'cat') print(z)
307c0d178659494d3639d78df5f4b1bd1dfc9607
thomasmcclellan/pythonfundamentals
/02.01_strings.py
525
4.21875
4
# Strings hold text info and hold "" or '' # Can have [] 'hello' "hello" "I'm a dog" my_string = 'abcdefg' print(my_string) print(my_string[0]) print(my_string[3:]) print(my_string[:3]) #Goes up to, BUT NOT INCLUDING the number print(my_string[2:5]) print(my_string[::]) print(my_string[::2]) #The number is the step s...
db9b0664ad2182357ef7700c226e075064a81cb0
meganwhite/assignments
/sayhello.py
225
4.09375
4
#!/usr/bin/env python2 #This is importing the person's name import sys #This is assigning the input to a variable name = sys.stdin.read() #This is printing the person's name based on input print "Hello " + name + "!" #hello?
d06bfab759a239109461a7b4750fd7654ca0a885
AndrewsMota/PythonListas
/listBiblioteca.py
6,273
3.96875
4
Questão 1 cod = []#CÓDIGO titl = []#TÍTULO qntd = []#QUANTIDADE mat = []#MATRÍCULA emp = []#EMPRÉSTIMO livr = []#LIVRO solic = []#SOLICITAÇÃO while True: print('[1] Cadastrar exemplar') print('[2] Registrar empréstimo') print('[3] Emitir relatório de empréstimos') print('[4] Indicar livr...
646c590662f0f8c7236f3c9ca13b59aac39711c1
mihneaciorica/notiunipython
/firstsqlitecursor.py
1,962
3.765625
4
import sqlite3 conn = sqlite3.connect('emaildb.sqlite') cur = conn.cursor() cur.execute('DROP TABLE IF EXISTS Counts') cur.execute(''' CREATE TABLE Counts (org TEXT, count INTEGER)''') fname = input('Enter file name: ') if (len(fname) < 1): fname = 'mbox.txt' fh = open(fname) for line in fh: if not line.startsw...
7a8ba79ac5faf354c7d8c5752274b18ac1ade7c9
alaasal95/problem-solving
/StudentsMarks.py
182
3.578125
4
m=[None]*3 i=0 while(i<3): n=int(input('enter num=')) m[i]=n i=i+1 print(m,type(m)) while(i<3): if(m[i] <50 or m[i]>100): print()
f87960e8c7639be822b395665a4130f0fce7363b
alaasal95/problem-solving
/recursion.py
361
3.796875
4
# def tri_recursion(k): # if(k > 0): # result = k + tri_recursion(k - 1) # print(result) # else: # result = 0 # return result # # print("\n\nRecursion Example Results") # tri_recursion(6) def Alaa1(nu): if(nu > 0): r=nu + Alaa1(nu - 1) print(r) else: ...
f3882831f37a57d5d52c96b284ed98f8ee0308f0
alaasal95/problem-solving
/check_oddEven.py
146
4.25
4
num=int(input('Plese enter number:')) if (num %2 == 0): print('this number it is Even') elif (not(num %2 )==0): print('odd')
d7c16c08b73fa5b2a45356431d35416a2e30155e
alaasal95/problem-solving
/Convert_second _to_hour_min_second.py
323
4.15625
4
''' ----->Ex:// read an integer value(T) representing time in seconds and converts it to equivalent hours(hr),minutes(mn)and second(sec) ''' p1=int p2=int p3=int second=4000 p1=second%60 p2=second/60 print('p2_',p2) p3=p2%60 print('p2',p2) p2=p2/60 print(p2 ,":",p3,":",p1...
20714f72f814a3370e32eca310a59eff287d146a
alaasal95/problem-solving
/Uppercase_counts.py
853
4.03125
4
''' ----->Ex:// using function to counts uppercase letter in 20 letters entered by the user in the main program. ''' def main(): Alaa() def Alaa(): n=input('enter letter=') uppercase(n) lowercase(n) def uppercase(n): uppercase = ['A', ...
bbd015bcf5c2d65a04c3e4194dac55d827a3d2f1
alaasal95/problem-solving
/number invers.py
562
4.09375
4
# # t=' alaa salim' print( t.capitalize()) print(t.upper()) print(t.center(45)) #يقوم بالغاء المسافات print(t.strip()) print(t.replace('alaa','star')) #يعكس الكبتل الى سمول والسمول الى كبتل print(t.swapcase()) #to check if it can make it printing or nor print(t.isprintable()) print(t.isdecimal()) ...
eb0a9dd345b17da5c74655bbbd118d670cb1cfec
alaasal95/problem-solving
/sum&Sub.py
337
3.859375
4
#----> Sum=(1)^x-(3)^x+(5)^x-...+(n)^x i=1 sum=0 n=int(input('Enter last number {n}=')) x=int(input('Enter Upper number{x}=')) while(i<=n): if(sum>0): sum=sum-pow(i,x) print('sum-i=',sum) elif(sum<=0): sum=sum+pow(i,x) print('sum+i=',sum) i=i+2 print(...
e7d7de0aa967dd24000f949da994f770ceec8adc
alaasal95/problem-solving
/whileloop.py
194
3.84375
4
# برنامج يطبع الاعداد الزوجية بين 1 الى 100 num=1 while ( num<=100 and num >=1): if (num %2 == 0): print(num) num = num + 1
34c5631d27b0531810207e26cdda28e547cd31cf
alaasal95/problem-solving
/stopword.py
179
3.828125
4
#خروج من الحلقة عندما تصل للكلمة banana : x=['apple','banana','egge'] for i in x: print(i) if (i == 'banana'): break
4bcd6196af4c11a1bf4119e3bd5f72ffa36ee979
bmzk/asad
/ReadAndWriteJson.py
937
3.65625
4
'''读写Json文件''' import json import random d={"a":'a',"b":2,'c':0.5,'d':[1,2,'y']} def dump_(): file_w=open('f.json','w+',encoding='utf-8') obj={"a":'a',"b":2} for i in 'abcdefg': obj['a']=i obj['b']=random.randint(10,99) print('dump_',obj) json.dump(obj,file_w,indent=5) ...
a9eb39c3957b4f3926e660f017b779b798fd8036
hello2sys/myLeetCode
/83. Remove Duplicates from Sorted List.py
630
3.6875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteDuplicates(self, head): """ :type head: ListNode :rtype: ListNode """ if not head: return None ...
7d84e65f037d610bbb0f9e8c71ab1cbb90f43d87
hello2sys/myLeetCode
/26. Remove Duplicates from Sorted Array.py
510
3.53125
4
class Solution: def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ lens=len(nums) if lens==1: return 1 if lens==0: return 0 first,second=0,1 while second<lens: if nums[first]==nums[se...
06e6aa8918528136b1b4a56e463dcfb369580261
emmanuelthegeek/Python-Exercises
/Widgets&gizmos.py
1,130
4.25
4
#An online retailer sells two products. widgets and gizmos. Each widget weighs 75 grams, while each gizmo weighs 112 grams. #Write a program that displays the total weight of an order, in kilograms, given two variables containing the number of widgets #and gizmos. #Solution # 1 widget = 75g # 1 gizmos = 112g # 1000g ...
034931c27d37ef44fe6e2b1ed7f08ea6ee621674
c3pknow/block-my-schedule
/Schedule.py
775
3.5625
4
class Schedule(): hours_week = 168 # 168 hours in a week hours_day = 24 def __init__(self): self.items = [] def add(self, element): self.items.append(element) def count(self): return len(self.items) def get_free_time(self): return self.hours_week - self.g...
6cc0e043bd8778e825fa2fd6748518a6e641a5f9
MihaiDinca1000/Game
/Exercitii/Test_inheritance.py
2,254
4.59375
5
''' In this Python Object-Oriented Tutorial, we will be learning about inheritance and how to create subclasses. Inheritance allows us to inherit attributes and methods from a parent class. This is useful because we can create subclasses and get all of the functionality of our parents class, and have the ability to...
6e8bc9ef06c8a191841a19a0d370b9db212ea97d
MihaiDinca1000/Game
/Exercitii1/writeFileArgsParse.py
800
3.796875
4
import argparse import os par = argparse.ArgumentParser(description="write text into a file") # defineste argumente par.add_argument('file',type=str, help='the file to store the text in') par.add_argument('text',type=str, help='the text to write to the file') args = par .parse_args() print("writing to {}"...
e5adf7b3fbfe65c18f959543e462e8f4496a6895
MihaiDinca1000/Game
/Exercitii1/list1.py
1,121
3.546875
4
a = [1, 1, 2, 3, 5, 8, 13, 8, 21, 34, 55, 89] b = [1, 2, 3, 4, 3, 5, 6, 8, 7, 7, 8, 9, 10, 11, 12, 13] # c=[] # # for i in a: # for j in b: # if i == j: # c.append(i) # sau j # # # print (c) # # # sau !!! # import random # a=random.sample(range(1,30),15) # b=random.sample(ra...
054d31f8f0c1a31d606bfbf0dfdf5c2c5bf60ba4
Hayashi-Yudai/TDD_Python
/src/money.py
547
3.8125
4
class Money: def __init__(self, amount, currency): self.amount = amount self.currency = currency def __eq__(self, other): return self.__dict__ == other.__dict__ def __add__(self, other): return Money(self.amount + other.amount, self.currency) def __mul__(self, multipli...
43bdd743c29efec4b9756ce9d6ecd8f5bcf61b99
porregu/unit3
/unitproject.py
1,336
4.21875
4
def arearectangle(a,b): """ solve the area of the rectangle :param a: heigth :param b: with :return: return the fucntion to do it more times """ return a*b def withh():# dpuble (h) because dosent let me put one # with called by the user """ make the user tell the with :return: t...
943287e83db56144b29604f643b0720ae40a71f2
tuxnotes/python_notes
/python3_programming_tricks/cha02/2-5.py
622
3.578125
4
from random import randint, sample sample('abcdefgh',randint(3,6)) # 第1轮 d1 = {k: randint(1,4) for k in sample('abcdefgh',randint(3,6))} # 第2轮 d2 = {k: randint(1,4) for k in sample('abcdefgh',randint(3,6))} # 第3轮 d3 = {k: randint(1,4) for k in sample('abcdefgh',randint(3,6))} # solution 1 # find 公共键 [k for k in d1 ...
37ef6fbdf2526027063fa52da0b9f2033023b975
tuxnotes/python_notes
/python3_programming_tricks/ch07/7-7.py
981
3.546875
4
# class A: # def __del__(self): # print('in __del__') # # a = A() # a2 = a # a2 = None # 循环引用,下面是一个双向链表 import weakref class Node: def __init__(self, data): self.data = data self._left = None self.right = None def add_right(self, node): self.right = node n...
2741e63984b81219e0a80a36076ace883706be0a
bunk0man/python
/intro/print.py
90
3.671875
4
n = int(raw_input('N: ')) res = '' for x in xrange(1,n+1): res += str(x) print res
64e6da16bbfc8c4b6abbc8d792c69c58719062d5
wtrelease/Vision-Racing
/Race Game/COM_AI.py
3,755
3.65625
4
import math import pygame from pygame.locals import * """Function to determine steering based on Center of Mass of road ahead""" def COM(car, road, screen, font, draw = False): window_width = 140 #View window width window_length = 120 #View window length step_size = 10 #Step size of spots to check in wind...
b6d777bda60b89b9880543ecdd6f132a111b039e
tanay2098/homework4
/task2.py
1,023
4.15625
4
import random # importing package random nums = [] # initializing an empty list called nums for i in range(0,2): # Loop for 2 elements nums.append(random.randint(0,10)) # generating 2 numbers between 0 to 10 and appending them in the list t1 = tuple(nums) # converting list into a tuple named t1 correct_answ...
d756622c8a0197d4c636e3daa690a9a9557d38fc
tragicmj/python
/lco/test.py
265
3.84375
4
balance = 4*5*(6/2) print(balance) print('HELLO WORLD!') # array iceteas = ['lemon', 'peach', 'mint'] print(iceteas) print(iceteas[2]) # for loop for superman in iceteas: print(superman) # function def make_tea(): print("I can make ice tea") make_tea()
9206b5cd0cf7fc00ae7661b45c665d8e796d4864
SumanM-IIIT/IIIT-H_Sem1_Suman
/SSD/LAB_Green/LAB7_13Oct/2020202018_Lab6/Q4.py
429
3.6875
4
def test_div(bin_num): tmp = bin_num p = 0 digit = 0 dec = 0 while(tmp != 0): digit = tmp % 10 dec += digit * pow(2, p) tmp = tmp // 10 p += 1 if dec % 5 == 0: return True else: return False bin_string = input() list_bin = bin_string.split(',') set_bin = set() for i in range(0, len(list_bin)): i...
dd683322964cc90eb3ac8989dd6ce479680eb35a
Bluette1/PythonTutorial
/Sets/GuessTheNumber.py
287
3.546875
4
n = int(input()) A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} str = input() while str != 'HELP': B = {int(s) for s in str.split()} if input() == 'YES': # keep set only B A = B else: # remove all elements of B from A A -= B str = input() print(A)
f948671a6b37bff7e370ed45631888537a140e36
paamb/comp_programming
/Documents/Programmering/python/Ferdige produkter/casino_chips_fast.py
196
3.8125
4
def solve(arr): arr.sort() if arr[0] + arr[1] < arr[2]: print(arr[0] + arr[1]) else: sum_of_elements = sum(arr) print(sum_of_elements // 2) solve([1,2,3])
523679081a7b7e4d2daa4e71ebad19e7d442c0d0
ocmob/DL_assignments_2019
/assignment_1/code/train_mlp_pytorch.py
6,653
3.734375
4
""" This module implements training and evaluation of a multi-layer perceptron in PyTorch. You should fill in code into indicated sections. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import numpy as np import os from mlp_pytorch impo...
9954bff4bcbb17f9d0a043ffb1c05c0163b247e2
ocmob/DL_assignments_2019
/assignment_1/code/train_convnet_pytorch.py
6,908
3.65625
4
""" This module implements training and evaluation of a Convolutional Neural Network in PyTorch. You should fill in code into indicated sections. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import numpy as np import os from convnet_py...
454d17f776cd6cb00dd89b734ce2f818e31451fb
nadrowskyy/banking-system
/banking.py
5,822
3.546875
4
import random from math import ceil import sqlite3 conn = sqlite3.connect('card.s3db') cur = conn.cursor() cur.execute('''CREATE TABLE IF NOT EXISTS card ( id INTEGER NOT NULL, number TEXT NOT NULL, pin TEXT NOT NULL, balance INTEGER DEFAULT 0 ...
4263c67e70e6343be9049f5d8ad51c1e5b6bb9aa
werellel/autocomplete
/trie.py
1,943
4.03125
4
from collections import deque ''' https://en.wikipedia.org/wiki/Trie ''' class Node: def __init__(self) -> None: # Note that using a dictionary for children (as in this implementation) # would not by default lexicographically sort the children, which is # required by the lexicographic sorting m...
574a0c28c20bae6ba5c6c4cab1a1dbcf624c9a06
coss2000/AprendaCSharp
/Tablas.py
331
3.875
4
for i in range(1,11): encabezado="Tabla del {}" print(encabezado.format(i)) for j in range(1,11): # El i tiene el numero base y j el elemento de la tabla. salida="{} x {} = {}" print(salida.format(i,j,i*j)) else: # Cuando concluye todo lo indicado se ejcuta este codigo. prin...
bdf2d15f14a34789a296aca8a21623ae8fd414ca
tomasdisk/cubeTransform
/cube.py
9,222
3.609375
4
from math import sin, cos, sqrt # inported below within methods # import matplotlib.pyplot as plt # import matplotlib.lines as mlines class Point2d: def __init__(self, x, y): self.x = x self.y = y self.cords = (x, y) class Point3d: def __init__(self, x, y, z): self.x = x ...
47636521b751e489e9798bf89943c1e5faf9c036
sheethal23/Geometric-Shapes
/shapeee.py
710
4.09375
4
""" This is an abstract super class for geometic shapes. The methods of this class need to be defined in the sub classes; otherwise, an error will be raised to alert the user. """ class Shape: def delegate ( self ): self.area ( ) # returns total surface area of a shape self.perimeter ( ) # r...
f76f683497bbf7caff26732105b355888d3160e1
damiannolan/python-fundamentals
/current-time.py
224
4.1875
4
# Problem 2 - Current Time import time; import datetime; # Print the the date and time using 'time' print("Current time is : ", time.asctime(time.localtime(time.time()))) print("Today's date is: ", datetime.date.today())
0da9cced26a9ef8c8cc05ced6d72bf7993be889b
ApaDoctor/3AC-interpreteer
/instructions.py
26,050
3.515625
4
import re import sys import scope from errors import * """ Functions which names are written in upper case are predefined implementation of IPPcode instructions. You don't need to call them directly. (Private). All of them are called by Instruction instance """ def splitter(arg): """ Splits argument value w...
00940b0351fb026d89b2cff67c62100c8ec0d3a4
binarymason/grafana-demo
/job.py
657
3.546875
4
from random import randint class Job(object): def __init__(self, *, name, chaos): self.name = name self.num_bytes = randint(1000,10000) self.num_seconds = randint(1,60) self.succeeded = True if something_happened(chaos): self.num_exceptions = randint(...
ec38eb36959482eef387b672cac7cb05d631410e
GeovaneBarros/API_Titanic
/venv/lib/python3.8/site-packages/dict_tools/mysql.py
1,170
3.78125
4
from typing import Dict from typing import List def to_num(text: str) -> int or float: """ Convert a string to a number. Returns an integer if the string represents an integer, a floating point number if the string is a real number, or the string unchanged otherwise. """ try: retur...
7cd1c80d8f61509a4fdd74d8d2289a3cc390cc32
JJJOHNSON22/Python-OOP
/store_and_products/products.py
630
3.5625
4
class Product: product_id = 0 def __init__(self,name,price,category): Product.product_id += 1 self.name = name self.price = price self.category = category self.id = Product.product_id def update_price(self,percentage_change): if (percentage_change > 0): ...
6aefdff9aa0c22ad8727493b3b8225e326e6e7f4
raymondseah/beginner-python-projects
/madlibs.py
335
3.78125
4
# name="raymond" # print("i am " + name) # print("i am {}".format(name)) # print(f"i am {name}") adj = input("Adjective: ") verb1 = input("verb1: ") verb2 = input("verb2: ") famous_person = input("Farmous person: ") madlib = f"Pythong is so {adj}! i love to {verb1}. \ Stay {verb2} like you are {famous_person}"...
95179addb44dc4d3688dfeb5b129e389b384c0f8
rohanpillai20/Rohan-Pillai-Blog-Files
/Merge-Cells-Python.py
2,410
3.515625
4
""" This was created to answer a question on StackOverflow. Link: https://stackoverflow.com/questions/51172234/merging-values-in-dataframe-to-write-in-excel/51187298 """ # Import Files import pandas as pd from openpyxl.workbook import Workbook from openpyxl.utils.dataframe import dataframe_to_rows exportPath = r'C...
b78f554179724000b1d6d6be21ffea01ec63addd
korivernon/All-About-Algorithms
/program.py
5,923
3.625
4
import random import sys #import pygame def wordbank(file = "bank.csv"): f = open(file, "r") word = [] definition = [] blank_2 = [] alt = [] #alternate word study = [] for line in f: lst = line.split(",") #print(lst) word.append(lst[0]) definition.append(lst[1].replace("- "...
10e133ab96fa9bccafe222e0e98fed84ba1f4398
pnheinsohn/IIC2233-PrograAvanzada
/pnheinsohn-iic2233-2017-2/Actividades/AC01/Actividad01.py
5,538
3.953125
4
class Ciudad: lista_de_comunas = [] def __init__(self, nombre_ciudad): self.nombre_ciudad = nombre_ciudad self.nombre_comuna = "" self.continuar = "" self.comuna = "" def agregar_comuna(self): while True: self.nombre_comuna = input("Inserte nombre de la...
db9e00a5d63e30c8cdbe498e4114fe974e3f8df5
Ala123Sobhan/Python-Programming
/HillClimbing.py
1,472
3.984375
4
""" import header.py and all its functions """ import header from header import * def do_hill_climbing(tweak_function = shuffle_function): """ Runs hill climmbing algorithm Keyword argument: tweak_function- the tweaking function you want to use- it can be swap_function(default) or shuffle_function ...
cf02661f08ee3bebd66f8361a5bbef4a360c058d
hptruong93/MACA
/domain_knowledge/AbstractDomainKnowledge.py
931
3.734375
4
import abc class AbstractDomainKnowledge(object): """ Abstract class for domain knowledge """ __metaclass__ = abc.ABCMeta def __init__(self): super(AbstractDomainKnowledge, self).__init__() self.dataset = None # Data used to train/validate/test the model. See class AbstractD...
b74017f961cdddbc73ea733f5a9dedb547e24623
rrguhan6/Data-Structures
/q/q.py
1,305
3.984375
4
class node: def __init__(self, data): self.data = data self.next = None class q: def __init__(self): self.head = None self.rear = None def print(self): cur = self.head if cur: while (cur): print(cur.data) cur = ...
68fd2aeb3b46e192cadba70f7796c07241fbc6b6
jiayu520/test
/scatter_squares.py
418
3.671875
4
import matplotlib.pyplot as plt x_value = list(range(1,1001)) y_value = [x**2 for x in x_value] plt.scatter(x_value,y_value,s=40) #设置图标标题并给坐标轴加上标签 plt.title("Square Number",fontsize=24) plt.xlabel("Value",fontsize=14) plt.ylabel("Square of Vlaue",fontsize=14) #设置刻度标记的大小 plt.axis([0,1100,0,1100000]) #plt.tick_params(...
1a7a66c64d42251ab7c1e369337692c67a0bee0f
Grupy-GO/dojo_30_06_2018
/front_x.py
997
3.875
4
""" # B. front_x # Given a list of strings, return a list with the strings # in sorted order, except group all the strings that begin with 'x' first. # e.g. ['mix', 'xyz', 'apple', 'xanadu', 'aardvark'] yields # ['xanadu', 'xyz', 'aardvark', 'apple', 'mix'] # Hint: this can be done by making 2 lists and sorting each of...
f2d489036a7adcc971ede2b7d4d9d7efcabb7055
VeraJulian/Project-Euler
/Solved-Problems/problem056.py
319
3.5625
4
# Numbers raised to 90-100 have the most digits so we start with 90^90 prev,answer,num = 0,0,0 for base in range(90,101): for power in range(90,101): x = str(base ** power) num = sum(int(digit) for digit in x) if num > prev: prev = num answer = prev print answer
d2aff0ff91f9fe772e179d7e0b7d0e59d05c8723
VeraJulian/Project-Euler
/Solved-Problems/problem006.py
362
3.75
4
#real 0m0.038s #user 0m0.015s #sys 0m0.013s # Finds the difference between the sum of the squares of the first one hundred # natural numbers and the square of the sum sum_of_squares = 0 for i in range(101): sum_of_squares += (i*i) square_of_sum = 0 for i in range(101): square_of_sum += i square_of_sum *= square_of_s...
b0c76a2eabda360be80cd7467268c934d4a835f0
vkulkar/central-limit-theorem
/central_limit.py
1,807
3.796875
4
# Demonstrates the central limit theorem. # Flip a coin (Heads = 1, Tails = 0 or vice versa) n times and compute the sum. Repeat m times. # Creates a normalized histogram of the sums and compares to the theoretical Gaussian distribution. # Theoretically, the mean value of the sum should be n/2.0 # The variance should b...
8b622de9a312ebbfa21d9654f092fc858027a021
Pietrohenri/acessibilidade
/Udemy/variavel.py
311
3.765625
4
x = 20 y = 30 z = 100 w = (x + y) * z /100 print(w) print("Este texto será impresso no console") print(x) print("Texto e duas variaveis ", x , "," , z) m = "Python" print (type(m)) print (type(x)) var = input("informe o valor: ") var = int(var) print(type(var)) var = float(var) print(type(var))
ef2a449b3270e413578a3a695d69b6bd48d69219
kuntal-samanta/my-data-processing
/my_pandas/working_with_data.py
3,722
3.65625
4
import pandas as pd """ data = {'Name':['Jai', 'Princi', 'Gaurav', 'Anuj'], 'Age':[27, 24, 22, 32], 'Address':['Delhi', 'Kanpur', 'Allahabad', 'Kannauj'], 'Qualification':['Msc', 'MA', 'MCA', 'Phd']} df = pd.DataFrame(data) df["Name"] = df["Name"].str.lower() # Lowercasing df["Name"] = df[...
ef84e285695a555b1b5ee2447c6e20d3f0137edb
kmust-why/Python
/project/猜数字小游戏/caishuzi1.py
774
3.703125
4
import random print('这是一个猜数字的小游戏,游戏规则是系统给出一个0-9的数字,自己才输入一个,如果三次以内猜中,则赢,否则就输了。') ls = [] s = random.randint(0,9) #print('随机数:%d' %s) for count in range(9): number = int(input('请输入0-9中的一个数字:\n')) ls.append(number) #print(ls) if count == 8: while s in ls: ...
19b3d0011dfb2cba46a101e22040a1f798920fd1
mathieurenault1/BusProject
/schedule_format.py
1,535
3.640625
4
# from https://www.geeksforgeeks.org/convert-json-to-csv-in-python/ import json import csv import pandas def format(): ''' with open( "C:/Users/jurri/Documents/Studie/DSDM 2020 - 2021/Project 1/Online Data/timetable_per_line_and_stop_16dec.json") as json_file: data = json_file schedu...
d08c1496f210d301395fddc09ea7d91aae0805fd
shafin191/Analysis_of_Alogrithm
/Assignment1/Max_in_Mountain.py
1,168
3.96875
4
#2.4. An array A[1 . . n] of integers is a mountain if it consists of an increasing sequence #followed by a decreasing sequence, or more precisely,If there is an index m ∈ {1, 2, . . . , n} such that #• A[i] < A[i + 1] for all 1 ≤ i < m, and #• A[i] > A[i + 1] for all m ≤ i < n. #In particular, A[m] is the maximum elem...
82bd6970962a9f11921c2dc8892969dacad895c8
srholde2/Project-4
/queue.py
1,103
4.28125
4
class Queue: # queue class constructor def __init__(self): self.queue = ["car", "car", "car", "car", "car"] def enqueue(self): item = input("Please enter the item you wish to add to the queue: ") self.queue.append(item) def dequeue(self): item = self.queu...
32da0cb7983277f58083003ce91214ebf846d0c5
anupamaad96/bigdata
/rockpapersciss.py
1,037
3.96875
4
print "Rock Paper Scissors" print"r-Rock...p-Paper...s-Scissors" chances=10 p1=0 p2=0 while chances > 0: in_1=raw_input("Player1: Choose r/p/s?") in_2=raw_input("Player2: Choose r/p/s?") if in_1 != in_2 : #for the different inputs if in_1=='r': if in_2=='p...
ebafbadce626568dd7364147c70e56eee087a028
margierain/bootcamp-6-exerices
/Day 3/child.py
396
3.734375
4
from inheritance import Parent class Child(Parent): # to over you need to use the same function name ''' learning on how to overide the parent class ''' def parent_method(self, output_string): print "child yes method {}".format(output_string) child = Child() print child.parent_method("called")...
9b6c8c15779c4a38443ffaf961703b7dd9381fd2
sm212/advent-of-code-2019
/03_02.py
863
3.703125
4
input_file = open('./input/03.txt') input_data = input_file.read() data = input_data.split('\n') wire1, wire2 = data[0].split(','), data[1].split(',') dir_x = {'L' : -1, 'R' : 1, 'U' : 0, 'D' : 0} dir_y = {'L' : 0, 'R' : 0, 'U' : 1, 'D' : -1} def get_distance(wire): "Make a dictionary of all points traced by a wire ...
2089e0bca37e8ff0f920c3ea24dbb1fede69215f
NienkeUijlen/Oefenen
/OefentestopgaveC.py
187
3.59375
4
import math v=float(input()) # vuurkracht z=float(input()) # zwaartekracht a=float(input()) # horizontale afstand print("{0:.2f}".format(0.5*math.asin((z*a)/v**2)))
390f93094382831c433b47aab4a0c5a5d028e103
maycatk/learnPython
/wumpusGame.py
2,344
3.78125
4
#-*- coding:utf-8 -*- from random import choice cave_numbers = range(0,20) caves = [] for i in cave_numbers: caves.append([]) unvisited_caves = range(0,20) visited_caves = [0] unvisited_caves.remove(0) #准备工作 while unvisited_caves !=[]: i = choice(visited_caves) if len(caves[i]) >= 3: continue #随...
592727a594fe3ebf3fac67e7d78870735334a6f0
khosravm/Anomaly-Detection
/Basic Models for AD/Simple_AD.py
6,467
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ A case study of anomaly detection in Python - 1st: create a dummy dataset - 2nd: Detecting anomalies just by Visualization - 3rd: Clustering based approach for anomaly detection k-means clustering is a method of vector quantization (vq), originally from signal...
cb6330c03b56f99a344884d1d396e3e90f7dd534
tejas-muthya37/Speckbit-PPA-B1-
/div.py
199
4.03125
4
def divide(): try: a = int(input("Enter the first number : ")) b = int(input("Enter the second number : ")) print(a/b) except ZeroDivisionError: print("division by zero!") divide()
e1181d6826c9f12824b6810c6ef82946090a356c
Fama18/Programmation_Python
/duree_vol.py
1,107
3.9375
4
def main() : h_depart = int(input("Donner l'heure de depart : ")) min_depart = int(input("Donner les minutes de depart : ")) h_arrive = int(input("Donner l'heure d'arrivee : ")) min_arrive = int(input("Donner les minutes d'arrivee : ")) if h_arrive > h_depart : if min_arrive > min_depart : ...
def7ba24e6404c8c55863c17089bfc3fc3c6137c
Fama18/Programmation_Python
/Puissance2.py
286
3.984375
4
def main() : x = float(input("Donner la valeur de x : ")) n = int(input("Donner la valeur de n : ")) puissance_x = 1 for i in range(1,n+1): puissance_x *= x print("x puissance n egal : ", str(puissance_x)) if __name__ == '__main__': main()
6d864bbe1c650fb461b27e0224ebb13680b7ec04
Fama18/Programmation_Python
/Somme5_entier.py
222
3.921875
4
def main() : somme = 0 for i in range(1,6): nombre = int(input("Donner un nombre : ")) somme += nombre print("la somme des 5 nombres est : ", str(somme)) if __name__ == '__main__': main()
38e734f41b0dfcf7ddf445dfc9849fa5d986ccfb
tara0017/Advent-of-Code
/2018/day14.py
1,841
3.65625
4
#day 14 def create_new_recipe(): global recipes, elf1_index, elf2_index sum_of_recipes = recipes[elf1_index] + recipes[elf2_index] if sum_of_recipes < 10: recipes.append(sum_of_recipes) else: digit_1 = sum_of_recipes % 10 digit_2 = int(sum_of_recipes / 10) recipe...
53d594737734c6d098f0c203cdf594b137653235
tara0017/Advent-of-Code
/2020/day10.py
1,475
3.640625
4
# day10 def get_values_at_most_three_away(v): values = [] for d in data: if d > v and d <= 3+v: values.append(d) return values # read file data = [] f = open('day10.txt','r') for x in f: data.append(int(x)) # add starting point data.append(0) # add end...
883ba2350227817a975377b0ae12d38767dac7d3
tara0017/Advent-of-Code
/2017/day7.py
2,100
3.609375
4
#day7 class node: def __init__(self, name, value, children, parent): self.name = name self.value = value self.children = children self.parent = parent def print_info(self): print("Name: ", self.name) print("Value: ", self.value) print("C...
18e6b65b788a9ac571caf8b0ad5fec407eb92504
tara0017/Advent-of-Code
/2021/day21.py
7,336
3.625
4
# day 21 class player: def __init__(self, position, score = 0): self.position = position self.score = score def play_turn(): global dice_value, p1, p2, turn, game_over turn += 1 if turn % 2 == 1: p = p1 else: p = p2 # update position steps_to_move = 3 ...
d8362ad118ab3838323d76c3341fa12e94d5680b
tara0017/Advent-of-Code
/2015/day23.py
2,052
3.6875
4
# day23 def increase(reg): global a, b if reg == 'a': a += 1 elif reg == 'b': b += 1 def triple(reg): global a, b if reg == 'a': a *= 3 elif reg == 'b': b *= 3 def half(reg): global a, b if reg == 'a': a /= 2 elif reg == ...
3af3e5ff90466adb99b90372f7b00718104f628d
tara0017/Advent-of-Code
/2016/day7.py
3,686
3.53125
4
#day7 def passes_abba_test(s): for i in range(len(s) - 3): if s[i] == s[i+3] and s[i+1] == s[i+2]: if s[i] != s[i+1]: return True return False def passes_aba_test(s): result = [] for i in range(len(s) - 2): if s[i] == s[i+2] and s[i] != s[i+1]: ...
b12e70e4dd19002c00717e2b73b1625e59ddb477
tara0017/Advent-of-Code
/2019/day4.py
1,106
3.828125
4
#day4 def is_never_decreasing(n): s = str(n) for i in range(len(s)-1): if s[i] > s[i+1]: return False return True def has_same_adjacent_digits(n): s = str(n) for i in range(len(s)-1): if s[i] == s[i+1]: return True return False def has_t...
170cd37e1ba6e52b9669e1bd416ad2c271a18bce
tara0017/Advent-of-Code
/2020/day23part2.py
2,798
3.796875
4
# day23 part 2 class cup: def __init__(self, value, next_cup): self.value = value self.next_cup = next_cup def create_cups(): global cup_dict, cups c = cup(cups[0], None) cup_dict[cups[0]] = c # create a cup for the initial input values for i in range(1, len(cups)): ...
64131cbfedd7e769f8fee43ba4f607d81db026c5
tara0017/Advent-of-Code
/2017/day23.py
1,855
3.6875
4
#day23 def st(r, v): global registers #v is given as a letter from the register insted of a value if v.upper() != v: v = int(registers[v]) registers[r] = int(v) def sub(r, v): global registers #v is given as a letter from the register insted of a value if v.upper() != v...
6fff56e1d994de46ebb5945964267ed7ed1b8b49
tara0017/Advent-of-Code
/2018/day2.py
1,645
3.546875
4
#day2 #part2 def have_one_diff(b1, b2): num_diff = 0 for i in range(len(b1)): if b1[i] != b2[i]: num_diff += 1 if num_diff > 1: return False if num_diff == 1: return True def find_almost_match(box): for i in range(len(box)): box1 = box[i] ...
2fcf4a9ecc9d62e14a004a613cd9ca5a9b60bbe8
Anisimov96/lesso-2
/lesson2_it_2.py
517
3.84375
4
def comparison (line_1, line_2): if type(line_1) == type(line_2) == type('str') : if len(line_1) > len(line_2) and line_2 != 'learn': a =2 return(a) elif line_2 == 'learn': a = 3 return(a) a = 1 return(a) else: a = ...
1050e66e270df03c2c88cb35e5d4bf364de138b7
hiranmayee1123/Hacktoberfest-2021
/windowslidingproblem.py
1,013
4.21875
4
#This technique shows how a nested for loop in some problems can be converted to a single for loop to reduce the time complexity. #Let’s start with a problem for illustration where we can apply this technique – #Given an array of integers of size ‘n’. #Our aim is to calculate the maximum sum of ‘k’ #consecutive elem...
68b34f0dd6f0f0ac7ed75d4cc2c0f79f22b34002
ltts40000356/PyProj_1
/venv/Assignment_03052021/Problem_3.py
280
4.03125
4
# Find the first repeated character in a String sampleStr = "aeioissuebdfhkssd" duplicates = [] for char in sampleStr: if sampleStr.count(char) > 1: if char not in duplicates: duplicates.append(char) print("First Character that was duplicated: " + duplicates[0])
112f14dff1ec0ea8f803e760588054250bbc97e7
ltts40000356/PyProj_1
/venv/Assignment_10052021/stringSplit.py
210
3.765625
4
def split_and_join(line): wordlist = line.split(" ") return('-'.join([str(word) for word in wordlist])) if __name__ == '__main__': line = input() result = split_and_join(line) print(result)
7d986c06bcee39077a9c5e9f1525939b2e291877
jorchube/GameEngine
/tests/engine/geometry/test_point.py
1,150
3.625
4
import unittest from game_engine.geometry.point import Point3D class TestPoint3D(unittest.TestCase): def test_should_create_3D_point(self): point = Point3D(x=2, y=4, z=6) assert 2 == point.x assert 4 == point.y assert 6 == point.z assert (2, 4, 6) == point.as_tuple() ...
8c0e752eabde88263b1dab0c11ade34a000a29d5
Universe-Man/python-practice
/python-project/answers/gameclassesAnswers.py
3,152
3.640625
4
class Game: def __init__(self, noOfQuestions = 0): self._noOfQuestions = noOfQuestions @property def noOfQuestions(self): return self._noOfQuestions @noOfQuestions.setter def noOfQuestions(self, value): if value < 1: self._noOfQuestions = 1 print("\n...
da7b39e1036aed108944cdc8c55cc979bd242996
Anandhakrishnan-CodeBlock/0tohero
/local_global.py
82
3.703125
4
a = 2 print(a) def add(): a = 3 b = 3 print(a + b) add() print(a)
bddd075d98d8f9b54c7f3b8a0bfa5912333297c2
mittelmax/Snake
/Snake.py
3,686
3.515625
4
import pygame import random import math # Init Pygame pygame.init() # Clock clock = pygame.time.Clock() # Screen screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption("Snake") # Sprite class class Sprite: length = 1 lastx = [] lasty = [] def __init__(self, leng...
1f6f3eb7a84970be2acd28f42334052ce59221d2
solidworks1210/JustDemo
/DataTool/utils/StringUtils.py
758
3.515625
4
# -*- coding:utf-8 -*- # -------------------- # Author: SDN # Description: 字符串操作相关 # Time: 2017/3/20 # -------------------- def connect(*args): """ 拼接字符串:不同编码的可以比较,但不能直接拼接 :return: """ if len(args) > 0: result = '' # 全转为字符串 for item in args: if ty...