blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
33045cb42695bef731487e891707001b62deb17c
Pallavi2000/heraizen_internship
/internship/M_1/primeseries.py
779
4.03125
4
"""Program to accept 2 different numbers from the user and print all the prime numbers between these 2 numbers.""" LB=int(input("Enter Lower bound value ")) UB=int(input("Enter Upper bound value ")) flag=True for i in range(LB,UB+1): if i<2: flag=False else: for j in range(2,(i//2)+1): ...
c0edf60cdc054c8c61920ccec1746eeba0821ae4
nessx/Programacion-1
/UF2/M3-UF2-1/act4.py
151
3.703125
4
nota=[] for i in range(2,100,2): nota.append(i) for i in range (2, len(nota),1): if i<len(nota)-1: print str(nota[i])+",", else: print nota[i]
4eacabef0ad20c682d3953a639ca0b9ad82d4441
BerkeleyGW/BGWpy
/BGWpy/Abinit/utils.py
1,295
3.578125
4
from __future__ import print_function, division import collections from copy import deepcopy def is_number(s): """Returns True if the argument can be made a float.""" try: float(s) return True except: return False def is_iter(obj): """Return True if the argument is list-lik...
a06caa27c1c24ca17364d270f1288d4a404c37d4
ShijieLiu-PR/Python_Learning
/month01/python base/day01/code01.py
556
3.9375
4
""" 汇率转换器 输入美元,显示人民币 """ #1.获取数据 str_usd = input("请输入美元:") float_usd = float(str_usd) #2.逻辑处理 rmb = float_usd * 6.708 # 3.显示结果 print(rmb) """ pycharm常用的快捷键 1. 移动到本行的开头:home 2. 移动到本行的末尾:end 3. 复制一行代码:Ctrl+D 4. 注释代码:Ctrl+/ 5. 选择列并多列输入:鼠标左键+Alt 6. 移动行:shift+alt+上下箭头,或者用ctrl+shift+上...
dc14ea15db73339c3d45b0370c8d8a9de545cfff
mzhao3/CS-HW-2017
/03.23.17cw.py
1,221
3.5625
4
def make_pi(): return [3,1,4] def same_first_last(nums): if len(nums) >= 1: return nums[0] == nums[-1] else: return False def common_end(a, b): return a[-1] == b[-1] or a[0] == b[0] def has23(nums): return 2 in nums or 3 in nums def count_evens(nums): i = 0 count = 0 ...
6a06d9c48b097c27c90bdcae8f20717c7d19e460
KB-perByte/CodePedia
/Gen2_0_PP/Assignment/geeksForGeeks_sorting0ton^2-1.py
146
3.5
4
for t in range(int(input())): input() a = sorted([int(i) for i in input().split()]) for i in a: print(i, end=' ') print()
9098e5750e663bb6ad50701392672c0144118f73
Adarsh-shakya/python_lab
/interchange-lest.py
150
3.71875
4
#interchange first and last elemant of the list #[1,2,3,4,5,6,7,8,.9] #[9,2,3,4,5,6,7,8,1] a=[1,2,3,4,5,6,7,8,9] a[0],a[-1]=a[-1],a[0] print(a)
54a4775231b67c83962cdd47148ce54b2a157118
Archibald-300/lab-2
/6.py
197
3.921875
4
import turtle turtle.shape('arrow') num = 7 for i in range(num): turtle.forward(50) turtle.stamp() turtle.left(180) turtle.forward(50) turtle.left(180-360/num) turtle.mainloop()
e4753d2b4d7c6c2cc65e5de9d0265bdaa6659442
zhuyuedlut/advanced_programming
/chapter5/temp_file.py
913
3.859375
4
from tempfile import TemporaryFile with TemporaryFile('w+t') as f: # Read/write to the file f.write('Hello World\n') f.write('Testing\n') # Seek back to beginning and read the data f.seek(0) data = f.read() f = TemporaryFile('w+t') # Use the temporary file f.close() with TemporaryFile('w+t...
352c1be2745ee6731e52d7c1e6175244ab11e1b1
yoraish/lela
/python/gate.py
6,051
3.734375
4
# A class for a 2D gate. import numpy as np import time from abstract_gate import AbstractGate class Gate(AbstractGate): """A parent class for gates. This class specifies the parameters used for a generic gate. """ def __init__(self, name = 0, width = 20, frame_width = 2, frame_length = 2, translatio...
c89daf004ce01ef9382564709cbbbf5d4ec9255f
michaelzh17/python001
/parameter03.py
606
3.640625
4
#!/usr/bin/env python3 def enroll(name, gender): print('name:', name) print('gender:', gender) def enroll_deft(name, gender, age=7, city='Beijing'): print('name:', name) print('gender:', gender) print('age:',age) print('city:',city) def add_end_static(L=None): if L is ...
588ba0e97d9876d48dcb74d90251479853d51a57
codeAligned/Leet-Code
/src/P-295.py
1,369
3.796875
4
from heapq import * class MedianFinder: def __init__(self): """ Initialize your data structure here. """ # lq - max-heap for the left half # rq - min-heap for the right half self.lq, self.rq = [], [] def balance(self): # Make sure the le...
64bdb45c7bf8e78f1f1b232ad2c81f460a08fd28
Chan-Dru/g4g
/sorting/QuickSortIterative.py
905
3.75
4
def partition(arr,l,h): pivot = arr[h] i = l-1 j = l while (j<h): if(arr[j]<pivot): i += 1 arr[i],arr[j] = arr[j],arr[i] j += 1 i += 1 arr[i],arr[h]=arr[h],arr[i] return i def QuickSort(arr): n = len(arr)-1 stack = [0]*n top = -1 top ...
b6e8e3257ebb5635caeb64bada714de8175d8ce4
hosmanadam/coding-challenges
/@Codewars/5_calculating-with-functions/calculating-with-functions.py
1,276
3.953125
4
"""https://www.codewars.com/kata/calculating-with-functions/train/python""" from operator import add, sub, floordiv, mul from inspect import stack NUMS = {'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9} OPS = {'plus': add, 'minus': sub, 'times': m...
c84794a9b55638cc082f8d7f436c4eb1f0a1d123
Carole-Ouedraogo/CP_Python_Challenges
/5easy-3.py
1,320
3.984375
4
''' Easy Question #3 This is an extension of question #2. Given a list of dictionaries, write a function admin that returns the name and birthdate of all users that are marked as "admin". For example: users = [ { 'name': 'Homer', 'role': 'clerk', 'dob': '12/02/1988', 'admin': Fal...
765b8e473b528e39a3660af7cab4c97f4a3472af
SauravHoss/CSci_127
/fall_flower.py
310
3.625
4
#Saurav Hossain #08/28/18 #Makes a flower #Import turt and name import turtle t = turtle.Turtle() #make it perrrrrrty t.color("violetred2", "hotpink") t.shape("turtle") #Repeat 4 times: for i in range(36): t.forward(100) t.left(145) t.forward(10) t.right(90) t.forward(10) t.left(135) t.forward(100)
d03310f6c6ce9b97daa9e678455fc21e6dc0cdf0
eric-edouard/epsi-python
/exercises/13.py
352
3.890625
4
""" In this exercise, you need to create a class NumberList that inherits from the Python list class. This class shall have a method sum() which takes no parameters and returns the sum of all the elements in the list """ class NumberList(list): def sum(self): return sum(self) liste = NumberList([2, 24, 25, 4]) ...
0a3093f17930d34d06bba8240e361545331dd0cc
nata27junior/Curso-de-Python
/Mundo 1/ex007.py
182
3.828125
4
nota1 = float(input('primeira nota')) nota2 = float(input('segunda nota')) media = (nota1+nota2)/2 print(' a media da nota 1 {} e nota 2 {} é : {:.2f}'.format(nota1,nota2,media))
ef425fedffb2a3d38d4828332fe3c3956fb67196
guiqiqi/AirPolutionData
/Functions.py
647
3.5
4
import datetime class TimeClass(object): def GetTimestamp(strtime): try: return int(time.mktime(timetuple)) except ValueError: return False def GetTimestr(time_stamp): model = '%Y/%m/%d %H:%M' time_tuple = time.localtime(int(time_stamp)) return time.strftime(model, time_tuple) def Ge...
d545d7b5683553c18bcd75d40b66bb4af0e6044b
snpushpi/P_solving
/text_justification.py
2,459
3.9375
4
""" STATEMENT Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. CLARIFICATIONS - Can we pack as much words as can in a sentence starting from the left? Yes, greedy approach is fine. - Does the line last has to be taken care of s...
62d90ca1b494575ce876e20d892fe2c82250a847
Md-Hiccup/Problem-Solving
/python/send_email.py
1,574
3.59375
4
import smtplib port = 2525 smtb_server = '' # server = smtplib.SMTP_SSL('smtp.gmail.com', 465) # server.login("hussain.mohammad@valueleaf.com", "Hiccup@321") # server.sendmail( # "hussain.mohammad@valueleaf.com", # "ask2md@gmail.com", # "this message is from python") # server.quit() import smtplib, ssl from e...
0d4740da8fed5d2a6f51e8775d1d300afdcdafa0
albtronics/raspberrypi
/LED_Blink/LED_Blink.py
462
3.71875
4
print("a l b t r o n i c s . c o m") import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library import time GPIO.setwarnings(False) # Ignore warning for now GPIO.setmode(GPIO.BOARD) # Use physical pin numbering GPIO.setup(40, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and set initial value to low (o...
fc7dcbe0f5e425332da5d6e5fbd082af9cdab248
adeeshaek/primate-social-network
/data_saver.py
5,433
3.53125
4
""" Macaque Simulation Project Adeesha Ekanayake 1/02/2014 data_saver.py ------------- Saves analytical data to disk, using xlwt """ from xlwt import Workbook from tempfile import TemporaryFile import constants def save_age_data(data_list, book): """ saves data to an excel file in the specified workbook paramet...
a9f0c5c8375c45acbcd6ff0658f993b0d3a5a85b
Chris-Kenimer/Python-Fundamentals
/scores_and_grades.py
669
4.0625
4
def scoreInput(): response = raw_input("Please enter a score: ") return response def scoreEval(value): if int(value) in range(59,70): print "Score: " + str(value) + "; Your grade is D" elif int(value) in range(69,80): print "Score: " + str(value) + "; Your grade is C" elif int(value)...
dc8b3cfc68b3386b978136002ec6d59e0de5d26e
Feedmemorekurama/py_course_burkatsky
/Homework/hw_9/unique_list.py
167
3.953125
4
list1 = [1,1,2,3,5,8,13,21,34,55,89] list2 = [1,2,3,4,5,6,7,8,9,10,11,12,13] set1 = set(list1) set2 = set(list2) set3 = set1.union(set2) set3 =sorted(set3) print(set3)
8f73607bdb7a88e75500d55e80d2ede3f32b11ac
zchen0211/topcoder
/python/leetcode/tree_bst/501_find_mode_in_bst.py
1,973
3.828125
4
""" Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST. Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than or equal to the node's key. The right subtree of a node contains only nodes with ke...
b32bf383cdeecfe2e05b34bde15f47b290f2fd03
optimaxdev/BrotherBot
/basic/tests/test_collection.py
1,762
3.515625
4
from unittest import TestCase from basic.Object import Object from basic.Collection import Collection class TestCollection(TestCase): def test_add_and_get_items(self): collection = Collection() obj = Object(ident=1, name='test') self.assertEqual(0, collection.get_length()) self.as...
796a4c604077c01ed5c8f77e3997cc9b1c1e9e3a
L200180015/algostruk
/MODUL_1/14.py
233
3.8125
4
def formatRupiah(n): x = str(n) if len(x) <= 3 : return 'Rp ' + x else: p = x[-3:] q = x[:-3] return (formatRupiah(q) + '.' + p) print ('Rp' + (formatRupiah(q)) + '.' + p)
de05990a05d8f3834e8b2be450b7f4f12a85c77d
michael-creator/password_locker
/user.py
947
3.921875
4
import pyperclip class User: ''' this class generates instance of new users ''' user_list = [] def __init__(self,username , email, password): self.username = username, self.email = email, self.password = password, def save_user(self): ''' function that ...
1bba94aef59c9c2f1f636355385545aed2b1842c
myliu/python-algorithm
/leetcode/sqrt_x.py
501
3.65625
4
class Solution(object): # http://www.matrix67.com/blog/archives/361 def mySqrt(self, a): """ :type a: int :rtype: int """ # Randomly pick the square root of a to be a x = a # Use Newton's method to continuously find better x # f(x) = x^2 - a ...
412ad9853e26dd5e2f317616433b715ecb275688
Carryours/algorithm004-03
/Week 07/id_738/LeetCode_493_738.py
3,893
3.53125
4
class Solution(object): # 解法1 def reversePairs(self, nums): """ 翻转对:https://leetcode-cn.com/problems/reverse-pairs/ 逆序对:对于(i, j), i < j 并且 nums[i] > nums[j]的对,称为逆序对 对逆序对求解出所需要的东西,是在算法中非常经典的问题,需要重视 :type nums: List[int] :rtype: int """ # 对于逆序对的问题,我...
368e4bd9a00b972444c7fce03cd2c8a88201acde
Greeza/Business
/python/第4次作业/A.py
240
4.09375
4
''' 题目描述 判断输⼊的字符串是否是回⽂串,若是,则输出Yes,否则输出No 输入 rssr 输出 Yes 样例输入 rssr 样例输出 Yes ''' s=input() if(s==''.join(reversed(s))): print('Yes') else: print('No')
f673da68371d83e5c5a7fa95004eccfd3a6c2a93
martinjakopec/euler
/eul10.py
267
3.59375
4
import math zbroj = 0 def is_prime(x): output = True for i in range(2, int(math.sqrt(x) + 1)): if x % i == 0: output = False return output for i in range(2,2000001): if is_prime(i): zbroj += i print(zbroj)
af49f7ee4aff6b69f3465edba7096d6e3ff050a6
Lucyxxmitchell/PythonOOCardGames
/src/PlayingCard.py
5,552
3.890625
4
import random class PlayingCard: suits = {"H": "Hearts", "D": "Diamonds", "S": "Spades", "C": "Clubs"} faces = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"] user_hand = 0 # Function: generate_deck # Description: This function generates a 52 pack of cards, with four suites and...
4ebcfc2b85129740e6d8a6b571dac1b71b09142b
LiveFox-Star/calender
/calendar.py
549
3.71875
4
def to_year_str(year): if year == 1: return "元" return str(year) ERA = [(1982, "明治"), (1912, "大正"), (1926, "昭和"), (1989, "平成"), (2019, "令和")] while True: year = input("年を4桁で入力してください") if year == "0000": break try: y = int(year) if y < 1900 or y >2050: c...
ad936eef3c20cceeb8ca3f702d5dea732b695291
Jovioluiz/IA
/Tarefas RNAs/rna_mpl.py
1,128
3.78125
4
#tarefa 4 #Jóvio L. Giacomolli import numpy as np #função sigmoide def sigmoid(x): return 1/(1 + np.exp(-x)) #arquitetura da MPL n_input = 3 n_hidden = 4 n_output = 2 #vetor dos valores de entrada(aleatoria) x = np.array([1, 2, 3]) #pesos camada oculta weights_in_hidden = np.array([[0.2, 0.1,...
02420ce1ee476ab12f6601a817d864952710d226
kulkarniachyut/FF_Programming
/q1.py
1,953
4.09375
4
from collections import Counter class Item : ''' Creates an Item object with name and value attributes ''' def __init__(self,name,value) : ''' create a constructor and initialise the object with attributes ''' self.name = name self.value = value def get_item...
89b077e0b207e05e1cfccc8011c16c5f899b52d2
zuzivian/nlp-golden-globes
/Winner.py
4,552
3.53125
4
# -*- coding: utf-8 -*- import json import nltk import re from nltk.corpus import stopwords from classifier import * # Nat's code for classifiying tweets # Usage: tweet_dic['Best Screenplay - Motion Picture'] : returns a list of strings (unicode) #tweet_dic = get_and_classify_tweets('./data/gg2013.json', 1000000, gg2...
f16ae649a376a8c696f14dda41102d447de917c3
diegoParente23/curso-python
/gguppe/funcoes_com_parametros.py
1,861
4.6875
5
""" Funções com Paramêtros (de entrada) - Funções que recebem dados para processamento - entrada -> processamento -> saída - Funções podem ter N paramêtros de entrada - Paramêtros são variáveis declaradas na definição de uma função - Argumento são dados passados durante a execução de uma função - A ordem dos paramêtro...
49956a619db88e3cb4282bc2abd6f87e4c7dbb79
Ayushd70/RetardedCodes
/python/lambda.py
272
4.1875
4
# Program showing some examples of lambda functions in python double_number = lambda num: num*2 reverse_string = lambda string: string[::-1] add_numbers = lambda x,y: x+y print(double_number(5)) print(reverse_string("Hi, this is a test !")) print(add_numbers(10, 23))
793f3c2ea8f92e4025c651b1dc4a9964f0b23c8a
unet-echelon/by_of_python_lesson
/git_clone/googprog/lesson5/home_task1.py
307
3.546875
4
import time man = ["Гена", "Григорій", "Міша"] women = ["Катрина", "Лиза", "Маша"] manwomen = man + women time.sleep(1) print('Чоловіки') print(str(man)) time.sleep(1) print('Жінки') print(str(women)) time.sleep(1) print('Всі разом') print(str(manwomen))
064f8881bd644fb3cd13b0328c766a46f3fc6e8c
hacktoolkit/django-htk
/utils/text/algorithms.py
2,399
3.828125
4
# Third Party (PyPI) Imports import numpy def levenshtein_distance(w1, w2): """The Levenshtein distance algorithm that compares two words https://en.wikipedia.org/wiki/Levenshtein_distance https://blog.paperspace.com/implementing-levenshtein-distance-word-autocomplete-autocorrect/ Returns an `int` ...
23831e161861b3a3d7754ace8c7fc485b3b8c204
DanielTurnquist/CSCI1133
/hw12.py
6,419
3.953125
4
#Problem A. class Adventurer: # ========================================== # Purpose: each object of this class represents a character in a turn-based RPG # Instance variables: name - the name of the character (string) # level - the character's level value (integer) # strength - how strong...
f1c65dba9712ddeafd2ebf313bfc33cdcd9a29b2
ChainsawRambo/NJIT-CS-100
/Practice Midterm 1 Fall 2017 (2).py
1,144
3.96875
4
#Devon Keen ##CS 100-017 #10/9/18 #Practice Midterm 1 2017 Fall #MCQ #1. a #2. c #3. e #4. d #5. e #6. b #7. a #8. a #9. d #10. d #11a. def double_circle(t,radius): t.down() for i in range(2): t.circle(radius) t.right(180) #11b. def circle_line(t,radius,mult...
d0cc85deb14feb889d8541f46a3bfd759d1b0cc8
mfkiwl/jurigged
/tests/snippets/dandelion:v2.py
459
3.6875
4
class Bee: def __init__(self, zs): self.buzz = "bu" + "z" * zs class Flower: def __init__(self, name, npetals): self.name = name self.npetals = npetals def pluck(self): self.npetals -= 1 def sing(self): return f"O {self.name}, how beautiful are thee {self.npeta...
81c5e752e316579a1e4bd3828a482cd94691998c
daniel-reich/ubiquitous-fiesta
/TDrfRh63jMCmqzGjv_21.py
136
3.703125
4
def is_anti_list(lst1, lst2): if lst1 == lst2: return True for x in lst1: if x not in set(lst2): return False return True
eea118d6e4c643afa248c27133fb5e7c86c2dab6
JDorangetree/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/7-islower.py
128
3.8125
4
#!/usr/bin/python3 def islower(c): x = ord(c) if x > 96 and x < 123: return True else: return False
d8cc47b7ea710d06114a901a78c68d2d2b73cedb
nageshnnazare/Python-Advanced-Concepts
/Date&Time/date_time.py
1,130
3.5625
4
#Date Time from datetime import datetime, timedelta from time import strftime def main(): now = datetime.now() utc = datetime.utcnow() print(f'NOW: {now}') print(f'UTC: {utc}') print(f'Offset: {now.utcoffset()}') #Time print(f'Hour: {now.hour}') print(f'Minute: {now.mi...
0e5eee6a9bc90a457cbdfc47a60f0f420b44bce8
heasleykr/Algorithm-Challenges
/timer.py
598
4.09375
4
def sum_iterative(n): #how many times does this go? N times #range starts at zero so 'n+1' out = 0 for i in range(n+1): out += i return out #Recursion #if you give value of 10, it's going to loop backwards. Generates a stack in memory #Consumes a lot of memory #Python has a maximum recursi...
015bddaa7a87f2f6231095347e8b0b95a86fef81
muklah/Kattis
/Problems' Solutions/nastyhacks.py
364
3.65625
4
n = int(input()) result = [] for i in range(n): r, e, c = input().split() rf = int(r) ef = int(e) cf = int(c) if(ef - rf > cf): result.append("advertise") elif(ef - rf == cf): result.append("does not matter") elif(ef - rf < cf): result.append("do not advertis...
2ff89706618c589b4071a55a5071c59cc6958e96
yosoydead/Sorting-algorithms
/radix sort/helpers.py
1,807
4.15625
4
def getDigit(num, place): #if its the last digit you want #only return the modulo of 10 of the given number if place == 0: return num%10 #else, find the tens or hundreds, etc to divide the given number #so it will have the desired last digit toDivide = pow(10, place) #divide th...
6062cf30e342dff4cd54744ebeb84dd39a57be8c
kgbking/cs61a_fa11
/dice.py
1,737
4.25
4
"""Functions that simulate dice rolls A die is a function that takes no arguments and returns a number from 1 to n (inclusive), where n is the number of sides on the die. Types of dice: Dice can be fair, meaning that they produce each possible outcome with equal probability. For testing func...
d2ffd7494b68359f85ec993c555a135fd14662c8
zingpython/greatKaas
/day_two/day_two_exercise_4.py
967
4.03125
4
limit = int(input("Enter the limit: ")) sieve_list = list( range(2, limit+1) ) #While loop moves from start of list to end of list #We use a while loop because we will be removing items from the list index = 0 while index < len(sieve_list): #Index2 starts at index +1 because we want to check if every item after th...
7d1b60eb33ab8aad11d6eb4af5ab2a58627b4ee7
i50918547/270201034
/lab7/example4.py
222
4.25
4
employees = {} for i in range(3): name = input("Enter name: ") salary = input("Enter salary: ") employees.update({name : salary}) sorted_salaries = sorted(employees.items(), reverse=True) print(sorted_salaries)
d22dcf1bd327ab7fda641a3061fa9c1b3e6b9522
RashmiVin/my-python-scripts
/airline_booking.py
2,401
4.0625
4
BOOKED = 1 FREE = 0 NO_SEAT = "NO_SEAT" seats = { "a1": FREE, "b1": FREE, "c1": FREE, "d1": FREE, "e1": FREE, "f1": FREE, "g1": FREE, "h1": FREE, "i1": FREE, "j1": FREE } def runTheProgram(): goToLoop() def createBooking(): seatNumber = NO_SEAT for key, value in...
53395756045dea09b58d2c35dcf76eb5b9373200
zhaolijian/suanfa
/leetcode/529.py
1,261
3.59375
4
class Solution: def updateBoard(self, board, click): def dfs(i, j): if not (0 <= i < height and 0 <= j < width and board[i][j] == 'E'): return d = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]] # 记录炸弹数 temp = 0 ...
66bdf72157f59214f5cd5ac627f19b741e01827b
Ayon134/code_for_Kids
/10class.py
702
3.921875
4
import random import turtle p1=turtle.Turtle() p1.color("green") p1.shape("turtle") p1.penup() p1.goto(-200,100) p1.goto(300,60) p1.pendown() p1.circle(40) p1.penup() p1.goto(-200,100) p2=p1.clone() p2.color('blue') p2.penup() p2.goto(-200,-100) p2.goto(300,-140) p2.pendown() p2.circle(40) p2.penup() p2.goto(-200,-100)...
fecf288cff84524e4b7941daac417b689a3a8535
cs-fullstack-2019-fall/python-arraycollections-b-cw-Deltonjr2
/becoming.py
1,558
4.21875
4
# PROBLEM 1 Create a function with the variable below. # ``` # arrayForProblem2 = ["Kenn", "Kevin", "Erin", "Meka"] # ``` def problem1(): # !! : there is nothing in this function def arrayForProblem2(): # !! : there is nothing in this function def arrayForProblem2(): listNames = [ "Kenn", "Kevin"...
d2267a1852fdef5f734c76d0484d6464688b561c
dg5921096/Books-solutions
/Python-For-Everyone-Horstmann/Chapter7-Files-and-Exceptions/P7.18.py
606
3.78125
4
# Write a program copyfile that copies one file to another. The file names are specified # on the command line. For example, # copyfile report.txt report.sav # IMPORTS from sys import argv, exit # FUNCTIONS # main def main(): if len(argv) != 3: exit("Error: Invalid number of arguments") readFile...
1dbaae7c781bdc99650f9fa3366db2cd70284747
abrahamq/interviewStudy
/general/findMostFrequentInteger.py
412
3.53125
4
#o(n) time, O(n) space def mostFrequent(inputArr): frequency = dict(); for each in inputArr: if each not in frequency: frequency[each] = 1 else: frequency[each] = frequency[each]+1 top = 0 for each in inputArr: if frequency[each] > top: ...
18d719a4c720c6b95ef9cbad9cfd58be4223e344
avneetkaur1103/workbook
/Algorithms/DP/palindromic_subsequence.py
612
3.734375
4
""" Given a sequence, find the length of the longest palindromic subsequence in it. """ def lps(str): n = len(str) dp = [[0 for _ in range(n)] for _ in range(n)] for l in range(1, n+1): for i in range(n-(l-1)): j = i+l-1 if l == 1: dp[i][j] = 1 elif l == 2: dp[i][j] = 2 if str[i] == str[j] else ...
0c4fb648751deebe7220093896482bc2fbe354b4
haraldosan/pi_collisions
/collisions.py
1,038
3.609375
4
#The most inefficient way of solving PI, inspiration taken from the 3Blue1Brown's Youtube channel's video covering this interesting problem: https://www.youtube.com/watch?v=HEfHFsfGXjs #Not yet complete, recursion does not take new input returned from function into account. import math class Collisions: c...
74149f0cdf00d3fc309cf01132298bdb8f9fa600
rchin-mwh/barcode_design
/barcode_design_rk_2.py
5,108
3.5
4
#!/usr/bin/env python # Design DNA barcodes for sequencing experiments import random import csv # This is from pypi python-levenshtein: try: from Levenshtein import distance except: print("python-levenshtein package not found, please install") class BarcodeDesigner: def __init__(self, ...
4319f71a397040e7576f5af9adeb7fcf41b336f0
sankeerthankam/Code
/Leetcode/Bootcamp/Week 2/263. Ugly Number.py
1,276
4.0625
4
# Approach 1: # Calculate prime numbers until n # Calculate factors of n # Perform the intersection of the two sets to get the prime factors of 'n' # Return True if max(prime_factors) > 6 def isUgly(num): if num == 0 or num > pow(2, 31) or num < pow(2, -31): return False if num == 1: r...
935ce8814f64ad229c6c0689e2ec31a6920ecb4e
miriamlam1/csc365-databases
/MiriamLam1_lab-1a/schoolsearch.py
4,753
3.765625
4
# Miriam Lam # Databases CSC365 # The program will look through students.txt file in the same directory # Some starter code taken from Canvas import sys StLastName = 0 StFirstName = 1 Grade = 2 Classroom = 3 Bus = 4 GPA = 5 TLastName = 6 TFirstName = 7 # search students by last name # print the last...
270d4cbc36d83a620f5f03aeee792a87fdd8df4b
soongxin/lint
/datastruc/arrayStack.py
1,965
3.921875
4
class Stack(object): """使用数组实现一个栈""" def __init__(self): self.data = [] def push(self, num): """压栈操作""" self.data.append(num) def pop(self): """返回从栈中弹出的元素, 当栈为空的时候, 抛出IndexError""" return self.data.pop() def peek(self): """查看当前栈顶的元素, 当栈为空的时候, 抛出Inde...
dd60b3b4a1953c6d125e494630b7751d2f4787a9
ImamMuis/TugasAkhir
/system_development/basic_OOP.py
347
3.625
4
class ClassA(): var1 = 0 var2 = 0 def __init__(self): ClassA.var1 = 1 ClassA.var2 = 2 def methodA(self): ClassA.var1 = ClassA.var1 + ClassA.var2 return ClassA.var1 class ClassB(ClassA): def __init__(self): print(ClassA.var1, "1") print(ClassA.var2, "2") object1 = ClassA() sum = object1.methodA() ob...
daa3088c3cb2b2fb4e6b79629fdfb1fdf0eed06b
myfairladywenwen/cs5001
/week08/test_demo/a_class.py
248
3.75
4
class AClass: def __init__(self, an_attribute): """Initializes class attribute""" self.an_attribute = an_attribute def return_a_value(self, n1, n2, n3): """Adds three numbers together""" return n1 + n2 + n3
2c2becbfc6666b483d5dd8393f2b876831d3ddf9
jtlai0921/MP31601
/CH12/CH1221C.py
711
3.703125
4
# 以內建函式write()分段寫入檔案 -- 切片作法 prose = ''' To his Heart, bidding it have no Fear Be you still, be you still, trembling heart; Remember the wisdom out of the old days: Him who trembles before the flame and the flood, And the winds that blow through the starry ways, Let the starry winds and the flame and the flood Cover o...
c4358e41f5fa1136a6506f30cf703652fe906856
AKASH1233808/Python
/comparsion operator.py
368
4.21875
4
#python Program to overload #a comparsion operators class A: def __init__(self,a): self.a = a def __gt__(self,other): if(self.a>other.a): return True else: return False ob1 = A(2) ob2 = A(3) if(ob1>ob2): print("ob1 is greater than ob2") els...
8bdea94525eb5552c80861c010b788e5013bbe58
agapow/Py-phylo-core
/phylo/core/tree/iterable_tree_mixin.py
6,508
4.28125
4
""" Tree iterators and functions for searching within a tree. Tree iterators should follow the general form: iter_object_[direction] (tree, start=None, stop=None) where: * iterators are named as ``iter_object[_direction]``, where ``object`` is the type being returned by the iterator (e.g. ``node`` or ``branch``)...
10e6f29978b350891bc54479568848aaac4fa257
robertoffmoura/CrackingTheCodingInterview
/Python/Chapter 03 - Stacks and Queues/q5.py
764
3.71875
4
def sortStack(stack): helperStack = [] helperStackStart = 0 def extractBiggest(): biggest = float("-inf") count = 0 while (len(stack) > 0): current = stack.pop() if (current > biggest): biggest = current count = 1 elif (current == biggest): count += 1 helperStack.append(current) whil...
771bc70d53bb9e29b6555124843f91acc6aa0688
450703035/leetcode
/字符串/8、链表回文.py
1,354
3.5625
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 14 14:06:10 2020 @author: Administrator """ """ 题目描述:链表回文 leetcode 234 [https://leetcode-cn.com/problems/palindrome-linked-list/](https://leetcode-cn.com/problems/palindrome-linked-list/) 请判断一个链表是否为回文链表。 **示例 1:** ``` 输入: 1->2 输出: false ``` **示例 2:** ``` 输入: 1->2->2...
f3e518ecfeeb4e22681fd6dfee4fbaaf0a5c9dd4
rcmoura/aulas
/determina_escolha.py
127
4.09375
4
fim = int(input("Entre com o fim-> ")) x = int(input("Entre com o inicio-> ")) while fim >= x: print(fim) fim = fim - 1
3941d1d84aaa3cefa7ae5e7aaad2992280e5224d
Timelomo/leetcode
/13 Roman to Interger.py
585
3.609375
4
class Solution: def romanToInt(self, s: str) -> int: d1 = {"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000} d2 = {"IV":4,"IX":9,"XL":40,"XC":90,"CD":400,"CM":900} length = len(s) i = 0 sum = 0 while(i<length): if( d2.get(s[i:i+2]) ): su...
4f36d6aeb332c01df57bc7a4bee4a26f9b45b2d6
vincepmartin/playground
/google/ion_flux_relabling/answer.py
901
4.125
4
def answer(h,​ ​q): # Define a Node object. class Node(): def __init__(self, key_value): self.key_value = key_value self.left = None self.right = None # Post order traversal code. def postOrder(root): if root: # Explore the left child. ...
c76d134c63ccd54934f8ca54422b5ff52b49aae6
praveenv253/idsa
/endsem/find-the-count.py
803
3.859375
4
#!/usr/bin/env python def main(): import sys from bisect import bisect_left # http://docs.python.org/2/library/bisect.html#searching-sorted-lists def contains(a, x): """Locate the leftmost value exactly equal to x""" i = bisect_left(a, x) if i != len(a) and a[i] == x: ...
4e101fd5666fbc5da3da6e772f0718173a5b49ea
rossmfadams/AlgorithmsP2
/bubbleSort.py
878
4.375
4
# bubbleSort.py for Algorithms Project 2 # O(n^2) Sorting Algorithm # Bubble Sort which will take the list and sort it by switching the numbers # when they are greater than the previous number and continue doing this until # the list is sorted # Bubble Sort Algorithm used: https://medium.com/@george.seif94/a-to...
d9fee80d9b6a7a423411163fe5ad74a8db5f9e06
inteljack/EL6183-Digital-Signal-Processing-Lab-2015-Fall
/project/Examples/Examples/PP2E/Other/Old-Tutor/feet.py
507
4.0625
4
class ShoeSketch: # make a new class object print 'making a class...' # printed when the class is defined shoeSize = 7.5 # class data shared by all instances def feet(self, value = None): # make a method function if not value: return sel...
4db66242c95f4e6da0e4b6e5cf8987331bab1b8f
pyroRocket/Python
/Python101.py
3,893
4.46875
4
# Strings print("Hello World!") # Double quotes print('Hello World') # Single quotes # You cant mix type of quotes ex: print('Hello world") print("""This is a multi line string""") print("\n") # new line # Math print("Math time: ") print(67 + 69) # Add print(67 - 69) # Subtract print(67 * 69) # Multiply print...
989e190d28947e6786cc109cc8b721159daea4eb
vijaymaddukuri/python_repo
/training/DataStructures-Algorithm/sorting/sortByHeight.py
620
3.890625
4
def sortByHeight(itemList): newList=[] for k in itemList: if k != -1: newList.append(k) for i in range(len(newList)-1,0,-1): for j in range(i): if newList[j]>newList[j+1]: temp=newList[j] newList[j]=newList[j+1] newList...
d6a01ac48f5738a20f9a7d421889589b10af9515
C-CCM-TC1028-102-2113/tarea-3-programas-que-usan-funciones-AlbertoCS7
/assignments/10Bisiesto/src/exercise.py
462
3.890625
4
def bisiesto(año): if año%100==0 and año%400!=0:#2. Revisa las condiciones para determinar si un año No es bisiesto return 'No es bisiesto :(' elif año%4==0 and a%100!=0: #1. La variable a, no existe. return 'Si es bisiesto :)' def main(): #escribe tu código abajo de esta línea año ...
00e0de13e8bce4de3fa2717b98ccbc66c4d8802a
tainenko/Leetcode2019
/leetcode/editor/en/[1309]Decrypt String from Alphabet to Integer Mapping.py
1,338
3.796875
4
# You are given a string s formed by digits and '#'. We want to map s to # English lowercase characters as follows: # # # Characters ('a' to 'i') are represented by ('1' to '9') respectively. # Characters ('j' to 'z') are represented by ('10#' to '26#') respectively. # # # Return the string formed after ma...
280f28af05187d5c4acea6ce7c469010202744fc
JasmineZhen218/hypoxemia
/FeatureGeneration/feature_extraction.py
8,727
3.609375
4
"""Contains functions for feature extraction. Functions: linear_lstsq - Linear least-squares filtering linear_lstsq_deriv - Linear least-squares derivative approximation finite_approx_ewma_and_ewmvar - Finite-window approximations of exponentially weighted moving average and variance spectral_ent...
7940440d6a9a1cb03b108f5aaf40e6048d214664
abdurrahimyilmaz/Regression
/3-Polynomial Regression/polynomialRegression.py
2,078
3.59375
4
# -*- coding: utf-8 -*- # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Position_Salaries.csv') x = dataset.iloc[:, 1:2].values #matrix y = dataset.iloc[:, 2].values #vector # Splitting the dataset into the Training set a...
25426ea8a8becef32ca6a906492acb857a3ca261
HenriqueNO/Python-cursoemvideo
/Desafios/Desafio_043.py
578
3.703125
4
peso = float(input('Informe o seu peso: ')) altura = float(input('infome sua altura: ')) calc = peso / (altura * altura) from time import sleep sleep(0.5) if calc <= 18.5: print('\033[1;31mAbaixo do peso\033[m, IMC= {:.2f}'.format(calc)) elif calc <= 25: print('\033[1;33mPeso ideal\033[m, IMC= {:.2f}'.format(ca...
fdfc50ed6b4258b64e636beb4b1aed60cb0b9969
tuanprono1hn/luonganhtuan-fundamentals-c4e16
/Session3/homework/ship21.py
1,041
3.953125
4
print() sheepsize = [10, 50, 300, 150, 260, 90, 25, 30] print("Hello, my name is Tuan and these are my sheep size: ") print(sheepsize) print() print("Now ny biggest sheep has size {}, let shear it!!!".format(max(sheepsize))) print() print("After shearing, here is my flock: ") sheepsize[sheepsize.index(max(sheepsize))] ...
9a8f7a5a7a205d213a252781ada85f16a8569137
RakeshKumar045/DataStructures_Algorithms_Python
/Sorting/Insertion sort.py
385
4.03125
4
def insertionsort(arr): length = len(arr) i = 1 end = arr[0] while i < length: if arr[i] < end: x = arr.pop(i) for j in range(0, i): if x < arr[j]: arr.insert(j, x) break end = arr[i] i += 1 retur...
ba1c3dd0f7ab3910b9e953abcb52ff3b94f32bb8
xy2333/Leetcode
/leetcode/sort_algorithm.py
2,973
3.65625
4
def bubble_sort(lst): for i in range(len(lst)-1): flag = 0 for j in range(len(lst)-i-1): if lst[j] > lst[j+1]: lst[j],lst[j+1] = lst[j+1],lst[j] flag = 1 if flag == 0: break def select_sort(lst): for i in range(len(lst)-1): minindex = i for j in range(i+1,len(lst)): if lst[minindex] > lst...
4385773d24f0f04ed0a1c99524d7de516da854b4
LennyBoyatzis/code-challenges
/problems/arrays_and_strings/plus_one.py
405
3.9375
4
from typing import List def plus_one(digits: List[int]) -> int: for index in range(len(digits) - 1, -1, -1): if digits[index] is not 9: digits[index] = digits[index] + 1 return digits else: digits[index] = 0 return [1] + digits if __name__ == '__main__': ...
9e01f8c44c0b493708fbb9ec44587e7ac89f068d
haely/IoT-Baby-monitor
/aws_dynamo_sms_me.py
1,557
3.5
4
# Contributors: # Haely Shah # Josiah Morrison # Importing the nexmo library URL: https://developer.nexmo.com import nexmo import RPi.GPIO as GPIO from time import sleep sensor_pin = 17. # Initialized GPIO 17 for motion sensor GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(sensor_pin, GPIO.IN) ...
0a0a6ded545f27c328b29ef8fddfa9517461fa88
KelineBalieiro/Python
/alien1.py
1,043
3.578125
4
# alien_color = 'green' # if alien_color == 'green': # print("Você ganhou cinco pontos!") # alien_color = 'blue' # if alien_color == 'green': # print("Você ganhou cinco pontos!") # else: # print("Você ganhou dez pontos!") # alien_color = 'green' # if alien_color == 'green': # print("Você ganhou ci...
191879d69c6851ac2fedd3c1ae5d7e13e407cc14
Kondziu123/gitrepo
/python/silnia.py
701
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # silnia.py # n! = 1 dla n=(0, 1) # n! = 1 * .... * n dla N+ - {1} def silnia_it(n): wynik = 1 for i in range(2, n + 1): wynik = wynik * i return wynik def main(args): """Funkcja głównna""" # pobierz od użytkownikaliczbe naturalna #...
68d21fa7445746c465217b98d2cfa78b5bfa4666
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/mnhper001/question3.py
748
3.984375
4
def Encrypted_message(string): if len(string)==1: if string=="z": return "a" return chr(ord(string)+1) if string[0]==" ": return " "+Encrypted_message(string[1:]) if string[0]==".": return "."+Encrypted_message(string[1:]) if string.isupper(): ...
8d290cb15b73556ccc749357273de6ba3bd68b08
Grojszek/python-advance
/5-input_parsing/zad5.py
1,675
3.65625
4
def read_input(filename: str) -> list: with open(filename, 'r') as read_file: lines = read_file.readlines() values = [] one_type = [] for line in lines: if line == '\n': values.append(one_type) one_type = [] else: one_type.append(line.replace('...
fdc56ef651d80ef4e045e102870263b3a8e6cb4d
Brody-Liston/Pracs-by-Brody-Liston
/prac_07/used_cars.py
1,562
3.875
4
"""CP1404/CP5632 Practical - Client code to use the Car class.""" # Note that the import has a folder (module) in it. from car import Car def main(fuel=None): """Demo test code to show how to use car class.""" my_car = Car(180) my_car.drive(30) my_car.car_name = "Ford GT" # ---------------------...
2286f5748e545ddab5f048bec4f892c98be6b75a
SimmonsChen/LeetCode
/回溯/面试题 08.12. 八皇后.py
4,744
3.5
4
""" 设计一种算法,打印 N 皇后在 N × N 棋盘上的各种摆法,其中每个皇后都不同行、不同列,也不在对角线上。 这里的“对角线”指的是所有的对角线,不只是平分整个棋盘的那两条对角线。 注意:本题相对原题做了扩展 示例: 输入:4 输出:[[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]] 解释: 4 皇后问题存在如下两个不同的解法。 [  [".Q..",  // 解法 1   "...Q",   "Q...",   "..Q."],  ["..Q.",  // 解法 2   "Q...",   "...Q",   ".Q.."] ] """ ...
16d4fe3c6a48a559c28b175229962363f4e2f873
chuzcjoe/Leetcode
/922. Sort Array By Parity II.py
1,302
3.53125
4
class Solution: def sortArrayByParityII(self, A: List[int]) -> List[int]: n= len(A) """ odd = [] even = [] for i in range(n): if i % 2 == 0: odd.append([A[i],i]) else: even.append([A[i],i]) ...
f0808136d79518b7a5f4a5e30db76ae8b5a23393
007AMAN007/python-tutorial
/mysql/mysqlTut.py
489
3.5
4
import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="", database="mypythondb" ) # print(mydb) #check if connected # mycursor = mydb.cursor() # mycursor.execute("CREATE DATABASE mypythondb") #create database mycursor = mydb.cursor() # mycursor.execute("CREATE TABLE ...
caf87081c477f74fdc208a365c05c348ae791da1
saisurajpydi/Dynamic-Programming
/Interview Prep/BalParant.py
560
3.71875
4
""" Q1: Balancing Parenthesis: Given a string of parenthesis you have to print the minimum number of deletions that can be made so to balance the parenthesis. """ n = input() stack = [] op = 0 cl = 0 dele = 0 for i in range(len(n)): if(n[i] == "("): op += 1 stack.append(n[i]) if(n[i] == ")"): ...