blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5b0c8fc9f82e9e39c9ee7a1d6f9ee9687aea3281
filmote/PythonLessons
/Week2_4.py
956
4.125
4
import turtle def polygon(aTurtle, sides, length): counter = 0 angle = 360 / sides while counter < sides: aTurtle.right(angle) aTurtle.forward(length) counter = counter + 1 # ------------------------------------------------- # set up our shapes # triangle = { "name": "Triangle"...
63526f56cdceb9832abfecc2667b0a72e27e8bba
Biofobico/learn_python
/chp6_dictionaries/alien.py
1,156
3.890625
4
alien_0 = {'color': 'green', 'points': 5} print(alien_0) alien_0['x_position'] = 0 alien_0['y_position'] = 25 print(alien_0) new_points = alien_0['points'] print(f"You just earned {new_points} points!") print(alien_0['color']) print(alien_0['points']) alien_1 = {} alien_1['color'] = 'violet' alien_1['points'] = 7...
5fa6884b11f9481ee914f6f186cabeb319f48453
landalex/FinalProject
/pythonShineTest.py
422
3.828125
4
newList = [] for i in range(len(listOrig)): newList.append(listOrig[i]) counter = 0 for i in range(len(listOrig) - 1): counter += 1 if listOrig[i] > listOrig[i+1]: newList[i+1] = newList[i] newList[i] = listOrig[i+1] elif listOrig[i] <= listOrig[i+1]: newList[i+1] = listOrig[i+1] if counter == ((len(listOr...
bfb620c5098c6f05221f30ce7f4105f2230d926e
mathieuguyot/advent_of_code_2020
/src/day_3.py
683
3.78125
4
file = open('./data/day_3.txt',mode='r') lines = file.read().splitlines() file.close() def slope(lines, offset_col, offset_row): col_size = len(lines[0]) cur_col = 0 cur_row = 0 tree_count = 0 while cur_row < len(lines): if lines[cur_row][cur_col % col_size] == "#": tree_count +...
85589f4690b21964fb054087e313ea1649f2fb78
rifanarasheed/PythonDjangoLuminar
/FILEIO/covid_analysis.py
1,617
3.96875
4
# need each states confirmed cases from covid_19_india dataset covid = open("covid_19_india.csv","r") # file reading dict = {} # created an empty dictionary to get count of confirmed cases of each state # key value # state confirmed for line in covid: ...
b43f1787d4d20358f4c34fcb3ed8327ca88794d6
MaesterPycoder/Python_Programming_Language
/python_codes/reverse.py
64
3.75
4
a=list(input("Enter number:")) a.reverse() print("".join(a))
127ef87c7ba3865e982df6149ecdd385541dad80
chinmairam/Python
/data.py
519
3.625
4
filename = 'data.txt' try: with open(filename) as f: for line in f: items = line.split(',') total = 0 try: for item in items: num = int(item) total += num print("Total = " + str(total)) e...
41be38486c6d0191158300ad2794f4eb9f71d546
kabdesh/lesson-1
/nice.py
609
4.03125
4
number = int (input ("Введите число 1-12: ")) if number == 1: print("январь") elif number == 2: print("Февраль") elif number == 3: print("Февраль") elif number == 4: print("Февраль") elif number == 5: print("Февраль") elif number == 6: print("Февраль") elif number == 7: print("Февраль") elif...
3648230763806af85c8eb7fcd19f081b0c15b3d4
b166erbot/sql-khanacademy
/sql-6.py
2,124
3.875
4
import sqlite3 from os.path import exists def bancoDeDados(*args: tuple): """ Função que comita os comandos sql. """ connection = sqlite3.connect('teste6.db') cursor = connection.cursor() cursor.execute(*args) retorno = cursor.fetchall() connection.commit() connection.close() r...
0f17cd7822955aeb9e6c03d60686f5be829cf61c
MirnaZe/Tarea_03
/rendimientoAuto.py
916
3.71875
4
#Mirna Zertuche Calvillo A01373852 #Un programa que calcula el rendimiento de kilometros por litro de gasolina, lo transforma a millas por galon y calcula cuantos litros se necesitan para ciertos kilometros def KmporLitro(Km,Lt): Kxl=Km/Lt return Kxl def MiporGalon(Km,Lt): KaM= Km/1.6093 LaG= Lt*0.264...
cc839b7b7be1f4516d7bb83ded927308947c0c08
slih01/Alleyway
/ball.py
488
3.78125
4
from turtle import Turtle import random class Ball(Turtle): def __init__(self): super().__init__() self.shape("circle") self.color("white") self.shapesize(stretch_len=0.7,stretch_wid=0.7) self.penup() self.hideturtle() self.goto(random.randint(-250,250),0) ...
0062e95b427d3b2feae277c76bf6a0cc3b0fb5fd
Tailsxky/python_learning_demo
/guess_random_number/project.py
719
4.125
4
from random import randint guess_number = randint(1,50) #print(type(guess_number)) bingo = False your_guess = int(input("guess a number between 1 to 50: ")) while bingo == False: '''if(type(int(your_guess)) != int): print("please input a number:") your_guess = input("guess again: ")''' if(you...
2b360e7cb9203ef081fc826be56edc17a31a9bff
haiwenzhu/leetcode
/substring_with_concatenation_of_all_words.py
1,168
3.53125
4
class Solution: """ @see https://leetcode.com/problems/substring-with-concatenation-of-all-words/ """ # @param S, a string # @param L, a list of string # @return a list of integer def findSubstring(self, S, L): l = len(L[0]) lenOfL = len(L) res = [] ...
23e304867b047472eeb4eb211b8789593122d89a
andrew8gmf/python
/matrizes_matematica/1-e).py
633
3.953125
4
import numpy as np import random print("\nSoma de matrizes\n") x = int(input("Ordem das matrizes: ")) y=x*x matrizA = np.arange(y).reshape(x,x) for i in range(x): for j in range(x): matrizA[i][j] = random.randint(0,9) print("\n\nMatriz A: \n") for i in range(x): for j in range(x): print(matrizA[i][j], end=" "...
a4405e1698d6e00f2da2d4cfba2b228bd6f92580
gokilarani/python
/large.py
183
3.78125
4
a=input() b=input() c=input() if (int(a)>int(b)) and (int(a)>int(c)): print('a is great') elif (int(b)>int(c)): print('b is great') else: print('c is great')
b7fe74be0601476f0f521dea48c572d619d0e637
zakir360hossain/MyProgramming
/Languages/Python/Learning/basics/builtins/sorting.py
353
3.90625
4
state = ['PA', 'MA', 'NJ', 'NY', 'TN', 'CA', 'DE', 'AL', 'AZ', 'AR'] print(sorted(state)) print(sorted(state, reverse=True)) fruit_and_price = {'Apple': 1.99, 'Banana': 0.99, 'Orange': 1.49, 'Cantaloupe': 3.99, 'Grapes': 0.39} print(sorted(fruit_and_price.keys())) # or just fruit_and_price, .keys() not needed print(s...
31cc77d837c979e5fb6dbfb92084bb6856685399
running258/autotest_2
/test.py
255
3.734375
4
class A: def __init__(self): A = 'A' self.a = 'a' print('init A') class B(A): def __init__(self): super(B, self).__init__() # self.b = 'b' # print('init B') pass b = B() print(b.a)
580678e760f446055328a93b1d23e907d551adc3
jacklynknight08/py_FamilyDictionary
/family_dict.py
725
4.59375
5
# Define a dictionary that contains information about several members of your family. my_family = { 'mother': { 'name': 'Beth', 'age': 50 }, 'sister': { 'name': 'Jessi', 'age': 33 }, 'brother': { 'name': 'Joey', 'age': 29 }, 'father': { ...
5f80776fc0ed601c7adb3b6e156df2a1ea660e44
1098813507/Taller-de-Algoritmos
/4.py
239
3.890625
4
print("la suma de 2 numeros ") nume1=float(input("digite un numero")) print(nume1) nume2=float(input("digite un numero")) print(nume2) suma=nume1+nume2 print("la suma de los numeros"+str(sume1)+"y"+str(num2)+"es"+str(suma1)) print("end")
927dbedba275860b05ec924a1a92e8ae50f8ede3
saidadem3/hrank
/Python/dictionary/dictionary.py
703
3.875
4
if __name__ == '__main__': #how many students we will create in our dictionary n = int(input()) student_marks = {} #first input (name) is the key for the dictionary (student_marks) - line 9 #(*line) takes multiple inputs and stores them as the values to a student - line 9 #(scores) converts each...
ce0dadb022f46b32ed8f33ea71e5d477082b424a
ankurjaiswal496/Leetcode-Solutions
/problems-tab/459. Repeated Substring Pattern.py
378
3.578125
4
class Solution: def repeatedSubstringPattern(self, s) : # print(len(s)//2) for k in range(1, len(s)//2 +1): # print(s[k:] + s[:k]) if s == s[k:] + s[:k]: print(s[k:] + s[:k]) return True return False obj=Solution() obj.repeatedSu...
4a750716d15ce023e41f8d8f470b27260371e10f
KirillKras/python_basic
/pb_les5_e2.py
255
3.5625
4
# Задача-2: # Напишите скрипт, отображающий папки текущей директории. import os def view_dir(): for r, d, f in os.walk(os.getcwd()): for folder in d: print(folder) view_dir()
8411b8c8c7a1501a182c9ec80b8578f8860fb9d1
CWJWANJING/Number-guessing
/number-guessing.py
1,860
3.828125
4
import random import pdb # can decide how many people to play # maximum players # 1&2: number in range 1-100 # 3: number in range 1-150 # 4: 1-200 # 5: 1-250 # 6: 1-300 # enter the number of player first # 2-players: def checknum(inp, guessnum): correct = False if inp < guessnum: print(f"The number ...
054f4dd0d87129f8f94d891757e71723aabfeb20
SilvesSun/learn-algorithm-in-python
/dynamic programming/718_最长重复子数组.py
702
3.53125
4
from pprint import pprint from typing import List class Solution: def findLength(self, nums1: List[int], nums2: List[int]) -> int: # dp[i][j] 表示以下标i-1结尾的nums1, 和以下标j-1结尾的nums2的最长重复子数组长度 m, n = len(nums1), len(nums2) dp = [[0] * (n+1) for _ in range(m+1)] res = 0 for i in ra...
6fc9c09ac901664d3ae7551efdb81acf0b294ccb
jan-2018-py1/joelstiller_classwork
/find_character.py
359
4.3125
4
# Assignment: Find Characters # Write a program that takes a list of strings # and a string containing a single character, and prints a new list of all the strings containing that character. def find_char(chr,xlist): for x in xlist: if chr in x: print x word_list = ['hello','world','my','name...
cd2a711edd3d890da1b921859b3f93278fccb01c
rakshi2002/stars
/subtraction/subtraction.py
115
3.53125
4
def dosubtraction(): a=9 b=4 c=a-b #difference of a and b print(a,"-",b,"=",c) dosubtraction()
2abbabee6552232b65fb159cf765c6e4b7c95e68
bcasalvieri/Modern-Python-Bootcamp
/10_looping_in_python/emoji_art_exercise.py
110
3.96875
4
for num in range(1, 10): print("😀" * num) num = 1 while num < 10: print("😀" * num) num += 1
c406b50f8f4e827b0b9b7ed5e81ef187592f446b
RosaIss/advent_of_code
/2018/d2_1.py
691
3.71875
4
""" --- Day 2: Inventory Management System part 1---""" import sys def calculate_checksum(ids): two_char = 0 three_char = 0 size_alpha = 26 alpha = [0] * size_alpha for i in ids: alpha = [0] * size_alpha for c in i: alpha[ord(c) - ord('a')] += 1 two_char += 1...
5aafa164b62e8db0a9e2e57906f2bb5c6641ff42
michedomingo/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/tests/test_models/test_rectangle.py
6,622
3.671875
4
#!/usr/bin/python3 """ This module contains unittest for /models/rectangle.py """ import unittest from models.base import Base from models.rectangle import Rectangle class TestRectangle(unittest.TestCase): """This class TestRectangle defines tests for class Rectangle methods""" def test00_args(self): ...
0dd110262d016921388a93e0783183e5781d3833
Yasara123/Grade-Prediction-System
/final_SFT/win_Login.py
3,238
3.515625
4
__author__ = 'Yas' from Tkinter import * from ttk import Button from Tkinter import Tk import base64 import tkMessageBox as box import os from PIL import Image, ImageTk ''' This is the login class of the system. It verify the username and password by using config text file. If user fogot the pass word he/she can chang...
2f543f213abb7f5f10db6a7d2e7f0b36487e6801
RaymondTseng/ThaiTravel
/Search/engsegment.py
2,774
3.625
4
# -*- coding:utf-8 -*- import nltk from nltk.corpus import stopwords import json comments = ['I am not fond of shopping. But when i got there in saw the affordable and a lot of clothes to choose and made me wants to shop. This mall will also test your bargaining skills. The only problem is the mall close at 8pm. It is ...
adc818ff6f429531b325c8b1e4c4a70e4d2a4b39
djaychela/playground
/dna/tax_calc.py
939
3.640625
4
def calc_tax_due(amount, allowance_used): tax_amount = 0 lower_rate = 0.2 higher_rate = 0.4 additional_rate = 0.45 if amount < 11500 and not allowance_used: return 0 elif amount < 11500 and allowance_used: return amount * lower_rate elif amount >= 11500 and not allowance_use...
263fed61f8c65bb8f0565e4419692b2a77ced64e
catherning/PRe_deap
/csv_splitter.py
2,489
3.5625
4
#from https://gist.github.com/jrivero/1085501 import os def split(action, delimiter=',', row_limit=10000, output_name_template='output_%s.csv', output_path='.', keep_headers=True): """ Splits a CSV file into multiple pieces. A quick bastardization of the Python CSV library. Arguments: ...
07097e7867a7ba2ba51e0e8f02ec1cc3fb650add
utkarsh04apr/python
/python-coding-W3school/looping/7-for-else.py
153
3.8125
4
data = [1,3,5,7,9,11,21,13,15,17] for n in data: if n%2==0: print("even no is in data") break else: print("no even no is there")
bd3ce93a9907ef45c161d941cb50ee224a74c715
jinglongzou/Sword_Offer
/Sword_Offer/issue20.py
1,137
3.59375
4
# -*- coding:utf-8 -*- # 定义栈的数据结构,请在该类型中实现一个能够得到栈中 # 所含最小元素的min函数(时间复杂度应为O(1))。 # 考察栈的概念、建立、O(1)时间复杂度:则要求要么是顺序表存储,要么是单独一个变量 # 因此构建一个变量来存储最小值,并在,插入和删除时维护最小值 # 构建一个辅助栈来存储最小值,这样出入栈、返回最小值都是O(1);利用空间换取时间 class Solution: def __init__(self): self.s = [] self.s_ = [] def push(self, node): # w...
a83098ebae4ba14847dffb543170443c4dcc0ecc
aleblucher/An-lise-de-Treli-as-Planas
/inn.py
1,078
3.640625
4
def readMecSol(file_name): with open(file_name, "r") as arquivo: #read file file = arquivo.readlines() def is_number(s): #test if a string is a number try: float(s) return True except ValueError: pass try: import unicodedata ...
d6ff42b0aff7248b0bb3e3dcab9dd09ec5e524b8
zhaolijian/suanfa
/leetcode/sword_to_offer3.py
826
3.625
4
# 找出数组中重复的数字。 # 在一个长度为 n 的数组 nums 里的所有数字都在 0~n-1 的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。请找出数组中任意一个重复的数字。 # 方法1 原地操作 class Solution: def findRepeatNumber(self, nums) -> int: i = 0 while i < len(nums): if nums[i] == i: i += 1 continue if nu...
0e891b3314e45a3736d95659400dce657f014eb6
jvano74/advent_of_code
/2015/day_08_test.py
3,435
4.3125
4
import re class Puzzle: """ --- Day 8: Matchsticks --- Space on the sleigh is limited this year, and so Santa will be bringing his list as a digital copy. He needs to know how much space it will take up when stored. It is common in many programming languages to provide a way to escape special ...
6e4e9688f2c6cecad539820f70cfffdef574364c
iCoder0020/Competitive-Coding
/CodeChef/Python/FCTRL2.py
240
3.59375
4
#ID: ishan_sang #PROG: FCTRL2 #LANG: Python def fact(n): ans=1 for n in range(n,1,-1): ans*=n return ans t=int(input()) for t in range(t,0,-1): n=int(input()) print(fact(n),"\n")
db97b01da5544db0f3d3658a752e562734118a9a
cpp337323012/PycharmProjects
/DataTestPG/Python_Base/part01/my_reg.py
507
3.640625
4
''' 2019年12月11日22:58:14 11位手机号码匹配: 移动: 139 138 137 136 135 134 150 151 152 157 158 159 联通: 130 131 132 185 186 145 电信: 133 153 180 199 ''' import re def checkCellphone(cellphone): reqex = '^(13[0-9]|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$' result = re.findall(reqex,cellphone) if result: pri...
9396f066893e4ae52cf2e00832722c7d22445cb0
ChiShengChen/2018makeNTU_meowmeow
/gesture-keyboard-master/suggestions.py
2,438
3.703125
4
import os ''' Author: Federico Terzi This library contains the classes needed to manipulate words and obtain suggestions This is a work in progress.... ''' class Hinter: ''' Hinter is used to load a dictionary and obtain some suggestions regarding the next possible letters or compatible words. ''' def __init__...
e2dfb63f574b39e04f078332e45a9a23d7efade9
Jungeol/algorithm
/leetcode/easy/202_happy_number/django.py
680
3.546875
4
""" https://leetcode.com/problems/happy-number/ Runtime: 32 ms, faster than 66.18% of Python3 online submissions for Happy Number. Memory Usage: 12.7 MB, less than 100.00% of Python3 online submissions for Happy Number. """ class Solution: def __init__(self): self.numbers = [] def isHappy(self, n: int...
f98f5bf9e75576272321876f87a4474ef0b554d2
Wictor-dev/ifpi-ads-algoritmos2020
/iteração/22_boi_magro_e_gordo.py
1,087
3.921875
4
def main(): n = int(input('N: ')) print('### Boi 1 ###') n_iden = int(input('Digite o número de identificação')) nome = input('DIgite o nome do boi: ') peso = float(input('Digite o peso do boi: ')) n_iden_menor = n_iden nome_menor = nome peso_menor = peso count = 2 ...
a1c058ec923cd9351a6da054dfc25ce9a5eb8de8
jonhoward42/python101
/fundamentals/5.if_statements.py
540
4.40625
4
#!/usr/bin/env python variable = 15 ## Basic IF statement if variable < 10: # <- Note the ":" symbol print("Less than 10!") ## Else IF (elif) if variable > 16: # <- Greater than print("Greater that 16") elif variable < 10: # <- Less than print("Less than 10") elif variable == 15: # <- Equal to print("Number is 1...
055577212d1fa5abd936ea7979f595d528f357a1
Manju321/FinalCode
/9_Code.py
1,402
4
4
"""Using Python 3.6 Ans for 9th Program : Write a Selenium script that fills the form www.practiceselenium.com/practice-form.html and submits the page. After submitting , verify that the page navigates to home page """ import os from selenium import webdriver from selenium.webdriver.support.ui import Select...
80b065ffc31b3e5dbb3df1524457106449c51062
soundzues/Python-Practice
/arr_sum.py
378
3.921875
4
#sum array from functools import reduce #initialize arr: arr = [] #take number of input from user num = int(input("please enter the number of elements you want to enter: ")) #range #take inputs from the user for i in range(num): x = int(input()) arr.append(x) #test print all var i#print(*arr) #sum all array ele...
bb00be8e0a70b596b740a3399c26be1c2e74b5db
clovery410/mycode
/Algorithm2/coin_change_greedy.py
1,961
3.6875
4
optimal = {} def greedy_change(total, choice): if total == 0: return # import pdb # pdb.set_trace() if total / choice[0] > 0: print('%s ' % choice[0]) return greedy_change(total - choice[0], choice) elif total / choice[1] > 0: print('%s ' % choice[1]) return gr...
086f4e6cac6f8b99f6e309254f77024ae7404691
LTUC/amman-python-401d4
/class-16/code_review/binary-tree/binary_tree/binary_search_tree.py
1,096
4.0625
4
from binary_tree.binary_tree import BinaryTree, Node # See you at 11:11 class BinarySearchTree(BinaryTree): def add(self, value): if not self.root: self.root = Node(value) return def _traverse(node, value): # O(log n) # if no root, add to the root #...
272f85e353bc1fb0d8644dab4920dd9006f10893
lindo-zy/leetcode
/双指针/395.py
496
3.90625
4
#!/usr/bin/python3 # -*- coding:utf-8 -*- class Solution: def longestSubstring(self, s: str, k: int) -> int: if len(s) < k: return 0 for c in set(s): if s.count(c) < k: return max(self.longestSubstring(t, k) for t in s.split(c)) return len(s) if __...
bf4692216001d3a8f4f650dc22f909cd183e994c
superkuang1997/DataStructure-Python
/recursion/fractalTree.py
561
3.515625
4
import turtle def tree(branch_len): if branch_len > 25: t.forward(branch_len) t.right(45) tree(branch_len - 50) t.left(90) tree(branch_len - 50) t.right(67.5) tree(branch_len - 50) t.left(45) tree(branch_len - 50) t.right(...
971c2e9b5e124029bbdb8b539036694835bf628d
ketkarmayank/Algorithms
/segment.py
2,674
4.1875
4
"""Learning how to work with Segment Trees. Also learning how to work with Docstrings """ class Node(object): """This will act as Node element Args: start_idx(int): Suggests where the range starts end_idx(int): Suggests where the range ends value(int): Stores sum till this point ...
ebc1a2f78e19ffe82d1e6fe069ef1ee2e8e5b935
SouravDebnath09/AutomateBoringStuff_Pickki
/www.py
798
3.984375
4
#Hotel_Cost Function Start def hotel_cost(nights): return 140*nights #Hotel_Cost Function Ends #Plane_Ride_Cost Function Starts def plane_ride_cost(city): if city=="Charlotte": return 183 elif city=="Tampa": return 220 elif city=="Pittsburgh": return 222 elif city=="Los Angeles": return 475 #...
127988d509c3e89034416c123c2cd16d8d708fc1
sridivyapemmaka/PhythonTasks
/AllStringMethods1.py
711
4.28125
4
#capitalize() (converts the first charecter to upper case_ a="sridivya" b=a.capitalize() print(b) #case fold() (converts string into lower case) a="DIVYA" b=a.capitalize() print(b) #center() (returns center string) a="sridivya" b=a.center(12) print(b) #count() (return num of times specifie...
b9bb6ab35f6d5da6ef4cfcc669636cbe79b7cff0
Shad0wpf/python_study
/12_file.py
996
3.5625
4
#coding=utf-8 # 写通讯录 # f = open('D:\\Code\\Python\contact.txt','w') # f.write('姓名'+'\t性别'+'\t电话'+'\t\t地址'+'\n') flag = 'Y' # while flag.lower() == 'y' or flag == '': # name = input('请输入姓名:') # sex = input('请输入性别:') # phone = input('请输入电话号码:') # address = input('请输入联系地址:') # s = name + '\t' + s...
01f36d2467ddeedb37a999676eea3024deacdb17
klm127/rpio-cli-state-machine
/src/Game/GameObject.py
4,361
4.03125
4
""" A Game object. Holds x and y positions """ class GameObject: """ A game object holding position and size info. x,y are top left coordinates for variable size object :param x: the x coordinates on the game map :type x: int :param y: the y coordinates on the game map :type y: int :...
9fd41262847ca60446ef24771c3ab225ec66721f
bengori/python
/homeworks/les1/task4.py
768
4.28125
4
""" Пользователь вводит целое положительное число. Найдите самую большую цифру в числе. Для решения используйте цикл while и арифметические операции. """ while True: number = input('Введите целое положительное число (n):\n >>> ') if int(number) <= 0: print('Надо ввести целое положительное число!') ...
0902604ed9152a0e1092b54680a2ec0d0bf01788
int-invest/Lesson3
/DZ6.py
855
3.921875
4
'''Задача 6 ''' ord_a = ord('a') ord_z = ord('z') ord_sp = ord(' ') def int_func(var_1): for el in var_1: org_el = ord(el) if org_el > ord_z or org_el < ord_a: return '' return var_1.title() var_1 = input('Введите слово маленькими латинскими буквами\n') print(int_func(var_1)) '''З...
38c59fa0508f3d4e4d87a8a2a5d9bd3ac62b5b8a
taoddiao/introduction_to_algorithm
/quick_sort.py
335
3.5
4
def quick_sort(a, p, r): if p < r: q = partition(a, p, r) quick_sort(a, p, q - 1) quick_sort(a, q + 1, r) def partition(a, p, r): x = a[r] i = p for j in range(p, r): if x > a[j]: m = a[i] a[i] = a[j] a[j] = m i += 1 a[r] = a[i] a[i] = x return i a = [9,2,8,7,1,3,9] quick_sort(a, 0, len(a)...
06a949a6edb6465592ecc6a4f5679fe0ec2ba732
dadnotorc/orgrammar
/leetcode/双指针/0023_Merge_k_Sorted_Lists/Solution.py
1,224
3.78125
4
class Solution(object): def mergeKLists(self, lists): """ :type lists: List[ListNode] :rtype: ListNode """ if not lists: return None if len(lists) == 1: return lists[0] mid = len(lists) // 2 # 注意是 两条 / l1, l2 = self.mergeKList...
7103714dbac529832a8654b37370501ba2ab016d
xiaoniuv/python_demo
/45.py
2,069
3.84375
4
# def __setattr__(self,name,value): # self.__dict__[name] = value + 1 # def __setattr__(self,name,value): # super().__setattr__ = value + 1 # class C: # def __getattr__(self, name): # print(1) # def __getattribute__(self,name): # print(2) # def __setattr__(self, name, value): # ...
baf6958a8aef54fe3f94a73b42b0122bf93eab74
tuanderful/project-euler
/012.py
2,675
3.515625
4
# Highly divisible triangular number # Problem 12 # The sequence of triangle numbers is generated by adding the natural numbers. # So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first # ten terms would be: # 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... # Let us list the factors of the first sev...
cc61475f585ac8ba23fd3f0792435d6d3170c59d
cryogenic-dreams/PythonFunFolder
/Basic/vulcano.py
284
3.875
4
def vulcano(row): """ This program makes a vulcano with the rows you want. But, since row = 8, you will need a bigger screen to see the vulcano." """ n = 1 while n < 2 ** row: print (((2 ** row) / 2) - n) * " " + "**" * n n = n * 2
1101a765d36e0b21a0af05624782d8879b2892bf
nanareyes/CicloUno-Python
/Ciclo For/ejercicio2_for.py
250
3.671875
4
# 2. Leer 5 personas y pedir salario. Imprimir sumatoria de salario. suma_salario = 0 for i in range(5): salario = int(input("Ingrese el salario: ")) suma_salario = suma_salario + salario print("La suma de los salarios es: ", suma_salario)
d463b083ab5a6c82adc569af0c911ce937cf0863
Samk208/Udacity-Data-Analyst-Python
/Lesson_3_data_structures_loops/top_three.py
611
4.5
4
# Write a function, top_three, that takes a list as its argument, and returns a list of the three largest elements. # For example, top_three([2,3,5,6,8,4,2,1]) == [8, 6, 5] def top_three(input_list): """ :param input_list: list :return: Returns a list of the three largest elements input_list in order from ...
dc15a7bcfccd5bee2c09ffa611a4eef90b4be485
Souriish/Bubble-Sort-Using-Python
/arrays bubbleSort.py
321
4.25
4
def bubbleSort(arr): o=len(arr) for i in range (o-1): for j in range (0, o-i-1): if arr[j]<arr[j+1]: arr[j], arr[j+1]= arr[j+1], arr[j] arr=[9,1,2,7,5,8,6,4,0] bubbleSort(arr) print("Array in descending order:") for i in range (len(arr)): print (arr[i]) ...
230732936e0454d328fb11b227d11e652fdbc5ba
codevr7/samples
/LCM.py
363
3.8125
4
# LCM def lcm(n,m):# Defining a function for LCM and its inputs inp_1 = []# 2 empty lists inp_2 = [] if n < m: larger = m small = n else: larger = n small = m for i in range(1,11): val = larger*i val_1 = small*i inp_1.append(val_1) inp_...
1de71dd4a3ec7e117b84c6ad0f3d755e080a7057
sigurjono18/daemaverkefni2
/Lausn.py
1,448
4.125
4
#Exercise no. 44 in chapter 4 in the textbook. #You should output the result in a table, formatted in the following manner: #The first line contains the word "Upper case", right justified, 15 spaces wide, followed by the count of upper case characters, right justified, 5 spaces wide. #The second line contains the word ...
44d2eb543f7ae62e20666e84073d281ba812c3ca
jradd/pycookbook
/ch1/cookbook1_17.py
637
4.125
4
'1.7 Extracting a Subset of a dictionary' '''Problems You want to make a dictionary that is a subset of another dictionary. ''' prices = { 'ACME': 45.23, 'AAPL': 612.78, 'IBM': 205.55, 'HPQ': 37.20, 'FB': 10.75 } # Make a dictionary of all prices over 200 p1 = { key:value for key, value in prices.item...
d792bbac99a4649247ffb673779199ff06e3fddc
paweldrzal/python_codecademy
/flat_list.py
239
4.0625
4
#flattening a list n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]] def flatten(lists): results = [] for li in lists: for m in li: results.append(m) return results print flatten(n) #output [1, 2, 3, 4, 5, 6, 7, 8, 9]
2018cbe1902f22a10d56c2d1aca7989f497b8721
scidam/algos
/algorithms/intervieweing.io/minsumsubarr.py
473
3.5625
4
# Find subarray of a given size and having minimum sum of elements arr = [1,4,2,6,7,3,1,2,2,3] size = 3 def find_min(arr, size=size): ss = sum(arr[:size]) i = 0 j = size - 1 mem = (i, j) while j < len(arr) - 1: j += 1 i += 1 probe = ss - arr[i - 1] + arr[j] print(s...
caf4387424151c18fb3021f668e7af3b9939c259
muyisanshuiliang/python
/function/InheritDemo.py
2,414
4
4
from types import MethodType class People(object): def run(self): print("我是父类的方法") # 子类如果有该方法,则调用子类方法,没有则直接调用父类方法 class Student(People): def run(self): print("我是一个学生") class Worker(People): name = "张三" def eat(self): print("工人需要吃肉") def run_twice(people): people.run...
19fd3260b6d4cde4dfb65546177e8dfb895d2856
satishhirugadge/BOOTCAMP_DAY11-12
/Task3_Question3.py
493
4.28125
4
# 3. Write a program to get the sum and multiply of all the items in a given list. list=[1,2,3,4,5] # we have to perform the sum and multiple of this all number. def sum(): result=0 # here we stareted with 0 be cause e want to add it for i in list: result+=i print(result) sum() #Multiplicatio...
70a0950ce287f2523f20a5cad1f4e6006a53a669
manesioz/hill-cipher
/Hill Cipher - Encryption .py
1,317
4.0625
4
''' A simple implementation of a Hill Cipher, which is a polygraphic substitution cipher which uses linear algebra ''' import random import math import numpy as np #make encryption matrix X = np.random.randint(1, 26, size=(2, 2)) def det_checker(A): if ((np.linalg.det(A))%2 != 0) or ((np.linalg.det(A))%13 ...
9747a57f97b56bc04ecd6d117a555dcbdf1a758a
Mimoona/Python_Homework
/Lesson-7/Lesson7-HW.py
1,682
4.09375
4
# -*- coding: utf-8 -*- """ Created on Wed Jul 15 21:51:08 2020 @author: Mimoona Raheel """ print("Exercise 1:") print("~~~~~~~~~~~") number_1=input('Please enter a number:') number_2=input('Please enter another number:') if number_1 > number_2: print(f'{number_1} is bigger than {number_2}.') else: print(f'{numb...
94b14bf0d4015297a2162eb9be7e3671bc7b1147
UWPCE-PythonCert-ClassRepos/SP_Online_Course2_2018
/students/NatalieRodriguez/Lesson07/db/populate_db.py
5,541
3.703125
4
""" Learning persistence with Peewee and sqlite delete the database to start over (but running this program does not require it) """ from create_db import * from datetime import datetime, timedelta from dateutil.parser import parse import pprint import logging def date_converter(date): return dat...
8a21a85e4ee72b413fdc24a675f86d8a11ddd505
Dflorez015/Exercism_python
/scrabble-score/scrabble_score.py
439
3.765625
4
def score(word): scrabble_pieces = { "A" : 1, "E" : 1, "I" : 1, "O" : 1, "U" : 1, "L" : 1, "N" : 1, "R" : 1, "S" : 1, "T" : 1, "D" : 2, "G" : 2, "B" : 3, "C" : 3, "M" : 3, "P" : 3, "F" : 4, "H" : 4, "V" : 4, "W" : 4, "Y" : 4, "K" : 5, "J" : 8, "X" : 8, "Q" : 10, "Z" :...
df70b561030cc040a74a351956be3c3b0f4689b8
baidongbin/python
/疯狂Python讲义/codes/06/6.1/self_in_constructor.py
415
3.78125
4
class InConstructor: def __init__(self): # 在构造方法中定义一个foo变量(局部变量) foo = 0 # 使用self代表该构造方法正在初始化的对象 # 下面代码将会把该构造方法正在初始化的对象的foo实例变量设置为6 self.foo = 6 # 所有使用InConstructor创建的对象的foo实例变量将设为6 print(InConstructor().foo)
51303b6674613fcdc68d3123359a71542fdca5e7
frankie9793/Algorithms-and-Data-Structures
/Sorting/insertionSort.py
243
4.03125
4
# Time O(N^2) | Space O(1) def insertionSort(array): for i in range(len(array)): j = i while j > 0 and array[j] < array[j - 1]: array[j], array[j - 1] = array[j - 1], array[j] j -= 1 return array
4811396f8ea43bf4f4092d646726e8aabdd202c3
wldolan/CS590-python
/table_dict_count_search.py
1,224
3.78125
4
import os, sys, csv filename = sys.argv[1] #counting lines of file# def count_lines(filename): num_lines=0 with open(filename) as file: for line in file: lines = line.split() num_lines += 1 print ('this file contains {} lines'.format(num_lines)) #creating a dictionary...
025cd6969efcd12658001b31240b9b670e5afcfa
nicholasippedico/Python-Coding
/Filemanager.py
2,838
3.5
4
# -*- coding: utf-8 -*- """ @author: Nicholas Ippedico, Nick Braga, Alec Mitchell """ import csv, DatabaseManager class FileManager: def __init__(self, dbm): self.data={} self.dbm = dbm #loads the csv file def load_csv(self, fn): with open(fn) as csv_file: ...
1643394266dfed7b75403d6ebca07ef60d6cf6b2
brianhuynh2021/Python_fundamentals
/cat_amount.py
158
3.84375
4
def getCatAmount(): numCats = input('How many cats do you have?') if int(numCats) < 6: print('You should get more cats.') cat = getCatAmount()
139221d3ae34bdf563605b5d8fcb330f6164f146
Darlley/Python
/LIVRO_CursoIntensivoPython/Capitulo_3/ex06.py
1,228
3.75
4
#3.6 – Mais convidados: Você acabou de encontrar uma mesa de jantar maior, #portanto agora tem mais espaço disponível. Pense em mais três convidados para o #jantar. #• Comece com seu programa do Exercício 3.4 ou do Exercício 3.5. Acrescente #uma instrução print no final de seu programa informando às pessoas que você #e...
26d07c998e39a0ba695510ff2c4b6d70285b68dc
callaunchpad/MOR
/environments/robot_arm/maddux/robots/link.py
5,545
3.734375
4
""" A Link object holds all information related to a robot link such as the DH parameters and position in relation to the world. """ import numpy as np from ..plot import plot_sphere import math class Link: def __init__(self, theta, offset, length, twist, q_lim=None, max_velocity=30.0, link_size...
dbe1111d8ebe75f659f08be974cab4af2a56b12b
SBNC-Bavlab/ML-Algorithms-Visualization-and-Positioning
/Bokeh/Decision_Tree/ID3_Decision_Tree/bucheim.py
6,437
3.6875
4
##################################################################################################### # Implementation of "Drawing rooted trees in linear time(Buchheim, Jünger and Leipert, 2006)"# # constant for distance between two nodes distance = 5 def tree_layout(node): """ main function """ first_walk(n...
fefa5bb0cdb9a427b18496e81f36ea0e6c33d400
AymanNasser/Python-For-Everybody-Specilization
/Access Web Data/Week2/Regular expression.py
285
3.609375
4
import re fh = open('../../romeo.txt','r') accum = 0 # Program that extract all digits from text & convert extracted string(digits) to ints for line in fh: line = line.strip() tempList = re.findall('[0-9]+',line) accum = accum + sum(list(map(int,tempList))) print(accum)
a279da51992f3d15ba5dbe460d3c6a998eb56a9e
atrivedi8988/DSA-Must-Do-Questions
/01_Fizz Buzz/Ideal Solutions/fizzBuzz.py
461
4.09375
4
# Print "Fizz" for multiple of 3 and print "Buzz" for multiple of 5 def fizzBuzz(N): for value in range(1, N + 1): # For multiple of 3 ----> Print "Fizz" if value % 3 == 0: print("Fizz") continue # For multiple of 5 ----> Print "Buzz" if value % 5 == 0: ...
4be4628954923ac3d05337c9f86d5f63fe073063
pianowow/various
/giftedmathematics.com/sum to 24/thread test.py
1,246
3.765625
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: CHRISTOPHER_IRWIN # # Created: 14/01/2013 # Copyright: (c) CHRISTOPHER_IRWIN 2013 # Licence: <your licence> #------------------------------------------------------------...
953dc20852482cdf7931de39b5e559546b1e9945
macraiu/software_training
/leetcode/py/33_Search_in_Rotated_Sorted_Array.py
1,040
4.09375
4
""" You are given an integer array nums sorted in ascending order (with distinct values), and an integer target. Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). If target is found in the array return its index, otherwise, return -1. Examp...
3edc40d6c15b4caf0758b2afff0141e86b7066e9
chan032/PS
/1629.py
436
3.828125
4
''' 모듈러 성질 : (a * b) mod c = (a mod c * b mod c) mod c ''' a, b, c = map(int, input().split()) def pow(base, exponent): if exponent == 1: return base else: half = exponent // 2 halfPow = pow(base, half) if exponent % 2 == 0: # even return (halfPow % c) * (halfPow...
841ed16f5853175da956b8bfb6606aefa35d1f02
gyoscha/PythonPY100
/Занятие2/Лабораторные_задания/task2_4/main.py
507
3.9375
4
if __name__ == "__main__": # постарайтесь не использовать "магические" числа, # а по возможности дать переменным осмысленные названия и использовать их lesenka = 'Hello,world' for index, value in enumerate(lesenka, start=5): index = ' ' * index # пробел умножаю на индекс: 5, 6 и тд pr...
8237a49c13453a7af06bef2f77632abccc54fe8a
tanni-Islam/test
/module.py
104
3.515625
4
import re item = [] for i in dir(re): if "find" in i: item.append(i) print sorted(item)
4f4c09e361c707b01307fdd6ebe9aafe545819f1
iatecookies/LearnPython
/studenttest.py
1,792
3.71875
4
""" Chapter 11 Grading Students Practicing sets """ file1 = open("studenttests.txt") file2 = open("studentpassedtests.txt") studenttests = file1.read().splitlines() studentpassedtests = file2.read().splitlines() list2 = [] for (i, j) in zip( studenttests, studentpassedtests): studenttests = i.split(":") stud...
25237e1aac4fa404aa529a189641d0e864683c30
peterocean/python_tutorial
/list_as_queue.py
298
3.78125
4
#!/usr/bin python3 #-*- coding:utf-8 -*- from collections import deque fruits = ['orange', 'apple', 'pear', 'banana', 'apple', 'banan'] queue = deque(["Eric", "John", "Michael"]) print(queue); queue.append("Terry") print(queue) queue.append("Graham") print(queue) queue.popleft() print(queue)
088e70c0dba72155cda10de965a7671bea8fb2f7
luiz-vinicius/URI-Online-Judge
/problems/1017.py
71
3.78125
4
x = int(input()) y = int(input()) r = "%.3f" % ((y / 12) * x) print(r)
12bf93f8741ae96055c8f077d8df991b8564527a
FerFabbiano/Algoritmos-I
/Clase 12-04.py
1,541
4.34375
4
"""Si lo que voy a agregar es un elemento suelto, uso append, si lo que le voy a agregar es otra lista, uso extend.""" """Ejemplo: l1 representa p(x)=3+x-2x^2+5x^3. l2 representa p(x)=2+0x+x^2+x^3. Hacer una funcion que le paso p1 y p2, y devuelve la suma.""" def sumarpolinomios(lista1, lista2): indice...
9de40b0e719ab2c8f27287c49c3114dc74bfc4bd
Prathmesh311/Data-Structures-and-Algorithms-Specialization
/Algorithmic Toolbox/Algorithmic Warm Up/Fibonacci Number/fibonacci_number.py
550
4.125
4
# python3 def fibonacci_number_naive(n): assert 0 <= n <= 45 if n <= 1: return n return fibonacci_number_naive(n - 1) + fibonacci_number_naive(n - 2) def fibonacci_number(n): assert 0 <= n <= 45 if n == 0: return 0 if n == 1: return 1 numbers = [] numbers.a...
63fcaa6ede97a0b9b213650cd940a30eae406f60
ian-james-johnson/time_series_exercises
/acquire.py
4,354
3.75
4
# Time Series: Data Acquisition Exercises #Function for Exercise #1 #------------------------ # 1. Using the code from the lesson as a guide # and the REST API from https://python.zgulde.net/api/v1/items as we did in the lesson, # #create a dataframe named items that has all of the data for items. #This function acq...
8e4623bc5e69701b66c330484e36750f65df8ef0
mosel123/codePython
/elementosBasicos/operaciones.py
462
3.796875
4
import os numero1 = 10 numero2 = 10 resultado = numero1 + numero2 print("El resultado de la suma es: ",resultado) numero1 = 10 numero2 = 10 resultado = numero1 - numero2 print("El resultado de la resta es: ",resultado) numero1 = 10 numero2 = 10 resultado = numero1 * numero2 print("El resultado de la multipliacion es:...
b0b35fd1726c5bfca3fd8e357e894b0f59893220
trollius/work
/load_csv_sql.py
859
3.671875
4
import csv import sqlite3 # Create the database connection = sqlite3.connect('test.db') connection.text_factory = str cursor = connection.cursor() # Create the table cursor.execute('DROP TABLE IF EXISTS prices') cursor.execute('CREATE TABLE prices ( myid integer, parent_id integer, hlevel integer, name text, descrip...
284a4e14c64c73fe81874d8e57eae4b55eca1c95
keviv202/Python-Code
/intersection_part2.py
231
3.796875
4
class find: def find(self,i,j): n = [] for i1 in i: if i1 in j: n.append(i1) print(n) j=[2, 2] i=[1,2, 2,1] f = find() if len(j)>len(i): f.find(i,j) else: f.find(j,i)