blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
16a295cd0da09604e14a46bd128e476b398046ed
jamezlim/PythonProgramming
/Lim_Cheolhyun_assignment7/Lim_Cheolhyun_assignment7_part1.py
2,600
4.3125
4
#Part 1a valid1 = True while valid1: name = input ("Please enter a username:") if len(name) < 8 or len(name) > 15: print ("Username must be between 8 and 15 characters.\n") continue elif name.isalnum()== False: print("Username must contain only alph...
8b157d4c8b4a6aff6bae1d609cc273d173339eba
luozhiping/leetcode
/middle/insert_interval.py
1,050
3.578125
4
# 57. 插入区间 # https://leetcode-cn.com/problems/insert-interval/ # Definition for an interval. class Interval(object): def __init__(self, s=0, e=0): self.start = s self.end = e class Solution: def insert(self, intervals, newInterval) : intervals.append(newInterval) if len(interval...
7b6c2b601263a6b0181337aa673914fbb8878ff8
SandeshDhawan/PythonPrograms
/For_Loop_Program/VerifyPowerOfNumber.py
294
3.859375
4
class Power: def checkPowerOfNumber(self, x, n): res = 1 for i in range(1, n + 1): res = res * x print(x, " Power of ", n, " is =", res) base = int(input("Enter Base")) power = int(input("Enter Power")) ob = Power() ob.checkPowerOfNumber(base, power)
ce6fc40ff8210d779d4749fa937d376313da8cc2
JulieDaniel/python_assignments
/comparing_lists.py
560
4.125
4
list_one = [1,2,5,6,2] list_two = [1,2,5,6,2] def compare_lists(list_one, list_two): if list_one==list_two: print "The lists are the same" else: print "The lists are not the same." compare_lists(list_one, list_two) list_one = [1,2,5,6,5] list_two = [1,2,5,6,5,3] compare_lists(l...
a7af73bd3e0c73beac8be0a358acb0a044a29a01
CodeMyGame1/PythonRemixes
/My Creations/Progress Bar/progressbarclass.py
1,295
3.90625
4
#Credit: @aaditisawesome import turtle import time class ProgressBar(): def __init__(self): self.a = turtle.Turtle() self.intro = turtle.Turtle() self.length = 20 def draw_bar(self): for x in range(2): self.a.forward(200) self.a.left(90) self....
be7d69d1bbccfaf94ddc14a0ceb8ed3aaaa96fe9
dermo64/advent2020
/day8/day8.py
1,071
3.5
4
#!/usr/bin/env python import sys def run_program(program): pc, acc = 0, 0 visited = {} while pc < len(program): next = 1 if program[pc][0] == 'acc': acc += int(program[pc][1]) elif program[pc][0] == 'jmp': next = int(program[pc][1]) if pc + next in vis...
e3bfcdfa89271087ed900699163b1a15ad2959ce
JaeZheng/jianzhi_offer
/37.py
2,136
3.671875
4
""" 题目描述: 统计一个数字在排序数组中出现的次数。 解决思路: 第一种:暴力遍历 第二种:二分查找,查找K出现的第一个索引和最后一个索引 """ # -*- coding:utf-8 -*- # 第一种 # class Solution: # def GetNumberOfK(self, data, k): # if not data: # return 0 # if len(data)==1: # if data[0] == k: # return 1 # else: # ...
6d7bc847f8439728d4a7a8b286df9f4fa12da4de
bayliewarrick/python101
/11-7/addtwonumbers.py
123
3.984375
4
number1 = int(input("Enter a number: ")) number2 = int(input("Enter a second number:" )) sum = number1 + number2 print(sum)
d89e409273d3e3a1f15b575011b4093801efc52b
SandeepThokala/ZeroToMasteryPython
/Generators/Fibonacci.py
361
3.671875
4
def fib(n): a = 0 b = 1 t = 0 l = [0,1] for i in range(n): t = a+b a = b b = t yield a ''' for ii in fib(0): print(ii) ''' def golden_ratio(n): for k in range(2, n): for i in fib(k): for j in fib(k-1): print(f'fib({k}): {i}, fib({k-1}): {j}') print('golden ratio:...
0b2368c88b3582f43fc8cc077d61c52adc5d1190
angelavuong/python_exercises
/OOP/access_specifiers_cars.py
540
4.0625
4
class Car: numberOfWheels = 4 _color = "Black" #Protected attribute __yearOfManufacture = 2017 #Private attribute class BMW(Car): def __init__(self): print("Protected attribute color: ", self._color) car = Car() print("Public attribute numberOfWheels: ", car.numberOfWheels) bmw = BMW() print(...
2612f9db61c68a224b806a059fe44443070d3aa4
BoHongtao/Base-Python-code
/基础代码/多线程.py
1,399
3.578125
4
import time, threading # def loop(): # print('thread %s is running...' % threading.current_thread().name) # n = 0 # while n < 5: # n = n + 1 # print('thread %s >>> %s' % (threading.current_thread().name, n)) # time.sleep(1) # print('thread %s ended.' % threading.current_thread()....
081f3215dbebd3330ee1043a2755907e8eb5382d
rtb89/WebScraping
/EmailCount.py
1,111
3.8125
4
"""ead through the mbox-short.txt and figure out who has the sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a count of the number of ...
1313e65550747c7069b21026efa43019e7006418
nesen2019/everyday
/ctasks/year_2021/month_06/day_20210622/L00000092.py
3,457
4.15625
4
''' 92.Reverse Linked List II 92.反转链表 II https://leetcode-cn.com/problems/ reverse-linked-list-ii 给你单链表的头指针 head 和两个整数 left 和 right ,其中 left <= right 。请你反转从位置 left 到位置 right 的链表节点,返回 反转后的链表 。   示例 1: 输入:head = [1,2,3,4,5], left = 2, right = 4 输出:[1,4,3,2,5] 示例 2: 输入:head = [5], left = 1, right = 1 输出:[5]   提示: ...
964b0d8bf3f01e69c6383bcbf84e6aac903ed2ec
shi-tou/python_study
/sample_100/s006.py
505
3.90625
4
# 斐波那契数列。 # 斐波那契数列(Fibonacci sequence),又称黄金分割数列,指的是这样一个数列:0、1、1、2、3、5、8、13、21、34、……。 # 在数学上,费波那契数列是以递归的方法来定义: # F0 = 0 (n=0) # F1 = 1 (n=1) # Fn = F[n-1]+ F[n-2](n=>2) def fn(n): if(n == 0): return 0 elif(n == 1): return 1 else: return fn(n-1)+fn(n-2) print(str.format("输出第...
360cfd5a7c0dfa09365fd8478b6e0660b2ee7b71
phanisai22/HackerRank
/Practice/30 Days/7-Day Arrays.py
245
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sun May 26 09:26:53 2019 @author: uppup """ if __name__ == '__main__': n = int(input()) arr = list(map(int, input().rstrip().split())) for i in range(0, n): print(arr.pop(), end=' ')
f9f25ed88ce5031840393d59d20216b567cf5b20
zameerdelhve/PythonTraining
/DicApp.py
147
3.671875
4
my_dic = {"1": "One", "2": "Two", "3": "Three", "4": "Four"} print(my_dic["1"], my_dic["2"]) print(my_dic.get("4"))
cea64e76d81b8248b5015b8e42f26d512d1b410b
winston5/coding-for-office-workers
/week-01-python/wk01-homework-05.py
302
3.609375
4
def googoodan(): dan = int(input("몇 단을 출력하시겠습니까?")) if 1 < dan < 10: for num in range(1,10): print("{} x {} = {}".format(dan, num, dan*num)) else: print("2에서 9 사이의 숫자만 입력해 주세요.") googoodan() googoodan()
2d1cfb8d6fe054aa7f12c47fe5ef6a34e31c793f
jaredbebb/PythonCode
/RegularExpressionsPart2.py
492
3.75
4
import re #Regular Expressions Part II x = "From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008" y = re.findall("^From \S+@\S+",x) print("Match if From is at the beginning of line, non white space, @, non white space:",y) #Match @, match non-blank character, any number of non blank characters #"[^ ]", ^ i...
d25fd99ed9810131c35a266f29675f5e9e47332f
surajslab/SortingAlgosPython
/merge_sort.py
753
4.0625
4
def merge_sort(arr,start,end): if(start<end): mid= (start+end)//2 merge_sort(arr,start,mid) merge_sort(arr,mid+1,end) merge(arr,start,end) def merge(arr,left,right): mid = (left+right)//2 l_count=left temp=[] i=left j=mid+1 while(i<=mid and j<...
737f8726cfd5112cb363560ba641088c7074c62d
BelongtoU/nguyentienanh-fundamental-c4e26
/session1/homework/2.area of circle.py
151
3.515625
4
#2. rad = float(input("Bán kính hình tròn: ")) area = 3.14*rad**2 print("Diện tích của hình tròn bán kính", rad, "dvd là:", area, "dvdt")
bd3077d78b1022e810b3f4e91b10dd40e2698726
DiegoVinasco/CSCI-4511W
/RunTests.py
3,985
4.0625
4
import SlidingPuzzle as main from datetime import datetime from random import randint def runTest(problem): # Given a problem this will run both the manhattan and straight line tests are print print("Initial State:") print(problem) print("\nRunning Manhattan Test") start_time = datetime.now() m...
79bdb34d7ce588a2ab6f1aebb8a454ab0f9848d2
vishwesh5/Project-Euler
/problem1.py
379
3.640625
4
# Specify upper limit UPPER = 1000 # Multiples of 3 below 1000 multiplesOf3 = [i for i in range(0,UPPER,3)] # Multiples of 5 below 1000 multiplesOf5 = [i for i in range(0,UPPER,5)] # Multiples of 15 below 1000 multiplesOf15 = [i for i in range(0,UPPER,15)] # Sum of multiples of 3 or 5 below 1000 answer = sum(multiplesO...
c398c84222c156278c7946363221a811036e3e14
GeorgeDanicico/Fundamentals-of-Programming-Year1
/Fundamental Of Programming/Lab10/Domain/A10Module.py
2,978
3.609375
4
class IterableDataStructure: def __init__(self): self._object_list = [] def add(self, obj): self._object_list.append(obj) def __len__(self): return len(self._object_list) def __setitem__(self, item, value): self._object_list[item] = value def __getitem__(self, i...
5aae75ba2b14e582b3a4f4722d3496e165448870
nmm131/pythonic-practice
/src/main/file_io.py
1,499
3.84375
4
""" Created on Mar 14, 2021 @author: N8 """ import re import csv TEXT_FILE = 'student.txt' CSV_FILE = 'users.csv' def add_student(first_name): with open(TEXT_FILE, 'a') as file: file.write(first_name) return None def find_student(first_name): with open(TEXT_FILE, 'r') as file: for name...
ff406afdfe17376cfda297e2903718d48f4cf202
515255476/python_docker
/test_4.py
212
3.5625
4
class Test3(): def test_3(self): data1 = {"name": "yang", "funcode": "003003"} data2 = {"funcode": "234556"} data_new = dict(data2, **data1) print(data_new) Test3().test_3()
a90a7ffa1f3a32f04a8f4ccec8598ea7a40a881e
heenach12/pythonpractice
/Linked_List/sort_0_1_2_linkedlist.py
1,915
3.59375
4
"""Given a linked list of N nodes where nodes can contain values 0s, 1s, and 2s only. The task is to segregate 0s, 1s, and 2s linked list such that all zeros segregate to head side, 2s at the end of the linked list, and 1s in the mid of 0s and 2s. Example 1: Input: N = 8 value[] = {1,2,2,1,2,0,2,2} Output: 0 1 1 2 2 ...
7b79cd4e479b365389fbc1315b00af992ba72e01
outdoorpet/3D_click_annotate
/_3D_mouseclick.py
3,910
3.953125
4
import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import proj3d import numpy as np def visualize3DData(X, annotes): """Visualize data in 3d plot with popover next to mouse click (middle button) position. Modified from DonCristobal's Answer on StackOverflow: http://stackoverflow.com/questions/...
5d5f27a208efbdeb8c44feb0aad3402d0c7da07f
dave-vazquez/Graphs
/projects/ancestor/ancestor.py
1,468
3.796875
4
from graph import Graph from util import Stack, Queue import pprint p_print = pprint.PrettyPrinter(width=30).pprint def earliest_ancestor(ancestors, starting_node): graph = Graph() # add the vertices for pair in ancestors: graph.add_vertex(pair[0]) graph.add_vertex(pair[1]) # add the...
2e54557575a3f51f7bab6bfb0a5fb50ad8b802b6
madinamantay/webdev2019
/week10/Informatics/5/B.py
100
3.609375
4
import math def f(a,n): return pow(float(a),float(n)) a, n = input().split() print(f(a,n))
f40532776e6ce34f564a9f2597cadf18c1fbaa13
SachinHg/python-exercises
/palin_idx.py
641
3.75
4
def palindromeIndex(s): s_r = s[::-1] len1 = len(s) if s == s_r: return -1 else: i = 0 s_ar = list(s) while i < len1//2: if s_ar[i] != s_ar[len1-1-i] : if s_ar[i+1] == s_ar[len1-1-i] and s_ar[i+2]==s_ar[len1-1-i]: return i ...
d69be2c425082f5bede5c2b489b17e8c47b4f7da
gHuwk/University
/First course/2nd semester/Python3/r.py
2,701
3.5
4
import pygame from pygame import * from math import * WIN_WIDTH = 900; WIN_HEIGHT = 640 BACKGROUND_COLOR ='#00BFFF' earth = Rect((0,round(WIN_HEIGHT*(2/3))),(WIN_WIDTH,WIN_HEIGHT)) def rot_center(image, angle): orig_rect = image.get_rect() rot_image = pygame.transform.rotate(image, angle) ...
84c9cb48eaaa3182501f47041a8c303ef5490013
arattha/CodingTest
/백수/코테공부/BFS&DFS/Binary Tree Level Order Traversal II.py
1,850
3.84375
4
########################################################################################## #107. Binary Tree Level Order Traversal II # #https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ # ###############################################...
5c29e2aa0c33616ae2f799b2df440161103f369e
mubaskid/new
/SELFTEST/guess.py
389
3.78125
4
import random number = random.randint(0, 100) for i in range(1, 99): try: user = int(input("Guess the lucky number: ")) if user == number: print("Hurray!!") print(f"You guessed the number right, it's {number}") break except(ValueError): user != num...
de577644a4c65c7d50c1309757f0b711d8485574
chuzcjoe/Leetcode
/382. Linked List Random Node.py
1,077
3.78125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def __init__(self, head): """ @param head The linked list's head. Note that the head is guaranteed to be not null...
039014740c505ec8d1a804d3f1b3b1f532e60b0c
vaj90/python
/Week13/ex1.py
2,938
4.03125
4
import _sqlite3 from contextlib import closing db_str = "movies.sqlite" def print_query(cs, q): cs.execute(q) result_set = cs.fetchall() for row in result_set: print(row) print() conn = _sqlite3.connect(db_str) c = conn.cursor() print("A SELECT statement that gets the content of all column...
dde2b08b979bfa6032a63c05ac6904e819ec1741
Katherinaxxx/leetcode
/兴业数金2021春招.py
1,026
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2021/4/19 4:33 PM @Author : Catherinexxx @Site : github.com/Katherinaxxx @File : 兴业数金2021春招.py @Description: 判断输入的字符串是否包含字母和数字,并统计字符数目 """ def is_chinese(uchar): if uchar >= u'\u4e00' and uchar <= u'\u9fa5': return True return False def is_engli...
b11714cc0e7db92bb25fdf78020f6ee38ade0d14
tulilishidameinv/tulili
/python/购物车1.py
1,262
3.796875
4
product_list = [ ( "电脑", 1999), ( "鼠标", 10), ( "游艇", 20), ( "美女", 998),] shopping_list = [] salary = input("请输入您的工资:") if salary.isdigit(): salary = int(salary) while True: for index,item in enumerate(product_list): print(index,item) user_choice = input("请选择商品,退出请输入q:...
8b6646f5da8840e82476bb97f9e5c2668963a612
Aeronyx/School
/conversations.py
1,531
3.921875
4
# File: conversations.py # Name: George Trammell # Date: 9/8/19 # Desc: Program has a discussion with the user. # Sources: None # OMH from time import sleep # Initial Greeting print('Hello! What is your name?') name = input('Name: ') # Capitalize name if uncapitalized name = name[0].upper() + name[1:] print('Hello %s...
a8f307edf7029d99e8a94ddf7b67c1964216eb57
haibenben/DesignPattern
/Observer/ObserverPattern.py
2,031
3.5625
4
# coding: utf8 import abc class Subject(object): """抽象主题""" __metaclass__ = abc.ABCMeta @abc.abstractmethod def add_observer(self, observer): pass @abc.abstractmethod def remove_observer(self, observer): pass @abc.abstractmethod def notify(self): pass clas...
5d6ae8d237bd78bc50242f38e47fe103ee3556d9
EmotionalPoker/MAS_SimulationOfEmotions
/PokerLib/PokerRules.py
23,832
3.953125
4
# -*- coding: utf-8 -*- """ Created on January 1 2020 @author: Hari Vidharth """ import itertools class Poker: """ Class defining poker rules, takes the player cards and the community cards as input for the class to be used by the individual check functions. """ def __init__(sel...
8fdddf91c83bef9d716749c0dc5250c93a35800a
epoll006/CTI-110-0902
/P3HW1_RomanNumerals_ErnestPollard.py
629
3.84375
4
#CTI-110 #P3HW1- Roman Numerals #Ernest Pollard #9/29/2018 # userNumber = int( input( "Please enter a number: " ) ) print() if userNumber == 1: print( "I" ) elif userNumber == 2: print( "II" ) elif userNumber == 3: print( "III" ) elif userNumber == 4: print( "IV" ) elif userNumber == ...
cd63ff3f0bc8a46f75ab8a6a3c0fd19931ff5aa0
stootee/aoc2020
/day12/main.py
2,677
3.6875
4
class Moves: def __init__(self, orientation=90, pos=(0, 0)): self.pos = pos self.orientation = orientation def turn(self, direction, degrees): multiplier = 1 if direction == 'L': multiplier = -1 self.orientation = (self.orientation + (degrees * multiplier)) ...
557953370d4a41e54847ec318223616665f3dd6a
halo2404/python-latex-moodle-quiz
/simple-examples-ger/beispiel3_statistik1.py
971
3.5625
4
import matplotlib.pyplot as plt import random def drawpie(names,percentages): labels = names sizes = percentages fig1, ax1 = plt.subplots() ax1.pie(sizes, labels=labels, startangle=90, textprops={'fontsize': 14}) ax1.axis('equal') plt.savefig(pngfile,dpi=150,quality=95,transparent=True) return for x in ...
0d4b7335fb53dfeae0701338c0a98675c6dc0c47
ramaseshan/search-it
/search.py
774
3.734375
4
import os import fnmatch def find_all(pattern,path): print "Searching" for root,dirs,files in os.walk(path): for name in files: if fnmatch.fnmatch(name,pattern): print (os.path.join(root,name)) if __name__ == '__main__': if os.name =='posix': file_path = raw_input("Enter a path to search ...
aeaac6aeba1fec6e06bc28191ff58f24511f990c
danielwood95/IoTSecurityHub
/packetInspection/chisqr.py
756
3.5625
4
#============================================================================== # SPRING 2016 JUNIOR INDEPENDENT WORK #title : chisqr.py #description : This program calculates the chi squared value of the payload # : of a packet of transmitted data and returns the result #author : ...
5be5263b4f17d774b1bdb5133715129ba73bd1da
xiajingdongning/liuyangli
/Mastermind/src/Marble.py
1,888
4.15625
4
import turtle from Point import Point MARBLE_RADIUS = 15 class Marble: def __init__(self, position, color, size): self.pen = self.new_pen() self.color = color self.position = position self.visible = False self.is_empty = True self.pen.hideturtle() self.size ...
9b6eed8c4ca0a94ffadc346843cbddb3dd0a6d5b
mathlizard/programming-challenges
/matrix_tracing.py
1,445
3.75
4
# ---------------------------------------------------- # https://www.hackerrank.com/challenges/matrix-tracing # ---------------------------------------------------- import functools @functools.lru_cache(maxsize=None) def pow__mod_c(a, k, c): """computes a^k (mod c), we assume a,k>=1, c > 1 integers""...
f0a15181d6b37bcaf771c7f0657acd39a34c54bd
haijunXue/python_info_sytem_exercise
/student_info.py
2,287
4.1875
4
str_print = "name: {}\tmath: {}\tchinese: {},english: {}\ttotal: {}\t" grade_list = [] while 1: print(""" ************** 1. create 2. show 3. search 4. delete 5. modify ************** """) action = input("input your operation:\n") if action == '1': "create stude...
93202e86855413bac4d61d5542ffab1a1bb66c71
drdcs/Algorithms-and-System-Design
/Array/findRange.py
911
3.75
4
""" Given an array containing only 0s and 1s, find the largest subarray which contains equal no of 0s and 1s. The expected time complexity is O(n). Input: arr[] = {1, 0, 1, 1, 1, 0, 0} Output: 1 to 6 (Starting and Ending indexes of output subarray) """ def maxLenOfArray(arr, n): hashmap = {} max_le...
da3ac5c14d9da34efb04f4e3a1a0475a47cb8d00
lucasolifreitas/ExerciciosPython
/secao4/exerc25.py
110
3.546875
4
acres = float(input('Digite o valor em acres: ')) print(f'O valor em metros quadrados é: {acres * 4048.58}')
125ed58a82801db50a0a995256d1a2b032fb300d
vikasjoshis001/Python-Course
/17_leapyear.py
212
4.125
4
year=input("Enter an Year") try: year=int(year) except: print("Enter valid Year") if (year%4==0 and year%100==0 and year%400==0): print("It is Leap Year")200 else: print("It is a not a Leap Year")
30222fa967246377ed2e2714498db7fd4a1a70d9
kyuyounglee/20210713-
/Ex10_1.py
540
4.1875
4
list_a = [10,20,30,40] print(list_a) # 1 reversed 순수하게 reversed를 사용하면 된다 for n in reversed(list_a): pass # 2. reversed 를 한 후에 다시 리스트에 담아서 사용하면 된다. list_a_rev = list(reversed(list_a)) for n in list_a_rev: pass # 3 reversed를 변수에 담아서 사용하면 처음은 가능하지만 위치정보가 초기화 안되서 두번째 부터 안됨 # 처음한번은 되지만 두번째 부터는 출력안됨 tem...
838d0ad8067474faf35e2b47d36c61fec7744fe3
SidSoft/rosalind
/revp/revp.py
1,079
4.0625
4
""" Locating Restriction Sites A DNA string is a reverse palindrome if it is equal to its reverse complement. For instance, GCATGC is a reverse palindrome because its reverse complement is GCATGC. See Figure 2. Given: A DNA string of length at most 1 kbp in FASTA format. Return: The position and length of every reve...
b587273ef4d82f16c7cd3aeebb0714ec00511772
jdukosse/LOI_Python_course-SourceCode
/Chap13/randomlights.py
1,793
3.984375
4
from tkinter import Tk, Canvas from tkinter.ttk import Button, Frame from random import choice, randrange from trafficlight import TrafficLight class RandomLightsWindow: """ Graphical window that displays multiple traffic lights of different sizes. """ def __init__(self): root = Tk() # C...
62053cecafd6af3f06c130024215c19e63ee1385
zakaleiliffe/IFB104
/Week Work/Week 8/Building IT systems/IFB104-Lecture08-Demos/5-place_demo.py
1,267
4.65625
5
#---------------------------------------------------------------- # # Placement demo # # A simple demonstration of using the place manager to # arrange several widgets into a particular pattern # (adapted from Y. Liang, "Introduction to Programming # using Python"). # # Note that the precise appearance of this window w...
2465bd66dc82d4ab87b42d07caa28f31f3b6b00b
24Savage/python-notes
/数据结构与算法/搜索/二分法.py
369
3.625
4
def bis(arr, target): # arr 一定升序 i, j = 0, len(arr)-1 while i < j: mid = i+j >> 1 if arr[i] < target: # 等号在left决定了是 bisect_left i = mid + 1 else: j = mid return {'索引':i, '值': arr[i]} if __name__ == '__main__': arr = [1,1,1,2,2,4,5,5] res = bis(a...
48eb02f5d600e4d774d77ba0403122b72b726d13
diawest82/Worklog-project-3
/entries.py
19,665
3.84375
4
import re import datetime import sys import csv class Entries: def __init(self): self.records = [] # Prompt menu to add a new entry or lookup previous entries def prompt_menu(self): self.clear_screen() while True: print(('*' * 10)+"MENU"+('*' * 10)) print...
4bdc71c2f7220984ab756ea57a2c92c82ebad88b
Mike-droid/EjerciciosCursoPython
/funciones.py
396
3.90625
4
import turtle def main(): window = turtle.Screen() mike = turtle.Turtle() make_square(mike) turtle.mainloop() def make_square(mike): length = int(input("Tamaño del cuadrado: ")) for i in range(4): make_line_and_turn(mike,length) def make_line_and_turn(mike,length): mik...
8ef69121694c7c4d2fc9917f85a40a066cce36fc
hersey/Python
/linkedlist.py
944
3.765625
4
# Level 4 in Python Challenge. http://www.pythonchallenge.com/pc/def/linkedlist.php # Base url has a pageid=some_num. when you input that number into the new page id, it jumps to a new page. import urllib, re baseurl="http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=" #pageid="12345" pageid="8022" co...
af18209493211249c8e37bd51828bbd12ff73a41
rafaelperazzo/programacao-web
/moodledata/vpl_data/305/usersdata/279/69439/submittedfiles/formula.py
259
3.78125
4
# -*- coding: utf-8 -*- p=float(input('\n.digite o valor de p.')) print('\n %.2f.'%p) i=float(input('\n.digite o valor de i.')) print('\n%.2f.'%i) n=float(input('\n.digite o valor de n.')) print('\n%.2f.'%n) v=float=((1+i)**n) print('\n%.2f.'%v)
d65a93c7775813c39d37539e7912396258eb1f1b
dismedev/CS104-3
/average.py
325
4.03125
4
numberofscores = 0 score1 = 0 score2 = 0 total = 0 average = 0.0 scorecount = 0 #numberofscores = input("Please enter the number of scores you want to average: ") score1 = int(input ("please enter a test score: ")) score2 = int(input ("please enter a test score: ")) average = (score1 + score2) / 2 print(avera...
5a8f7ae8cd72014dc203d3520d368642223f9c32
Nishant-MC/Machine-Learning
/ps2-gradient-descent/ps2-p2A-normalize_housing.py
1,965
3.9375
4
import math # Returns the average of a list L of numbers def mean(L): return sum(L)/len(L) # Returns the (population*) standard deviation of a list L of numbers def stdev(L): avg = mean(L) return math.sqrt( mean( [ (x - avg)**2 for x in L ] ) ) if __name__ == "__main__": print("Reading ...
c8620d7ac9f26e03e7e38dddba328412af59f660
imoren2x/biblab
/Python/02_Ejercicios/02_OOP/Ex08_PrivateAttr.py
704
3.640625
4
#!/usr/bin/python #-*- coding: latin-1 -*- import os import sys import time class JustCounter: __secretCount = 0 def count(self): self.__secretCount += 1 print self.__secretCount ### END count ### ### JustCounter ### if __name__ == '__main__': counter = JustCount...
8a9065e619261ff3b560ceb7aefe530e995583c0
amantaya/Image-Processing-Python
/image-processing/05-creating-histograms/GrayscaleMaskHistogram.py
879
4.0625
4
""" * Generate a grayscale histogram for an image. * * Usage: python GrayscaleMaskHistogram.py <filename> """ import sys import numpy as np import skimage.draw import skimage.io import skimage.viewer from matplotlib import pyplot as plt # read image, based on command line filename argument; # read the image as gray...
f10847a5928f7555e0debd091d65bac3c8ad8da9
bellepoque7/Python_Intro
/Python_Intro/2.[End]SNU_BDI_Python_II/05Day/03Table_easy.py
594
3.828125
4
a = ['Pyton','Java', 'C++', 'R'] map_by_len = map(len,a) print(map_by_len) print(list(map_by_len)) #갯수를 반환한다. b = ['string','list','dict','tuple'] map_by_endswith = map(lambda x: x.endswith('t'), b) print(list(map_by_endswith)) #t 원소로 끝나는지 확인하기. ### 02Table을 좀더 간략하게 from pprint import pprint with open('table.cs...
104863254b8a36f0320ab423d4371b783dec1208
JoseManuelGzz/GroupProject
/Evolutionary.py
4,829
3.640625
4
""" Evolutionary: """ #import matplotlib.pyplot as plt import math import random import numpy import time #from Dataset import Dataset import operator class Evolutionary: """ _init_ Constructor for the Evolutionary class parameters: ...
fb9051075a6f1fe42232672aeda445a59c04907e
steve-yuan-8276/pythonScrapy
/pythonForE/forPractice.py
123
3.59375
4
words = ['Steve', 'Grace', 'Hongbian'] for i in range(len(words)): print(f'Good Luck! {words[i]}. You are No {i + 1}')
f3ef591cbe91628208e106da8de08e61261f930f
AlexChristian720/OOP
/Object Oriented Programming/List.py
280
3.796875
4
empty_list=[]#Empty_List str_list=['Life','Is','Bueatiful'] #A List_Of String int_list=[1,4,5,9,18]#Int_List mixed_list=['This',9,'is',18,45.9,'a',54,'mixed',99,'list']#Mixed Item List print(empty_list) print(str_list) print(type(str_list)) print(int_list) print(mixed_list)
29429cce6abdf307115d7ced95661b7133b3fa58
zhaozhekey/Python-
/Day07/代码/01-小作业.py
1,705
3.828125
4
import random # 有一个列表names,保存了一组姓名names=['zhangsan','lisi','chris','jerry','henry'] # 再让用户输入一个姓名,如果这个姓名再列表里存在,提示用户姓名已存在 # 如果这个姓名再列表里面不存在,就将这个姓名添加到列表里 names = ['zhangsan', 'lisi', 'chris', 'jerry', 'henry'] # 方法一: # while True: # name = input("请输入一个姓名") # for i in range (0,len(names)): # if name == nam...
da1617da180b8623ff9063688b671081c9582b2c
gemmechu/competitiveProgramming
/Quarantine Daily/merge.py
827
3.640625
4
class Solution(object): def merge(self, intervals): """ :type intervals: List[List[int]] :rtype: List[List[int]] """ intervals = sorted(intervals) if (len(intervals)< 2): return intervals def is_overlap(a,b): if(a[1]>=b[0]): ...
c5ea424587a5f0aabbacffe56c76062c710cb055
hasnatosman/turtle
/shape.py
354
3.734375
4
import turtle #turtle.shape("turtle") turtle.color("blue") turtle.speed(1) def curve(): for i in range(200): turtle.forward(1) turtle.right(1) def heart(): turtle.left(140) turtle.forward(113) curve() turtle.left(120) curve() turtle.forward(120) ...
829e72d77ea785fa3d92d5c74450210207662120
careduardosilva/TheHuxley
/FOR/Soma de uma sequência de números.py
408
3.84375
4
numbers_amount = int(input()) #Quantidade de numeros total = 0 if(numbers_amount <= 10000 and numbers_amount >= 0): #a quantidade de numeros n pode ser negativa e nem maior que 10000 for i in range(0,numbers_amount): #Aqui iremos iterar numbers_amount vezes number = int(input()) #Pedimos um numero t...
3e0d16ca14f7d324be46b299d3b762e46fc70f46
KustomApe/dev
/.history/string_format_20220425174347.py
172
3.75
4
age = input('あなたの年齢を入れてください') year = 2012 print('私の年齢は{}歳です。'.format(age)) print('今年は西暦{}年です。'.format(year))
a096814d1ecd5477944d547174f3ac0c070ac6b6
zhenningtan/DataStructure_Algorithms
/2_sum2.py
2,283
3.546875
4
import time def readData(file): array=[] with open(file, "r") as f: for line in f: elem = line.strip() if elem: num = int(elem) array.append(num) return array array = readData("prob-2sum.txt") print len(array) print min(array), max(array) #=...
d2117ed83c5b82f500d4f2634c647f63b4adeb0b
shreydesai/ctci
/ctci/ch1/question6.py
443
3.515625
4
def string_compression(string): cstring = [] curr = string[0] count = 0 for char in string: if char == curr: count += 1 else: cstring.append('{}{}'.format(curr, count)) curr = char count = 1 cstring.append('{}{}'.format(curr, count))...
7b5120e458925011193d91e7147821cf1b7fa809
gauravbachani/Fortran-MPI
/Matplotlib/tutorial011_histogram.py
669
3.984375
4
# Plotting tutorials in Python # Histogram Plots # IQ distribution of a random normal population import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl mpl.style.use('classic') mean = 100 sd = 15 N = 1000 binsize = 20 IQ = np.random.normal(mean, sd, N) # plt.hist(IQ, binsize, facecolor='chocolat...
82e2e63ad235dbe1a105e86e763f760436bbdcfb
Uthaeus/practice_python
/character_input.py
345
4.125
4
print("Welcome!") name = input("Please enter your name: ") age = int(input("Please enter your age: ")) year = (100 - age) + 2018 num = int(input("Enter any number you'd like: ")) message = "Well hello there, {0}. You say that you are {1}, which means that in {2} you will be 100 years old.".format(name, age, year) + "...
f41592605e70d35b116f576f365fa55174fcef38
Aasthaengg/IBMdataset
/Python_codes/p03227/s487668286.py
49
3.546875
4
s=str(input()) print(s if len(s)==2 else s[::-1])
82db645909ffeed22e0dd3dc44d9548666933d0c
Ben-Rapha/Python-HW-2nd-SEMESTER
/plaindrome.py
1,665
4.34375
4
#KINGSLEY.OTTO #CSI 33 #HOMEWORK 11 #Write a recursive function that detects whether a string is a palindrome. The #basic idea is to check that the first and last letters of the string are the same #letter; if they are, then the entire string is a palindrome if everything between #those letters is a palindrome....
62f53e8d51cd93e944091a0dc00c35966692ccdc
conalryan/python-notes
/challenges/doubledeco.py
913
4.5
4
#!/usr/bin/env python from functools import wraps """ Write a decorator to double the return value of any function. If a function returns 5, after decoration it should return 10. If it returns "spam", after decoration it should return "spamspam", etc. """ # "inner decorator" - receives function being decorated def ...
559abe40eb2df07bdcfe8b849ad0254b5fe32451
patricksegfault/Advent-of-Code
/2016/aoc6 - 2016.py
571
3.625
4
import collections pInput = [] with open('aoc6Input.txt', 'r') as fp: for line in fp: pInput.append(line.strip()) def partOne(): rotated = zip(*pInput[::-1]) word = '' for w in rotated: word += collections.Counter(w).most_common(1)[0][0] return word def partTwo()...
35e57d91f500b329a988628b25fa779c7bd0e7d8
mrgomides/VemPython
/desafios/exe025.py
291
3.78125
4
# Projeto: VemPython/exe025 # Autor: rafael # Data: 14/03/18 - 16:54 # Objetivo: TODO Crie um programa que leia o nome de uma pessoa e diga se ela tem "SILVA" no nome nome = str(input('Informe um Nome: ')) print('É verdadeiro que tem Silva no seu nome? {}'.format('silva' in nome.lower()))
eb74bf7563ab10894c66ce3292d8ffb04076c5ff
jamesledwith/Python
/PythonExercisesWk2/5PowerRadioConversion.py
598
4.0625
4
#This program will convert power to dBM, or dBm to power, based off user's choice from math import log10 print("Program for Power Ratio Conversions ") print("1. Power to dPm") print("2. dBm to Power") choice = int(input("Enter your choice: ")) if choice == 1: milliwatts_power = float(input("Enter Power in milliw...
b2a01242207dfe6635242a84dbaa66ebe992545e
srunnikr/distributed_systems
/Hadoop/hadoop-cluster-docker/hadoop-master/files/process_bigrams.py
818
3.546875
4
import sys def main(): with open(sys.argv[1],'r') as f: lines = f.readlines() bigrams = [] total_count = 0; for line in lines: l = line.split('\t') bigrams.append((l[0], int(l[1]))) total_count += int(l[1]) bigrams.sort(reverse=True, key=lambda x: x[1]) #print bigrams # is it # distinct bigrams or total...
1a3c167bb53d4d86a0ad25414402b3f85b690733
ayoubbenaissa/MachineLearningRep
/UdemyML/Part 4 - Clustering/Section 24 - K-Means Clustering/K_Means/K_Means/Kmeans.py
1,596
3.796875
4
#importing lybraries : import numpy as np import matplotlib.pyplot as plt import pandas as pd #import dataste: dataset = pd.read_csv('Mall_Customers.csv') X = dataset.iloc[:, [3,4]].values #using elbow method to determine optimal number of clusters: from sklearn.cluster import KMeans wcss = [] for i in range(1, 11):...
1e685959581258200dd9da491a1d5f3e6be1fc06
lanjingjing1992/1506A_workspace
/day03/call.py
478
3.53125
4
#coding=utf-8 from day03 import Test # r=Test.Recursion() # print r.recursion5(5) # print r.rubbitnum(8) # sum=0.0 # for i in range(1,21,1): # sum+=float(r.calcmolecule(i)/r.calcdenominator(i)) # print sum # num1=int(raw_input('请输入数字:')) # num2=int(raw_input('请输入共有几个数字相加')) # sum=0 # for i in range(1,num2+1,1):...
2e40a5404c9a5bf463356ae5db551a15db6533ae
durmusyasar/Python-Projects
/SıfırdanileriSeviyePythonKursu/72-pisagor_bulma.py
307
3.59375
4
def pisagor_bulma(): pisagor_listesi = list() for i in range(1,101): for j in range(1,101): c = (i ** 2 + j ** 2) ** 0.5 if (c == int(c) ): pisagor_listesi.append((i,j,int(c))) return pisagor_listesi for i in pisagor_bulma(): print(i)
90781876c3c0697bb473d5c4a62e9a9cfceee1e5
jathinraju/python-assignment-4
/python assignent 4/ass4max.py
300
4.40625
4
# to find maximum of three numbers def three(a,b,d) : if a>b and a>d : print(a," is maximum") elif b>a and b>d : print(b," is maximum") else : print(d," is maximum") x = int(input("enter a number x :")) y = int(input("enter a number y :")) z = int(input("enter a number z :")) three(x,y,z)
91528131782c8ffb7cb3bf8411973d159c9af00a
JacobDuvall/pythonPPL
/gradingProject/homework6.py
5,009
3.8125
4
# Author: Jacob Duvall # Date: April 22, 2019 # store student's information # a student has an id number, name, grade, type, and optional location # beginning of html def starthtml(output): output.write('<html>') output.write('<style> table { border-collapse: collapse; width: 15%; } table td { width: 50%; tex...
0c21f8a2c82db7a9df7fd0786485ace76c234104
wang19k/PredictingMarchMadness
/basketball_parser.py
4,437
3.625
4
import sys import numpy as np import pandas as pd import csv def main(): team_names = create_dict_from_csv("teams.csv") inputs = get_input_frames("RegularSeasonDetailedResults.csv", team_names) clean_inputs(inputs) def create_dict_from_csv(filename): """Creates dictionary mapping team ID to team name...
608ade35cf63cef5ddbe7bfebebdd035299a3e13
MrHamdulay/csc3-capstone
/examples/data/Assignment_7/nthjon001/util.py
2,830
3.84375
4
"""Utility functions to manipulate 2D arrays Jonathan Nathan 27 April 2014""" def create_grid(grid): """create a 4x4 grid""" for i in range(4): grid.append([0,0,0,0]) return grid def print_grid(grid): """print out a 4x4 grid in 5-width columns within a box""" print("+--...
23b252e9560ef689b29e4a501d5617310acf9912
edudawla/CRUD
/02.insere_no_final.py
259
3.59375
4
#inserir conteudo ao final arquivo = open('novo.txt', 'r') lista = arquivo.readlines() novo = input('Digite a palavra a ser adicionada: ') lista.append(f'{novo}\n') arquivo = open('novo.txt', 'w') for i in lista: arquivo.writelines(i) arquivo.close()
bb3616abd6b96bbcc9e7510a8087473dae2adc05
kun1987/Python
/chapter6_EX8.py
397
4.125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- def gcd(a,b): #this functon finds the greatest common divisor (GCD) of a and b. if a == 0 or b == 0: return 0 elif not isinstance(a, int) or not isinstance(b, int): print 'gcd is only defined for integers.' else: r = a % b ...
47331eb339e00add0e65f7ad14b0976fd2b16118
wverbeke/deepLearning
/miscTools/listContent.py
472
3.71875
4
""" functiones to list the content of a directory """ import os def listContent( directory_name, typeCheck): for entry in os.listdir( directory_name ): full_path = os.path.join( directory_name, entry ) if typeCheck( full_path ) : yield full_path def listSubDirectories( directory_name...
b199a6a5752a443e8326c092f1989612f1137900
YashK1299/LeetCode
/Decode String.py
2,895
4.125
4
""" Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume that the input string is always valid; No extra white...
bab1fed33f00d3ffdbd51256032e2a77133b1cff
rdilip/Project-Euler
/problem4.py
230
3.53125
4
def isPal(num): if num == int(str(num)[::-1]): return True return False largest_pal = 0 for a in xrange(100,1000): for b in xrange(100,1000): if isPal(a*b): if (a*b) > largest_pal: largest_pal = a*b print largest_pal
478f75ec65d4c62606d09507d6a4fd50e905dcd1
Lucatiel123/cookbook
/c12/p2_event1.py
989
3.515625
4
""" event.wait(timeout=None):调用该方法的线程会被阻塞,如果设置了timeout参数,超时后,线程会停止阻塞继续执行; event.set():将event的标志设置为True,调用wait方法的所有线程将被唤醒; event.clear():将event的标志设置为False,调用wait方法的所有线程将被阻塞; event.isSet():判断event的标志是否为True。 """ import threading from time import sleep def test_event(n, event): while not event.isSet(): ...
f81b9765896172d139fbcca6eef3d9453140f303
linhx13/leetcode-code
/code/128-longest-consecutive-sequence.py
541
3.609375
4
from typing import List class Solution: def longestConsecutive(self, nums: List[int]) -> int: nums = set(nums) res = 0 for x in nums: if x - 1 not in nums: y = x c = 1 while y + 1 in nums: y += 1 ...
6021bc64b68a8a33735172095b11209bd80b6615
patlub/Andel-SLC-Day-2
/fizz_buzz.py
616
4.34375
4
def fizz_buzz(number): """ A function fizz_buzz to return 'Fizz', 'Buzz', 'FizzBuzz', or the argument it receives, all depending on the argument of the function, a number that is divisible by, 3, 5, or both 3 and 5, respectively Args: number: """ if not isinstance(number, int) o...
aad0fb65f8d0d774b180db0fa691ba49966eb82c
Vivekg95/Python-Tutorial
/practixe12.py
516
4
4
n=int(input("enter no of students:")) d={} for i in range(n): marks=int(input("enter student's marks:")) name=input("enter name of students:") d[name]=marks #print(d) while True: name=input("enter student name to get marks:") marks=d.get(name,-1) if marks==-1: print("student not foun...