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
b20e6a3e61c832ca4dfecdd2bb5506083c7f24fa
adkhune/aditya-codes
/pythonscripts/recursion/factorial1.py
291
3.75
4
import pandas import timeit def main(): print("find of a factorial of n: n!") n = 6 timeit print("fctorial of {} is {}".format(n,factorial(n))) def factorial(n): if n == 1 or n == 0: return 1 return n * factorial(n-1) if __name__=="__main__": main()
f3cfe542f2d63141c0e0f6e0360d372899ce344b
adkhune/aditya-codes
/pythonscripts/dictionaries/sorting.py
577
3.78125
4
import operator def main(): print('Let us see how to sort in dictionaries') dict1 = {'aa':1, 'pp':4, 'cc':2, 'tt':3} print('this is our dict1=', dict1) sorted_dict1 = sorted(dict1.items(), key=operator.itemgetter(1)) print('after sorting it acc to values=',sorted_dict1) sorted_dict2 = sorted(di...
bd541d380c68c3ed9a5efbbec118b69d9a35feca
adkhune/aditya-codes
/pythonscripts/insertionsort.py
394
4.09375
4
def main(): list = [2,5,0,6,7] print("sorted numbers=",insertionSort(list)) def insertionSort(numbers): for i in range(0,len(numbers)): current = numbers[i] j = i-1 while numbers[j] > current and j>=0: numbers[j+1] = numbers[j] j=j-1 numbe...
80077e9e5324d70914a79967097e0f58e1161b72
evespiration/Webscraping-Udemy
/WebScrapingA.py
6,989
3.578125
4
import time # to use sleep function to allow website to load from selenium import webdriver # to connect to a browser and access an URL from bs4 import BeautifulSoup # to remove HTML tags from HTML content from selenium.webdriver.common.keys import Keys # so I can press the Enter Key in the search fields import pan...
dfb2a28ed745af251dc85d8d24f8e8006cf897ff
amani021/100DaysOfPython
/Day_6.py
1,584
4.09375
4
# -------- DAY 6 "FizzBuzz" -------- # Goal: Check an input if it is divisible by (3 and 5) or (3 or 5) or none of them. from tkinter import * root = Tk() root.title('100 Days Of Python - Day 6') root.configure(background='#B3E5FC') # --------------- CREATE A FRAME --------------- frame = LabelFrame(root, text=' Fiz...
50384540ecb37dca4f55a9ef395a8e480296176a
amani021/100DaysOfPython
/Day_2.py
334
3.984375
4
# -------- DAY 2 "Basic Info" -------- # Goal: Learn more about the day 1's goal. print('Welcome to iPython Supermarket') bill = float(input('How much is your bill? ... ')) tax = bill*(15/100) print(f'TAX is 15%\nBill is {bill}') print(f'~~~~~~~~~~~~\nThe total including the TAX is {bill+tax}$') print('THANK YOU, SEE Y...
2e0d0c56a3dbd4baf528ec145887b3dd355d8196
mon0theist/Automate-The-Boring-Stuff
/Chapter 12/update_produce.py
924
3.578125
4
#! /usr/bin/python # # ATBS Chapter 12 - Updating a Spreadsheet # produceSales.xlsx # # Update the following prices: # Celery - 1.19 # Garlic - 3.07 # Lemon - 1.27 import openpyxl wb = openpyxl.load_workbook('produceSales.xlsx') sheet = wb.get_sheet_by_name('Sheet') # The produce types and their updated prices # If ...
936db64e955730755cc244be94cf280e25051ef2
mon0theist/Automate-The-Boring-Stuff
/Chapter 04/characterPictureGrid1.py
2,631
3.796875
4
# Character Picture Grid # # Say you have a list of lists where each value in the inner lists is a one-character string, like this: # # # grid = [['.', '.', '.', '.', '.', '.'], # ['.', 'O', 'O', '.', '.', '.'], # ['O', 'O', 'O', 'O', '.', '.'], # ['O', 'O', 'O', 'O', 'O', '.'], # ...
981c2e7984813e752f26a37f85ca2bec74470b40
mon0theist/Automate-The-Boring-Stuff
/Chapter 04/commaCode2.py
1,183
4.375
4
# Ch 4 Practice Project - Comma Code # second attempt # # Say you have a list value like this: # spam = ['apples', 'bananas', 'tofu', 'cats'] # # Write a function that takes a list value as an argument and returns a string # with all the items separated by a comma and a space, with and inserted before # the last item. ...
e8e5b4e8b4fde7a877ee26d8a064985293531427
mon0theist/Automate-The-Boring-Stuff
/Chapter 05/fantasyGameInventory_l2d2.py
1,119
3.796875
4
# ATBS Chatper 5 Practice Project - Fantasy Game Inventory List to Dictionary # 2nd attempt for revision/review # No looking at past solutions! # # Some of the code is already given in the problem, just need to fill it in # Display Inventory function from previous exercise def displayInventory(inventory): print("I...
3c2f7e0a16640fdb7e72795f10824fcce5370199
mon0theist/Automate-The-Boring-Stuff
/Chapter 07/strongPassword.py
1,249
4.375
4
#! /usr/bin/python3 # ATBS Chapter 7 Practice Project # Strong Password Detection # Write a function that uses regular expressions to make sure the password # string it is passed is strong. # A strong password has: # at least 8 chars - .{8,} # both uppercase and lowercase chars - [a-zA-Z] # test that BOTH exist, no...
c3450d7b24260189e3599c6e79f11d00e7636b60
mon0theist/Automate-The-Boring-Stuff
/Chapter 10/debugging_coin_toss.py
1,773
4.09375
4
#!/usr/bin/python # ATBS Chapter 10 # The following program is meant to be a simple coin toss guessing game. The # player gets two guesses (it’s an easy game). However, the program has several # bugs in it. Run through the program a few times to find the bugs that keep the # program from working correctly. # I didn't...
9705306602423b9133baac671d04659de2336df9
aaron22/ProjectEuler
/src/Problem3.py
498
3.9375
4
''' Created on Apr 6, 2011 @author: aaron ''' def solve(): ''' The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? ''' num = 600851475143 # take care of 2; it's a special case while (num % 2 == 0): num /= 2 for...
bda60753962f59bf11041338b0dfca3b0242d079
dnlsyfq/py_centos
/pay_analysis.py
524
3.5
4
from csv import DictReader employee_info = [] with open("employees.csv", newline="") as f: reader = DictReader(f) for row in reader: row["age"] = int(row["age"]) row["salary"] = float(row["salary"]) employee_info.append(row) # Example dictionary in employee_info # { # "id": "10", #...
7df5fbc8f66813f75584f8410da004809e37fcf9
whobbes/l_systems
/solution/l_systems_solution.py
2,948
3.96875
4
import turtle import random as rd class L_systemDrawer(): '''Provide ways to build a L-system and draw it with a turtle''' def __init__(self, instructions='F-G-G', iterations=5, distance=10, angle=120): self.t = turtle.Turtle() self.wn = turtle.Screen() self.instructions = instructions...
e444ca6c4052246efa10b95d11c61ee32ad8f33f
RiyaSingh15/data-structure
/array/maximum_sum(i x arr[i]).py
829
3.65625
4
# Find maximum value of Sum( i*arr[i]) with only rotations on given array allowed class sum_maximum: def __init__(self): self.array_input() def array_input(self): length = int(input("Enter the number of elements: ")) input_array = [] for i in range(0, length): input...
589a0295445328ed89c44450ae9ff3066bd7c159
RiyaSingh15/data-structure
/array/rearrange_positive_negative_alternatively.py
1,451
4.09375
4
# Rearrange array in alternating positive & negative items class rearrange_positive_negative_alternatively: def __init__(self): self.array_input() def array_input(self): length = int(input("Enter number of elements in the array: ")) input_array = [] for i in range(length): ...
b3d152ca85b7cf29fa67753bcf587cad14a9911b
iguyking/adventofcode
/2020/day4/others/aoc2040.py
1,792
3.59375
4
import re #check ranges if they apply to a field #expect the ruleset in either one of these two formats: # cm:150-193,in:59-76 # 1920-2002 def check_ranges(ranges,data): if ":" in ranges: #determine range to use if there are multiple units ranges=dict([x.split(":") for x in ranges.split(",")])[re.searc...
6250b682331f1f64e54494d173e54aa53780a21a
ZYSLLZYSLL/Python
/代码/code/day14/Demo02_time.py
1,209
3.59375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/19 15:01 # @Author : ZY # @File : Demo02_time.py # @Project : code import time # 时间戳 a = time.time() print(a) # 结构化时间 东八区时间(北京时间) c = time.localtime() print(c) # UTC时间,国际时间,和北京时间差八个小时 d = time.gmtime() print(d) # 格式化时间 结构转格式 print(time.strftime('%Y-%m-...
d19ad2bd766829f6cd179101b3615d8ede6425a7
ZYSLLZYSLL/Python
/代码/code/eg/一行代码计算1到100的和.py
265
3.5
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/27 9:05 # @Author : ZY # @File : 一行代码计算1到100的和.py # @Project : code print(sum([i for i in range(1, 101)])) print((lambda i: sum(i))(i for i in range(1, 101))) print(sum(range(1, 101)))
f950540f7fd7e20c033f7b562a41156f5c43a1f2
ZYSLLZYSLL/Python
/代码/code/day06/Demo07_列表常用操作_修改_复制.py
1,104
4.1875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/11 15:35 # @Author : ZY # @File : Demo07_列表常用操作_修改_复制.py # @Project : code # 修改指定位置的数据 # a = [1, [1, 2, 3], 1.23, 'abc'] # a[1] = '周宇' # print(a) # 逆置:reverse() # a = [1, [1, 2, 3], 1.23, 'abc'] # a.reverse() # print(a) # # print(a[::-1]) # 排序 sort() 默认升序 #...
88e3452998a093ef0737ee0aed0c8c41861411dc
ZYSLLZYSLL/Python
/代码/code/eg/Demo12_.py
4,627
3.640625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/13 14:45 # @Author : ZY # @File : Demo12_.py # @Project : code """ 需求:进入系统显示系统功能页面,功能如下: 添加学员 删除学员 修改学员信息 查询学员信息 显示所有学员信息 退出系统 系统共6个功能,用户根据自己需求选取。 步骤分析 1.显示功能界面 2.用户输入功能序号 3.根据用户输入的功...
73eb8edd0464520f902279c952bc1949343722c7
ZYSLLZYSLL/Python
/代码/code/day18/111.py
238
3.734375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/29 13:19 # @Author : ZY # @File : 111.py # @Project : code s = '*' for i in range(1, 8, 2): print((s * i).center(7)) for i in range(5, 0, -2): print((s * i).center(7))
e6d51bc9001f005cd5e3868d990f300f720ac019
ZYSLLZYSLL/Python
/代码/code/day06/Demo02_列表.py
504
3.9375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/11 10:23 # @Author : ZY # @File : Demo02_列表.py # @Project : code """ 列表(list,数组):以中括号为边界,以逗号隔开的数据(各种类型) 特点: 1,有序的 2,可变的 3,支持索引 4,支持切片 """ a = [1, True, None, [1, 2, 3], 'abc', (1, 2, 3), {'a': 1}, {1, 2, 3}, 1.23] for ...
e742395c74a60bfbf6bb75fe3fbb72ae989c573b
ZYSLLZYSLL/Python
/代码/code/eg/Demo03_质数之和.py
863
3.625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/11 19:02 # @Author : ZY # @File : Demo03_质数之和.py # @Project : code # 质数之和 质数 只能被自己和1整除的数叫质数 ts:2 3 5 7 11 13 17 # for a = 0 b = 0 for i in range(2, 101): for j in range(2, i): if i % j == 0: a = 1 if a == 0: b += i ...
a9b80c05ba415f16cb1c0e92baec6cca38860dc2
ZYSLLZYSLL/Python
/代码/code/eg/Demo06_判断三角形.py
1,157
3.96875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/11 19:23 # @Author : ZY # @File : Demo06_判断三角形.py # @Project : code # 需求:根据边判断三角形,直角,锐角,钝角 # a = int(input('请输入三角形的第一条边:')) # b = int(input('请输入三角形的第二条边:')) # c = int(input('请输入三角形的第三条边:')) # # if c < a: # a,c = c,a # if c < b: # a,b = b,a # if b < a:...
6dd3477022671fa8652ca9626a92b55496543767
ZYSLLZYSLL/Python
/代码/code/day08/Demo07_文件操作_读_写.py
1,939
3.78125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/13 15:25 # @Author : ZY # @File : Demo07_文件操作_读_写.py # @Project : code """ 写入文件 """ # encoding 可以把文件类型变成utf-8 # a = open("a.txt", "w", encoding="utf_8") # 打开文件设置权限 # a.write('hello world\n') # 默认不会换行 写入文件内容 # a.write('hello world\n') # a.write('hello ...
33b4d7d80b3701c9593c590d65a327ff69a002a4
ZYSLLZYSLL/Python
/代码/hei_ma/Demo07_while...else.py
601
3.84375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/8 19:48 # @Author : ZY # @File : Demo07_while...else.py # @Project : code # i = 0 # while i < 5: # i += 1 # print("hello world") # else: # print("输出五次了") # while不正常结束时,else里的内容不执行 i = 0 while i < 5: i += 1 if i == 3: break pr...
8c0310c63b76fb2d8bdc439201e66a22273f4077
ZYSLLZYSLL/Python
/代码/hei_ma/Demo05_while应用.py
473
3.671875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/7 16:41 # @Author : ZY # @File : Demo05_while应用.py # @Project : code # 需求:1-100 累加和 i = 0 count = 1 while count <= 100: i += count count += 1 print(i) # 1-100里偶数的累加和,即2+4+6+8……, i = 0 count = 1 while count <= 100: if count % 2 == 0: i...
c0a45d0c65e6eb7b403a299b0cf6086e13bab296
ZYSLLZYSLL/Python
/代码/code/day11/Demo06_类属性和类方法.py
871
4.09375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/16 16:02 # @Author : ZY # @File : Demo06_类属性和类方法.py # @Project : code """ 类属性 """ # class A(): # # 类属性 # name = 'A' # # # 成员属性 # def __init__(self): # self.age = 23 # # def printInfo(self): # print(A.name) # # # a = A() # p...
9817da4716a09b2aef31e84d4db409d06f03a02d
ZYSLLZYSLL/Python
/代码/code/day10/Demo06_搬家具.py
1,109
3.9375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/15 17:37 # @Author : ZY # @File : Demo06_搬家具.py # @Project : code # 房子类 class House(): def __init__(self, addr, area): self.addr = addr self.area = area self.free = self.area self.funcList = [] def __str__(self): ...
19803babdb60c45644620079e296c27bdc014815
petcsclub/python-projects
/battleship/battleship_single.py
14,232
3.796875
4
# imports from random import randint, choice from operator import add, mul from time import sleep def setPlayerShips(shipNames, shipLength, playerShipAliveCoords, playerGrid, directionMap): '''Get and set the ship placements of the player''' print('Set the position of your ships!') printGrid(playerGrid, ...
d2dc37941832c97787f4dd0ecc7c2fe9574f6988
petcsclub/python-projects
/battleship/battleship_multi.py
12,724
3.921875
4
# imports from random import randint, choice from operator import add, mul from time import sleep import os def setPlayerShips(shipNames, shipLength, playerShipAliveCoords, playerGrid, playerNumber, directionMap): '''Get and set the ship placements of the player''' # Get player name print("Hello Player "...
cf1e3aa630ec34233b352168bd4b0818565883cb
sofianguy/skills-dictionaries
/test-find-common-items.py
1,040
4.5
4
def find_common_items(list1, list2): """Produce the set of common items in two lists. Given two lists, return a list of the common items shared between the lists. IMPORTANT: you may not not 'if ___ in ___' or the method 'index'. For example: >>> sorted(find_common_items([1, 2, 3, 4], [1,...
ea326d20c18ed1933aa011c844859f5292e9e636
KlubInformatycznyLearnIT/Programistyczne-Puzzle
/Python/stoLat.py
752
4.09375
4
def stoLat(): wiek = int(input("Podaj swój wiek: ")) rokKiedy100Lat = (2018-wiek)+100 kiedy100Lat = rokKiedy100Lat-2018 print("Lat potrzebnych do osiągnięcia wieku 100 lat: {}".format(kiedy100Lat)) print("Rok osiągnięcia wieku 100 lat: {}".format(rokKiedy100Lat)) stoLat() def stoLatUzytko...
33ed3a85ac7ec37e390aab5d7f4a7330facf6d29
KlubInformatycznyLearnIT/Programistyczne-Puzzle
/Python/odwrocone_zdanie.py
603
3.84375
4
# metoda nr1 def odwrocZdanie1(x): y = x.split() result = [] for word in y: result.insert(0, word) return " ".join(result) # metoda nr2 def odwrocZdanie2(x): y = x.split() return " ".join(y[::-1]) # metoda nr3 def odwrocZdanie3(x): y = x.split() return " ".j...
c2dd84d87e72965c1b301061093ec5a5b3759b0a
kevinmu/xwgen
/square.py
1,898
3.5625
4
"""Class representing the a single square in the crossword grid.""" from dataclasses import dataclass from typing import Optional @dataclass class Square: is_black: bool = False letter: Optional[str] = None index: Optional[int] = None starts_down_word: bool = False starts_across_word: bool = False...
974719c9fd09762406b5eb26d07582ec10256f12
jrm2k6/pytanque
/src/models/Game.py
1,577
3.578125
4
import math class Score(object): def __init__(self, nb_teams_playing, winning_score=13): self.winning_score = winning_score self.nb_teams_playing = nb_teams_playing self.scores = [0] * nb_teams_playing def __str__(self): return 'Scores : [ ' + ','.join(str(x) for x in s...
a47d242c90902ccb969ca515885dd8f229d0261f
charliecheng/LeetCodeOJ
/MedianofTwoSortedArrays.py
1,379
3.53125
4
class Solution: # @return a float ''' It is said that it is better not to use recursion in python. By default Only 1000 times recursion is allowed sys.setrecursionlimit(10000) ''' def findMedianSortedArrays(self, A, B): m=len(A) n=len(B) if (m+n)%2==1: ret...
f3ffd8b106b118377428818d3fade0a24aa0fdb7
Vibhu1024/Python-tkinter
/messegeme.py
850
3.6875
4
import tkinter import tkinter.messagebox root = tkinter.Tk() def display_and_print(): tkinter.messagebox.showinfo("Info","Just so you know") tkinter.messagebox.showwarning("Warning","Better be careful") tkinter.messagebox.showerror("Error","Something went wrong") okcancel = tkinter.messageb...
f203168252fea12f76058bbe861c6ccf1c718672
zhaokang555/Developer
/Python3/201508/11-__getattr__And__call__-Creative.py
614
3.671875
4
class Chain(object): def __init__(self, path = ''): self._path = path def __getattr__(self, path): # 返回的是一个对象,而不是一个方法!!!! return Chain('%s/%s' % (self._path, path)) def __call__(self, path = ''): return Chain('%s/%s' % (self._path, path)) def __str__(self): return self._path __repr__ = __str__ def main...
07afcb0856341565e6b894945ff7a63d8aa58634
Gogulaanand/100DaysOfCode
/LeetCode problems/Four-Divisors.py
766
3.71875
4
# Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. # If there is no such integer in the array, return 0. # Example 1: # Input: nums = [21,4,7] # Output: 32 # Explanation: # 21 has 4 divisors: 1, 3, 7, 21 # 4 has 3 divisors: 1, 2, 4 # 7 has 2 di...
ec4172cb48ea9126cbc746455b807f6b9ee29106
Gogulaanand/100DaysOfCode
/LeetCode problems/leafSimilarTrees.py
521
3.625
4
# Leaf-Similar Trees # https://leetcode.com/problems/leaf-similar-trees/ #Sol 1: DFS class Solution: def leafSimilar(self, root1: TreeNode, root2: TreeNode) -> bool: def dfs(node: TreeNode, l: List) -> bool: if node is None: return if node.left is None and node.rig...
8350e4ff2c7442c4c2b685ece638b1e30a5756b2
Capping-CPCA/Surveys
/test2.py
710
3.53125
4
import csv #connects to the web server on a port #conn = cpcapep.connect(connection,port here) #Allows Python code to execute PostgreSQL command in a database session. #cursor = conn.cursor() csvfile = open("r2.csv","rb") #Loop that goes through each row and creates an insert statement reader = csv.reader(csvfile) for...
5efe6e27964e98c49ae15c3f572152a6efba648b
vtombou/python_par_la_pratique_101_exercices_corriges
/exercices/debutant/exercice020.py
346
3.78125
4
"""Récuperer des éléments communs à deux listes """ liste_01 = [1, 5, 6, 7, 9, 10, 11] liste_02 = [2, 3, 5, 7, 8, 10, 12] liste_commun = [i for i in liste_01 if i in liste_02] print(liste_commun) #Solution Formateur sliste_01 = set(liste_01) sliste_02 = set(liste_02) intersect = sliste_01.intersection(sliste_02) ...
d267475569338b2eb07a3c11b873f336af0bafbc
vtombou/python_par_la_pratique_101_exercices_corriges
/exercices/debutant/exercice009.py
181
3.5625
4
"""Ordonner une chiane de caractère """ chaine = "Pierre, Julien, Anne, Marie, Lucien" chaine = chaine.split(", ") chaine = sorted(chaine) chaine = ", ".join(chaine) print(chaine)
3035c5c5578e0d60d57be62f9a5767c074d57973
vtombou/python_par_la_pratique_101_exercices_corriges
/exercices/avancer/exercice089.py
403
3.65625
4
def recuperer_item(liste, indice): if abs(indice)>=0 and abs(indice)<len(liste): return liste[indice] elif indice < 0 and abs(indice) == len(liste): return liste[indice] else : return "Index {i} hors de la liste".format(i=indice) liste = ["Julien", "Marie", "Pierre"] print(recupere...
7e7a96a194384485ae8273f118e65dc898e832de
vtombou/python_par_la_pratique_101_exercices_corriges
/exercices/debutant/exercice038.py
371
3.515625
4
a = 4 b = 6 c = 2 ens = {a,b,c} min_1 = min(ens) ens.discard(min_1) min_2 = min(ens) ens.discard(min_2) min_3 = min(ens) print("Les nombres dans l'ordre sont {}, {} et {}".format(min_1, min_2, min_3)) #Solution Formateur, very nice a1 = min(a, b, c) a3 = max(a, b, c) a2 = (a + b + c) - a1 - a3 print("Les nombres ...
c8c423d8d764a4b66645cb5000aa3e9c92381ae1
caiocanic/MIT-OCW-6.000
/6.0001/Hangman/hangman.py
11,854
4.15625
4
# Hangman Game # ----------------------------------- import random import string def load_words(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending on the size of the word list, this function may take a while to finish. """ print("Loading word list from ...
bb080ba26c9453f545c0d4fad561e1c15673be7f
sieradzkidamian/pythonSubapps
/menuModules/numberChecker.py
1,157
3.8125
4
def checkNumbers(): numbers = [] userNumber = 'x' sumOfNumbers = { 'lessThan': 0, 'biggerThan': 0, 'equalTo': 0 } print('Wpisz liczby do porówniania, jeśli chcesz zakończyć wpisywanie użyj klawisza enter') while(userNumber != ''): userNumber = input('Podaj liczbę...
80def11f9a59bf9eb55afb739c2e2176c0e0448e
marianaamaralarruda/MAC110
/Aulas/Aula 13.03.py
1,363
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Mar 13 08:31:25 2018 @author: mariana.frasson Problema Dado um inteiro positivo n, imprimir os n primeiros naturais ímpares. Exemplo: para n = 4, o programa deve exibir 1 3 5 7. """ def main(): n = int(input("Digite n: ")) impar = 1 while...
7f5565fb5c2c4b451c72e2b8bfc781439002c8c4
marianaamaralarruda/MAC110
/Aulas/Aula 03.04.py
2,585
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Apr 3 08:01:33 2018 @author: mariana.frasson """ """ Dados n pontos (x,y) para cada ponto, determinar se (x,y) pertence a região H. """ def main1(): n = int(input("Digite n:")) count = 0 while count < n: x = float(input("Digite ...
956b1da44ab5987ca8c4c82b78067f75861a9eb4
alee1412/projects
/python-challenge/PyBank/main.py
2,398
3.875
4
import os import csv filepath = os.path.join("budget_data_1.csv") #Total Months with open(filepath, newline="") as csvfile: csvreader = csv.reader(csvfile, delimiter=",") print("Financial Analysis") print("**************************************") total_months = [] for row in csvreader: ...
cc90a2abad5545744475f0f0066dce42e9ac32ad
pabhd3/Coding-Challenges
/adventofcode/2015/13 - Knights of the Dinner Table/arrange.py
1,857
3.59375
4
from itertools import permutations from json import dumps def findHappyness(people): print("People:", people) total = len(list(permutations(people, len(people)))) count = 0 # Loop through seating combinations best = {"arrangement": None, "happyness": 0} for combo in permutations(people, len(pe...
8875ce74923a7f3f2aa47a4de4bbc6caa1e80fc2
pabhd3/Coding-Challenges
/adventofcode/2015/05 - Doesn't He Have Intern-Elves For This/niceList.py
1,909
3.59375
4
if __name__ == "__main__": # Get data from flatfile with open("input.txt", "r") as r: data = r.read() r.close() niceCountSetA, niceCountSetB = 0, 0 for name in data.split(): # Make a list of every two letters everyTwoLetters = [name[i] + name[i + 1] for i in range(0, len(...
d093a437bb9d08605f63ea0a9d81d4f2b8fcf1f2
pabhd3/Coding-Challenges
/adventofcode/2019/04 - Secure Container/password.py
1,615
3.796875
4
def findPassword(pRange): start, end = pRange.split("-") possibilities = [] for p in range(int(start), int(end)+1): # Check if 6 digit number if(len(str(p)) != 6): continue # Check for at 1 pair of adjacent same numbers double = False strP = str(p) ...
18d450fe88c4c6df2456c0b93fd666c1a5a2fdae
Golden-cobra-bjj/itstep
/lesson3/welcome.py
59
3.640625
4
name = input("What is your name?") print('"Hello, Neo :)"')
1c1cebceb7f945f2d9488a911c45b868a05ceb3c
Dhyaneshwaran-Vaitheswaran/Calculator
/Calculator_tkinter.py
3,549
3.953125
4
from tkinter import * ###main() window = Tk() window.title("Calculator") window.configure() operator="" text_input=StringVar() #Entry num = Entry(window, font="arial 20 normal",width=20, borderwidth=5, textvariable=text_input, bd=30, insertwidth=3, bg="powderblue") num.grid(row=0, column=0, columnspan=3, padx=10, pa...
acd1c76acbeb71338fa504768fff792701a7e3a4
jimtoGXYZ/scrapy_spiders_repository
/cd_lianjia_spider-centOS/data_analysis/c_gen_area_mean_price_pic.py
1,409
3.6875
4
""" 2020年2月17日15:44:53 按照不同的小区进行分类并计算小区总价平均值 使用plt进行数据展示 """ import matplotlib.pyplot as plt import pandas as pd plt.rcParams['font.sans-serif'] = ['SimHei'] # 显示中文 plt.rcParams['axes.unicode_minus'] = False # 显示负号 from_path = "..\\doc\\processed_data\\cd_lianjia-v3_ed.csv" to_path = "..\\doc\\pic\\ar...
f69ef00c44a9f5cc889a67bd509786ea306bcf0e
bhavesh-09/addskilleetcode
/WEEK2/Sorting/mergetwoll.py
902
3.921875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: head=ListNode(0) ptr=head while head: if l1 is N...
be522a17498e9c460579c7558b4fbf25061ef593
lwbrooke/dailyprogrammer
/easy/2017-06-12_challenge-319-condensing-sentences/solutions/condense.py
753
3.90625
4
#!/usr/bin/env python3 def main(): with open('input.txt') as f_in: for line in f_in.readlines(): print(condense(line.strip())) def condense(sentence): condensed = [] tokens = list(reversed(sentence.split(' '))) while len(tokens) > 1: first, second = tokens.pop(), tokens.p...
f14f50012773c003f4d5d3f89942189ed1071f08
FlyingBirdSwim/Python
/other_code/max_of_sum.py
924
3.609375
4
#!usr/bin/env python # coding=utf-8 # 输入:列表list # 输出:list的子列表中,和最大的子列表(最少为一个元素)以及sum值 # 1.常规实现 2.尽量优化(未完成) import time from memory_profiler import profile data = [-1, -2, -1, 1, -2, 3, -1, 2, -3, 2] @profile() def max_1(lt): max_sum = 0 max_list = [] for i in range(len(lt)): ...
30aa6513cd0eb7965abcba481995614d613c3c1b
mnxtr/Leetcode
/Arrays/First_Missing_Positive.py
1,147
3.703125
4
# Given an unsorted integer array nums, find the smallest missing positive integer. # Example 1: # Input: nums = [1,2,0] # Output: 3 # Example 2: # Input: nums = [3,4,-1,1] # Output: 2 # Leetcode 41: https://leetcode.com/problems/first-missing-positive/ # Difficulty: Hard # Solution: Sort the list as you iterate t...
a27ecb0e07e8cb284ee3226b6f63d954b1aae65f
mnxtr/Leetcode
/Arrays/Two_Sum_Sorted.py
1,126
4
4
# Given an array of integers numbers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. # Return the indices of the two numbers (1-indexed) as an integer array answer of size 2, where 1 <= answer[0] < answer[1] <= numbers.length. # You may assume that each i...
6afbd8e0f14f30d194df6f42b4e432d84eb579d3
mnxtr/Leetcode
/Arrays/Find_Pivot_Index.py
1,159
4.0625
4
# Given an array of integers nums, calculate the pivot index of this array. # The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right. # If the index is on the left edge of the array, then the left sum is 0 be...
2c13bb164982403cd2bdc5017d65d4b62dfe6a75
jhutar/RedBot
/plan.py
14,425
3.59375
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- import os import os.path PATHS = ['|', '/', '-', '\\'] def is_edge(coords): return coords[0] % 2 == 1 or coords[1] % 2 == 1 def is_vertex(coords): return coords[0] % 2 == 0 and coords[1] % 2 == 0 def can_put(c, coords): if c == '#': return True if c not in ...
102fb4b9db411b63dcceca6d381a771fec65b0c2
121910314010/10B14-Lab-Assignment
/L13- Binarytree.py
218
3.734375
4
class Node: def __init__(self, data): self.left = None self.right = None self.data = data def DispTree(self): print(self.data) root = Node(15) root.DispTree() Output:- 15
35eb58c9c2f9d6f431225606b12b0f414ea7a6c4
SSudhashu/ModelAuto
/ModelAuto/ModelSelection.py
6,261
3.53125
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt # Regression Model Selection def Regress_model(x_train,y_train,x_test=None,y_test=None,degree=2,test_size=0.1): """[summary] DESCRIPTION :- Regressin Model selection. This Model wil...
a8bf8c4ea895e621812b82a880cd9b62cff97eb1
Nadine278/design-patterns_wsb
/dp1.py
1,463
3.5625
4
# Language Translator # Adaptee: Incompatible interface # 1 class English: def Greeting(self): return "Hello!" def Farewell(self): return "Good byee." # Adapter Class, which takes functionality provided by English, morphs it into functionality expected by the polish p...
709fc9d07868898643a74f008b9107d0ec391eec
Sandyky/pdftojson
/pypdf_text_generator.py
699
3.5625
4
# pypdf_text_generator.py # importing required modules import PyPDF2 def extract_text_by_page(pdf_path): # creating a pdf file object pdfFileObj = open(pdf_path, 'rb') # pdfFileObj = open('Test for json (2) (1).pdf', 'rb') # creating a pdf reader object pdfReader = PyPDF2.PdfFileReader(pdf...
f2585c3c300b3dece289d3eddf8e4b8e0270e4e1
jaredad7/CSC_BACKUPS
/university/CSC325/Homework/HW4.py
151
3.828125
4
#Search an unordered array def search(x, arr): for i in range(len(arr)): if x == arr[i]: return i return -1 print(search(1, [2,4,9,5,8,1,0]))4
9abe35cda5b6d4d7a3460cdee7a2a368893fa37b
jaredad7/CSC_BACKUPS
/university/CSC325/Homework/HW5.py
336
4.03125
4
#Write a binary search def binSearch(arr, first, last, K): if last < first: index = -1 else: mid = int((first+last)/2) if K == arr[mid]: index = mid elif K < arr[mid]: index = binSearch(arr, first, mid-1, K) else: index = binSearch(arr, mid+1, last, K) return index print(binSearch([1,2,3,4,5,6,7,...
bf2a05fff10cf1fa6a2d0e5591da851b22069a78
adamny14/LoadTest
/test/as2/p4.py
219
4.125
4
#------------------------------ # Adam Hussain # print a square of stars for n #------------------------------ n = input("Enter number n: "); counter = 1; while counter <= n: print("*"*counter); counter = counter +1;
c76fb61d59cc8b7be29675d495bac11a645d34c1
echo750/python
/python_test/高阶函数.py
976
3.6875
4
#1淶Ӣĸ def normalize(name): return name[0].upper()+name[1:].lower() # : L1 = ['adam', 'LISA', 'barT'] L2 = list(map(normalize, L1)) print(L2) #2reduce() def prod(L): def f1(x,y): return x*y return reduce(f1,L) print('3 * 5 * 7 * 9 =', prod([3, 5, 7, 9])) if prod([3, 5, 7, 9]) == 945: print('Գ...
c94cd9920eef06a3e26a5880252c4b2058c01669
KlippRid/codepub
/Workshop/step1.py
556
3.5625
4
import random import radio from microbit import button_a, Image, display, sleep # Create an array with the three prepicked images (HEART, PITCHFORK and PACMAN) to # use instead of stone, rock, scissor. By terminology we call these "tools" # tools = <write array here> random.seed(463473567345343) my_id = 'foo' tool ...
4b7cee3fbbb50e5bad5d7a439daaf8b001d8f2e6
fmbdti/Projeto-02
/idade_anos_cachorro.py
160
3.71875
4
idade = int(input("Quantos anos você tem?")) print(f'Se você fosse um cachorro, você teria {idade * 7} anos!! \n') print(" '0'____' ") print(" |||| ")
b8307df493ecd72dc573304ae500e81fdd531dc9
Flip-SG/python-code
/Memory-Test/memory_test_function.py
340
3.875
4
# -*- encoding: utf-8 -*- """ Memory Usage Test using Function and List """ # Defining a Function def fibonacci_fun(max): nums = [] a, b = 0, 1 while len(nums) < max: nums.append(b) a, b = b, a + b return nums # Calling the Function for n in fibonacci_fun(100000): print(n) # Usage:...
69d9f24c6cb5b375c1cd4533a1479221c4dfb813
Jeevanantham13/programizprograms
/swappingvaraibleswithouttemp.py
268
4.0625
4
#swapping variables without using temporary variable a = int(input("enter the value of a:")) b = int(input("enter the value of b:")) print("the values of a and b are:",a,b) a = a+b b = a-b a = a-b print("the swapped varaibles of a and b are:",a,b)
bc4d287f92a9c8fc88b40f9a44f29bba615efc41
Jeevanantham13/programizprograms
/celciustofarenheit.py
185
4.3125
4
#coverting celsius into farenheit celcius = int(input("enter the celcius rate:")) farenheit = celcius * 32 print("the farenheit of the given celcius is:",farenheit,'farenheit')
25be821b8a8dcfde4e0e43f5b6f8321cb32d1717
ercas/scripts
/isopen.py
5,734
3.734375
4
#!/usr/bin/env python3 import datetime import json import math WEEKDAYS = [ "mon", "tue", "wed", "thu", "fri", "sat", "sun" ] FORMATS = [ "%I:%M %p", "%H:%M", "%I %p", "%H" ] CLOSED = "\x1b[31mClosed\x1b[0m" OPEN = "\x1b[32mOpen\x1b[0m" def parse_time(time_string): """ Attempt to convert a time string into a dat...
62a3e0306d82ddce02ba9f471c7b0d1f3ffa9199
wangtao666666/Data-structure-Algorithm
/Sort/2-sort.py
492
3.546875
4
#encoding='utf-8' """ 短冒泡排序 """ def shortBubbleSort(alist): exchanges = True item = len(alist) - 1 while item > 0 and exchanges: exchanges = False for i in range(item): if alist[i] > alist[i+1]: exchanges = True temp = alist[i] ...
d00c727795694f3d0386699e15afeb5cb4484f89
VictoriaAlvess/LP-Python
/exercicio5.py
565
4.40625
4
''' 5) Escreva um programa que receba três números quaisquer e apresente: a) a soma dos quadrados dos três números; b) o quadrado da soma dos três números.''' import math print("Digite o primeiro número: ") num1 = float(input()) print("Digite o segundo número: ") num2 = float(input()) print("Digite o terceiro número:...
4ac46568573edf2b5528846c93b19a864a0b903c
KrzysztofNyrek/strip_exponentiation
/rozbierz_potegowanie.py
1,056
3.546875
4
# coding: UTF-8 def rozb_pot(liczba, potega): liczba = str(liczba) i = 1 a = liczba b = liczba pot = potega lic = int(liczba) lista =[] #Exceptions if lic == 0: return '1' elif pot == 0: return '1' elif pot == 1: return b elif lic == 1:...
aa24f9c6c050d9da74ee0fdb271cbcf1d28a5f40
Laishuxin/python
/3.web服务器/1.正则表达式/7.re高级用法.py
531
3.65625
4
import re # search 不从开始匹配,只匹配一次 ret = re.search(r"\d+", "阅读次数:9999, 点赞:888") # 返回一个列表,不需要用group() ret1 = re.findall(r"\d+", "阅读次数:9999, 点赞:888") # 将匹配到的所有!!内容替换 然后返回整个内容 ret2 = re.sub(r"\d+", "7777", "阅读次数:9999, 点赞:888") # 切割字符串, 返回一个列表 ret3 = re.split(r":| ", "info:1111 小米 guangdong") print(ret.group(...
d77e3f0c1b69178d36d43f767e4e12aed8a821da
Laishuxin/python
/2.thread/3.协程/6.create_generator_send启动.py
742
4.3125
4
# 生成器是特殊的迭代器 # 生成器可以让一个函数暂停,想执行的时候执行 def fibonacci(length): """创建一个financci的生成器""" a, b = 0, 1 current_num = 0 while current_num < length: # 函数中由yield 则这个不是简单的函数,而是一个生成器模板 print("111") ret = yield a print("222") print(">>>>ret>>>>", ret) a, ...
51f77bec87dafe67de8cd09bcc1413bb200fd55b
Laishuxin/python
/6.web_mini框架/6.装饰器/4.装饰器-调用参数的函数.py
512
3.9375
4
""" 装饰器是在原来函数不修改的前提下,对函数整体加功能 """ def set_func(func): def call_func(a): # 注意这里也需要传入参数 print("-----这是权限验证1------") print("-----这是权限验证2------") func(a) # 注意这里也需要传入参数 return call_func @set_func def test1(num): print("这是test1函数 %d" % num) @set_func def test2(num): ...
16734679a66a28546fc4707d5f508a2ecb98b873
Laishuxin/python
/2.thread/1.线程/4.多线程共享全局变量-互斥锁.py
959
3.8125
4
import threading import time g_num = 0 def test1(num): global g_num # 上锁,如果之前没上锁,此时上锁成功 # 如果上锁之前,已经被上锁,那么此时会堵塞在这里,直到锁被解开为止 mutex.acquire() for i in range(num): g_num += 1 # 解锁 mutex.release() print("------in test11111 g_num = {}".format(g_num)) def test2(num)...
9ea09bff31a3f8612de32e1c48afd0a7de7782ab
prathyushaVV/algoexpert
/TwoNumberSum.py
705
3.609375
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 30 23:39:55 2020 @author: Prathyusha Vaigandla """ array = [9, 10, 11, 0, -4 ,-5, -6, -1] count = 0 target = 0 triplets = [] array.sort() for i in range(len(array)-3): for j in range(i+1,len(array)-2): left = j+1 right = len(array)-1 while left...
1bb08f16176e0ef96228ec8696e9fcbf0fe4d7fc
prathyushaVV/algoexpert
/LargestRange.py
799
3.796875
4
def largestRange(array): dupHash = {} largeArray = [] longValue = 0 for i in array: dupHash[i] = True for i in array: if not dupHash[i]: continue dupHash[i] = False currentValue = 1 left = i-1 right = i+1 while left in dupHash: ...
434328739627343a2181d5499073dc2e41a9bd1b
l3ouu4n9/LeetCode
/algorithms/840. Magic Squares In Grid.py
2,652
4.09375
4
""" A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Given an grid of integers, how many 3 x 3 "magic square" subgrids are there? (Each subgrid is contiguous). Example 1: Input: [[4,3,8,4], [9,5,1,9], ...
fbb4ce33a955eec2036211a7421950f027330a0b
l3ouu4n9/LeetCode
/algorithms/7. Reverse Integer.py
860
4.125
4
''' Given a 32-bit signed integer, reverse digits of an integer. E.g. Input: 123 Output: 321 Input: -123 Output: -321 Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of t...
74a739b7b55ef53fe62e892d468b8ee5b4d94e6f
l3ouu4n9/LeetCode
/algorithms/350. Intersection of Two Arrays II.py
610
4
4
""" Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2,2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [4,9] Note: Each element in the result should appear as many times as it shows in both arrays. The result can be in ...
e29e7c01ed08fc5cef0d2eeb50da36e3c86ffa25
Ryuji-commit/AtCoder-Python
/ABC165/165_B.py
163
3.515625
4
import math X = int(input()) now = 100 count = 0 while(True): count += 1 now = math.floor(now * 1.01) if now >= X: print(count) break
66c6394de9d7b855ff15d1c30686a4301a576d7e
Ryuji-commit/AtCoder-Python
/ABC173/173_C.py
1,535
3.890625
4
import copy # ここら辺はライブラリで求めるのが正解 def combination(num): result_combination = [[0]] recursion([], 1, num, result_combination) return result_combination def recursion(combination_list, i, max_num, result_combination): if i > max_num: if len(combination_list) > 0: result_combination....
2a569c9d2f1d8065df49a6e5c32ed258772df51e
datsaloglou/100DaysPython
/Module1/Day14/challenge_completed_da.py
1,749
3.65625
4
content = ["Wayne is the toughest guy in Letterkenny.", list(range(0,101,10)), ("Wayne", "Dan", "Katy", "Daryl"), 10.4] for i in range(0, len(content)): # if the object is immutable, print the type and advance to the next step. if type(content[i]) is tuple: print ("{} is a {}".format(content[i], type...
10eec44cfcbb285ef26963cb919db5b1c8fa4b78
grigorescu/abalone
/server/gameState.py
18,269
4.0625
4
import copy from ball import white, black, empty import utils class GameState: """Stores the state of the game at any given time.""" def __init__(self): """Start a new game.""" self.board = [ [black, black, black, black, black], [black, black, black, black, black, bla...
4f85b8be417d4253520781c0f99e31af282d60b7
sjtrimble/pythonCardGame
/cardgame.py
2,811
4.21875
4
# basic card game for Coding Dojo Python OOP module # San Jose, CA # 2016-12-06 import random # to be used below in the Deck class function # Creating Card Class class Card(object): def __init__(self, value, suit): self.value = value self.suit = suit def show(self): print self.value +...
1e6e66026c83ba3c859b919c7df9a344b2493847
MikeThomson/Project-Euler-Python
/problem001.py
116
3.734375
4
#!/usr/bin/python total = 0 for i in range(1,1000): if ((i % 3) == 0) or ((i % 5) == 0): total += i print total
6e2fd2cc56821e6aeb9ac0beb5173a9d57c03f67
ericd9799/PythonPractice
/year100.py
421
4.125
4
#! /usr/bin/python3 import datetime now = datetime.datetime.now() year = now.year name = input("Please enter your name: ") age = int(input("Please enter your age: ")) yearsToHundred = 100 - age turnHundred = int(year) + yearsToHundred message = name + " will turn 100 in the year "+ str(turnHundred) print(message)...
1b6d711b5078871fca2de4fcf0a12fc0989f96e4
ericd9799/PythonPractice
/modCheck.py
497
4.125
4
#! /usr/bin/python3 modCheck = int(input("Please enter an integer: ")) if (modCheck % 4) == 0: print(str(modCheck) + " is a multiple of 4") elif (modCheck % 2) == 0: print(str(modCheck) + " is even") elif (modCheck % 2) != 0: print(str(modCheck) + " is odd") num, check = input("Enter 2 numbers:").split() num =...