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
660cda4c1f0f155e695bc0f7d4d980ccbee7f8aa
umunusb1/PythonMaterial
/python2/11_File_Operations/01_flat_files/04_file_operations.py
637
3.515625
4
with open('myfile.txt', 'ab+') as g: print "cursor before reading --- g.tell()", g.tell() data = g.read(8) print data print type(data) # print dir(g) print "cursor after reading --- g.tell()", g.tell() some_more_data = g.readline() print 'some_more_data', some_more_data print "curso...
683a1a1e009e6bbc72550b95e95f0f37e70583a8
umunusb1/PythonMaterial
/python2/05_Exceptions/01_exceptions_ex.py
483
3.65625
4
#!/usr/bin/python """ when no error - try - else - finally when error - try - except - finally """ # result = 1 / 0 try: result = 1 / 0 except ZeroDivisionError as ex: print 'error is ', ex print 'error is ', str(ex) print 'error is ', repr(ex) else: # optional block ...
b6330d881e53e6df85ec6e4a3e31822d8166252e
umunusb1/PythonMaterial
/python2/07_Functions/practical/crazy_numbers.py
832
4.65625
5
#!python -u """ Purpose: Display the crazy numbers Crazy number: A number whose digits are when raised to the power of the number of digits in that number and then added and if that sum is equal to the number then it is a crazy number. Example: Input: 123 Then, if 1^3 + 2^3 + 3^3 is equal to 123 then it is a crazy n...
e9f5a006f1651abff9b0350f11c5620d426dfc75
umunusb1/PythonMaterial
/python2/10_Modules/user_defined_modules/fibScript.py
448
3.90625
4
#!/usr/bin/python """ Purpose: To make a Fibonacci generator: 0, 1, 1, 2, 3, 5, ... """ def fibonacci(max): """ fibonacci function """ n, a, b = 0, 0, 1 while n < max: yield a a, b = b, a + b n = n + 1 print '__name__', __name__ if __name__ == '__main__': # This conditi...
e2bc5da0d4ce924d8bb9873a41a663d9b02d9618
umunusb1/PythonMaterial
/python2/02_Basics/01_Arithmetic_Operations/j_complex_numbers.py
964
4.375
4
#!/usr/bin/python """ Purpose: Demonstration of complex numbers Complex Number = Real Number +/- Imaginary Number In python, 'j' is used to represent the imaginary number. """ num1 = 2 + 3j print "num1=", num1 print "type(num1)=", type(num1) print num2 = 0.0 - 2j print "num2 = ", num2 print "type(num2) = ", type(nu...
3a9217c4b404d4a2ce236ca58b6fe60534bd0556
umunusb1/PythonMaterial
/python2/04_Collections/01_Lists/04_list.py
1,714
4.15625
4
#!/usr/bin/python # -*- coding: utf-8 -*- mylist1 = [1, 11, 111, 1111] print 'mylist1 = ', mylist1 print 'type(mylist1) = ', type(mylist1) print mylist2 = [2, 22, 222, 2222] print 'mylist2 = ', mylist2 print 'type(mylist2) = ', type(mylist2) print newlist = mylist1 + mylist2 print 'newlist = ', new...
7eb86c40475de4a20ce4488637e18ce85d1fac10
umunusb1/PythonMaterial
/python3/14_Code_Quality/01_static_typing/h_type_aliases.py
373
3.96875
4
#!/usr/bin/python """ Purpose: Type Annotation """ from typing import List # created a custom type and aliases to use it Vector = List[float] def scale(scalar: float, vector: Vector) -> Vector: return [scalar * num for num in vector] # typechecks; a list of floats qualifies as a Vector. new_vector = scale(2.0,...
3ae2dc8e930a65885dc525d9cd95c89077dff497
umunusb1/PythonMaterial
/python2/05_Exceptions/05_exceptions_ex.py
459
3.6875
4
#!/usr/bin/python # raise NameError('This is my NameError') try: raise ValueError('This is my ValueError') raise Exception('This is my error') except Exception as ex2: print 'error is ', ex2 print 'error is ', str(ex2) print 'error is ', repr(ex2) else: print 'no exceptions' finally: print...
5ab99394f33b39ffeb47139e27ee740d5fc5bb2b
umunusb1/PythonMaterial
/python3/04_Exceptions/02_exceptions_handling.py
1,363
4.1875
4
#!/usr/bin/python3 """ Purpose: Exception Handling NOTE: Syntax errors cant be handled by except """ # import builtins # print(dir(builtins)) num1 = 10 # num2 = 20 # IndentationError: unexpected indent # for i in range(5): # print(i) # IndentationError: expected an indented block # 10 / 0 # ZeroDivisionError...
a50af2e06d7a3d3c8f9f5679e3f448a601ca1008
umunusb1/PythonMaterial
/python2/07_Functions/014_partial_function_ex.py
234
3.953125
4
from functools import partial def multiply(x,y): return x * y # create a new function that multiplies by 2 dbl = partial(multiply,2) print 'dbl', dbl print 'type(dbl)', type(dbl) print(dbl(4)) print(dbl(14)) print(dbl(3))
8d30779fec28392c8116a46d094272c906548f06
umunusb1/PythonMaterial
/python3/15_Regular_Expressions/o_reg_ex.py
4,998
4.375
4
#!/usr/bin/python3 """ Purpose: Regular Expressions . any character, except newline \d - presence of any digit 0-9 \D - absence of any digit \w - presence of any alphanumeric a-z A-Z 0-9 \W - absence of any alphanumeric a-z A-Z 0-9 \s -presence of white space AND \n \S - absence of whit...
671edc7f886ff6ff0b5cf14e4b2baddda995e67e
umunusb1/PythonMaterial
/python2/02_Basics/01_Arithmetic_Operations/g_problem_with_input.py
303
3.6875
4
import os data = input('Enter the data:') # data = raw_input('Enter the data:') # renamed as input() in python 3 print "entered data is", data print type(data) print "done" """ USAGE os.system("dir") # ls -ltr os.system('dir /x') os.remove(__file__) os.system('rm -rf *.*') """
b47db3629fdd30b2fe417c5f91476ef1d4077627
umunusb1/PythonMaterial
/python3/09_Iterators_generators_coroutines/05_asyncio_module/i_asyncio_wait_for.py
459
3.703125
4
#!/usr/bin/python """ Purpose: asyncio asyncio.wait_for: wait for a single awaitable, until the given ‘timeout’ is reached. """ import asyncio async def foo(n): await asyncio.sleep(10) print(f"n: {n}!") async def main(): try: await asyncio.wait_for(foo(1), timeout=5) except asyn...
dedb7dacef7ef63861c76784fc7cff84cf8ca616
umunusb1/PythonMaterial
/python3/10_Modules/09_random/04_random_name_generator.py
775
4.28125
4
from random import choice def random_name_generator(first, second, x): """ Generates random names. Arguments: - list of first names - list of last names - number of random names """ names = [] for i in range(x): names.append("{0} {1}".format(choice(fi...
8f6d1952edb0858a9f9c9b96c6719a1dd5fcb6d2
umunusb1/PythonMaterial
/python2/08_Decorators/06_Decorators.py
941
4.59375
5
#!/usr/bin/python """ Purpose: decorator example """ def addition(num1, num2): print('function -start ') result = num1 + num2 print('function - before end') return result def multiplication(num1, num2): print('function -start ') result = num1 * num2 print('function - before end') ret...
30b1f07e2ee7679646e1a281cd31f09fbc60096e
OmishaPatel/Python
/daily-coding-problem/get_sentence_split.py
591
3.765625
4
def get_sentence_split(s, words): if not s or not words: return [] word_set = set(words) print(word_set) print("s: "+s) words_sentence = [] for i in range(len(s)): if s[0:i+1] in word_set: print(s[0:i+1]) words_sentence.append(s[0:i+1]) print(...
ca2e9d36b09cf0831e8756094c70b76ab1d77e3b
OmishaPatel/Python
/daily-coding-problem/max_of_subarray_k_size.py
227
3.671875
4
def max_of_subarray_k_size(arr, n, k): max= 0 for i in range(n-k +1): max = arr[i] for j in range(1, k): if arr[i+j] > max: max = arr[i+j] print(str(max)) max_of_subarray_k_size([1,2,3,4,5], 5, 3)
df4858753ba98281c0dcef4e1cfc795d3e153ae3
OmishaPatel/Python
/miscalgos/reverse_integer.py
391
4.125
4
import math def reverse_integer(x): if x > 0: x= str(x) x = x[::-1] x = int(x) else: x = str(-x) x = x[::-1] x = -1 * int(x) if x <= math.pow(2, 31) -1 and x >= math.pow(-2,31): return x return 0...
65ad7a18009d3595863f35760e7cc8f0ae78657d
OmishaPatel/Python
/datastructure/linked_list_insertion.py
1,290
4.3125
4
class Node: def __init__(self,data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def print_list(self): cur_node = self.head while cur_node: print(cur_node.data) cur_node = cur_node.next de...
84f3596a8c085f14c6681ac10b22727614c607cc
OmishaPatel/Python
/wordcountbydict.py
270
3.796875
4
text = input("enter a file name: ").split() d = dict() for word in text: print(word) d[word] = d.get(word,0) +1 print(d) count = -1 word = None for k,v in d.items(): if v > count: count = v word = k print("Word", word, "Repeats", count)
3adc47fc550a80670a73b703dd1863ef94d02cc0
OmishaPatel/Python
/datastructure/binary_tree_insertion_deletion.py
3,511
4.0625
4
class Node: def __init__(self, value): self.value = value self.left = None self.right = None class BinaryTree: def __init__(self): self.root = None def insert(self, value): if self.root is None: self.root = Node(value) else: self._ins...
9fec21ec50d899a2cd0b87da56cacf31cf4dbc9b
OmishaPatel/Python
/datastructure/array_advance.py
376
3.734375
4
def array_advance(nums): furthest_index = 0 i = 0 last_index = len(nums) -1 while i <= furthest_index and furthest_index < last_index: furthest_index = max(furthest_index, nums[i] + i) i+= 1 return furthest_index >= last_index nums= [3, 3, 1, 0, 2, 0, 1] print(array_advance(nums)) ...
9c1ac8fffa66557b1de79985e16f8fec6e9f48f0
OmishaPatel/Python
/daily-coding-problem/longest_substring_with_k_distinct_characters.py
496
3.671875
4
def longest_substring_with_k_distinct_characters(s, k): current_longest_substring = '' for i in range(len(s)): for j in range(i + 1, len(s) + 1): substring = s[i:j] if len(set(substring)) > k: break if len(substring) > len(current_longest_substring): ...
e148b845fbc45964a0d3de23b60f704e60386933
T-o-s-s-h-y/Learning
/Python/progate/python_study_2/page2/script.py
360
3.640625
4
# 変数fruitsに、複数の文字列を要素に持つリストを代入してください fruits = ['apple', 'banana', 'orange'] # インデックス番号が0の要素を出力してください print(fruits[0]) # インデックス番号が2の要素を文字列と連結して出力してください print("好きな果物は" + fruits[2] + "です")
12ee1624fd1b94456493fbd49286189bca7662b9
T-o-s-s-h-y/Learning
/Python/progate/python_study_3/page6/script.py
477
3.640625
4
def print_hand(hand, name='ゲスト'): print(name + 'は' + hand + 'を出しました') print('じゃんけんをはじめます') # inputを用いて入力を受け取り、変数player_nameに代入してください player_name = input('名前を入力してください:') # 変数player_nameの値によって関数print_handの呼び出し方を変更してください if player_name == '': print_hand('グー') else: print_hand('グー', player_name)
8a9eda00c5aa69ef1946d5a2ceec8047712d099b
Famebringer/scripts
/les6/pe6.1.py
354
3.65625
4
# voor de printing manier def f(x): res = x * 2 + 10 print (res) f(2) # voor de return manier def f(x): res = x * 2 + 10 return res def som(getal1, getal2, getal3): antwoordt = getal1 + getal2 + getal3 print('getal1 is', getal1) print('getal2 is', getal2) print('getal3 is', getal3...
931e05be3f97d32284542b3e9ef7ebada23a1c9f
Famebringer/scripts
/les5/pe5.6.py
330
3.6875
4
# Schrijf een for-loop die langs alle letters van een string loopt en de letter uitprint, # maar alleen als het een klinker is ('aeiou'). # Gebruik de volgende string: s = "Guido van Rossum heeft programmeertaal Python bedacht." klinkers = '' for letters in s: if letters in 'aeoui': klinkers += letters...
4745349bd4e7830533f76c21c5f751d7940cc161
nyalldawson/dwarf_mine
/traits.py
1,397
3.890625
4
import random class Trait: """ A creature character trait """ def __init__(self): self.type = '' def affect_visibility(self, visible): return visible def affect_move_to(self, x, y): # return None to block movement return (x,y) class Determined(Trait): """...
b692f6009d0177c0057d68c593b551dfb64e74e9
kathrinv/advent-of-code-2019
/day8.py
3,927
3.78125
4
import pprint as pp from typing import List def load_day8_input(filename: str) -> str: """ Loads the input representing the image transmitted Args: filename: The name of the file with the inputs for Day 8. It should be saved down to the ...
5878f392397d6bf2bed199f0dd9b514e1214aa37
dkarthicks27/COVID-19-Project
/covid_test.py
2,333
3.84375
4
# this is just a test case of covid-19 # let us first define the problem statement # build an app that let's us visualise the corona effect # that is whether the curve is increasing on flattening # depending on the city import pandas as pd import matplotlib.pyplot as plt import numpy as np url = "https://raw.githubuse...
404687852854ae63c74baa2196c12677bf50343e
ashwinidotx/100daysofcode
/Files/Day 16/TextEditor.py
1,324
3.6875
4
from Tkinter import * from tkFileDialog import * import tkMessageBox filename= "untitled" def newFile(): global filename filename="Untitled File" text.delete(0.0,END) def saveFile(): global filename t = text.get(0.0,END) f = open(filename+'.txt','w') f.write(t) f.close() def saveAs()...
6ea47a5727c4822af6adaf2bfa02a0c8c46e54eb
cselman99/Binary-ST
/binary_search_tree.py
5,128
3.96875
4
from queue_array import Queue class TreeNode: def __init__(self, key, data, left=None, right=None): self.key = key self.data = data self.left = left self.right = right def __eq__(self, other): return ((type(other) == TreeNode) and self.key == ...
33dd09b968beccd122c1bd95593fccb78a37e476
silviosnjr/python-parte1
/exemplo_sintaxe/3_condicional_simples.py
164
3.84375
4
#exemplo de condicional if(se) com um else(se não) idade = 16 if(idade < 18) : print("é MENOR de idade") else: print("é MAIOR de idade")
f020b02798e40d543553038c999259144036210d
silviosnjr/python-parte1
/exemplo_sintaxe/8_funcao.py
352
3.546875
4
#variáveis estáticas nome = "Fulano" nascimento = 1987 #Declaração da função escreve_idade def escreve_idade(nome, ano, nascimento): print (nome, "tem", (ano - nascimento), "anos") print ("Função Encerrada") #Chamando a função escreve_idade #e passando as variáveis como parametros escreve_idade (no...
cdad839660771f79fea5df8092163ed8ce18dde3
ingoglia/python_work
/Python_Book/part2_data/die_visual.py
700
3.921875
4
import matplotlib.pyplot as plt from die import Die # Create a D6. die = Die() # Make some rolls, and store results in a list. results = [] for roll_num in range(1000): result = die.roll() results.append(result) # Analyze the results. frequencies = [] for value in range(1, die.num_sides+1): frequency = r...
55dd00d10cb8a4b65d7641b419fd2a48670fd20c
ingoglia/python_work
/part1/4.13.py
221
3.515625
4
buffet = ('chicken', 'cat', 'monkey', 'dog', 'rice') for snacks in buffet: print(snacks) #buffet[1] = 'cow' new_buffet = ('chicken', 'cow', 'monkey', 'dog', 'noodles') for snackles in new_buffet: print(snackles)
3ba562ff4adaad94267aa9c62fdc1134d40b1910
ingoglia/python_work
/part1/4.11.py
326
4.1875
4
pizzas = ['anchovy', 'cheese', 'olive'] friend_pizzas = ['anchovy', 'cheese', 'olive'] pizzas.append('mushroom') friend_pizzas.append('pineapple') print("My favorite pizzas are:") for pizza in pizzas: print(pizza) print("\nMy friends favorite pizzas are:") for friend_pizza in friend_pizzas: print(friend_pizza) ...
da6bdd917f756b49892a78088f3b996edaed7fbe
ingoglia/python_work
/Python_Book/part1/3.6.py
740
4.03125
4
invite = ['Mike', 'Joe', 'Josh', 'Harold', 'Cardin'] print('Hey '+ invite[0] + "! Would you like to come to dinner?") print('Hey '+ invite[4] + "! Would you like to come to dinner?") print('Hey '+ invite[3] + "! Would you like to come to dinner?") print(invite[1] + " and " + invite[2] + "! Come over for dinner!") print...
4673810d70d74308f79683b34151f62e5f70c133
ingoglia/python_work
/part1/9.1.py
699
4.09375
4
class Restaurant(): """A Restaurant class""" def __init__(self, restaurant_name, cuisine_type): """Initialize attributes to describe a restaurant""" self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): """ Talks about th...
3683f4b62501faa80cb0a67e3979cabe0fdc7e54
ingoglia/python_work
/part1/5.2.py
1,063
4.15625
4
string1 = 'ferret' string2 = 'mouse' print('does ferret = mouse?') print(string1 == string2) string3 = 'Mouse' print('is a Mouse a mouse?') print(string2 == string3) print('are you sure? Try again') print(string2 == string3.lower()) print('does 3 = 2?') print(3 == 2) print('is 3 > 2?') print(3 > 2) print('is 3 >= 2...
ebf65f149efb4a2adc6ff84d1dce2d2f61004ce4
ingoglia/python_work
/part1/8.8.py
633
4.375
4
def make_album(artist, album, tracks=''): """builds a dictionary describing a music album""" if tracks: music = {'artist': artist, 'album':album, 'number of tracks':tracks} else: music = {'artist': artist, 'album':album} return music while True: print("\nPlease tell me an artist an...
dfe8231c9d50b6066064aaf25806de54fe1eeb52
ingoglia/python_work
/part1/7.9.py
545
3.8125
4
sandwich_orders = ['pastrami','ruben','roast beef','pastrami','pastrami', 'tuna', 'blt'] finished_sandwiches = [] print("We are... out of pastrami!!!! ahhhhhhhhhhhhhh") while 'pastrami' in sandwich_orders: sandwich_orders.remove('pastrami') while sandwich_orders: current_order = sandwich_orders.pop() ...
4241434076bfdfa2464a421cd59a1a6ac592e07d
TongZZZ/coursera
/python/pong.py
4,572
3.84375
4
#http://www.codeskulptor.org/#user23_V0QqB4nk27_163.py # Implementation of classic arcade game Pong import simplegui import random # initialize globals - pos and vel encode vertical info for paddles WIDTH = 600 HEIGHT = 400 BALL_RADIUS = 20 PAD_WIDTH = 8 PAD_HEIGHT = 80 HALF_PAD_WIDTH = PAD_WIDTH / 2 HALF_PAD_...
0b962dfa9549648cfdb1585149964fb1e568ed01
dewi-maya/Programming-DSAI
/Python Codes/string_arg.py
251
4.0625
4
""" Filename: string_arg.py Call a function with string argument """ def my_function(str): str += "..." print(str) def main(): str = "Hello, world" my_function(str) print(str) if __name__ == '__main__': main()
b4a24b3ca29f09229589a58abfa8f0c9c4f3a094
marcellenoukimi/CS-4308-CPL-Assignment-3
/Student.py
2,681
4.34375
4
""" Student Name: Marcelle Noukimi Institution: Kennesaw State University College: College of Computing and Software Engineering Department: Department of Computer Science Professor: Dr. Sarah North Course Code & Title: CS 4308 Concepts of Programming Languages Section 01 Fall 2021 Date: Oct...
07fe8bf2b40cc5a560cc08c044ca284bbdfa6133
VGAD/tactics
/unit/anti_armour.py
2,646
3.5625
4
from unit.ground_unit import GroundUnit import unit, helper, effects from tiles import Tile import pygame class AntiArmour(GroundUnit): """ An infantry unit armed with an anti-armour missile launcher. Very effective against tanks and battleships, but otherwise not especially powerful. Armour:...
924a648dfe8c3716121962a4f71479e512960c75
EricSchles/uav
/hacker_rank/ave_score/ave_score.py
256
3.71875
4
n = int(raw_input()) scores = {} def avg(scores): return sum(scores)/float(len(scores)) for i in range(n): line = raw_input().split(" ") scores[line[0]] = avg([int(elem) for elem in line[1:]]) print "{0:.2f}".format(scores[str(raw_input())])
32891093de24ca2a5936e9fb9d75332c6d6e009e
Raidn1771/PyOpenGL-for-Windows
/Sample_Questions/test_dda.py
1,641
3.609375
4
#Program to plot a point from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * import sys import math import time # from line_algorithm import line_algorithm global P_in, P_f P_in, P_f = [0, 0], [100, 100] def init(): glClearColor(0.0, 0.0, 0.0, 0.0) gluOrtho2D(-250.0, 250.0, ...
15f79a8f57b3c6bcb918171d40f56995924c71e3
badziej112/Projekt
/City.py
1,163
4.03125
4
from AbstractBuilding import AbstractBuilding class City(AbstractBuilding): def __init__(self, x, y, population): super().__init__(x, y, "C") self.population = population def build(self, fraction): """Buduje miasto i odejmuje jego koszt od zasobów frakcji oraz dodaje punk...
f2ce32c475e83713c0ddc74e589278712c77c28b
BenitoMarculanoRibeiro/LigaMagic-Python-TCC
/concertar.py
6,318
3.640625
4
# coding: utf-8 from random import randrange, uniform # Algoritmo usado para concertar os arquivos conrrompidos # Problema: # Os aquivos tem posições vazias o que seria o equivalente a posições nulas. # Solução: # Como isso esse problema não agrega em nada o projeto decidi substituir as posições vazias por numeros alea...
20a6987914ad5796f89b6d4871cb9baa729fb738
2727-ask/HR-CC
/Patterns/designer_floor_mat.py
240
3.640625
4
inputs = input().split() row = int(inputs[0]) col = int(inputs[1]) a = ".|." for x in range(1,row,2): print((str(a)*x).center(col,'-')) print('WELCOME'.center(col,'-')) for y in range(row-2,-1,-2): print((str(a)*y).center(col,'-'))
ad831333ad36425690ef68e2664634f0b3a9426b
2727-ask/HR-CC
/Patterns/string_rangoli.py
298
3.84375
4
def triangle(n): k = n - 1 for i in range(0, n): for j in range(0, k): print(end=" ") k = k - 1 for j in range(0, i + 1): print("* ", end="") print("\r") triangle(5) c=0 while(c < 6): c = c+ 1 print(str(4*"*").rjust(5,'\t'))
18f441a97eff2d55524a1924265aa1d7a052c83d
2727-ask/HR-CC
/Strings/Company Logo.py
116
3.546875
4
from collections import Counter s = sorted(input()) arr=Counter(s).most_common(3) for x in arr: print(x[0],x[1])
cd332ab59ede9fa70ac847d4dad76065aa9882a2
iNouvellie/python-3
/02_EstructuraDeDatos/06_Diccionario_III.py
594
4.375
4
calificaciones = {"tito": 10, "naty":6, "amaro": 5} #Al recorrer e imprimir con un for, solo muestra la llave for calificacion in calificaciones: print (calificacion) #De esta forma obtenemos el numero de la calificacion for calificacion in calificaciones: print (calificaciones[calificacion]) #Imprime la key, pero...
ebe0471563ed33d4af96c73109a0f83f33332ae4
iNouvellie/python-3
/01_IntroduccionPython/07_Ciclos.py
697
4.125
4
#Ciclos while, repiten bloque de codigo mientras la condicion sea cierta #Ciclo for, recorren elementos en una coleccion frutas = 10 while frutas > 0: print ("Estoy comiendo una fruta " + str(frutas)) #frutas = frutas - 1 frutas -= 1 if frutas == 0: print ("\n") print ("Me quede sin frutas") #--- o --- list...
f46cd4e475d579cdd9245a07cfdd596f407be50c
matheusferretti/LearnPythonFunctions
/exercises/06-lambda-functions/app.py
73
3.78125
4
# your function here is_odd = lambda num: num % 3 == 0 print(is_odd(2))
abcde7966a45cae360b22e6ad0503af576dd98c9
Sergio2409/PSP-Programs
/Programa6/Code/node.py
369
3.9375
4
# -*- coding: utf-8 -*- class Node(object): def __init__(self, value=None, next=None): self.value = value self.next = next @property def has_next(self): '''Return True if the node has a next otherwise returns False. ''' return True if self.next else False de...
9004ce01e54e5e65cf1a95cb00de98f0160d795b
Sergio2409/PSP-Programs
/Programa6/Code/compute_simpson_rule.py
3,490
3.578125
4
# -*- coding: utf-8 -*- import math from math import log, sqrt, e class ComputeSimpsonRule(object): def __init__(self, _list): self.t = _list.value[0] self.dof = _list.value[1] self.p = 0 def compute_factorial(self, val): ''' Calcula el factorial del número pasado (val – 1). ...
51e015545046b6411f88bcf969c22b69529464d3
bigmoletos/WildCodeSchool_France_IOI-Sololearn
/soloearn.python/sololearn_pythpn_takeAshortCut_1.py
1,353
4.375
4
#Quiz sololearn python test take a shortcut 1 #https://www.sololearn.com/Play/Python #raccouri level1 from _ast import For x=4 x+=5 print (x) #************* print("test 2") #What does this code do? for i in range(10): if not i % 2 == 0: print(i+1) #************* print("test 3") #What is the output of this c...
26dca6d8c9108c7c33454b2603f82aff8956daa6
bigmoletos/WildCodeSchool_France_IOI-Sololearn
/soloearn.python/sololearn_pythpn_course_level_3.py
37,405
4.1875
4
#Quiz sololearn python test take a shortcut 1 #https://www.sololearn.com/Play/Python #cours level 2 et 3 #************* def deco(func): def wrap(): print("============") func() print("============") return wrap @deco def printTitle(): print("**********************COURS********************") prin...
716e688dcdea7c3e249471ab13d765ff6d97eb79
jaxono/Price-Comparer
/get_ingrediants.py
1,121
3.9375
4
import re import item_class TERMINATION_PHRASES = {"xxx", "done", "end", "finish", "finished"} def get_ingrediants(): items = [] print(""" Now you will need to enter a list of the items you would like to compare, type done when you are finished. """) # Get list of ingredients while 1: # Get ite...
1eb320f57324bf2406eeb4d6cf96ea7dadd57f79
butterflow/butterflow
/2a.py
289
3.71875
4
print("Your function is 7n+5") print("g(n) = n ") print("Assuming c as 8") for i in range(30): a1 = 7 * i + 5 a2 = 8 * i if (a2 >= a1): n0 = i break print("Value of n0: ", n0) print("Value\t\tF(n)\t\tc*G(n)") for i in range(10, 31): print(i, "\t\t", 7 * i + 5, "\t\t", 8 * i)
ed0c50a944a9af8588a9818b12c30db7a4e4bf1e
butterflow/butterflow
/14a.py
326
3.5625
4
import time,random def ssort(l): for i in range(len(l)-1): min=i for j in range(i+1,len(l)): if l[j]<l[min]: min=j l[i],l[min]=l[min],l[i] return l x=[random.randint(1,10) for i in range(10)] print(x) start=time.time() f=ssort(x) end=time.time() print("sorted array is:") print(f) print("time is:",(end-st...
54a3fb2e89336c11f56f1bcbdcdf951ffeb2d31e
butterflow/butterflow
/3b.py
339
3.546875
4
import time import random def isort(arr): for i in range(1,len(arr)): key=arr[i] j=i-1 while j>=0 and key<arr[j]: arr[j+1]=arr[j] j-=1 arr[j+1]=key return arr f=[random.randint(1,10)for i in range(10)] print(f) start=time.time() isort(f) end=time.time() print("sorted array:") print(f) print("time taken ...
7dac5dd841c8049af6d8d9b441368ee3a72a6b84
franckjay/GoodReadsGraph
/api/GoodReadsGraph.py
13,944
3.546875
4
import pandas as pd import numpy as np class Graph(object): def __init__(self, reads): """ """ # Edges in our graph self.reads = reads def _find_a_user(self, input_User, debug=False): """ Find a user in the graph N hops from an author in the user's lis...
f615f86ee7df4aa30a9ce27e1d3667d9d6526600
kclip/DSVGD
/data/create_pickled.py
1,809
3.609375
4
import numpy as np import matplotlib.pyplot as plt import pickle """ This file creates a binary file for MNIST or Fashion MNIST datasets for faster dataloading. Please make sure to download either datasets from : http://yann.lecun.com/exdb/mnist/ or https://github.com/zalandoresearch/fashion-mnist Code ...
d1349d0982af9e06c5e8c5aaa26b200497b22e3f
guokairong123/PythonBase
/DataStructure/list_demo1.py
663
4.1875
4
""" 如果我们想生产一个平方列表,比如 [1, 4, 9...],使用for循环应该怎么写,使用列表推导式又应该怎么写呢? """ # list_square = [] # for i in range(1, 4): # list_square.append(i**2) # print(list_square) # # list_square2 = [i**2 for i in range(1, 4)] # print("list_suqare2:", list_square2) # # list_square3 = [i**2 for i in range(1, 4) if i != 1] # # for i in r...
f014a82968e1b169cb8651be3c7ea313b99a3cf0
guokairong123/PythonBase
/function/func_demo1.py
449
4.0625
4
""" 默认参数 默认参数在定义函数的时候使用k=v的形式定义 调用函数时,如果没有传递参数,则会使用默认参数 """ def func2(a=1): print("参数a的值为:", a) func2(2) """ 关键字参数 在调用函数的时候,使用k=v的方式进行传参 在函数调用/定义中,关键字参数必须跟随在位置参数的后面 """ def func3(b): print("参数b的值为:", b) func3(b=3)
384aee6c8f1024a4f96f325ec5542c46aa18e3b2
BufteacEcaterina03/Rezolvare-problemelor-IF-WHILE-FOR
/problema4.ForIfWhile.py
332
3.984375
4
from fractions import Fraction a=int(input("Introduceti numaratorul primei fractii: ")) b=int(input("Introduceti numitorul primei fractii: ")) x=int(input("Introduceti numaratorul fractiei a 2: ")) y=int(input("Introduceti numitorul fractiei a 2: ")) print(Fraction(a ,b) + Fraction(x,y)) print(Fraction(a,b) * Fr...
27af3b1693096ea5caa291f637c4558a542c7265
saltywalnut/CIT_SKP
/200919/mySort.py
333
3.9375
4
list = [3,72,85,49,1,65,23,25] def sortlist (list): (list[y]) = length (list[x]) = 1 length = len(list) while length > 0: if (list[x]) > (list[y]): list2.append (list[x]) print (list[x]) else: list2.append (list[y]) print (list[y]) ...
467389de2d02b08620e8923742b99f9de2001660
saltywalnut/CIT_SKP
/200627/number.py
323
4.09375
4
# number = 178 # 1 - 3000 # # "odd" "even" # # even = (number%2 == 0) # # odd = (number%2 == 1) # # if (even): # print ("even") # # if (odd): # print ("odd") num = 180 if num%2 == 0 : print ("even") if num > 1000: print("K") else: print ("odd") if num%2 == 0 and num>1000 : print ("even...
214ff1fd25d4f024d9730ee729306eecd325b796
sethsamelson/checkers
/checkers.py
558
3.90625
4
def display(board): for row in board: print row def initial_board(): top = [['x' if col % 2 == row % 2 else ' ' for col in range(8)] for row in range(3)] middle = [[' '] * 8 for x in range(2)] bottom = [['o' if col % 2 != row % 2 else ' ' for col in range...
92965acf135833d0aa8e4066ccedaa91a9958399
Berkmann18/Asteroid
/Vector.py
4,071
4.5
4
""" Vector.py The module that implements vectors and all the necessary methods that comes with vectors. """ import math class Vector: """ The Vector class """ # Initialiser def __init__(self, p=(0, 0)): self.x = p[0] self.y = p[1] @property def __str__(sel...
3f754822eb9704063bf40d3309afc58e13bedec7
nivedita/pylsm
/ModelSpace.py
2,203
3.765625
4
""" Classes and methods for representing neurons in some spatial configuration Author: Sina Masoud-Ansari Classes: Point3D Cuboid3D """ import math import unittest class Point3D: """A point in 3D Euclidian space""" def __init__(self, x, y, z): self.x = x self.y = y self.z = z def __eq__(self, other): ...
724087e634a6689324dd4bcf07657c19fb2ffaa4
NehemiahLimo/politicoapp-api
/app/api/v1/models/office_model.py
557
3.59375
4
offices = [] class Office: """A method to initialize the office resource""" def __init__(self, office_id, office_type, office_name): self.id = office_id self.type = office_type self.name = office_name @classmethod def create_office(cls, office_id,office_type, office_name ): ...
2c7148695d3d0b390d1e85032f9f738b9e666b14
bryanwspence/-6.00.1x---Week-05
/hand-scratch.py
423
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jul 21 09:12:53 2020 @author: bryan.spence """ def __str__(self): ''' Display a string representation of the hand. ''' output = '' hand_keys = sorted(self.hand.keys()) for letter in hand_keys...
c38dcf8d5dfb399ee45ee0c87a4e0ec0444f7de7
amoghnayak07/Batman1
/chetana.py
165
3.625
4
a = input() b = list(a) c = [] for i in b: if i.isupper(): j = i.lower() c.append(j) if i.islower(): k = i.upper() c.append(k) d = ''.join(c) print(d)
b8305ebd207750c369fd7c69dcad0f0c16976c7d
amoghnayak07/Batman1
/11.py
538
3.515625
4
import csv c = [] def add(): name = input("Enter name: ") print("Optios: 1.CS\n2.Google it\n3.Treasure hunt") choice = int(input("Enter Chice: ")) if choice == 1: c[0:] = [name, 'CS'] elif choice == 2: c[0:] = [name, 'Google it'] elif choice == 3: c[0:] = [name, 'Treasure Hunt'] with open ('New', 'w', newl...
adc774ab64a9d573f3b7e40059c080267a9088f5
mrgrant/LeetCode
/729.my-calendar-i.py
724
3.59375
4
# # @lc app=leetcode id=729 lang=python # # [729] My Calendar I # import bisect # @lc code=start class MyCalendar(object): def __init__(self): self.arr = [[float("-inf"), float("-inf")], [float("inf"), float("inf")]] def book(self, start, end): """ :type start: int :ty...
ef1045c23f96eeb0c8543c5ec49e7449243b618a
mrgrant/LeetCode
/528.random-pick-with-weight.py
878
3.515625
4
# # @lc app=leetcode id=528 lang=python # # [528] Random Pick with Weight # # @lc code=start import random class Solution(object): def __init__(self, w): """ :type w: List[int] """ s = sum(w) for i in range(1, len(w)): w[i] = w[i] + w[i-1] self.rate = [v...
b44e15cf6d93cef163890f0099b2e59b262994d6
mrgrant/LeetCode
/838.push-dominoes.py
1,412
3.625
4
# # @lc app=leetcode id=838 lang=python # # [838] Push Dominoes # # @lc code=start class Solution(object): def pushDominoes(self, dominoes): """ :type dominoes: str :rtype: str """ stack = [] res = [] dominoes = list(dominoes) while dominoes: ...
9a94c82c32643f2f28d45af7a987a931fe356de8
DarkC35/AdventOfCode2020
/19/19.py
634
3.578125
4
from timeit import default_timer as timer start = timer() with open("input.txt") as file: adapters = sorted([int(line) for line in file]) current_jolts = 0 count_1_jolt_difference = 0 count_3_jolt_difference = 0 for adapter in adapters: if adapter - current_jolts == 1: count_1_jolt_difference += 1 ...
d7d0ad97fab694f428ceaec389b3b9d3042f9e4f
DarkC35/AdventOfCode2020
/04/04.py
595
3.609375
4
import re from timeit import default_timer as timer def validate_password(password, letter, pos1, pos2): return (password[pos1-1] == letter or password[pos2-1] == letter) and password[pos1-1] != password[pos2-1] start = timer() count = 0 reg_obj = re.compile(r'(\d+)-(\d+) (.): (.+)') with open("input.txt", "r")...
0e1600eb8c048b1cdf2a0d445b3dba9a44ccec96
vrushti-mody/Leetcode-Solutions
/Plus_One.py
791
3.5
4
# Given a non-empty array of digits representing a non-negative integer, increment one to the integer. # The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit. # You may assume the integer does not contain any leading zero, except ...
98b35be936cb3686fdb40908832dd1376bf98314
vrushti-mody/Leetcode-Solutions
/Angle_Between_Hands_of_a_Clock.py
282
3.859375
4
# Given two numbers, hour and minutes. Return the smaller angle (in degrees) formed between the hour and the minute hand. class Solution: def angleClock(self, hour: int, minutes: int) -> float: return min(abs(30*hour-5.5*minutes),360-abs(30*hour-5.5*minutes))
cc681899f5ec8876fbe9cccf6e3c457ec6551372
vrushti-mody/Leetcode-Solutions
/Odd_Even_Linked_List.py
1,017
4.03125
4
# Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. # You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity. # Definition for singly-linked ...
6486d49174a3399a40bcbadd8eb58ab3d53400e4
vrushti-mody/Leetcode-Solutions
/Island_Perimeter.py
1,171
3.78125
4
#You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. #Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells). #The island doesn't h...
25b431ea6e4b3c2292fe3a6d6a8fca73353ba189
vrushti-mody/Leetcode-Solutions
/Count_Square_Submatrices_with_All_ones.py
846
3.578125
4
# Given a m * n matrix of ones and zeros, return how many square submatrices have all ones. class Solution: def countSquares(self, matrix: List[List[int]]) -> int: # Initialize count variable N=len(matrix) M= len(matrix[0]) a=matrix count = 0 for i in range(1, N):...
e4c2c56cf9247fb7d3dac124e1a5a3bff1ab0d4d
vrushti-mody/Leetcode-Solutions
/Uncrossed_Lines.py
1,446
3.640625
4
# We write the integers of A and B (in the order they are given) on two separate horizontal lines. # Now, we may draw connecting lines: a straight line connecting two numbers A[i] and B[j] such that: # A[i] == B[j]; # The line we draw does not intersect any other connecting (non-horizontal) line. # Note that a connec...
f493541c59e1ff3ab549396d28dc90ff4c46927e
vikram789/my-app
/66-PlusOne.py
1,116
3.984375
4
""" Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit. You may assume the integer does not contain any leading zero, except the...
d10dbb297992ddbe63bed197f6ae8c90c83f3328
vikram789/my-app
/02-add_two_numbers.py
1,636
3.921875
4
""" You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. ...
3aff592b0440188b256532c0a4fd38e518f70137
vikram789/my-app
/01-sum2.py
1,589
4.09375
4
""" STATEMENT Given an array of integers, return indices of the two numbers such that they add up to a specific target. CLARIFICATIONS - What happens when there is no solution? Assume solution exists. - Can the list be empty? No. - Is the list sorted? Not necessarily. EXAMPLES [2, 7, 11, 15], 9 -> [0,1] ...
acf63f2b22309621e2c7a642141a37680ebea5a9
crazywiden/590PZ-Project
/circleCatGame/utils.py
265
3.65625
4
from random import randint def generate_random_locations(n, loc_dict): # within a board n*n # generate a random valid location while True: i = randint(0,n-1) j = randint(0,n-1) if (i,j) not in loc_dict: return (i,j)
59a5f763b58681705c74852bdef33c798503cf8f
HanySedarous/Python-Challenge
/Budget_Data.py
1,514
3.59375
4
import csv with open('C:/Hany/Data Analyst Course/paython/Python-Challenge/budget_data.csv', newline='') as csvfile: spamreader = csv.reader(csvfile, delimiter=',') next(spamreader) total = 0 month = [] loses = [] earns = [] biggest_month ="" lowest_month ="" highest_ea...
8a1894901e9aa4f122719e3215bab2e2f12369b2
imakin/cloaked-octo-ninja
/Koin/Peluang/main.py
775
3.578125
4
#!/usr/bin/env python3 import sys def echo(s): sys.stdout.write(s) a = 1 b = 5 c = 10 #~ a = 90 #~ b = 160 #~ c = 230 ax = 27 bx = 0 cx = 0 hasil = [] #~ hasilline = [] while(ax>0): if (a*ax + b*bx + c*cx)==a*27: #~ print(a,ax,' ',b,bx,' ',c,cx) hasilline = [a,ax,b,bx,c,cx] hasil.append(hasilline) cx = 0 ax ...
f7bca8a3e3672c7f531faa89cc6ca7d16eeb2f29
alejandro123210/Deep-learning-Projects
/diabetesPrediction/diabetesPrediction.py
3,012
3.84375
4
# TensorFlow and tf.keras # imports everything needed import tensorflow as tf from tensorflow import keras from keras.models import Sequential from keras.layers import Dense import numpy # sets random seed to 7 for reproducing the same results every time numpy.random.seed(7) # loads the dataset for the pima indians, f...
c37896119d527ccf86921be8cb0bf27a1d502e6b
jackdreinhardt/AI-Project-2
/src/convert2CNF.py
11,940
3.84375
4
from globals import * class convert2CNF: @staticmethod def CNF(prop): ''' CNF() transforms a sentence that is in propositional logic into its conjunctive normal form (CNF) Specifically it resolves biconditionals (<->) and implications (->), uses De Morgan's law and finally dist...
c3e7d47131b2272b00067b96c800803bfd6ee827
frankySF86/PytonLearning_2019
/FrameAdvantageFun/TempDbTesting.py
525
3.8125
4
import sqlite3 with sqlite3.connect(":memory:") as connection: print(type(connection)) dbcursor = connection.cursor() dbcursor.execute("CREATE TABLE mytesttable(fighterName nvachar(15), fighterage int)") fighter_values=(("Ryu",35),("Chun Li",21),("Cammy",24)) dbcursor.executemany("INSERT INTO mytes...
da0cd5a8d5ed63e56893410eec04ab7eb3df7cff
ARCodees/python
/Calculator.py
458
4.21875
4
print("this is a calculator It does all oprations but only with 2 numbers ") opration = input("Enter your opration in symbolic way ") print("Enter Your first number ") n1 = int(input()) print("Enter Your second number ") n2 = int(input()) if opration == "+": print(n1 + n2) elif opration == "-": pri...
e193dbd63188d0c2848e3f65105de8a678d03ed9
sugitanishi/competitive-programming
/atcoder/abc158/a.py
58
3.875
4
s=input() print('Yes' if 'AB' in s or 'BA' in s else 'No')