blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a23386136d97a6d9b58e540ad72feb99d1b5ec03
barreyo/smash-rl
/framework/games/ssbm/ssbm_observation.py
3,268
3.546875
4
"""Observation of a single frame.""" import numpy as np from framework.observation import Observation class Position(): def __init__(self, x, y): self.x = x self.y = y def __str__(self): return f"(x={self.x}, y={self.y})" class SSBMObservation(Observation): """Class denoting t...
3b0cf9b4245d17d9b34e873b8c2bb14d534d6058
yinyangguaiji/yygg-C1
/11-3.py
861
3.828125
4
class Employee(): def __init__(self,f_name,l_name,salary): self.f_name = f_name.title() self.l_name = l_name.title() self.salary = salary def give_raise(self,other=''): if other: self.salary += int(other) else: self.salary += 5000 ...
b33194554a1033cc0a2ab4f3c12338268f9adb50
Zarwlad/coursera_python_hse
/week7/task4.py
171
3.734375
4
nums = list(map(int, input().split())) setT = set() for num in nums: if setT.__contains__(num): print("YES") else: print("NO") setT.add(num)
3222d77b4e191dfb6bb0f1a41032e8b33484226d
Schnell5/InfSec
/Education/public_private_dec.py
2,768
3.921875
4
""" Public and Private decorators. Public decorator allows to get and set only attributes that were passed to them during decoration. Example: @public('data', 'size') - set and get operations will work only for 'data' and 'size' attributes. All other attributes (if any) are private and cannot be gotten and set. Priva...
6c61f28bc228d1a54de2eb29d0c10f399af88344
TenzinChemi/TENZIN_DSA
/sequence.py
207
3.796875
4
N=int(input()) number=1 l=1 while l<=N: for i in range(number,number+5): print(i,end=" ") print() for j in range(i+5,i,-1): print(j,end=" ") number=j+5 print() l+=2
209f2f73b3f9182f43bcfeb75a35bfcfab81b029
JohnHadish/hort503
/Assignment03/ex22.py
1,600
4.3125
4
print() #Prints out words + #adds / # divides - # subtracts * #multiplies % #remainder of division > < # greater than and less than, returns a boolina <= >= # Less to or equal and more than or equal = #assign a variable f"{variable}" # f string, allows for variables to be called in a string TRUE T # True, a boolian val...
d8af7a6b54458f438e4b36a571079a768c91372f
lfdyf20/Leetcode
/Word Break II.py
704
3.59375
4
import numpy as np class Solution(object): def wordBreak(self, s, wordDict): """ :type s: str :type wordDict: List[str] :rtype: List[str] """ return self.dp(s, wordDict, {}) def dp(self, s, wordDict, memo): if s in memo: return memo[s] if not s: return [] res = [] for word in wordDict: ...
e4ea6b0552af138845ee5f146808c73c8edc362a
cjwfuller/quantum-circuits
/quantum-circuits/quantum_gate.py
2,740
3.53125
4
import numpy as np import gate import register as r class QuantumGate(gate.Gate): """ super(<name of child class>, self) should be called before any methods in QuantumGate are called """ def __new__(cls, *args, **kwargs): if cls is QuantumGate: raise TypeError("quantum gate cl...
1fcc2e9a3b2a397f4587fcdf36c85d472b195f0f
kamesh051/django_tutorial-master
/python/testclass.py
197
3.859375
4
while True: name = input("enter user name:") if name == 'kamesh': continue password =input("Hi kamesh. enter your password:") if password =='sathya': break
20f54fff95aaf9e2f11adf2395dac23892594c1d
dairantzis/BBK_Introduction-to-Computer-Systems_2021
/Week 07/lists.py
1,216
4.375
4
# List initialisation list1 = [0 for i in range(15)] list2 = [1, 2, 3] list3 = ["a", "b", "c", "d", "b", "g"] print("List 1:",list1) print("List 2:",list2) print("List 3:",list3) list1[0:10] = [10] * 10 print("Ammended the first ten values of List 1:",list1) list1.extend(list3) print("Extended list1 with the it...
8a30c7f828aa62934505a830c255cede2c84306f
vincenttuan/yzu_python_20210414
/day05/List串列4.py
237
4.25
4
# List串列與Tuple元祖 a = [1, 2, 3, 4, 5] # 可修改 b = (1, 2, 3, 4, 5) # 不可修改 print(type(a), a) print(type(b), b) # 轉換 # list 轉 tuple a = tuple(a) print(type(a), a) # tuple 轉 list b = list(b) print(type(b), b)
468c7eaab970b396005712e6d8daa8cfa70097e0
best90/learn-python3
/packages/pillow/pil_resize.py
270
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from PIL import Image im = Image.open('test.jpg') w, h = im.size print('Original image size: %s x %s' % (w,h)) im.thumbnail((w//2, h//2)) print('Resize image to : %s x %s' % (w//2, h//2)) im.save('thumbnail.jpg', 'jpeg')
9aa42cc24649b875d611a054530f52b09bc88176
JohnlLiu/Sudoku_solver
/main.py
1,432
3.671875
4
#Sudoku board board = [ [7,8,0,4,0,0,1,2,0], [6,0,0,0,7,5,0,0,9], [0,0,0,6,0,1,0,7,8], [0,0,7,0,4,0,2,6,0], [0,0,1,0,5,0,9,3,0], [9,0,4,0,6,0,0,0,5], [0,7,0,3,0,0,0,1,2], [1,2,0,0,0,7,4,0,0], [0,4,9,2,0,6,0,0,7] ] def solve(board): #check if index is empty indx = is_empty(...
584378becf704c33ac7d33013c66d2af4291a3dd
MITZHANG/ThinkPython
/src/ch5/ex3/is_triangle.py
290
4.125
4
def is_triangle(a, b, c): if a>b+c or b>a+c or c>a+b: print('No') else: print('Yes') if __name__ == '__main__': print('请输入三角形的三条边长度:') a = int(input('a=')) b = int(input('b=')) c = int(input('c=')) is_triangle(a, b, c)
bb59539e7565e74414cf5d149c78b34e7ac288ed
ajj/ncnrcode
/bt5view/usans.py
2,969
3.625
4
#!/usr/bin/python #import Tkinter as Tk def numeric_compare(x, y): x = float(x) y = float(y) if x < y: return - 1 elif x == y: return 0 else: # x>y return 1 def getBT5DataFromFile(fileName): ''' Takes a filename and returns a dictionary of the detector values...
d5f6d3cc2927f5f67b3c25f92f5c5beec268b2d7
101vinayak/UGV
/obstacles.py
3,904
3.5
4
#!/usr/bin/python #This is the basic obstacle detection module import matplotlib.pyplot as plt import numpy as np import rospy from time import time import os from sensor_msgs.msg import LaserScan # This program includes the following hardcoded values: # Smallest cluster to detect as an object # Critical...
650de1ffd6971496e7eb1e53b0b94507c8080e0d
jayajr/EK128-Spring-15
/EK 128 Spring15/EK128-HW4/topfun.py
2,778
4.0625
4
#Uses ASCII value of character as comparison point. #E.g. '1'=49 'A'=65 'a'=97, #Therefore 1AaA1 is a hill, aA1Aa is a valley #An empty string is always False.n #A hill first strictly ascends then strictly descends. #A slope never ascends. #A valley first strictly descends then strictly ascends. def is_hill(se...
223388fbb982f44a47c0a3ed31f06a390cc09c1d
SokarWriter/pythonbrodas
/00 intro/tri.py
148
3.75
4
def triangulo (letter, size): angulo = "" for u in range (size): angulo = angulo + letter print (angulo) triangulo ("#", 5)
e8f14b50323f2dd69a415170b0fbf0911c10ca75
corbosiny/AI-Machine-learning
/MachineLearning/gaussian.py
6,610
3.546875
4
from __future__ import division import math import random import matplotlib.pyplot as plt class Gaussian(): eps = .00000001 def __init__(self, sigmaSquared, mu = 0, tolerance = .001): if not isinstance(mu, int) and not isinstance(mu, float): raise ValueError('Mu must be a numerical value...
20aa615db2e53372d9c76ded0a7444da54761673
StephanieTabosa/Mundo-02
/aula12desafio039.py
938
3.984375
4
# Faça um programa que leia o ano de nascimento de um jovem e informe, de acordo com sua idade: # Se ele ainda vai se alistar ao serviço militar; # Se é hora de se alistar; # Se já passou do tempo do alistamento. # Seu programa também deverá mostrar o tempo que falta ou que passou do prazo. from datetime import ...
9091b6fab13f9bca63f0db8143b83dc985b38798
zhuodannychen/Competitive-Programming
/Kattis/sortofsorting.py
241
3.578125
4
while True: n = int(input()) if n == 0: break names = [] for i in range(n): names.append(input()) names.sort(key=lambda x: (x[0], x[1])) for name in names: print(name) print()
c23aee1c7773377354345ada5d218dbcd835e306
aineko-macx/python
/ch10/10_1.py
275
3.9375
4
def nested_sum(list): sum = 0 for i in list: if type(i) == type([]): sum += nested_sum(i) else: sum += i return sum list = [1,2,3,4,5,6] list1 = [[1,2],3,4,[5,6]] print(nested_sum(list)) print(nested_sum(list1))
bc28a034bbad702c352988e8d59e633dc42c7468
avinashbhat/similarity-item-based
/engines.py
5,786
3.984375
4
import math from data import loadData, critics, loadNewData, load1mData # Takes 3 parameters, data, names of the items def euclid(itemData,ione,itwo): # Get what items are shared between two movies shared = {} total = 0 #print shared for person in itemData[ione]: if person in itemData[itwo]: shared[person] ...
1e9a6f3a48d1eea874d7be49ffdf0fa2f3418393
mxie622/LEETCODE_EASY
/easy_Question_solution.py
16,372
3.75
4
#https://leetcode.com/problems/rotate-array/description/ # Input: [-1,-100,3,99] and k = 2 # Output: [3,99,-1,-100] # Explanation: # rotate 1 steps to the right: [99,-1,-100,3] # rotate 2 steps to the right: [3,99,-1,-100] nums = [1,2,3,4,5,6,7] k = 3 class Solution: def rotate(self, nums, k): n = k ...
0af4fa88d5abdca2d8fa08a8919db3174888f277
maplekiru/python-ds-practice
/fs_04_reverse_vowels.py
494
4.28125
4
def reverse_vowels(s): """Reverse vowels in a string. Characters which re not vowels do not change position in string, but all vowels (y is not a vowel), should reverse their order. >>> reverse_vowels("Hello!") 'Holle!' >>> reverse_vowels("Tomatoes") 'Temotaos' >>> reverse_vowels("Re...
12a8896ff4c149d9746a5989cae56b92071e004b
lukdz/KursPython
/3lista/2zad.py
363
3.859375
4
import math def squareRoot(n): for j in range(0,n+2): sum = 0 for i in range(1,j+1): sum += (2*i-1) if sum > n: return j-1 return 0 for i in range(0,100): if squareRoot(i) != math.floor(math.sqrt(i)): print("number: ", i, "\tsquareRoot: ", squareRoo...
58200818ee0cf651ab2a9605cd815eca075dfb8f
RiyaPatricia/ShapeAI
/md5.py
123
3.578125
4
import hashlib hash=input("Enter Input:") last = hashlib.md5(hash.encode()) print("This is md5 Hash :",last.hexdigest())
af379974c07a29556d22a7d92a570e242677fa1f
Bjcurty/PycharmProjects
/Python-Refresher/01_variables/code.py
239
3.5625
4
# x = 15 # price = 9.99 # # discount = 0.2 # # result = price * (1-discount) # # print(result) # name = "Rolf" # # name = "Bob" # # print(name) # print(name * 2) # a = 25 # b = a # # print(a) # print(b) # # b = 17 # # print(a) # print(b)
c7cdfd7e8b74184f41bc96b138f450ae32671c26
PolopTechnology/Algorithms
/Python/Tortoise and Hare/TandH.py
244
3.859375
4
Tortoise = 0 Hare = 0 while True: Tortoise += 1 Hare += 2 if Tortoise == Hare: print(Tortoise) print(Hare) break if Tortoise == 10: Tortoise = 0 if Hare >= 10: Hare = 0
ad781de1b926fb941da1ec441d7f302820993d00
kokitsune/nichirin
/uEnkrypt.py
14,101
3.75
4
''' Project ala Pegeant: Encryption and Decryption. ''' from Tkinter import * class XOR: ''' For operation concerning XOR method. Attribute : A sequence of character. ''' def __init__(self, original='Default', rawkey='00000000', auto=False, filename='untitled'): self.root = Tk() ...
4a3738a60c7e4d7215d5f236a14ce3f001eff807
sharikgrg/week4.postcodes-to-txt-exercise
/function_postcodes.py
635
3.703125
4
import requests import json # request the data and using .json get the data in a dictionary. # prints out relevant data using the keys def importing_functions(postcode): request_postcode = requests.get('http://api.postcodes.io/postcodes/' + postcode) retrieving_data = request_postcode.json() postcode = jso...
e91b18ca4e4d8684d77d87f140a408fc9a45602c
RainbowTraveller/pythonPranks
/str_rev.py
650
4.21875
4
#!/usr/bin/python def reverse(mystr): #Get the length length = len(mystr); if(length > 0): str_list = list(mystr); begin = 0; end = length -1; while (begin < end): tmp = str_list[begin] str_list[begin] = str_list[end] str_list[end] = tmp ...
3aa4b30ab759164611a19a06a5625007cbac29ae
katebartnik/katepython
/Book/RepeatWhile/While1.py
144
3.71875
4
tab = [1, 2, 3, 4, 5] index = 0 x = 3 while index < len(tab): if x == tab[index]: print(index) break index = index +1
6d941c3a25b2946c94c1324912972dff4846c5a8
Chenbw0/motion_planning
/trajectory_plotting.py
639
3.546875
4
import region import matplotlib.pyplot as plt from numpy import * def PlotBubbles(bubbles): """ Plots bubbles given by the centers and radii found in bubbles. """ # bubbles is a list # bubbles[0] is a list of centers: [[x0,y0],[x1,y1],...,[xn,yn]] # bubbles[1] is a list of radii: [r0,r1,...,rn] fig = plt.gcf() ...
da864ddadea1fbb442db3f0a3c1ec807bcfbff4b
smiroshnikov/ebaPo4tu
/haim/lecture2/practice2.py
2,194
3.59375
4
long_element_list = [12.5, "abc", [4, 2, 53, "abnc"], {'one': 'The One', 'two': 'Two Files'}, (1, 'abc', 23, "A"), {'a', 'b', 'c'}, True] for e in long_element_list: print(type(e)) str = "hello" for ix, letter in enumerate(str): print(str[ix]) for l in str: print...
367f515017846773cd2c432c438e0bb34fb8e534
gyogy/haxx
/music_library/utils.py
1,588
3.515625
4
from random import shuffle from datetime import datetime def length_str_to_time_object(length): if len(length.split(':')) == 2: song_time = datetime.strptime(length, '%M:%S').time() else: song_time = datetime.strptime(length, '%H:%M:%S').time() return song_time def total_p_time(songs)...
35b8aaee7a202c475dbd0f6877763ce25d5d4bfd
RamazanAktas1/14.Hafta-Odevler
/14.hafta...1.odev.py
459
3.765625
4
def pageCount(): n = int(input()) p = int(input()) if n == p: print(n - p) elif (n - p) >= p : # starting from the beginning of the book if n % 2 == 0 : print(int(p / 2)) else: print(int(p / 2)) elif (n - p) <= p : # starting from the end of t...
ae298d8195b87febce3e3c1dbec86e4a53950db5
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_209/608.py
1,007
3.640625
4
#!/usr/bin/env python from math import pi from operator import itemgetter import itertools from multiset import * def get_area(pancakes): circle = pancakes[0][0] ** 2 * pi area = circle + 2 * pi * pancakes[0][0] * pancakes[0][1] for i in xrange(1, len(pancakes)): area += pancakes[i][0] ** 2 * pi + 2 * pi * panc...
bfd8ea9bbbf04a1269705b990a7a338f510f84db
xiamengyu/dirtysalt.github.io
/codes/contest/lintcode/first-unique-character-in-a-string.py
637
3.796875
4
#!/usr/bin/env python # coding:utf-8 # Copyright (C) dirlt class Solution: """ @param str: str: the given string @return: char: the first unique character in a given string """ def firstUniqChar(self, str): # Write your code here counter = 0 invalid = 0 for c in st...
209bcfff04625c5ca624bfede51f33ecf5a05ada
mafdezmoreno/HackerRank_Callenges
/Practice/ProblemSolving/SwapNodes_other.py
2,296
3.9375
4
#https://programs.programmingoneonone.com/2021/03/hackerrank-swap-nodes-algo-solution.html from collections import deque from types import new_class class Node: def __init__(self, index): self.left = None self.right = None self.index = index class BinarySearchTree: def __init__(self):...
3269fabe6eab3b76ba2a93c6e4a80c1730264d0b
ducnguyen166/aaa
/baikiemtra/bt4.py
140
3.71875
4
tong = 0 n = 1 print("hãy nhập vào số n: ") n = int(input()) for i in range(0, n + 1): tong += i print("Tổng là: ", tong)
d6acd9f6d97da62feb8140c2c11e22aafe010be4
PKStuff/task
/Practice_Algo/linked_list.py
2,219
4.21875
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def create(self, data): new_node = Node(data) if self.head == None: self.head = new_node return e...
d9eb46e18c17927192280d1b3cb7579972644573
anjolinea/Python-for-Everybody
/ch11ex1.py
242
3.96875
4
import re count = 0 hand = open("mbox-short.txt") regex = input("Enter a regular expression >> ") for line in hand: regex_occurences = re.findall(regex, line) for occurence in regex_occurences: count += 1 print(count, regex)
9a953a2c5cd0c6604e46560d31b23dedcdee5537
srihariprasad-r/workable-code
/codeforces/P58A_Chatroom.py
354
3.828125
4
inp_str = str(input()) valid_str = "hello" concat_str = "" pos_dict = {valid_str[i]: valid_str.count(valid_str[i]) for i in range(len(valid_str))} for i in inp_str: if i in valid_str and (i in pos_dict): if pos_dict[i] > concat_str.count(i): concat_str += i if concat_str == valid_str: pr...
1a2dccc84a82c15ccd1ba6664a984dc70240a598
MuhammadAbbasi/DSA_Semester3
/Assignments/Assignment 2/All questions/Q5.py
251
3.65625
4
'''What parameters should be sent to the range constructor,to produce a range with values 8, 6, 4, 2, 0,−2,−4,−6,−8? ''' range( 8, -9, -2 ) # The code below is for testing purpose only z = range( 8, -9, -2 ) for a in z: print(a)
6ec22cb0a5c75c6996aced9bdd59fc2e02dfe591
gitly110/python_exc
/python从入门到实践/data_download16/highs_lows.py
2,084
3.515625
4
import csv from datetime import datetime from matplotlib import pyplot as plt # 从文件获取最高、最低气温 def read_csv(filename): # filename = 'sitka_weather_2014.csv' with open(filename) as f: reader = csv.reader(f) hearder_row = next(reader) # # 查看文件头每个元素的索引及其值 # for index, column_header ...
daff0f4fb75eb03820a742adb23e82d59879aaab
robingreig/raspi-git
/Python3/PWM/pwm-led01.py
1,544
3.8125
4
# MBTechWorks.com 2016 # Pulse Width Modulation (PWM) demo to cycle brightness of an LED import RPi.GPIO as GPIO # Import the GPIO library. import time # Import time library GPIO.setmode(GPIO.BOARD) # Set Pi to use pin number when referencing GPIO pins. # Can use GPIO.setm...
a237d141c07d76a3e778504dbd573af19a3e8342
karan-jagtap/udemy-python-course
/Section-5/lists.py
377
4.0625
4
x = 'abcd' print(f'x: {x}') y = ['a', 'b', 'c', 'd'] print(f'y: {y}') y = ['a', 5, 'b', 5.7, 'c', 'd'] print(f'y: {y}') print(len(y)) print(y[2]) print(y[-3]) # delete last item print(y.pop()) print(y) # add new item in the end y.append(9) print(y) # remove item y.remove('c') print(y) # all methods of list print(...
d9834f356be1d2269b853ff5941c8624e0c19282
KristianHolme/theHardWay
/ex12.py
182
4.03125
4
age = input("What is your age?") height = input("How tall are you?") weight = input("How much do you Weigh?") print(f"So, you are {age} old, {height} tall, and you weigh {weight}.")
5770949912edf8bb7ba90a9a8b5cea38601da372
alizenalabdeen/python1
/functons.py
200
3.625
4
def mainas (number1,number2): print (int(number1)-int (number2)) frst = input("frist number : ") second = input ("second number : ") print(".............................") mainas(frst,second)
99359b2e151c66d931f86536c30fd78d1023a41d
taison2000/Python
/Examples/Change_Stuff_In_Other_file/file_2.py
1,286
3.625
4
#!C:\Python34\python.exe #!/Python34/python #!/usr/bin/python # -*- coding: utf-8 -*- ## ---------------------------------------------------------------------------- """ Python ~~~~~~~~~~~~~~~~~~~~~~ """ import os import time import file_1 # ---------------------------------------------------------------------...
af0c3f9fdd00913835810e26fc7d8470bae8d644
xpansong/learn-python
/对象(2)/6. 特殊属性.py
931
4.125
4
print('--------------特殊方法和特殊属性------------------') class A(object): pass class B: pass class C(A,B): def __init__(self,name): self.name=name class D(A): pass x=C('张三') print('------------------获得对象绑定的所有属性和方法------------------------') print(x.__dir__()) #有特定参数,返回对象的所有有效的属性名 print(dir(x)) print...
af0b1a032ad0bfcb71362334c0fb5e210f30231e
msksh/pythonBasic2
/practice.py
47,744
4.46875
4
''' station = "인천공항" print(station+"행 열차가 들어오고있습니다.") ''' ''' #연산자 print(1+1)#2 print(3-1)#2 print(2*5)#10 print(6/3)#2 print(2**3) #2^3=8 print(5%3) #나머지구하기 2 print(10%3) #1 print(5//3) #1 print(10//3) #3 print( 10 > 3) #True print(4 >= 7)#False print(10 < 3) #False print(5 <= 5) #True print(3 ...
6d81fdf2566623fbd25defcdc4d1030bf528afc2
Stephen-Kamau/july_work
/form_entry_GUI_app/form_entry.py
833
3.5
4
import tkinter as tk from tkinter import ttk app = tk.Tk() class LabelInput(tk.Frame): '''A frame containing labels and input''' def __init__(self,label='',input_class=ttk.Entry,input_var=None,input_args=None,label_args=None,**kwargs): super.__init__(parent,**kwargs) input_args=input_args or {} ...
b96b2965229dc167df01f0e272d221a9a9b0f5fb
zaeyon/algorithm-source-code
/20201121/baekjoon5543.py
312
3.8125
4
import sys minHam = 0 minBev = 0 for i in range(3): price = int(input()) if(i == 0): minHam = price if minHam > price: minHam = price for i in range(2): price2 = int(input()) if(i == 0): minBev = price2 if minBev > price2: minBev = price2 print(minHam+minBev-50)
51cdf72aa32c23835e67dfd7fa862c5fb9bb6d17
MustafaSaber/Genetic-Algorithms
/fuzzy_logic/variable.py
254
3.515625
4
class Variable: def __init__(self, name, value, sets=[]): self.name = name self.value = value self.sets = sets def __str__(self): return '(' + str(self.name) + ', ' + str(self.value) + ', ' + str(self.sets) + ')'
a742e98c86e6c38f4e5b0c2089f652d9e215c6a5
NikhilGupta1997/Machine_Learning_Models
/Linear Regression/Linear_Regression.py
4,266
3.5
4
''' ================= Linear Regression ================= ''' from mpl_toolkits.mplot3d import axes3d import numpy as np import matplotlib.pyplot as plt import math from matplotlib import cm from mpl_toolkits.mplot3d import Axes3D from matplotlib.ticker import LinearLocator, FormatStrFormatter import matplotlib.anima...
6de148ca131198ec2431d117b51ccde8bf781efa
CescWang1991/LeetCode-Python
/simulation/MerchantsBank/SelectNumbersInterval.py
1,520
3.5
4
# 挑选代表 # 我们有很多区域,每个区域都是从a到b的闭区间,现在我们要从每个区间中挑选至少2个数,那么最少挑选多少个? # 输入描述: # 第一行是N(N<10000),表示有N个区间,之间可以重复 # 然后每一行是ai,bi,持续N行,表示现在区间。均小于100000 # 输出描述: # 输出一个数,代表最少选取数量。 # 解题思路: # 贪心,按右端点排序(左端点一样可以),如果每个区间至少一个点,那么这个点一定是在右端点,这样子可以让后续的区间更容 # 易覆盖到这个点,从而减少选点的数量;同理,如果每个区间至少两个点,那个这个两个点一定也在右端点和右端点前一个点,原因是一样的。 # 答案正确:恭喜!您提交的程序通过...
6cef77bacbd50915b59e5109f588d3de0414c57a
bn-d/project_euler
/000-100/025/main.py
295
3.5
4
#!/usr/bin/env python3 import math if __name__ == '__main__': digit = 1000 cur = 1 pre = 1 indx = 2 while True: if math.log10(cur) >= digit - 1: print(indx) break cur = cur + pre pre = cur - pre indx += 1
e9674b28788a86b19b31d580205339517b9752d6
gabriellaec/desoft-analise-exercicios
/backup/user_009/ch27_2019_08_17_02_55_04_532945.py
66
3.546875
4
c = int(input('c: ')) a = int(input('a: ')) print(c*a*10*365/1440)
8a824549e12cf18fb59da9ab426bbbc6462c8167
qionouwens/TicTacToe
/main.py
3,207
4.09375
4
from Board_class import Board from ai import * def player_turn(): print("What do you play?") has_played = False while not has_played: # TODO implement try_except block if user does not input an integer play_cell = int(input()) if playing_board.turn(play_cell-1): has_pla...
a1065b26c6cf47a1d8c8e401c8b1cc737e94269f
mohammedkadiri/Python-Exercises
/Classes/exercise1.py
320
3.828125
4
class Person: def __init__(self, firstname, age): self.firstname = firstname self.age = age joe = Person("joe", 20) #use the setattr method to set the lastname without hardcoding setattr(joe, "lastname", "walsh") firstname = getattr(joe, "firstname", None) print(firstname + " " + joe.lastname)
3f2abf820ce17b90d0db721cf08878ec8fd787b1
shiki7/Atcoder
/ABC144/D.py
231
3.640625
4
import math a, b, x = map(int, input().split()) v = a*a*b # 台形 if v/2 < x: c = (v - x) * 2 / (a ** 2) print(math.atan2(c, a)/math.pi*180) # 三角形 else: c = x * 2 / (a*b) print(math.atan2(b, c)/math.pi*180)
add7c8902274e701cc5e732663febdad91d1ac50
gabriellaec/desoft-analise-exercicios
/backup/user_057/ch84_2020_06_21_01_35_43_046531.py
248
3.703125
4
def inverte_dicionario(dic): dic2 = {} for nome in dic.keys(): idade = dic[nome] if nome not in dic2.vallues(): dic2[idade] = [nome] else: dic2[idade].append(nome) return dic2
0131d16957478af7137dee164f7edea6b8db1be1
yuishizhume/noname
/day2.2.py
6,061
3.796875
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 19 20:29:29 2019 @author: Administrator """ #高级特性 #掌握了Python的数据类型、语句和函数,基本上就可以编写出很多有用的程序了。 #构造一个1, 3, 5, 7, ..., 99的列表 L = [] n = 1 while n <= 99: L.append(n) n = n + 2 #在Python中,代码不是越多越好,而是越少越好 #代码不是越复杂越好,而是越简单越好。 #切片 L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Ja...
778482417c7b4a03c51032515ed2a3cd794381d5
l-rushton/Financial-Asset-Beta-Tool
/BETA STONK CALCULATOR/EXCELVARCOVAR.py
764
3.734375
4
#EXCEL VARIANCE AND COVARIANCE CALCULATOR def variance(timeSeries): mean = 0 sum = 0 for i in range(len(timeSeries)): mean += timeSeries[i] mean = mean/len(timeSeries) for i in range(len(timeSeries)): sum += (timeSeries[i] - mean)*(timeSeries[i] - mean) return su...
b0a8b4a70b61381d0af0bb20adf6d4e7feb79a98
da-ferreira/uri-online-judge
/uri/1962.py
266
3.5
4
casos = int(input()) for i in range(casos): ano = int(input()) if ano == 2015: print('1 A.C.') else: if ano > 2015: print(f'{(ano + 1) - 2015} A.C.') else: print(f'{2015 - ano} D.C.')
4cc834b7d2342c01a848c427a2f8c133da0df55a
Vekselsvip/HW-Python
/homework5.9.py
162
3.5
4
List = [] for i in range(2, 100): y = 2 while y < i: if i % y == 0: break y += 1 else: List.append(i) print(List)
70365b712c0a3b386020229fc86d3b7ffe9ce6da
saikiran03/competitive
/CodeChef/Python/Fit_squares_in_triangle.py
251
3.609375
4
t = input() while(t): t -= 1 base = input() squares = 0 layer = 1 while ((base-(2*layer))/2 > 0) : number_of_squares = (base - 2*layer)/2 squares += number_of_squares layer += 1 print squares
6c35b63ec64fdae860e39a0f668de231d75fdb51
ddbff9/polygon-area-calculator
/shape_calculator.py
2,057
3.78125
4
class Rectangle: def __init__(self, width, height): self.width = width self.height = height pass def __str__(self): width = self.width height = self.height output = self.__class__.__name__ + f"(width={width}, height={height})" return output def set_height(self, height): sel...
76afe763e624a2026f4460a09eb527cf5996eeef
DoubleDPro/practice
/numbers/task_2.py
481
4.03125
4
''' С клавиатуры вводят три числа. Вывести в консоль произведение этих чисел. ''' first_number = int(input('Введите первое число\n')) second_number = int(input('Введите второе число\n')) third_number = int(input('Введите третье число\n')) mult = (first_number * second_number * third_number) print('Произведение чисел...
51bd0ac32719fd3f83862f6cd0b41cc5e131ca5b
saiarvind1997/noob
/task_2.py
269
3.6875
4
c=ord('a') d=ord('z')+1 while c<d: i=1 while i<10: print'{}{}'.format(chr(c),i) i+=1 c+=1 #alternate code with for loops: """ x= ord("a") y= ord("z")+1 for c in range(x,y): for i in range(1,10): print "{}{}".format(chr(c),i) """
92d17e9be140576aebada1d86b77bd50f3a0e96c
diegopnh/AulaPy2
/Aula 14/Ex060.py
155
3.828125
4
a = int(input('Insira o fatorial: ')) result = 1 n = 1 while n <= a: result = result*n n = n + 1 print('O fatorial de {} é {}'.format(a,result))
1beb6289f76f6709c8a8f25a1540b0e8c226e27d
DavidFontalba/DAW-Python
/secuenciales/20dinero.py
1,096
3.75
4
# Programa para decirte el total de euros y céntimos que tienes cuándo le insertes la cantidad de monedas # Autor: David Galván Fontalba # Fecha: 12/10/2019 # # Algoritmo # Pido monedas # Calculo # total en centimos <- 2e*200 + 1e*100 + 50c*50 + 20c*20 + 10c*10 # separo euros y centimos # Muestro el resultado print("...
5dd5444c4787c2d6f58c0b699549c465612ed848
rhythm1011/MNIST-Data-
/DataReader.py
1,443
3.796875
4
import tensorflow as tf """This script implements the functions for reading data. """ def load_data(): """Load the MNIST dataset and normalize pixel values into [0,1]. Returns: x_train: An array of shape [60000, 784]. y_train: An array of shape [60000,]. x_test: An array of shape [10000, 784]. y_test: An a...
d9e7b8334a0c1458dc75bb9abe75fc3822dda206
izaycarter/6.1.1-number-guesser
/level_3.py
538
4.09375
4
from random import randint number_of_guess = 0 number = int(input("pick a number between 1 and 100.. bet i can guess it: ")) high = 100 low = 1 guess = (high + low) // 2 while number_of_guess < 5: number_of_guess += 1 print(guess) if guess < number: low = guess guess = randint(low,high) ...
3f1538748018ab8f29c43cf13491afc20cb26120
abawchen/leetcode
/solutions/054_spiral_matrix.py
1,515
3.859375
4
# Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. # For example, # Given the following matrix: # [ # [ 1, 2, 3 ], # [ 4, 5, 6 ], # [ 7, 8, 9 ] # ] # You should return [1,2,3,6,9,8,7,4,5]. class Solution: # @param {integer[][]} matrix # @return {i...
ca0b52d189b285e83c3583b4c81d1f29a7d8b2bc
GGbits/CryptoPals
/Set2/challenge11.py
2,174
3.6875
4
# Python Version: 3.5 # Creator - GGbits # Set: 2 # Challenge: 11 # https://cryptopals.com/sets/2/challenges/11 # # Description: # Now that you have ECB and CBC working: # Write a function to generate a random AES key; that's just 16 random bytes. # # Write a function that encrypts data under an unknown key --- that i...
9c7bd2696e31ca4818f932bbe0c201009819aede
Ashishkapil/python-runs
/numbers-with-a-sum/sum-array.py
479
3.578125
4
def main(): alist = [1, 2, 4, 7, 11, 15] start = 0 end = len(alist) - 1 num = 28 while (1): if start >= end: print 'no such numbers found' break asum = alist[start] + alist[end] if asum == num: print 'the two numbers are: %d and %d'%(alis...
bddc145f009cbbb528ebdd1644b833a12b334ca4
dagute/Coding_Interview
/Python/Find pair that sums up to k/sumpair1.py
357
3.609375
4
# Find pair that sums up to k # By checking all pairs (brute force solution): # arr = [4, 1, 5, 7, 2] # k = 3 # Time complexity: O(n²) # Space complexity: O(1) def findPair(arr, k): for i in range(len(arr)): for j in range(i+1, len(arr)): if arr[i] + arr[j] == k: print(str(arr[i]), str(arr[j])) ...
472cbc52aebe4eb7cf5c94eb09b1862d1a221bfc
harshad90/pythonHardWay
/Exercise11.py
541
3.921875
4
print ("How old are you", end = ' ') age = input() print ("How tall are you", end =' ') height = input() print ("How much do you weigh", end = ' ') weight = input() print (f"So you are {age} year old and {height} cm tall and weigh about {weight} kg") print ("Which Car do you like?", end = '') car = input() print ("...
b2ca003ff94c3ea9d532e11382537c257d0ae22e
fabricio123/lista2python
/Questao3.py
189
3.96875
4
letra = str(input('digite a letra')) F = 'F' M = 'M' if letra == 'F': print('sexo feminino') if letra == 'M': print('sexo masculino') if letra != F and M: print('sexo inválido')
6cbf38a2b3a543ed21e8597e245c97d9c801f4a8
Octember/Euler
/python/29.py
892
3.5
4
# Consider all integer combinations of ab for 2 <= a <= 5 and 2 <= b <= 5: # 2^2=4, 2^3=8, 2^4=16, 2^5=32 # 3^2=9, 3^3=27, 3^4=81, 3^5=243 # 4^2=16, 4^3=64, 4^4=256, 4^5=1024 # 5^2=25, 5^3=125, 5^4=625, 5^5=3125 # If they are then placed in numerical order, with any repeats removed, # we get the following sequence ...
e352c14794332033d37353d382b041b20c10da9f
Diegooualexandre/PycharmProjects
/pythonCaelum/adivinhacao.py
405
3.84375
4
print('*'*24) print(f'*'*2+'Jogos de adivinhação'+'*'*2) print('*'*24) secret_number = 42 c = int(input('Write number: ')) print(f'Number submitted: {c}') if c == secret_number: print('Congratulations! You discover the number.') elif c > secret_number: print('Failed. Appointment is bigger than secret number') e...
c68fd7d86a9d42585bf2baf50f2ecbdc061c840e
siliconcortex/curiousweb
/electronics/floyd.py
26,383
3.859375
4
import random class template: def __init__(self): choice_a = '' choice_b = '' choice_c = '' choice_d = '' choices = [choice_a, choice_b, choice_c, choice_d] random.shuffle(choices) self.question = f"""""" self.answer = f"""A. {choices[0]} B. {choices[1]} C. {choices[2]} D. {choices[3]}""" ...
4e94afe25c884f25ee35c4ca286872d881b8843f
19-shubho/forsk-coding-shool-challenges
/day46.py
1,523
3.609375
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd dataset = pd.read_csv('bluegills.csv') feat = dataset.iloc[:, 0:1].values lab = dataset.iloc[:, 1].values #fitting linear regression --> from sklearn.linear_model import LinearRegression linObj = LinearRegression() linObj.fit(feat, lab)...
c5286553e52e0aa0e3e353ba85eb3584244b2fca
AndrianovaVarvara/algorithms_and_data_structures
/TASK/Хирьянов 16 лекция множества и словари/zzz.py
548
3.546875
4
import sys import pygame pygame.init() width = 500 height = 500 screen = pygame.display.set_mode((width, height)) pygame.display.set_caption('YAHOOOO') clock = pygame.time.Clock() x = 30 y = 30 vx = 50 vy = 50 while True: dt = clock.tick(50) / 1000.0 for event in pygame.event.get(): if event.type ...
633edc68b25a2b0aee5aaf76d82a17fbb8ef6c26
sendurr/spring-grading
/submission - Homework1/RYAN W BARRS_2234_assignsubmission_file_homework1/homework1/index_nested_list.py
245
3.640625
4
q = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h']] print "1)", q[0][0] print "2)", q[1] print "3)", q[2][1] print "4)", q[1][0] print "5) q[-1][-2] has value 'g' because it is the second value in the first list when counting from the right"
fd2b3797ef9c1f48ffd50715b78ab107d6076d7e
reichlj/PythonBsp
/Schulung/py01_einführung/f151_list_param.py
650
3.609375
4
def s(liste): print('sa:',id(liste)) liste += [47,11] print('sa:',liste) print('sb:',id(liste)) def s1(liste): print('s1a:',id(liste)) liste = liste + [47,11] print('s1a:',liste) print('s1b:',id(liste)) print('**** in-place ****') fib=[0,1,1,2,3] print('m :',fib) print('m :...
378ec2ee49c706f1fe4c12e26a0e7fdbef85dded
rwspicer/csv_utilities
/utility_test.py
812
3.65625
4
""" ross spicer 2014/08/05 this is an example of how the new utility_base class works """ import csv_lib.utility as util class my_utility(util.utility_base): def __init__(self, title , r_args, o_args, help): super(my_utility, self).__init__(title , r_args,("--b",), help) self.title = " my...
6c3651cdd10378be5597e8ec87ff2701d9c9ca37
tbobm/99problems
/python/lists/P23.py
392
3.609375
4
# encoding: utf-8 # 1.23 (**) Extract a given number of randomly selected elements from a list. # The selected items shall be put into a result list. # Example: # ?- rnd_select([a,b,c,d,e,f,g,h],3,L). # L = [e,d,a] import random def func(data, to_pop): res = [] for _ in xrange(to_pop): ...
32d552c85b096a6e4df239a61fa4be44115d5cbc
mutemibiochemistry/Biopython
/Assignment-1/question1.py
354
4.28125
4
#1converts temparature from degree celcius to degree fahrenheit def convert_celcius_to_fahrenheit(degree): #function fahrenheit = 1.8*degree + 32 #conversion formula print float(degree),"Celcius ->",fahrenheit, "Fahrenheit" #send output test1=convert_celcius_to_fahrenheit(50.0) #test example test2=co...
d850485556203c065a67246d18ca4019294427c9
LouisCaixuran/StudyMemo
/problem/migong2.py
790
3.578125
4
import copy source=[ [0,0,1,0,1], [1,0,1,0,1], [0,0,0,1,0], [0,1,0,0,0], [0,0,0,1,0]] class Migong(object): def __init__(self,source): self.source=copy.deepcopy(source) self.success=0 def move(self,x,y): if x==4 and y==4: print ("success") self.success=1 import pdb pdb.set_...
b9eee44a6f11f4168f634a14e8b356a92a216fe3
stonecyan/Algorithm-Practice
/EPI/DutchNationalFlag.py
477
3.53125
4
def dutchFlagPartition(list,pivot): smaller = 0 equal = 0 larger = len(list)-1 while equal<larger: if list[equal]<pivot: list[smaller], list[equal] = list[equal], list[smaller] smaller+=1 equal+=1 elif list[equal]==pivot: equal+=1 elif list[equal]>pivot: list[larger], ...
c9ecafb80fa4f636ce171bf87dd3817b8d9a86f1
fifa007/Leetcode
/test/test_atoi.py
745
3.515625
4
#!/usr/bin/env python2.7 ''' unit tests for atoi ''' import unittest import src.atoi class atoi_test(unittest.TestCase): sol = src.atoi.Solution() def test1(self): self.failUnless(self.sol.convert_str_to_int('1234') == 1234) def test2(self): self.failUnless(self.sol.convert_str_to_in...
52f7e1238efb0668d95ea965738969891d099d7a
dakshitsoni/J.A.R.V.I.S
/python jarvis.py
8,454
3.578125
4
# Commands of J.A.R.V.I.S are - # It can greet us when it is good morning it says morning and when it is afternoon it will say afternoon and when it is night it will say night. # It can take our commands and when we do not say anything it does not takes our commands. # It can turn on camera when we our in any meet...
aee36074db4ae9e22950597e4e9b3160ccab94cb
hrithikkothari1234/Sem-4
/Python/exp2/remove_puncs.py
193
4.3125
4
""" To remove punctuations from a string """ user_str = input("Enter string to remove puncs") import string for c in string.punctuation: user_str = user_str.replace(c,"") print(user_str)
3a12122d4e65fd58d473244fe50a9de3a1339b27
austinjhunt/dailycodingproblem
/dcp2.py
1,924
4.125
4
#This problem was asked by Uber. #Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. #For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our in...
b9f88338e6f1344a2fd073a2946e304459166dca
meysamrsl/python-homwork-calculator-asistant
/mashghe shab.py
3,219
4.21875
4
num1 = float(input('Enter number one\n')) num2 = float(input('Enter number two\n')) opration = input('''What do you want to do:\n + addition\n - subtraction * multiplication / division\n ''') def calculator(addition): if opration == '+': print(f'addition is: {addition}') addition = num1 + num2 calculator(...
8505454b5478ae3ddaa8196c0a3f70e1e1575403
leomcp/HackerRank_Solutions
/Problem Solving/Algorithms/Implementation/beautiful_days_at_the_movies.py
407
3.59375
4
def _get_reverse(num): rev = 0 while(num > 0): a = num % 10 rev = rev * 10 + a num = num / 10 return rev def beautifulDays(i, j, k): noOfBDs = 0 for day in range(i, j+1): revday = _get_reverse(day) diff = abs(revday - day) if (diff % k) == 0: ...