blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
1468451a6aba8cc88f561ec31892b71c8da4395c
sonilakar/SNA-Learning-Class-Stuff
/ShortestPaths.py
1,755
3.96875
4
print() import networkx from networkx import algorithms import matplotlib # create a weighted graph G = networkx.Graph() nA, nB, nC, nD, nE = 'A', 'B', 'C', 'D', 'E' G.add_nodes_from([nA, nB, nC, nD, nE]) G.add_weighted_edges_from([(nA,nB,2),(nB,nC,3),(nC,nD,4)]) G.add_weighted_edges_from([(nA,nE,9),(nE,...
55895597212b89446247b11f01530c29776a2822
VPP-CT/Backend-Flask
/hotel_parser.py
3,108
3.578125
4
"""Module for hotel searching and parsing. This module would process hotel related data, and return filtered result to the server. """ from __future__ import print_function import requests import json returnedNum = 200 # only return top 50 hotel data def search_hotels(hotel_data): # type: (str) -> object ...
c0b98e16909c75d0e9be772bfe8f6c91400f2329
sarahwang93/leetcode_summary
/src/searchTree.py
578
3.84375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class searchTree: def searchBST(self, root: TreeNode, val: int) -> TreeNode: #corner case res = [] i...
d1b7d84d24419fecf78c4929ec1e02d74c7d33e0
vkmrishad/string-find
/string_find.py
1,728
4
4
from typing import List def find(data: List[str], query: str): """ Function that will find all exact words from list of words. """ # List for storing result. result = list() # Check if data is a list. if type(data) == list: # Check if data and query is not None. if data an...
0e345182eac194768d04998afe39423f7515958e
danilevy1212/Exercism
/python/armstrong-numbers/armstrong_numbers.py
160
3.671875
4
def is_armstrong_number(number): num2str = str(number) length = len(num2str) return sum(int(num2str[i])**length for i in range(length)) == number
1af54799ccb47425656ae37daf665f02a09dcace
bcastor/A.I.---Sudoku
/backtrack.py
3,478
3.765625
4
''' COURSE: CS-550 Artificial Intelligence SECTION: 01-MW 4:00-5:15pm DATE: 15 April 2020 ASSIGNMENT: 05 @author Mariano Hernandez & Brandon Castor DESCRIPTION: Backtrack ''' from csp_lib.backtrack_util import (first_unassigned_variable, unordered_domai...
c27205377f4de9ef50f141c30b502a795c6dc118
wmjpillow/Algorithm-Collection
/how to code a linked list.py
2,356
4.21875
4
#https://www.freecodecamp.org/news/python-interview-question-guide-how-to-code-a-linked-list-fd77cbbd367d/ #Nodes #1 value- anything strings, integers, objects #2 the next node class linkedListNode: def __init__(self,value,nextNode=None): self.value= value self.nextNode= nextNode def insertNode(h...
ca845b51f55cef583bfc6b9ff05741d56f474fec
mbravofuentes/Codingpractice
/python/IfStatement.py
625
4.21875
4
import datetime DOB = input("Enter your DOB: ") CurrentYear = datetime.datetime.now().year Age = CurrentYear-int(DOB) #This will change the string into an integer if(Age>=18): print("Your age is {} and you are an adult".format(Age)) if(Age<=18): print("Your age is {} and you are a Kid".format(Age)) #In Pyt...
cde66f08f3e8ccd4e52c94d824e314ea6056f9c2
mbravofuentes/Codingpractice
/python/FindAge.py
199
4.0625
4
import datetime DOB = input("Enter your DOB: ") CurrentYear = datetime.datetime.now().year Age = CurrentYear-int(DOB) #This will change the string into an integer print("Your age is {}".format(Age))
a437e6ff2a34a1c63914332265ec25fba5f5aac8
eranilkrsharma/PythonCourse
/BasicCourse/Hello.py
360
3.796875
4
"""This is the first Python file Comments added """ print("Hello World Again test Git") #Format examples name = "Python" machine = "MyMac" print "Nice to meet you {0}. I am {1}".format(name,machine) # below can be used in Python 3 # f"Nice to meet you {name}. I am {machine}" #Booelan flag starts with Caps fe...
ae5354fd80a8cc13740a768d48d1226ff3d2964d
rayvonne828/Project-1
/ex47/ex47/lexicon.py
917
3.8125
4
class Lexicon(object): def __init__(self): self.directions = ['north', 'south', 'east', 'west', 'down', 'up', 'left', 'right', 'back'] self.verbs = ['go', 'stop', 'kill', 'eat'] self.stop_words = ['the', 'in', 'of', 'from', 'at', 'it'] self.nouns = ['door', 'bear', 'princess', 'cabinet'] self.numbers = [x fo...
2394253e7f9bb0c905b9917ee7a1501087bc1af0
williamsalas/EasyHours
/my_cal.py
960
4.03125
4
from tkinter import * from tkcalendar import * from datetime import datetime """ William Salas 9/6/20 Purpose: Designing a program to input and track hours worked, etc. """ # basic tkinter starter code root = Tk() root.title('EasyHours') root.geometry('600x400') file = open("text.txt", "a+") # date data type, todays ...
d36ac222c28deed0fdbfb9d06c2143fee26f28e3
StanislavHorod/LV-431-PythonCore
/3(3 task)_HW.py
218
3.984375
4
number = int(input("Write the number: ")) start_number = str(number) cash = 1 while number>1: cash *=number number-=1 final_number = str(cash) print("The factorial of the "+start_number+ " is: '"+ final_number)
4ad51b29bc544a7061347b6808da4fa6896e2a6b
StanislavHorod/LV-431-PythonCore
/Home work 2/2(3 task)_HW.py
401
4.15625
4
try: first_word = str(input("Write 1 word/numb: ")) second_word = str(input("Write 2 word/numb: ")) first_word, second_word = second_word, first_word print("The first word now: " + first_word + "\nThe second word now: " + second_word) if first_word == " " or second_word == " ": ra...
e8f91a9e3091299e48c986243efd63120147f730
StanislavHorod/LV-431-PythonCore
/lec 8.12/CW-4.py
329
3.578125
4
try: login = input("Press login: ") while True: if login == "First": print("Gracios, you are connected") break elif login == " ": raise Exception("Write login!") else: login = input("Try again\nPress login: ") except Exception as exi: p...
78bc2aebff4c8b27e3d10136e949a08f2032aabc
StanislavHorod/LV-431-PythonCore
/Class work 5/CW-4.py
1,398
3.84375
4
class CustomExaption(Exception): def __init__(self, data): self.data = data def __str__(self): return repr(self.data) days = { 1: "focus: Mondey", 2: "focus: Tuesday", 3: "focus: Wednesday", 4: "focus: Thursday", 5: "focus: Friday", 6: "focus: Saturday", 7: "focus: S...
ca77d5aa0a60f834e16bfc43be30d4f32d2e7f00
StanislavHorod/LV-431-PythonCore
/Home work 1/1(2 task)_HW.py
191
4
4
name = input("What is your name? \n") age = input("How old are ypu? \n") adress = input("Where do you live? \n") print("Hello, "+ name +". Your age is " + age+ ". You live in " + adress)
aad8fee13302cfa94e8d4533976a20f3cc908b2e
StanislavHorod/LV-431-PythonCore
/CW 5/CW - 2.py
1,028
3.96875
4
class Figure(): def __init__(self, color=None, type_figure=None): self.color = color self.type_figure = type_figure def get_color(self): return self.color def info(self): print(f'Фігура - {self.type_figure}, колір - {self.color}') class Rectangle(Figure): def __init__...
420837ef3802a6236b606bade8425f960acf7f4b
kidconan/demo
/neuralNetworks/classifiers/classifier.py
1,313
3.84375
4
'''@file classifier.py The abstract class for a neural network classifier''' from abc import ABCMeta, abstractmethod class Classifier(object, metaclass=ABCMeta): '''This an abstract class defining a neural net classifier''' def __init__(self, output_dim): '''classifier constructor''' ...
c2f09af2908cbb047746d1758162e273953d46e9
FarabiAkash/Pyhton
/EverydayCode/Odd_Numbers.py
150
3.90625
4
numbers= range(21) odd_numbers ="" for i in numbers : if i % 2 != 0: odd_numbers =odd_numbers + str(i) + " " print(odd_numbers)
df4bc513bb24346c05f07469ab49b7955a361bdc
mhrones/statistical-computing
/problem-sets/ps3-monte_carlo_player/ps3b.py
762
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: """ import random import ps2 import ps3a word_list = ps2.load_words() def test_mc_player(hand, N=100, seed=1): """ play a hand 3 times, make sure produced same scores. """ hand_score = ps3a.play_mc_hand(hand) if hand_score != ps3a.p...
2caf204be9de0b2ae802f1b96b71423a2e8da936
Laxiflora/fintech_final
/server/src/random_code.py
799
3.515625
4
from random import Random str = '' chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789' length = len(chars) - 1 random = Random() #生成16字的英數亂碼 for i in range(16): str+=chars[random.randint(0,length)] print(str) ''' import random, string def GenPassword(length): #隨機出數字的個數 numOfNum = r...
314f2a90c0c6fee4316d4e372799d425d31fe435
6871/matrix-display
/src/matrix_display/displays/display.py
1,259
3.8125
4
#!/usr/bin/env python3 """Module defining base MatrixDisplay class.""" class Display: """Base class for display-specific classes to extend.""" row_count = 0 col_count = 0 def __init__(self, row_count, col_count): """Initialise a display object. Parameters ---------- r...
61c48bb6251a1b866e9326ef1e931f760373f867
m3ddle/live-coding2
/main.py
930
3.921875
4
example = "vfdsjsfaffffffffreitirrrrrert" def longest_substring(string): substring_tracker = {} substring_length = 0 index = 0 subs_track = 0 curent_char = '' while index < len(string): if index < len(string) - 1: if string[index + 1] == string[index]: ...
3ea848cb1bbd54154386e8b066d0799a0d428248
sanjaykumardbdev/pythonProject_2
/111_test.py
975
3.609375
4
from tkinter import * import datetime root = Tk() date = str(datetime.datetime.now().date()) print(date) # need two frames: topFrame bottomFrame topFrame = Frame(root, height=150, bg='white') topFrame.pack(fill=X) bottomFrame = Frame(root, height=350, bg='#7fe3a7') bottomFrame.pack(fill=X) heading = Label(topFr...
3166ede4834ff94bcac3474b8e6c8be46ec282f8
sanjaykumardbdev/pythonProject_2
/53_Types_of_Methods.py
1,299
3.890625
4
# instance method # class method variable # static method variable # in case of var, class n static var are same but difnt in case of method class Student: #static or class var : outside var school = "Telusko" def __init__(self, m1, m2, m3): self.m1 = m1 self.m2 = m2 self.m...
6e07857a742c76f44fef1489df67d00f8b118cf6
sanjaykumardbdev/pythonProject_2
/59_Operator_overloading.py
1,272
4.46875
4
#59 Python Tutorial for Beginners | Operator Overloading | Polymorphism a = 5 b = 6 print(a+b) print(int.__add__(a, b)) a = '5' b = '6' print(a+b) print(str.__add__(a, b)) print(a.__str__()) # when u r calling print(a) behind it is calling like this : print(a.__str__()) print('-----------------------------') c...
9bb1168da52c3bdbb7015f7a61f515b10dc69267
ubercareerprep2019/Uber_Career_Prep_Homework
/Assignment-2/src/Part2_NumberOfIslands.py
2,348
4.28125
4
from typing import List, Tuple, Set def number_of_islands(island_map: List[List[bool]]) -> int: """ [Graphs - Ex5] Exercise: Number of islands We are given a 2d grid map of '1's (land) and '0's (water). We define an island as a body of land surrounded by water and is formed by connecting adjacent la...
dfc122137c813e45c1e45d22313e87022aee87d7
ubercareerprep2019/Uber_Career_Prep_Homework
/Assignment-2/tests/Part1_PhoneBook_Test.py
1,680
3.609375
4
from unittest import TestCase from Part1_PhoneBook import ListPhoneBook, BinarySearchTreePhoneBook class Part1_PhoneBook_Test(TestCase): def test_size(self): phone_book = ListPhoneBook() assert phone_book.size() == 0 phone_book.insert("ABC", 1111111111) assert phone_book.size() ==...
bb9f315828e67a214030776d6bd28595e8592cf9
Desty-3000/ISN
/421 Python.py
1,392
3.875
4
from random import* #on veut lancer 3 dés , qui doivent au final former une suite 4,2,1. Si un des #dés vaut 4,2,1 le dé n'est pas relancé . Au bout de 3 lancés sans la suite 421 #le joueur a perdu #lancementDes lance n dés aléatoires entre 1 et 6 et stocke les résultats dans r1 def lancementDes(n): r1 =...
b06d16f089b4fe4b73dcf8c7b04cd7dd0c9517c3
adocto/python3
/tutorial/mystuff/ex8.py
454
3.640625
4
formatter = "%r %r %r %r" #Prints numbers print(formatter % (1, 2, 3, 4)) #prints strings print(formatter %("one","two","test","okay")) #prints true/false print(formatter %(True, False, True, False)) #prints formatter string as literal string. print(formatter %(formatter,formatter, formatter, formatter)) #prints severa...
bbc9094b3949deb22766f21501d8f580d0750b09
adocto/python3
/hackerRankOlder/insertion_sort.py
381
3.9375
4
def insertion_sort(arr): i = 0 # if arr==[]: # return arr for i in range(len(arr)): if i == 0: arr[i] = arr[i] else: j = i for j in range(j, 0, -1): if arr[j] < arr[j - 1]: arr[j], arr[j - 1] = arr[j - 1], arr[j] ...
936da4fb6c7628cab7919507ca3fb8baaad97e8c
seancrawford-engineer/python_bootcamp
/coding_challanges/17_decorators/02_acess_control_decorator.py
2,116
3.703125
4
""" Implement a @access_control decorator that can be used like this: @access_control(access_level) def delete_some_file(filename): # perform the deletion operation print('{} is deleted!'.format(filename)) Your decorator should meet the following requirements: - It takes in an argument `access_level` and...
38a000d461e55ea657957c5ddf512e5ada182c54
aisaack/data-structure_practical-usage
/hash_table.py
2,353
3.734375
4
class Node: def __init__(self, data=None, pointer=None): self.data = data self.pointer = pointer class Data: def __init__(self, key, value): self.key = key self.value = value class HashTable: def __init__(self, table_size): self.table_size = table_size self....
3b93a7884308035fc7779e86d861cfaa48a58433
uttams237/GPython
/n-Derivative.py
1,335
3.890625
4
'''import sympy as sp x = sp.Symbol('x') a =(sp.diff(3*x**2,x)) print(type(a)) print(a)''' from scipy.misc import derivative import numpy as np from scipy import integrate import matplotlib.pyplot as plt from numpy import * from math import * X = np.arange(-10,10,1) s=input("Enter function : ") num = int(i...
1968a6c4b52571a860648d474b65f89e3c1a3708
shivahegonde/python_programs
/ass4.py
160
3.703125
4
if __name__=="__main__": base=int(input("Enter Base :: ")) height=int(input("Enter Height :: ")) AoT=1/2*(base*height) print ("Area of Triangle :: ",AoT)
6009d5c19d7d11bb847371c721d3f13e0fdefd49
lihararora/snippets
/python/general/prime.py
378
3.9375
4
#!/usr/bin/python ''' @author: Rahil Arora @contact: rahil@jhu.edu ''' def is_prime(num): for j in range(2,num): if (num % j) == 0: return False return True if __name__ == "__main__": low = int(input("Enter the lower bound: ")) high = int(input("Enter the upper bound: ")) for ...
a532b5e88316b3bee910035772a35293f62b8fee
stefanv/dpt
/dpt.py
8,466
3.671875
4
""" File dpt.py Discrete Pulse Transform Dirk Laurie, July 2009 """ from sys import maxint from collections import deque from math import sqrt """ Since we are importing deque anyway, it is simplest to define queue as a specialization of deque.""" class queue(deque): get = deque.popleft put = deque.append...
45de73534623a904402c42fb38e1d0694350ca69
samsalgado/Applied-Python
/Generators.py
873
3.765625
4
#functions that return an object that can be iterated over import sys def thegenerator(): yield 1 yield 2 yield 3 g = thegenerator() print(sum(g)) sorted(g) def countdown(num): print('Starting') while num > 0: yield num num -= 1 cd = countdown(9) value = next(cd) print(value) value...
bd829c3ee9c8593b97d74d5a1820c050013581f0
lepy/phuzzy
/docs/examples/doe/scatter.py
924
4.15625
4
''' ============== 3D scatterplot ============== Demonstration of a basic scatterplot in 3D. ''' from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np def randrange(n, vmin, vmax): ''' Helper function to make an array of random numbers having shape (n, ) with each n...
f844aa1f3acbfd7c75631a5f184945b3ebb8f9ac
skarthikeyan85/learn
/python/pramp_smallest_substring.py
1,423
3.890625
4
#pass # your code goes here ''' build a map for the arr eliminate chars from the str and decrement the str map such that i can still be valid with the arr map ''' def get_shortest_unique_substring(arr, str): arr_counts={} for elem in arr: arr_counts[elem] = 0 ans = '' uc = 0 h = 0 i = 0 while i ...
b251cdbaa7ec08e7eb13683e5e62640c298882f6
dianaalbarracin/Data-Science-Project-1
/project1.py
3,856
3.859375
4
#import open source python library to perform data manipulation import pandas as pd #import json import json #Read CSV file from path in my computer #in my case C:\Users\Diana Albarracin\Desktop\CO2Emission_LifeExp.csv df = pd.read_csv (r'C:\Users\Diana Albarracin\Desktop\CO2Emission_LifeExp.csv') #change to the pat...
a4568bbce0e3753e1223512bf3cc51abb478b99d
shahhena95/competitive-programming
/advent-of-code/2015/2015_01.py
565
3.609375
4
from collections import deque with open('./inputs/day_01.txt') as f: instructions = f.readlines() def count_floors(stack=deque()): [stack.appendleft(1) if char == '(' else stack.appendleft(-1) for char in instructions[0]] return sum(stack) def find_basement(instructions, stack=deque()): for i in ra...
97d14cefc1fe8ede2d0552a3172c2763c857571f
RanulaGihara/Pharmago_App
/python_files/plotting.py
566
3.53125
4
from math import sqrt import matplotlib.pyplot as plt import pandas as pd import numpy as np from sklearn.metrics import mean_squared_error df = pd.read_csv('paracetamol.csv', index_col='Date', parse_dates=True) print(df) xyz = df['sale'].values test = df.iloc[160:] print(xyz) arr1 = np.array([[1, 2], [3, 4]]) arr2...
40fe26bc966069a1fe4e2f3120fd4284db8c1e3f
sharlq/oldpythonprojects
/GUIP/check button and radion button.py
645
3.84375
4
import tkinter from tkinter import * # its important if it says Tk is not defined win =Tk() var=IntVar() c1 = IntVar() # we need variable to safe the value of the button and we declare it this way ch = Checkbutton(win, text= "musicl", offvalue = 0, onvalue=1 , height=5, width=10 , variable=c1) r= Radiobutton(win, t...
7a57ab12d477ea81624b1b95ab56ad8e6bda20f0
ninjaflesh/vsu_programming
/2_homework/7.py
325
3.640625
4
from random import randint rand = randint(0, 100) s = int(input("Vvod: ")) while s != rand: if s > rand: print("Загаданное число меньше!") else: print("Загаданное число больше!") s = int(input("Vvod: ")) print("Вы угадали число!")
56a4825f2be045fba3c8f40d7ec6747da61ade99
ninjaflesh/vsu_programming
/1_homework/7.py
167
3.625
4
x = input('Vvod x: ') y = input('Vvod x: ') x = int(x) y = int(y) counter = 0 for x in range(x, y + 1): if not x % 5: counter += x print(counter)
ba4da6e5828ff691027f8351128a08f628fa71a1
ninjaflesh/vsu_programming
/1_homework/5.py
302
3.84375
4
x = input('Vvod x: ') y = input('Vvod x: ') x = float(x) y = float(y) if x > 0 and y > 0: print('1 4etvert') elif x < 0 and y > 0: print('2 4etvert') elif x < 0 and y < 0: print('3 4etvet') elif x > 0 and y < 0: print('4 4etvert') elif not x or not y: print('na osi')
2a234e6d11a892afd3fb47bbc3899f7631932ca8
CromixPT/PythonLearning
/hello.py
249
3.796875
4
import sys x = 1 print("Hello ") x = 5 y = 10 print(x) print(y) y += x if y > 2: print("bad") print(y) test = "teste" print("Hello") print("teste") def greet(who_to_meet): greeting = "Hello, {}".format(who_to_meet) return greeting
529738259a0398c322cda396cfc79a6b3f5b38d3
nancydyc/algorithms
/backtracking/distributeCandies.py
909
4.21875
4
def distributeCandies(candies, num_people): """ - loop through the arr and add 1 more candy each time - at the last distribution n, one gets n/remaining candies - until the remaining of the candies is 0 - if no candy remains return the arr of last distribution >>> distributeCand...
110d2e7f3b77de72d9815c9e8a739571854f519d
asliturkcalli/Python_How-to-program_Exercises
/function/perfect number.py
935
3.75
4
""" perfect number is a number whose sum of its exclusive divisors is equal to itself forexample=6 exclusive divisors of 6=(1,2,3) and sum of=1+2+3=6 """ def perfect_number(number): num=0 for i in range(1,number): if number%i==0: num=num+i else: continue ...
e1dd7fe02716ecce724bf257cf3dfa3d15e374ca
asliturkcalli/Python_How-to-program_Exercises
/loop/multiplication with loop.py
141
3.703125
4
for i in range(1,10): for a in range(1,10): result=i*a print(f"{i}*{a}={result}") print("","",sep="\n")
ec872a3fbe9b00611cf04c35e30e6a923409bd64
Diegovsk/Aprendizado
/pythonTeste/ex78.py
438
4.0625
4
lista = [int(input("Digite um valor: ")), int(input("Digite um valor: ")), int(input("Digite um valor: ")), int(input("Digite um valor: ")), int(input("Digite um valor: "))] print(f'Você digitou: {lista}') print(f'O valor minimo digitado está na posição {lista.index(min(lista))} e seu valor é {min(lista)}...
9089b92bcc94161174a21d9e7fa45b17857b13bb
Diegovsk/Aprendizado
/pythonTeste/projetinhos/exaleatorio.py
3,092
3.78125
4
import random #declarando variáveis ope = str('Pedra') opa = str('Papel') opt = str('Tesoura') lista_opcoes = [ope, opa, opt] aleatorio = random.choice(lista_opcoes) opcao_selecionada = str(input('Vamos fazer um jogo?\nDuvido você ganhar de mim no pedra, papel ou tesoura. ' '\nA ...
f0fa4b9c13b33806a80c6582e15bda397fafe5b9
JonRivera/cs-guided-project-time-and-space-complexity
/src/demonstration_1.py
1,053
4.3125
4
""" Given a sorted array `nums`, remove the duplicates from the array. Example 1: Given nums = [0, 1, 2, 3, 3, 3, 4] Your function should return [0, 1, 2, 3, 4] Example 2: Given nums = [0, 1, 1, 2, 2, 2, 3, 4, 4, 5] Your function should return [0, 1, 2, 3, 4, 5]. *Note: For your first-pass, an out-of-place solut...
1abe6f6352b042a7656f2f11f92f49b437ad1077
yunabe/codelab
/swig/python/time_type.py
410
3.6875
4
class Time(object): def __init__(self, hour, minute, second): self.__second = hour * 3600 + minute * 60 + second @property def hour(self): return self.__second / (60 * 60) @property def minute(self): return (self.__second / 60) % 60 @property def second(self): return self.__second % 60 ...
c59eca98c3e4aa9ef73f03fbd4e222792aace43e
auserj/nand2tetris
/06/Python/hasmParser.py
5,701
3.625
4
# Copyright (C) 2011 Mark Armbrust. Permission granted for educational use. """ hasmParser.py -- Parser class for Hack computer assembler See "The Elements of Computing Systems", by Noam Nisan and Shimon Schocken This parser is slightly different than the parser design in the book. Because it is very diffi...
87ef151ab872b332a49826059af74669cf67ecc8
ccydouglas/thePythonBible
/pig.py
535
3.84375
4
original=input("Please enter a sentence: ").strip().lower() words= original.split() new_words=[] for o in words: if o[0] in "aeiou": new_word=o+"yay" new_words.append(new_word) else: vowel_pos=0 for letter in o: if letter not in "aeiou": vowel_pos= vowel_pos+1 ...
1dadfb8d032853879a5a45c7533676ee9f2be513
chenke17/python_learn
/learn_process_xls.py
1,408
3.546875
4
# -*- coding: utf-8 -*- import xlrd import sys # https://www.cnblogs.com/tynam/p/11204895.html # usage: python learn_process_xls.py ${filename} if __name__ == "__main__": filename = sys.argv[1] # 打开文件 data = xlrd.open_workbook(filename) # 查看工作表 sheets = data.sheet_names() print("sheets: ", sheets ) pr...
452f5cc48114e0b5451af11f18066a0af3125663
kjans123/heart_rate_databases_starter_introduction
/validate_date_time.py
3,870
4.53125
5
def validate_date_time(date_time): """"function that validates user input datetime. Checks to ensure input is of list type. Checks to ensure all elements are int. Check and forces list to be 7 elements longs (puts 0's in for hour, minute second and microsecond if none entered). ...
2565020d17a45f8fee20ad3a36513da3d6ed029c
sushimon/CodingBat-Exercises
/Python/Logic-2/close_far.py
625
3.796875
4
# Given three ints, a b c, return True if one of b or c is "close" (differing from a by at most 1), while the other is "far", differing from both other values by 2 or more. Note: abs(num) computes the absolute value of a number. # close_far(1, 2, 10) → True # close_far(1, 2, 3) → False # close_far(4, 1, 3) → True d...
249d6c41bcc2e11d3888642aaa0424d68b39082e
tuscanos/pyDaily
/L2/L2Q10.py
626
4.09375
4
# Question: # Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically. # Suppose the following input is supplied to the program: # hello world and practice makes perfect and hello world again # Then, the out...
e2dd799dc8af72c0411b6f551d97ef84f46b0997
tuscanos/pyDaily
/L2/L2Q15.py
323
4.03125
4
# Question: # Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a. # Suppose the following input is supplied to the program: # 9 # Then, the output should be: # 11106 d = input("Enter number: ") addCount = 0 for i in range(1, 5): addCount += int(str(d) * i) print(addCou...
265f3997aab05ef4e4b1b265326e6a5492eef2a0
corenel/auto-traffic-camera-calib
/misc/utils.py
899
3.671875
4
import cv2 def image_resize(image, width=None, height=None, inter=cv2.INTER_AREA): # initialize the dimensions of the image to be resized and # grab the image size dim = None (h, w) = image.shape[:2] # if both the width and height are None, then return the # original image if width is Non...
ba3d48ae6b982897ef620ce2f38103497d013de6
ajacks14/MockPractical2
/q3.py
694
3.96875
4
import random def randomguess(): randomno=random.randint(0,99) print(randomno) guesses=0 correct=False guess = int(input("Guess a number between 0 and 99: ")) guesses += 1 while not correct: while guess <0 or guess >99: guess=("you have guessed below 0 or above 99 guess ...
2997a5c9992bebe0d45ff62acd00b81cfab19897
rrodriguez2018/Ver_Hawksbill_Range_Test
/RPi_AutomationHat_API.py
2,178
3.671875
4
import RPiHAT_mod as Pihat def print_commands(): print("""Please enter a command: (1) drain for x seconds long (2) add DI water for x seconds long (3) open test loop valve & measure ADC1 uS (4) check Level to see if max water level detected (5) fill vessel up to maximum level (6) check Eme...
876962cd05e9f901392d9cc6262bb9c39936d31e
LeaneTEXIER/Licence_2
/S3/Codage/TP5/tp2.py
9,996
4.0625
4
##TEXIER Léane ##Groupe 1 import struct #Question 5: def integer_to_digit(n): """ Retourne le chiffre hexadécimal correspondant à n sous forme de caractère :param n: Entier décimal :type n: int :return: Chiffre n en hexadécimal :rtype: str :CU: n est un entier compris entre 0 et 15 inclus...
0e9bb8e8d914754431f545af8cf6358012c52ca1
MikeyABedneyJr/python_exercises
/challenge7.py
677
4.1875
4
''' Write one line of Python that takes a given list and makes a new list that has only the even elements of this list in it. http://www.practicepython.org/exercise/2014/03/19/07-list-comprehensions.html ''' import random from random import randint given_list = random.sample(xrange(101),randint(1, 101)) # even_numbe...
aecf0cd25de38821b669b51a5b48267379626e67
DanielSank/aes-victor
/encrypt_main.py
1,676
3.875
4
""" This is the main routine for performing AES-256 encryption. It reads a key from key.txt and performs key expansion. Then it reads plain text data from plaintex.txt', and encrypts that data using the key. It then writes the encrypted data to CTData.txt. """ from constants import Nr from encrypt_functions im...
537be385e6a599b2e3495753b8afa0e5c132c233
miths-git/Testing
/task4.py
5,134
4.34375
4
""" TRADITIONAL FUNCTIONS,ANONYMOUS FUNCTIONS & HIGHER ORDER FUNCTIONS 1. Write a program to reverse a string. Sample input: “1234abcd” Expected output: “dcba4321” def reverse(s): str = " " for i in s: str = i + str return str s = "Today is a wonderful day!" print("The orig...
17b8708b811972931ee04b1295ce8a272cb410cf
Everett1914/CS325HW1
/mergesort.py
2,101
3.953125
4
#Everett Williams #30JUN17 as of 02JUL17 #HW1 Problem 4 #Merge sort program #sort array using merge sort algorithm def mergeSort(alist): if len(alist)>1: mid = len(alist)//2 lefthalf = alist[:mid] righthalf = alist[mid:] mergeSort(lefthalf) #returns sorted left half which is sorte...
4d147ba2a66e2b63740cda46fabdad69a47925d9
mbarakaja/codility-lessons
/lesson1/binary_gap.py
1,757
3.828125
4
""" Binary Gap ~~~~~~~~~~ A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representatio...
4728ec496ae1d032e36d65dd2ce88c2ddc52b831
mbarakaja/codility-lessons
/challenges/digital_gold.py
2,250
4.0625
4
""" Dividing The Kingdom ~~~~~~~~~~~~~~~~~~~~ An old king wants to divide his kingdom between his two sons. He is well known for his justness and wisdom, and he plans to make a good use of both of these attributes while dividing his kingdom. The kingdom is administratively split into square bo...
18fa852cc95b13b76ef6f9c2effed76e9ca34e45
naturalis/sdmdl-pollinators
/Data Preprocessing/crop_predictions.py
2,318
3.90625
4
def crop(netherlands_locations, world_locations, xmin, xmax, ymin, ymax): """ Reads world_locations_to_predict.csv, and scans for coordinates that are withing the range of the Netherlands. These coordinates are written to a new file. :param netherlands_locations: A csv-file, to where the cropped ...
064514000707be0c1204f6e57d8ec3f02adb025d
Suraj-Mohite/Pattern_Practice
/pattern25.py
1,133
3.9375
4
""" input:4 1 2*2 3*3*3 4*4*4*4 4*4*4*4 3*3*3 2*2 1 """ def Pattern(no): try: no=str(no) no=int(no) if no<=0: print("ERROR: 0 and Negative numbers are not allowed") return for i in range(1,2*no+1): if i==1 or i==2*no: print("1") ...
9bc8c8becf15454c52961ba5c0321281ce702603
Suraj-Mohite/Pattern_Practice
/pattern2.py
419
3.6875
4
#accept row and column from user and disply ''' * * * * $ $ $ $ * * * * $ $ $ $ ''' def Pattern2(iRow,iCol): for x in range(1,iRow+1): for y in range(1,iCol+1): if(x%2==0): print("$",end=" ") else: print("*",end=" ") print() iRow=int(input("E...
9e6faf0e5896657070cf9d1ac6ccc70026385083
bbbarron/euler
/15euler.py
1,077
3.890625
4
""" Lattice paths Problem 15 Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 20×20 grid? """ import math def test(): n = 20 paths = math.factorial(2 * n) / (math.f...
d099937613e33925b2cd29456e066bfc30edcd43
CrossLangNV/python-for-java-devs
/joris/printer.py
1,459
3.828125
4
# Python 3.6+ example class Printer: def print(self): pass class YamlPrinter(Printer): def __init__(self, items=None): # assume this is a dict self._items = items def print(self): print('--- # YAML printer') for item in self._items: print(f'- {item}: {s...
187897f5d5727394535438e09ae1a64db3fb1a32
SeongwonChung/CodingTest
/dongbinbook/Graph/disjoint_set_cycle_detect.py
1,209
3.578125
4
""" 서로소 집합으로 무뱡향 그래프에서 사이클을 판별할 때 사용할 수 있다. union연산은 간선으로 표현된다. 간선을 하나씩 확인하면서 두 노드가 포함되어 있는 집합을 합치는 과정을 반복하는 것 만으로 사이클을 판별할 수 있다. 그래프에 포함되어 있는 간선의 개수가 E일때, 모든 간선을 하나씩 확인하며, 매 간선에 대해 union, find를 호출하는 방식. 무향그래프에만 적용 가능 """ def find_parent(parent, x): if parent[x] != x: parent[x] = find_parent(parent, pa...
4065c357fb3ff737db7c38321791081143203dee
SeongwonChung/CodingTest
/dongbinbook/BinarySearch/기출/28-고정점찾기.py
441
3.578125
4
n = int(input()) numbers = list(map(int, input().split())) def bin_search(numbers, start, end): if start > end: return -1 mid = (start + end) // 2 if numbers[mid] == mid: return mid left = bin_search(numbers, start, mid - 1) if left != -1: return left right = bin_sear...
c760c3d8328fea177e2c7dee166b003a61297258
SeongwonChung/CodingTest
/dongbinbook/Sort/sort_method.py
429
4.03125
4
""" sorted - O(NlogN) 정렬해서 리스트로 반환 """ array = [1,6,3,6,8,8,6,2,67,9,0] result = sorted(array) print('sorted', result) """ .sort() => list 의 method return 없이 list가 바로 sort됨 """ array.sort() print('.sort', array) pairs = [('성원', 25), ('다운', 23), ('재원', 26), ('범수', 30)] key_sort = sorted(pairs, key=lambda x: x[1]) # ...
18b1131cb6622c0d0a52b1b3cb8d57beba12a252
SeongwonChung/CodingTest
/dongbinbook/Implement/기출/10-자물쇠와열쇠.py
1,201
3.53125
4
def rotate(matrix): row = len(matrix) column = len(matrix[0]) rotated = [[0 for _ in range(row)] for _ in range(column)] for i in range(row): for j in range(column): rotated[j][row - i - 1] = matrix[i][j] return rotated def check(new_lock): size = len(new_lock) // 3 for...
f8919c74bdc5226401bfebd62281888447bb9e39
SeongwonChung/CodingTest
/Programmers/Graph/가장먼노드.py
825
3.5625
4
""" 우선순위큐 다익스트라로 풀이. """ import heapq def solution(n, edge): answer = 0 INF = int(1e9) distance = [INF for _ in range(n + 1)] graph = [[] for _ in range(n + 1)] for a, b in edge: graph[a].append(b) graph[b].append(a) def dijkstra(s): distance[s] = 0 q = [] ...
8a392c0f82d807276beb43190b225601ae4380f9
Oldgong1/Python_Project
/Python Final Project/flat.py
3,091
3.5625
4
#%% print("WELCOME COME TO MOMO") restart = ('y') reload = 3 balance = 500 while reload >=0: pin = int(input('Enter your password to continue''\n')) if pin == (1234): print('Your been has been verified, continue: ') while restart not in ('n', 'NO', 'no', 'N'): print("****************...
e6a688b5a85a54fedd45925b8d263ed5f79a5b41
shardul1999/Competitive-Programming
/Sieve_of_Eratosthenes/Sieve_of_Eratosthenes.py
1,018
4.25
4
# implementing the function of Sieve of Eratosthenes def Sieve_of_Eratosthenes(n): # Creating a boolean array and # keeping all the entries as true. # entry will become false later on in case # the number turns out to be prime. prime_list = [True for i in range(n+1)] for number in range(2,n): # I...
5a4091fcc02ab8625120f33dbc74a18f6d9a39e7
shardul1999/Competitive-Programming
/CODEFORCES/Beautiful_Year_800.py
195
3.71875
4
year=int(input()) year+=1 s=str(year) while True: if s[0]!=s[1] and s[0]!=s[2] and s[0]!=s[3] and s[1]!=s[2] and s[1]!=s[3] and s[2]!=s[3]: break year+=1 s=str(year) print(year)
30aad0e938f726ba882dddb5f6b66cb3f9140011
javad-torkzadeh/courses
/python_course/ch5_exercise3.py
553
4.21875
4
''' Author: Javad Torkzadehmahani Student ID: 982164624 Instructor: Prof. Ghafouri Course: Advanced Programming (Python) Goal: working with function ''' def get_students_name (): names = [] for _ in range (0 , 6): X = input("Enter your name: ") names.append(X) return names def include_odd_...
548e5b007a816be6cbbc83d3675a03a97fd65758
javad-torkzadeh/courses
/python_course/ch6_exercise2.py
817
4.1875
4
''' Author: Javad Torkzadehmahani Student ID: 982164624 Instructor: Prof. Ghafouri Course: Advanced Programming (Python) Goal: working with collection ''' my_matrix = [] for i in range (0 , 3): row = [] for j in range(0 , 2): X = float(input("Enter (%d , %d): " %(i , j))) row.append(X) my_...
4a47b563eec43fc7639baa9429835819a456c1da
gopeshkh1/ml_assignment1
/perceptron discriminant/2.py
2,200
3.515625
4
import matplotlib.pyplot as plt import numpy as np import pandas as pd class Perceptron(): ''' perceptron algorithm ''' def __init__(self): self.w = np.random.rand(3 , 1) print("initial w: {}".format(self.w)) # reads data-set and transform w over each iteration def transform(self, d...
bb8cb835b829d3d25ed0546c702f38bb840e1157
Vansh-Arora/Python
/fibonacci.py
202
4.21875
4
# Return the nth term of fibonacci sequence. def fibonacci(n): if n==1: return 1 elif n==0: return 0 return fibonacci(n-1)+fibonacci(n-2) print(fibonacci(int(input())))
03432128d834f955eb2a3eddff9780616993ad98
inwk6312fall2019/wordplay-ChandanaPagolu
/uses_only.py
134
3.8125
4
def uses_only(word, letter): for character in word: if character not in letter: return False return True
d9c60c605ef1668ba20ae377e6a56158e8d85b02
MichaelDeutschCoding/Advent-of-Code-2016
/day1_2016.py
2,292
3.90625
4
def move(starting, instructions, visited): x, y, heading = starting turn, d = instructions[0], int(instructions[1:]) if turn == 'R': heading = (heading + 1) % 4 elif turn == 'L': heading = (heading + 3) % 4 else: print("Heading Error.") return if...
116b7525e97b31490462f2cb9f6a8e82fbcaa1fb
KomalaB/pythontest
/Assignement -20201112 v2.py
641
4.03125
4
Id_num [] Stu_Name [] count=int(input("enter the number of IDs you will like to register :")) ct=count while count >0: for i in range(0,count): num=input("Enter the unique ID : ") if num in Id_list: print(" Id is Duplicate") name=input("Enter Student Name...
c7aa13b7daabb4febc7a5dbd48b6051ae8ceffea
adesh777/Show_the_data_structure_project_2_udacity
/problem_2.py
963
3.65625
4
import os def find_files(suffix, path): if not os.path.isdir(path): print("Add a valid directory path") return [] if not suffix or len(suffix) == 0 or suffix.isnumeric(): print("This is not a valid suffix", str(suffix)) return [] files_found = [] for f in...
c1850078b1122160830013a02b55749215c7c51f
nikmuhammadnaim/python_projects
/pomodoro/pomo_engine.py
726
3.6875
4
import time # Function for printing dictionary contents def print_dict(my_dict): ready_list = '' for key, value in my_dict.items(): ready_list += "\n{}) {}".format(key, value) return ready_list # Countdown function def pomodoro_timer(t_minutes): ''' Countdown clock function. This funct...
abd7c1d0295c72c50a1fcfc8f426ec9459b9c43a
yunusordek/DetectionOfAndroidMalware
/data _cleaning_and_data_integration/Combining.py
649
3.53125
4
import glob import os import pandas as pd # the path to your csv file directory mycsvdir = '' # get all the csv files in that directory (assuming they have the extension .csv) csvfiles = glob.glob(os.path.join(mycsvdir, '*.csv')) # loop through the files and read them in with pandas dataframes = [] # a list to hold...
12d71d2d83766b1548bc7e9b26a511c815dbe6a1
kyubeom21c/kosta_iot_study
/pythonPro/test04while.py
221
3.84375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys print('while') i=0 while True: i +=1 if i==5 : continue if i==10 : break name = raw_input("input name:") print("while" ,i) print("Hello {} ".format(name))
02e061272cca7eefdab81d926634fa00c0c22a91
david-ruggles/Bashfuscator
/bashfuscator/lib/misc_obfuscators.py
4,422
3.921875
4
from bashfuscator.common.random import RandomGen def obfuscateInt(num, smallExpr): """ Obfuscate an integer by replacing the int with an arithmetic expression. Returns a string that when evaluated mathematically, is equal to the int entered. @capnspacehook """ randGen = RandomGen() ex...
07beb28d57f6ba9264a5ce7e3708f5423d63bd35
Riaeuk/W3School
/Data_types1.py
116
3.984375
4
#The following code example would print the data type of x, what data type would that be? x = 5 print(type(x)) #int
6394034c37fae31c04181a9da315dc73f58529b4
william-james-pj/LogicaProgramacao
/URI/1 - INICIANTE/Python/1150 - UltrapassandoZ.py
219
3.515625
4
x = int(input()) y = 0 cont = 1 while y == 0: z = int(input()) if(z > x): y = 1 y = 0 w = x while y == 0: if(x > z): y = 1 else: x += w w += 1 cont +=1 print(cont)