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
55f6250afbc40ef2ff82cc69d7ce136b5e61df6d
ml758392/python_tedu
/python2/Day3_modlue_oop/pycharm/oop_5.py
593
3.625
4
# -*-coding:utf-8-*- class A: def foo(self): print('你好!') class B: def bar(self): print('How are you?') def pstar(self): print('@'*20) class C(A, B): def pstar(self): print('*'*20) if __name__ == '__main__': c = C() # 子类的实例继承了所有父类的方法 c.foo() # 如果多个父类...
6e507249b67a8332e0dab307a9f168cb597fbc68
ml758392/python_tedu
/python1/Day2_基础/pycharm/login_2.py
183
3.609375
4
#-*-coding:utf-8-*- user = input("username:") passwd = input("password:") if user == "yy" and passwd == "123456": print("Login successful") else: print("Login inorrect")
6af0400e64f62fd553527c7b57719a03968c7a8e
ml758392/python_tedu
/nsd2018-master/nsd1804/python/day08/count_patt2.py
544
3.546875
4
import re from collections import Counter class CountPatt: def __init__(self, patt): self.cpatt = re.compile(patt) def count_patt(self, fname): result = Counter() with open(fname) as fobj: for line in fobj: m = self.cpatt.search(line) if m: ...
5f8e4ec42ea9dfd48be6dc1e84a4c9a3d7895cad
ml758392/python_tedu
/python100例/Python100Cases-master/100examples/077.py
90
3.578125
4
l=['moyu','niupi','xuecaibichi','shengfaji','42'] for i in range(len(l)): print(l[i])
38f3d5077db94d81a8e8e7d212237be0521b926e
ml758392/python_tedu
/python2/Tkinter/5.点击按钮输出输入框中的内容.py
425
3.546875
4
# -*-coding:utf-8-*- import tkinter # 创建主窗口 win = tkinter.Tk() # 设置标题 win.title("YY") # 设置大小和位置 长x宽 距离 win.geometry('400x400+200+200') def showinfo(): print(entry.get()) entry = tkinter.Entry(win) entry.pack() button =tkinter.Button(win, text='提交', command=showinfo) button.pack() # 进入消息循环 win...
f1b0fb2020b926fb8e9a9971b3dc0a3a584b4bbe
ml758392/python_tedu
/nsd2018-master/nsd1802/python/day02/while_break.py
482
3.78125
4
# yn = input('Continue(y/n): ') # # while yn not in 'nN': # print('running...') # yn = input('Continue(y/n): ') # python DRY原则: Don't Repeat Yourself while True: yn = input('Continue(y/n): ') if yn in ['n', 'N']: break print('running...') ############################################# sum100...
b49f84b9ae3a5bceb5d069432a33a5200cea8b98
ml758392/python_tedu
/nsd2018-master/nsd1802/python/day04/list_method.py
603
3.765625
4
alist = [1, 2, 3, 'bob', 'alice'] alist[0] = 10 alist[1:3] = [20, 30] alist[2:2] = [22, 24, 26, 28] alist.append(100) alist.remove(24) # 删除第一个24 alist.index('bob') # 返回下标 blist = alist.copy() # 相当于blist = alist[:] alist.insert(1, 15) # 向下标为1的位置插入数字15 alist.pop() # 默认弹出最后一项 alist.pop(2) # 弹出下标为2的项目 alist.pop(alist....
b286bc4bd3179f174b808381c6f408bd80e2bcfe
ml758392/python_tedu
/python2/Day3_modlue_oop/pycharm/9.重写__repr__与__str__.py
807
4.15625
4
# -*-coding:utf-8-*- """ 重写:可将函数重写定义一遍 __str__() __repr__() """ class Person(object): """ :param :parameter """ def __init__(self, name, age): self.name = name self.age = age def myself(self): print("I'm %s , %s years old " % (self.name, self.age)) # __str__()在...
2c30c0c30b5075e5d27f93544cfadb95467c85fe
ml758392/python_tedu
/python2/Day3_modlue_oop/继承/worker.py
432
3.5625
4
# -*-coding:utf-8-*- from person import Person class Worker(Person): def __init__(self, name, age, money): super(Worker, self).__init__(name, age, money) def work(self): # 继承父类中的私有属性 # print(self.__money) print(A._Person__money) # 私有属性的名仍为父类的名 A = Worker('bob', 30, 10000) A...
e8a13cc7c1079e0ccc88ebfcf3f41acc8638f1ad
ml758392/python_tedu
/nsd2018-master/nsd1804/python/day05/railway.py
209
3.5
4
import time print('#' * 20, end='') counter = 0 while True: print('\r%s@%s' % ('#' * counter, '#' * (19 - counter)), end='') counter +=1 if counter == 20: counter = 0 time.sleep(0.3)
9ba277aca0b2ee7388da28eb1577c477db26efbb
ml758392/python_tedu
/nsd2018-master/nsd1802/python/day06/mygui3.py
525
3.5625
4
import tkinter from functools import partial def hello(word): def welcome(): lb.config(text="Hello %s!" % word) return welcome # hello函数的返回值还是函数 root = tkinter.Tk() lb = tkinter.Label(text="Hello world!", font="Times 26") MyBtn = partial(tkinter.Button, root, fg='white', bg='blue') b1 = MyBtn(text='B...
dc510858253ff64e6b52fc184714df2a3bbaeb2a
ml758392/python_tedu
/python100例/Python100Cases-master/100examples/006.py
170
3.75
4
def Fib(n): return 1 if n<=2 else Fib(n-1)+Fib(n-2) print(Fib(int(input()))) target=int(input()) res=0 a,b=1,1 for i in range(target-1): a,b=b,a+b print(a)
72dc30fd01b0534b20e07ec811ffc7903f0c265d
ml758392/python_tedu
/nsd2018-master/nsd1803/python/day03/mtable.py
173
3.53125
4
for i in range(1, 10): # 外层循环控制行 for j in range(1, i + 1): # 内层循环控制某一行 print('%sX%s=%s' % (j, i, j * i), end=' ') print()
28d4a6b3e584c628a2be3570b569d97cc58daf83
ml758392/python_tedu
/nsd2018-master/nsd1803/python/day08/mytime.py
740
3.75
4
class Date: def __init__(self, year, month, day): self.year = year self.month = month self.day = day def say_hi(self): # 必须有实例,通过实例调用 print('hello world!') @classmethod # 类方法,没有实例就可以调用 def create_date(cls, str_date): # cls是类本身,即Date y, m, d = map(int, str_dat...
33e6295afebb628d2a60097724496a36dc66d02f
ml758392/python_tedu
/nsd2018-master/nsd1802/python/day04/str_method.py
783
3.65625
4
py_str = 'hello world!' py_str.capitalize() py_str.title() py_str.center(50) py_str.center(50, '#') py_str.ljust(50, '*') py_str.rjust(50, '*') py_str.count('l') # 统计l出现的次数 py_str.count('lo') py_str.endswith('!') # 以!结尾吗? py_str.endswith('d!') py_str.startswith('a') # 以a开头吗? py_str.islower() # 字母都是小写的?其他字符不考虑 py_st...
443afc71938eb3f5beacfa7138b884488d1287c9
ml758392/python_tedu
/nsd2018-master/nsd1803/python/day06/mydict.py
916
3.71875
4
# adict = dict(['ab', 'cd', ('name', 'zhangsan')]) # print(adict) bdict = {}.fromkeys(['bob', 'alice', 'tom'], 7) print(bdict) for key in bdict: print('%s: %s' % (key, bdict[key])) print('%(bob)s' % bdict) bdict['tom'] = 8 # tom已经是字典的key,更新值 bdict['john'] = 6 # john没在字典中,新增一项 print(bdict) bdict.pop('alice') 7 ...
4d06d510df701a3589334f8849255717f5122e0b
ml758392/python_tedu
/nsd2018-master/nsd1804/python/day06/anon2.py
538
3.546875
4
from random import randint def mydiv(x): return x % 2 def func1(x): return x * 2 + 1 if __name__ == '__main__': alist = [randint(1, 100) for i in range(10)] print(alist) print(list(filter(mydiv, alist))) # alist中的每一项都作为mydiv的参数,如果返回值是True就留下来,否则过滤掉 print(list(filter(lambda x: x % 2, alist)))...
23765e98c4daee3f6dcc2177971dbd538878410c
ml758392/python_tedu
/python100例/Python100Cases-master/100examples/049.py
136
3.734375
4
Max=lambda x,y:x*(x>=y)+y*(y>x) Min=lambda x,y:x*(x<=y)+y*(y<x) a=int(input('1:')) b=int(input('2:')) print(Max(a,b)) print(Min(a,b))
3932d3894497eeea75c745a2468b84a6096252d0
ml758392/python_tedu
/python100例/Python-programming-exercises-master/python100/level2/9.py
519
3.984375
4
""" 编写一个接受行序列作为输入的程序,并在使句子中的所有字符大写后打印行。 假设为程序提供了以下输入: Hello world Practice makes perfect 然后,输出应该是: HELLO WORLD PRACTICE MAKES PERFECT 提示: 如果输入数据被提供给问题,则应该假定它是控制台输入。 """ lines = [] while True: s = input('input:') if s: lines.append(s.upper()) else: break for sentence in line...
2d1d7d32813d8fb72c7e889ea85b7ee5006f222b
ml758392/python_tedu
/python1/Day3_文件_fun_mod/pycharm/randpass.py
226
3.796875
4
# -*-coding:utf-8-*- from random import choice num = int(input("请输入密码的位数:")) string = "123456absimport!#@%" password = "" for i in range(num): password = password + choice(string) else: print(password)
7e40c4b9259486ee55d80691c66f8a8cc0efb36c
ml758392/python_tedu
/nsd2018-master/nsd1804/python/day01/hello.py
706
4.1875
4
# 如果希望将数据输出在屏幕上,常用的方法是print print('Hello World!') print('Hello' + 'World!') print('Hello', 'World!') # 默认各项之间用空格分隔 print('Hello', 'World!', 'abc', sep='***') # 指定分隔符是*** print('Hello World!', end='####') # print默认在打印结束后加上一个回车,可以使用end=重置结束符 n = input('number: ') # 屏幕提示number: 用户输入的内容赋值给n print(n) # input得到的数据全都是字符...
0030823476eda14a6172efa3228afab8b0f140e9
ml758392/python_tedu
/nsd2018-master/nsd1803/python/day03/mylist.py
240
3.5
4
[10] [3 + 2] [3 + 2 for i in range(10)] # 执行10次3+2 [3 + i for i in range(10)] # 循环控制3+i运行多少次 [3 + i for i in range(10) if i % 2 == 1] # 判断条件作为过滤依据 ['192.168.1.%s' % i for i in range(1, 255)]
b688b8ce2aa2cc925b936c49b5366147f6fb4b03
ml758392/python_tedu
/nsd2018-master/nsd1802/python/day07/books.py
444
3.65625
4
class Book: def __init__(self, title, author, pages): self.title = title self.author = author self.pages = pages def __str__(self): return '《%s》' % self.title def __call__(self): print('《%s》is written by %s' % (self.title, self.author)) if __name__ == '__main__': ...
ff8d1f55ebf3a241031f3c3499e7e4ac6c916d08
ml758392/python_tedu
/devops/Day1_fork_thread/Thread/7.线程通信.py
417
3.640625
4
# -*-coding:utf-8-*- import threading import time def oo(): event = threading.Event() def run(): for i in range(5): # 阻塞, 等待时间的触发 event.wait() # 重置 event.clear() print('sunck is a good man') threading.Thread(target=run).start() return ...
4ac57f656e4393651ca3b39b0916918e15bbe8d0
ml758392/python_tedu
/python1/Day2_基础/pycharm/game_2.py
820
4
4
# -*-coding:utf-8-*- import random all_choice = ['剪刀', '石头', '布'] win = [['剪刀', '布'], ['石头', '剪刀'], ['布', '石头']] num_player = 2 num_computer = 2 while num_player > 0 and num_computer > 0: computer = random.choice(all_choice) prompt = ''' (0)剪刀 (1)石头 (2)布 请出拳(0/1/2):''' player = int(input(pr...
e2364c287a56b8c3704ea927c94d1971f7eee6c5
ml758392/python_tedu
/python100例/Python-programming-exercises-master/python100/level2/8.py
368
4.03125
4
""" 题: 编写一个程序,接受逗号分隔的单词序列作为输入,并按字母顺序排序后以逗号分隔的顺序打印单词。 假设为程序提供了以下输入: 不,你好,包,世界 然后,输出应该是: 袋,你好,没有,世界 """ item = [x for x in input('input:').split(',')] item.sort() print(','.join(item))
2729e7bfbd3d0e37b2e3adbfcdc158c32a743184
ml758392/python_tedu
/nsd2018-master/nsd1803/python/day07/parial_func.py
350
3.5625
4
from functools import partial def add(a, b, c, d): return a + b + c + d if __name__ == '__main__': print(add(10, 20, 30, 5)) print(add(10, 20, 30, 15)) print(add(10, 20, 30, 25)) print(add(10, 20, 30, 35)) myadd = partial(add, 10, 20, 30) print(myadd(5)) print(myadd(15)) print(myad...
a75144bd1fa587df3cf16ef5e4eb6e5dc6eb92dc
Rekt77/Algorithm
/boj/2839.py
162
3.59375
4
kg = int(input()) if kg in [1,2,4,7]: print(-1) elif kg%5==1 or kg%5==3: print(kg//5+1) elif kg%5==2 or kg%5==4: print(kg//5+2) else: print(kg//5)
b629e4a4f0a8144c215791d92ebc074422615eaf
Rekt77/Algorithm
/boj/2747_generator.py
385
3.765625
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 25 01:06:23 2019 @author: Rekt77 """ import sys from itertools import islice def Fibonacci_numbers(): prev, curr = 0,1 while True: yield curr prev, curr = curr, prev+curr if __name__ == "__main__": f = Fibonacci_numbers() n = int(...
3da3ad094575ff79947fd44f3b651e8270dee9ac
Rekt77/Algorithm
/programmers/programmers_removepair.py
255
3.78125
4
string = "abaaba" stack = [] if len(string)%2 != 0: print(0) for each in string: stack.append(each) if len(stack) != 1 and (stack[-1]==stack[-2]): stack.pop() stack.pop() print(stack) if stack: print(0) else: print(1)
b713f81753cf0d6b36d066be7b53a61ea8d1374e
forthing/leetcode-share
/python/123 Best Time to Buy and Sell Stock III.py
1,262
3.75
4
''' Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions. Note: You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). ''' cl...
bb5892474298adf10e7aa203081f855ecffc5e11
forthing/leetcode-share
/python/060 Permutation Sequence.py
1,097
3.984375
4
''' The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): "123" "132" "213" "231" "312" "321" Given n and k, return the kth permutation sequence. Note: Given n will be between 1 and 9 incl...
7b1c566cc18b4dad37b9a62c20127d808b814d2e
forthing/leetcode-share
/python/030 Substring with Concatenation of All Words.py
1,745
3.84375
4
''' You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters. For example, given: s: "barfoothefoobarman" words: ["foo", "bar"] You sho...
8c326cefac9c979874f8a03334934c685a88c953
forthing/leetcode-share
/python/152 Maximum Product Subarray.py
813
4.21875
4
''' Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest product = 6. ''' class Solution(object): def maxProduct(self, nums): """ :type nums: Lis...
b7a2cbc135fc64b983bb4e94dd42001927d870b4
forthing/leetcode-share
/python/051 N-Queens.py
1,541
4.09375
4
''' The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicat...
5342778e7ce54985e47b35ffb838de3836a97382
forthing/leetcode-share
/python/219 Contains Duplicate II.py
885
3.625
4
''' Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k. ''' class Solution(object): def containsNearbyDuplicate(self, nums, k): """ :type nums: List[int]...
88ddaec1c09a46fac173c4b520c6253b59aad09b
kmair/Graduate-Research
/PYOMO_exercises_w_soln/exercises/Python/fcn_soln.py
1,248
4.40625
4
## Write a function that takes in a list of numbers and *prints* the value of the largest number. Be sure to test your function. def print_max_value(nums): print("The max value is: ") print(max(nums)) ## Write a function that takes a list of numbers and *returns* the largest number def max_value(nums): return ...
b29bf7aee53ceeca2952e5f2db345b2ff3fdb8b8
disconnect78/bandcamper
/bandcamper/metadata/track_metadata.py
2,424
3.59375
4
from abc import ABC from abc import abstractmethod from mutagen import File class TrackMetadata(ABC): """Handles the metadata of track files. Parameters ---------- filename : str or path-like object. The filename or file-path of the respective file to read/write metadata. Attributes ...
89e29e7a555fb0f7d760c8589d30b69642275c94
Danyt13/gitProjects
/calculatrice.py
1,625
3.5625
4
import tkinter as tk racine = tk.Tk() racine.title("Calculatrice") def carre0(): x = 1 y = 0 print("0") #création de widgets bouton_carre0 = tk.Button(racine, text="0", command=carre0) bouton_carre1 = tk.Button(racine, text="1") bouton_carre2 = tk.Button(racine, text="2") bouton_carre3 = tk.Button(rac...
82d3e7c695fbab62b222781240a1865cfe877151
Kaushalendra-the-real-1/Python-assignment
/Q2.py
779
4.125
4
# class Person: # def __init__(self): # print("Hello Reader ... ") # class Male(Person): # def get_gender(self): # print("I am from Male Class") # class Female(Person): # def get_gender(self): # print("I am from Female Class") # Obj = Female() # Obj.get_gender() # -----------------...
aa235b4ae0089d491d5defeea978a7c8d33b3640
TomCallegari/Python-Challenge
/combined_main.py
7,390
3.828125
4
import pandas as pd print(''' ''') print( '''Please choose a dataset for analysis: -------------------------------------------------- [1] for PyBank 'budget_data.csv' or [2] for PyPoll 'election_data.csv' ''' ) print('-'*50) print(''' ''') first_input = int(input('Se...
7da361d9b21c62037abb965c490ef2b30a266665
xynicole/Python-Course-Work
/Huang_Xinyi_Assignment5/Assignment5EX2/2.py
1,831
4.03125
4
''' Xinyi Huang (Nicole) xhuang78@binghamton.edu B58 Jia Yang Assignment #5(2) ''' ''' RESTATEMENT: this program is based on lucky sevens ask a user to input a money value OURPUT to monitor: rolls number money value INPUT to keyboard: money ''' import random #CONSTANTS SEVEN = 7 FOUR = 4 ONE = 1 # validation lo...
1b918e5f602dbf6500a09464a1e932bde3a82312
xynicole/Python-Course-Work
/lab/lab1BeforeCoding.py
1,057
3.828125
4
''' Rose Williams rosew@binghamton.edu B5_ Lab #1 ''' ''' ANALYSIS RESTATEMENT: Ask a user how many of each type of coin they have and output the total in dollars OUTPUT to monitor: total_dollars (float) - total amount of change in dollars INPUT from keyboard: quarter_count (int) dime_c...
dd78a214f6c3323713f6871391f6e0e9fd078cbc
xynicole/Python-Course-Work
/W12/ex5buttonDemo.py
809
3.875
4
from tkinter import * #from tkinter import messagebox ''' Demonstrates Button widget and info dialog box ''' class MyGUI: def __init__(self): # Create main window self.__main_window = Tk() # Create button with 'Click Me!' on face # doSomething method executed when clicked self.__my_...
a947f1570eadf213201881c0291514173b11e033
xynicole/Python-Course-Work
/W12/kiloConverterGUI2.py
4,519
4.125
4
import tkinter import kiloToMiles ''' Converts kilometers to miles Displays result in Label ''' class KiloConverterGUI: # --------------------------------------------------------------------------- # Constructor def __init__(self): # Create instance of MODe_l self.__kilo_val = kiloToMiles.K...
cf70fba4fc95f6f82cdf473c942fac876eb5324a
xynicole/Python-Course-Work
/lab/pi.py
1,123
3.9375
4
import random import math import turtle def main(): tyr = turtle.Turtle() wn = turtle.Screen() wn.setworldcoordinates(-2,-2,2,2) tyr.hideturtle() tyr.penup() tyr.goto(-1,-1) tyr.pendown() tyr.goto(-1,1) tyr.goto(1,1) tyr.goto(1,-1) tyr.goto(-1,-1) tyr.goto(-1,0) ...
e33a070506458cacbf4d52304982c491f2c9980d
xynicole/Python-Course-Work
/lab/435/ZeroDivideValue.py
595
4.25
4
def main(): print("This program will divide two numbers of your choosing for as long as you like\n") divisorStr = input("Input a divisor: ") while divisorStr: dividendStr = input("Input a dividend: ") try: divisor = int(divisorStr) dividend = int(dividendStr) print (dividend ...
881fc46faa626aaac3317dd9f65d3e8975b3f32e
xynicole/Python-Course-Work
/W12/kiloToMiles.py
1,148
4.25
4
''' Stores value in kilometers Retrieves value in kilometers or miles Displays value in kilometers and miles ''' class KiloToMiles: # Constructor def __init__(self, kilo = 0.0): self.__kilo = float(kilo) self.__KILO_TO_MILES = 0.6214 # Conversion constant # ----------------------------------...
52c4ef860f81460674b933a964cd84162cb69ab8
xynicole/Python-Course-Work
/W12/ex6quitButton.py
1,194
3.703125
4
import tkinter import tkinter.messagebox ''' Demonstrates Tk class destroy() method when Quit button clicked as well as info dialog box ''' class MyGUI: def __init__(self): # Create main window self.__main_window = tkinter.Tk() # Create button with 'Click Me!' on face # doSomething meth...
66a1cb0c5645c8b254243aac6ff976ed309a7adc
leyosu23/PythonAlgorithmStudy
/1_greedy&Implementation/0_exchange.py
336
3.671875
4
''' You are a clerk. There are 4 kinds of coins at the counter, which are 500,100,50,10. Find the minimum number of coins to be exchanged , assuming the guest is paying N. However, N is always a multiple of 10. ''' # O(n) n = 1260 count = 0 array = [500,100,50,10] for coin in array: count += n // coin n %= co...
a4db74268b564d6d62a4a20f022357d9e500510a
rbendev/jenkins_1.0
/flotte.py
4,581
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import random from navire import Navire class Flotte(): taille_grille = 9 nom = "flotte" nb_bateaux = 5 random_positions = [] position_safe = False noms_bateaux = ["porte_avion", "croiseur", "contre torpilleur", "sous-marin", "torpilleur", "cuira...
7b7a94cb9200528c466d4979c6cfd958a7a1b8f0
RSUBRAMANIAN1/data-structure
/code/linked list/linkedlist.py
1,138
3.921875
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def insertafternode(self, val): temp = self.head while(temp.data != val): temp = temp.next ne=input() tm...
6fe33376a1b69a905a4463a1b0795d267894bb1b
jasdeepbhalla/python-algorithms
/LCA.py
627
3.703125
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def lca(root, n1, n2): if root is None: return None if n1 < root.data and n2 < root.data: return lca(root.left, n1, n2) if n1 > root.data and n2 > root.data: return lca(root.right, n1, n2) return root d...
a62f3f806c8119ce2e13cdcd867ddbea0b04dc34
WilliamBlack99/cs-club-code-off
/alphabet.py
818
4.09375
4
def sort(in_string): # convert to list for ease of swapping characters in_string = list(in_string) # flag variable alphabetized = False while not alphabetized: alphabetized = True # will remain True if no values are swapped for i in range(len(in_string)): if i == 0: ...
d2ee40453faed04f6e08bacf0862fe762daca518
amarnadhreddymuvva/pythoncode
/armstrong.py
199
4.03125
4
num=int(input("eneter a number")) sum=0 temp=num while(temp>0): digit=temp%10 sum=sum+digit**3 temp=temp//10 if (num==sum): print(("armstrong number")) else: print("not")
240868c7fb1cf39a3db78c9c5912d7dc93c79e45
SamuelMontanez/Shopping_List
/shopping_list.py
2,127
4.1875
4
import os shopping_list = [] def clear_screen(): os.system("cls" if os.name == "nt" else "clear") def show_help(): clear_screen() print("What should we pick up at the store?") print(""" Enter 'DONE' to stop adding items. Enter 'HELP' for this help. Enter 'SHOW' to see your current list. Ente...
c158bda35f01e5fd9480c9b0519064d309a83047
Vibek/Back-up
/Human_intention/src/Train_model/jacobi_theta.py
565
3.703125
4
import numpy as np from scipy.linalg import solve '''____Define function____''' def jacobi(mu, var, x, k): D = np.diag(mu) R = mu - np.diagflat(D) for i in range(n): x = (var - np.dot(R,x))/ D print str(i).zfill(3), print(x) return x '''___Main function___''' mu = np.ar...
64fa14b4e6adfd945fdd346cc638656ca7b52640
kmorris0123/list_overlap_no_duplicates
/list_overlap_no_duplicate_nums.py
1,181
3.921875
4
import random import os play = True while play == True: list_one_size = random.randint(10,20) list_two_size = random.randint(10,20) list_one = [] list_two = [] common_list = [] x = range(1,list_one_size) for elem in x: num = random.randint(1,20) list_one.append(num) y = range(1,list_two_size) for ...
dbdf3bdd97752a32d7eb1eef8b0927a69276327c
gengkeye/orderbot
/apps/orderbot/utils.py
323
3.65625
4
# -*- coding: utf-8 -*- # import re def convert_str_to_list(text, seperator=' '): text_list = text.split(seperator) return list(filter(None, text_list)) def convert_str_to_num_list(text, seperator=' '): text_list = re.sub(r'\D', seperator, text).split(seperator) return list(filter(None, text_list)) ...
c99dcddf225321f2640e21f478676b1e7cb1ee2a
kristy0414/SF_crime_analysis
/SF_Crime_github.py
16,671
3.6875
4
# Databricks notebook source # MAGIC %md # MAGIC ## SF crime data analysis and modeling # COMMAND ---------- # MAGIC %md # MAGIC ##### In this notebook, you can learn how to use Spark SQL for big data analysis on SF crime data. (https://data.sfgov.org/Public-Safety/Police-Department-Incident-Reports-Historical-2003...
8ba4b76757a1073e7249d71a87a555c79dbee829
alcbeatriz/Pesquisa-Operacional
/REVISAO01/questao02.py
485
3.6875
4
listanum = [] maior = 0 menor = 0 media = 0 for c in range(0,10): listanum.append(int(input(f'Digite um valor para a {c} posição: '))) if c== 0: maior = menor = listanum[c] else: if listanum[c] >maior: maior = listanum[c] if listanum[c]<menor: menor = listanum...
1f643c74b3415e023798cc341e33ba98d1b18995
domzhaomathematics/Trees-4
/lca_binary_tree.py
2,059
4.03125
4
#RECURSIVE SOLUTION (post-order pattern) #Time complexity: O(n) #Space complexity: O(h) ''' Propagate from bottom if left is found and right is found (p,q). We have to traverse post-orderly to make sure we don't miss anything. This works because if they are not found in the left and right subtree respectively, it means...
637967ffadaf57dc97cbbcffff80829135e96f2a
mex3/fizmat-v
/helloworld.py
658
3.65625
4
#Решатель Квадратных Уравнений!!! # авторы: Матвеев и Орусов q = input() w = q.find('x^2') a = q[:w] if a == '': a = 1 else: a = int(a) d=max(q.find("2+"), q.find('2-')) z = max(q.find('x+'), q.find('x-')) b = q[d+2:z] if b == '': b = 1 else: b = int(b) e = q.find('=') c = int(q[z+2:e]) if d == ...
060370a41b9b3d0d207002ded9c38cd554cd5a6c
HemanandhiniGanesan/hello-world-eg
/BVRIT_Sample+programs.py
436
3.671875
4
# coding: utf-8 # In[2]: print ("hello world") # In[5]: a="hema" print ("hai",a) # In[6]: a=int(input("enter a number")) b=int(input("enter another number")) c=a+b print("Addition of two numbers:",c) # In[23]: import matplotlib.pyplot as plt var=['a','b','c'] var1=[5.5,6.2,6.3] plt.plot(var,var1) plt.ti...
d78d438330027e6b6078543100b5bb462e2e85f2
NazmiDere/11-HAFTA-OOP
/class battleships.py
8,258
3.90625
4
from random import randint,choice from time import sleep class battleships(): def __init__(self): self.table = [["--" for a in range(10)] for b in range(10)] self.all_coor = [[a, b] for a in range(10) for b in range(10)] self.time = False self.play() def horizontal(self, unit):...
ec8887453eaa5f263665f651338a470b4b8c5f7c
lura00/guess_the_number
/main.py
915
4.15625
4
from random import randint from game1 import number_game def show_menu(): print("\n===========================================") print("| Welcome |") print("| Do you want to play a game? |") print("| 1. Enter the number game |") print("| ...
4de0548a0dee06fe345de994055c5542903c5a03
cyril-wang/pythongames
/pagman/spritesandsounds2.py
7,460
3.859375
4
# using sounds and images # adding images with sprites # sprites - single two-dimensional image # sprites are drawn on top of the background # sprites are stored in image files on computer # pygame supports bmp, png, jpg, gif for images # and supports MIDI, WAV, MP3 for sound file # similar to collision de...
e8e73b3c67b961f756dfe9a7b5423e21ab7fe1ea
tamaramtz/958d7822-da73-4bbc-817f-fa79ac0778bc
/cashflows/main.py
1,059
3.578125
4
import fire import json from util import Cashflow from util import InvestmentProject class Main(object): #def present_value @staticmethod def describe_investment(filepath, hurdle_rate=None): investment_project = InvestmentProject.from_csv(filepath=filepath, hurdle_rate=hurdle_rate) descr...
278d9043abb7b40908cfe00e137a42ec3b4f5f41
Zojusane/pycharm
/dog.py
444
3.75
4
class Dog: def __init__(self, name, age, weight, length=5): """initialize the profile/attribute """ self.name = name self.age = age self.weight = weight self.length = length def sit(self): print(f"one {self.age} years old and {self.length}m long dog named {self.n...
a63b734707614e84d40d69fb1d98b2d97d8aff90
Ibrahim-Sakaama/OpenCV
/opencv/introOpenCV.py
984
3.96875
4
import cv2 #--------IMPORTANT--------------# #---------IF YOU HAVE AN IMAGE YOU'LL TREAT IT AS A MATRIX-------------# #----------THINK OF IT AS A MATRIX-------------------------------------# #imread() ==> pour lire une image A=cv2.imread("lena.jpg") #resize() ===> resize the image #A=cv2.resize(A,(200,200)) #demi i...
62f7d5df5a2e39a6df6b1c1e827ef29cd6fb6507
scardona7/nuevasTecnologias
/taller2/3.gradosC-gradosF.py
206
3.765625
4
#Digite los grados a Fahrenheit gradosC = int(input("Digites los Grados Centigrados: ")) formula = gradosC * (9/5) Fahrenheit = formula + 32 print(f"{gradosC} Centigrados son {Fahrenheit} Fahrenheit ")
b5f47944ad935dc8521a83a8563a333ea717e39b
scardona7/nuevasTecnologias
/taller2/4.lustro.py
171
3.71875
4
#Cantidad de segundos que tiene un Lustro segundos = int(input("Digite los Segundos: ")) lustro = (segundos) * 0.1577 print(f"{segundos} segundos son {lustro} Lustros")
13006b2b8a77c97f0f190a3228aa53452bbefc6d
scardona7/nuevasTecnologias
/taller1/ejercicio11.py
665
4.1875
4
""" 11) Algoritmo que nos diga si una persona puede acceder a cursar un ciclo formativo de grado superior o no. Para acceder a un grado superior, si se tiene un titulo de bachiller, en caso de no tenerlo, se puede acceder si hemos superado una prueba de acceso. """ titulo_bach = input("¿Tiene un titulo Bachiller?: (si...
c3ecdefab05f1ad587b863be8830ee7db9b9763b
Dave-weatherby/All-Projects
/Python-Projects/gradesCSVReader/gradesCSVReader.py
909
3.765625
4
from csv import reader def main(): # open connection to grade.csv file for reading infile = open("grades.csv", "r") # construct a CSVReader object to do the hard work csvReader = reader(infile) # this will be our 2D list! gradeData = [] # building my 2D list for row in csvReader: ...
3f70a5ee9ea439c77de3088b5626938c6f36c057
w78813967/python
/2/2.py
1,114
3.640625
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 10 14:13:04 2018 @author: user """ import mod a = mod.hello() print(a) def mydef(name): print('yo' , name) def mydef2(name): print('hi'+ name) def mydef3(name = 'noname'): print('hi', name) def redef(x): count = x * 10 return count mydef('ho') m...
8664ece33093d53bb4786a91fd25c2031de470aa
dshubham25/Algorithm-practice
/Arrays/ArrayMultiplication.py
724
3.71875
4
#Write a program that takes two arrays representing integers, and retums an integerWrite a program that takes two arrays representing integers, and retums an integer #representing their product def multiply(n1, n2): sign = -1 if (n1[0] < 0) ^ (n2[0] < 0) else 1 n1[0], n2[0] = abs(n1[0]), abs(n2[0]) result...
bb32fc280e0d7c86de56fd577fdd5f00dd5ab6ba
ico1036/Algorithm
/DataStructure/N01_Linked_list.py
892
4.0625
4
# Linked list # ex 3 nodes: 67 -> 30 -> 59 # Node: data , link(where is next) # -- Contents in Linked list # Head: First node # Tail: Last node # Number of nodes: ex 3 class Node: def __init__(sef,item): self.data = item self.next = None class LinkedList: def __init__(self): self.nodeCount = 0 self.h...
ec76011c2acc2385357706562219fcdbfb4091e0
GeorgeDonchev/war_card_game
/player.py
571
3.59375
4
class Player(): def __init__(self, name, hand): self.name = name self.hand = hand def play_card(self): drawn_card = self.hand.remove_card() print(f'{self.name} has placed {drawn_card}. ') print() return drawn_card def war(self): if len(se...
1adc325ba5f521539cc6f855d03bf7c96f5530b7
jchen49gsu/coding_practice
/leaf_similar_trees.py
661
3.796875
4
class TreeNode(object): def __init__(self,x): self.val = x self.left = None self.right = None class Solution(object): def leaf_similar_trees(self,t1,t2): res1 = [] res2 = [] self.find_leaf(t1,res1) self.find_leaf(t2,res2) return res1 == res2 def find_leaf(self,root,res): if root is None: re...
748af97e71f5a9de11069e055fde6189bda5898d
jchen49gsu/coding_practice
/429. N-ary Tree Level Order Traversal.py
751
3.71875
4
from collections import deque class TreeNode(object): def __init__(self,x,children): self.val = x self.children = children class Solution(object): """docstring for Solution""" def levelOderTraversal(self,root): queue = deque() res = [] if root is None: return res queue.append(root) while queue: ...
b41a5be37fad94bc8bcab7d9b73bbf5db114b7f6
jchen49gsu/coding_practice
/TT_missing_words.py
326
3.765625
4
class Solution(object): def missingWords(self,s,t): results = [] s = s.split() t = t.split() for i in xrange(len(s)): if s[i] not in t: results.append(s[i]) return results solution = Solution() s = "I am using HackerRank to improve programming" t = "am HackerRank to improve" print solution.missingWord...
a544b7b70aca23933437350ce1acbe9f42bc048a
anhvu2103/Python
/testcurrency.py
392
3.765625
4
h = open('test.txt', 'r') # Reading from the file content = h.readlines() # Varaible for storing the sum a = 0 # Iterating through the content # Of the file for line in content: for i in line: # Checking for the digit in # the string if i.isdigit() == Tr...
3cae92aaff622d16c388d184bc93968ce6773c8a
sainanda59/SID-TASK-2
/main.py
10,474
3.59375
4
from tkinter import * from PIL import ImageTk, Image from random import randint import sys import os global rock1, paper1, scissor1, spock1, lizard1, rock2, paper2, scissor2, spock2, lizard2 window = Tk() window.title("SID-TASK-2") window.config(bg='#3EDBF0') window.geometry('1990x900') welcome = Label(window, text="T...
42fdd37801f8ff633cf917b1acbb27572e087004
bushschool/IntroCS_MM
/SegregationModel.py
4,040
3.765625
4
import random def createOneRow(width): """ returns one row of zeros of width "width"... You should use this in your createBoard(width, height) function """ row = [] for col in range(width): row += [0] return row def createBoard(width, height): """ returns a 2d array with ...
9bd4c7a2ad369669220c7f600529857bb8e758d7
weimengpu/LING165_SP16
/ngrams.py
1,470
3.71875
4
import random # (Aux) Pad sentences. -> DONE! # (1) Store n-gram tokens. # (2) Randomly generates a sentence. def pad(n, line): # e.g. # n = 3, the coffee is good # -> <s> <s> the coffee is good </s> out = '<s> ' * (n - 1) out += line.strip() out += ' </s>' return out def update_ngram_...
91e4d05598cb27a723b4b4021557d9379d0f66fb
vijayrajanna/MachineLearning
/SVM/svm_author_id.py
1,252
3.578125
4
#!/usr/bin/python """ This is the code to accompany the Lesson 2 (SVM) mini-project. Use a SVM to identify emails from the Enron corpus by their authors: Sara has label 0 Chris has label 1 """ import sys from sklearn.svm import SVC from time import time sys.path.append("../tools/") from ema...
e6554cb7da5994038f046920b30f30e59d9ab0f2
loweffortwizard/Python-Activities
/function/PyFunctions.py
311
3.578125
4
''' defining function for importing. allow progs to import the def ''' #def for squaring a number. def squareNumber(num): answer = num * num return answer #def for multiplication of vars (not defined) num1 and num2. def multiply(num1, num2): answer = num1 * num2 return answer
09e30953c7b9fd71d2fd2725b1fd471df4fa47e6
loweffortwizard/Python-Activities
/function/Pyfunctions2importpyf.py
648
4.0625
4
''' from file - PyFunctions.py def squareNumber(num): answer = num * num return answer def multiply(num1, num2): answer = num1 * num2 return answer ''' #importing expernal functions. import PyFunctions #getting first number form user. num1 = int(input("Please enter the number you...
fc2aa8a79fe828d4d2c7c46524b194d7a347142c
loweffortwizard/Python-Activities
/exam/exammark.py
2,848
3.984375
4
import time import sys def wait(): time.sleep(1) #def to close prog def CloseProg(txt): txt.lower() if(txt!='y'): sys.exit() #prog to promp decision to end def UsersDecision(): userChoice = str(input("If you wish to use again, press \"Y\": ")) return userChoice def main(...
0adcd8285858ab6b5a8a22cb8d3de46619856757
eddyperea05/TT2
/punto10.py
262
3.84375
4
curso = {'Matemáticas': 6, 'Física': 4, 'Química': 5} totalcreditos = 0 for asignatura, credito in curso.items(): print(asignatura, 'tiene', credito, 'créditos') totalcreditos += credito print('Número total de créditos del curso: ', totalcreditos)
18a73e6c8cd9289ce5ba0fd1006dc2ce400e375f
LehlohonoloMopeli/level_0_coding_challenge
/task_3.py
350
4.1875
4
def hello(name): """ Description: Accepts the name of an individual and prints "Hello ..." where the ellipsis represents the name of the individual. type(output) : str """ if type(name) == str: result = print("Hello " + name + "!") return result else: ...
0373aee2574c6a156e4f71e41fc9e070f2ed9261
myusuf3/dom
/domainr/core.py
2,017
3.546875
4
""" Core functionality for Domainr. """ from argparse import ArgumentParser import requests import simplejson as json from termcolor import colored class Domain(object): """Main class for interacting with the domains API.""" def environment(self): """Parse any command line arguments.""" par...
302af6b0ab20d40f648327b77c11ee7766972d39
unfo/exercism-python
/word-count/word_count.py
276
3.75
4
def word_count(sentence): import re pat = re.compile('[^a-z0-9]+') words = [word for word in pat.split(sentence.lower()) if len(word) > 0] simple_freq = {} for word in words: simple_freq[word] = simple_freq[word] + 1 if word in simple_freq else 1 return simple_freq
aa013e73b5ad3308447c761634315efc67fe7ad4
unfo/exercism-python
/flatten-array/flatten_array.py
435
3.671875
4
import collections def _flatten(_in, depth): for item in _in: is_iterable = isinstance(item, collections.Iterable) is_string = isinstance(item, str) if is_iterable and not is_string: for _item in _flatten(item, depth+1): yield _item else: if ...
9d07cb1bbb8e780c193dbb19c6c0ef4b83cb7914
unfo/exercism-python
/bob/bob.py
723
4.25
4
def hey(sentence): """ Bob is a lackadaisical teenager. In conversation, his responses are very limited. Bob answers 'Sure.' if you ask him a question. He answers 'Whoa, chill out!' if you yell at him. He says 'Fine. Be that way!' if you address him without actually saying anything. He answers 'Whatever.' to any...
1276cd809f49a8752dd925822b93d94b3ae91362
unfo/exercism-python
/isogram/isogram.py
182
3.796875
4
def is_isogram(word): chars = list(word.lower()) chars.sort() prev = '' for char in chars: if char.isalpha(): if char == prev: return False prev = char return True
be97e8da8f3733fbb6c0a2e8abb0b950a11181c4
fitzcn/oojhs-code
/loops/printingThroughLoops.py
313
4.125
4
""" Below the first 12 numbers in the Fibonacci Sequence are declared in an array list (fibSeq). Part 1, Use a loop to print each of the 12 numbers. Part 2, use a loop to print each of the 12 numbers on the same line. """ fibSeq = ["1","1","2","3","5","8","13","21","34","55","89","144"] #part 1 #part 2
a48d3631cb3c12d91e9ebe2053e7c13fa21e5814
fitzcn/oojhs-code
/functions/functions1.py
310
4
4
def solveHW(r1,r2,dist): totalMPH = r1 + r2 time = dist/float(totalMPH) return time #print solveHW(550,650,2000) #print (solveHW(260,300,140)) def distance(r,t): d = r*t return d print (distance(5,10)) """ create a function called distance give it a rate and time return the distance traveled """
95c746698bc6bbadecdb49b57e7cc3aac5d387d5
fitzcn/oojhs-code
/apisamples/twitter/mytweets.py
3,754
3.59375
4
""" This code is from Thomas Sileo: http://thomassileo.com/blog/2013/01/25/using-twitter-rest-api-v1-dot-1-with-python/ A quick guide on how to retrieve your Twitter data with Python (from scripts/command line, without setting up a web server) and Twitter REST API v1.1. Requirements We will use requests along with ...
f946610b9b37543341bd0b8d27a809bd6102d383
BockeyE/LeetCodes
/leet/src/Q_1_10/Q7/Q7.py
961
3.609375
4
class Solution(object): def reverse(self, x): """ 执行用时 :20 ms, 在所有 Python 提交中击败了92.39%%的用户 内存消耗 :11.7 MB, 在所有 Python 提交中击败了25.38%的用户 """ if x >= 2147483647 or x <= (-2147483648): return 0 if x < 0: return -self.act(-x) else: ...