blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
d782dccee3324eeac1bb3b23f25dd958f2a063c4
bollustrado/tequila-hipchat
/calc_module_hipchat.py
1,094
3.828125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import re def solve(sub_input): # input is a list of tokens (token is a number or operator) tokens = (re.sub("[^0-9,*+-//]", "", sub_input)) #rez=calc.solve(re.sub("[^0-9,*+-//]", "", data)) pattern = re.compile("^([0-9]+)*$") if pattern.match(tokens): return "go f...
81a41c2f9e08bb3ef3e43d3fca7ce99aab820f0e
Sravanipetluri/Python-Lab-Cycle
/Replace duplicate occurance.py
458
3.96875
4
test_string = 'James is good in Science , Science is James favourite subject. ' print("The original string is : " + str(test_string)) repl_dict = {'James' : 'his', 'Science' : 'it' } test_list = test_string.split(' ') res = ' '.join([repl_dict.get(val) if val in repl_dict.keys() and test_list.index(val) != index ...
97a727f755fb0c925f877c7011e7772b7378a2e7
wilsonbow/Project-Euler
/problem16.py
311
3.921875
4
""" Project Euler Problem 16 Find sum of digits in 2**1000 Program produces correct answer """ POWER = 1000 number = 1 for power in range(POWER): number = number * 2 number_str = str(number) number_sum = 0 for digit in range(len(number_str)): number_sum += int(number_str[digit]) print(number_sum)
99bcb162f8b0ef422a887ae5796597235db711c9
wilsonbow/Project-Euler
/problem13.py
338
3.84375
4
""" Project Euler Problem 13 Find first ten digits of sum of heaps of numbers Program produces correct answer """ file = open('big_number_13.txt', 'r') num_sum = 0 for line in file: line = line.strip() num_sum += int(line) num_sum_str = str(num_sum) print("The first ten numbers of the sum are: {}".format(n...
ebe98be6885f66e602edd6e80341e7c0b7b3ba9c
pythonbtes/nandini
/btes/tkinter_example.py
151
3.921875
4
#to create a label and display message ''' import tkinter as tk root=tk.Tk() label=tk.Label(root,text="hello") label.pack() root.mainloop()'''
61f0240424ab5cc7d8e0b708278bfdf6b78de97b
jayuan1717/password-retry
/password.py
542
3.53125
4
password = 'a123456' timep = 3 import time while True: entre = input('please entre the password: ') if entre == password: time.sleep(1.5) print('You have logged in') break else: time.sleep(1) print('incorrect password') timep = timep - 1 if timep == 0:...
1df218be5a5e105a13eed8c63f469f4acddda353
AnthonySimmons/EulerProject
/ProjectEuler/ProjectEuler/Problems/Problem20.py
607
4.15625
4
#n! means n (n ? 1) ... 3 2 1 #For example, 10! = 10 9 ... 3 2 1 = 3628800, #and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. #Find the sum of the digits in the number 100! def Factorial(num): fact = num for i in reversed(range(1, num)): fact *= i return fac...
188d9bb0ce9e94064337061d10485754284a03d0
AnthonySimmons/EulerProject
/ProjectEuler/ProjectEuler/Problems/Problem2.py
739
4.03125
4
#Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: #1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... #By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. de...
1e38496bad510e31a4210c03ffb7dfbe13d2ba02
devikareddybhimanadam/pythonprogrammer
/77.py
122
3.8125
4
number=int(raw_input("")) cou=0 if number>0: for f in range(1,number+1): if number%f==0: print f,
6c195940b8be3650fd597a71a045638fca09b5e6
devikareddybhimanadam/pythonprogrammer
/32.py
116
3.75
4
str=raw_input("") char=0 w=1 for a in str: char=char+1 if(a==' '): w=w+1 print("") print(w)
9c0ede3d43b035ef1214cbce525bd801cb497231
devikareddybhimanadam/pythonprogrammer
/31.py
102
3.625
4
str=raw_input() char=0 w=0 for a in str: char=char+1 if(a==' '): w=w+1 print(char-w),
6c5b09cf1ee8780c69aeeaf691d92bcc5ee09e90
devikareddybhimanadam/pythonprogrammer
/80.py
182
3.765625
4
number=int(raw_input("")) dig = [] while number > 0: i = number % 10 if i & 1 != 0: dig.append(str(i)) number=number/10 dig = reversed(dig) print (" ".join(dig))
f99b9d736330ed66277e98311ccfb3a07b984f9e
Louis95/oop-in-python
/Exception/OnlyEven.py
595
4.125
4
''' While this class is effective for demonstrating exceptions in action, it isn't very good at its job. It is still possible to get other values into the list using index notation or slice notation. This can all be avoided by overriding other appropriate methods, some of which are double-underscore methods. ''' cl...
17ca9ab428fb31fee57f9eec8ae0bba56484c8c6
arkaanashadi/ArkaanAshadi_ITP2017_FinalProject
/Final/Classes/Display.py
1,726
3.5625
4
import pygame import pygame.font # Displays a text at the specified positions class Show: def __init__(self, generals, screen, given_text, font_size): # Initializes pygame.font pygame.font.init() # Gets screen information and generals self.screen = screen self.screen_rect ...
e1abcf46842c49528e2cacada041a29ce1a496f1
jorgegarcia1996/EjerciciosPython
/Ejercicios IF/Ejercicio4.py
392
3.828125
4
# Escribe un programa que pida un nombre de usuario y una contraseña y si se ha introducido “pepe” y “asdasd” # se indica “Has entrado al sistema”, sino se da un error. user = str(input("Usuario: ")) password = str(input("Contraseña:")) if user == "pepe" and password =="asdasd": print("Has entrado al sistema"...
0ca50b45d3af21e8e259afe116fdc5025e9f03eb
jorgegarcia1996/EjerciciosPython
/Ejercicios Python-repaso/BasicExcercisesPart1/Excercise9.py
165
4.46875
4
# Write a Python program to get the volume of a sphere. import math radius = float(input("Radius: ")) volume = (4/3) * math.pi * radius**3 print("%.2f" % volume)
07c3b9207164762711569bd3c2d6653f274a1c3c
jorgegarcia1996/EjerciciosPython
/Ejercicios Funciones/Ejercicio5.py
290
3.9375
4
# Realizar una función recursiva que reciba una lista y que calcule el producto de los elementos de la lista: def producto(lista): if len(lista) == 1: return lista[0] else: return lista.pop() * producto(lista) if __name__ == '__main__': print(producto([3,4,50]))
306d4ddd5597e23293f17553885eeed5670ea604
jorgegarcia1996/EjerciciosPython
/Apuntes.py
1,591
3.984375
4
# # IF # numero = int(input("Numero: ")) # if numero < 0: # print("Número es negativo") # elif numero > 0: # print("Número es positivo") # else: # print("Número es 0") # # WHILE # año = 2001 # while año <= 2017: # print ("Informes del Año", año) # año += 1 # else: # print ("Hemos termi...
77464bdc55273ce06381c5005b445a5e4c34f2a2
jorgegarcia1996/EjerciciosPython
/Ejercicios Diccionarios/Ejercicio4.py
700
4.15625
4
# Suponga un diccionario que contiene como clave el nombre de una persona # y como valor una lista con todas sus “gustos”. # Desarrolle un programa que agregue “gustos” a la persona: # Si la persona no existe la agregue al diccionario con una lista que contiene un solo elemento. # Si la persona existe y el gusto ...
8159c3f4c7dc70c389561a43e4db56590756a427
redpeng96/dev
/GUI/15_notepad.py
1,681
3.546875
4
import os from tkinter import * root = Tk() root.title("Windows Notepad") root.geometry("800x600+300+100") filename = "mynote.txt" def open_file(): if os.path.isfile(filename): f = open(filename, "r") txt.delete("1.0", END) txt.insert(END, f.read()) def save_file(): f = open(filename...
ca8a714b125bdf64e3caea9efa10b2cb7b262d99
yilunchen27/leetcode_learn
/LeetCode_Python-master/Algorithm-Easy/633_Sum_of_Square_Numbers.py
694
3.96875
4
class Solution: def judgeSquareSum(self, c): """ :type c: int :rtype: bool """ st = 0 ed = int(math.sqrt(c)) while st <= ed: total = st*st +ed*ed if total > c: ed -= 1; elif total < c: st += ...
5897917a7cfbe6586ef2942fd18a7f6bfc1b10d9
yilunchen27/leetcode_learn
/LeetCode_Python-master/Algorithm-Easy/422_Valid_Word_Square.py
1,315
3.8125
4
class Solution: def validWordSquare(self, words): """ :type words: List[str] :rtype: bool """ m = len(words) if m != 0: n = len(words[0]) else: n = 0 if m != n: return False for x in range(m): n...
c6d4636eedbafc16650429d309e427bd3f33444c
yilunchen27/leetcode_learn
/LeetCode_Python-master/Algorithm-Easy/566_Reshape_the_Matrix.py
1,593
4
4
class Solution(object): def matrixReshape(self, nums, r, c): """ :type nums: List[List[int]] :type r: int :type c: int :rtype: List[List[int]] """ h, w = len(nums), len(nums[0]) if h * w != r * c: return nums ans = [] for x...
dd4b7c03d405b2e3d3b5f8665cef54e72c462753
Larbi-Ernst/Graphing-application
/Python Curve Handler/MagicBox.py
8,876
3.671875
4
class Container(list): #this is the data class which shall serve as the data structure used to store graph coordinate data #inherits from list due to the shared functionality; differs in terms of operations however. def __new__(self,data): self.Accepted_Types = [int,float,complex] ...
e3da317eb5c93a9fb15ce6bfc1f3e7c3d72404b4
aunal16/project_euler_sols
/p3/python/p3.py
1,126
4.03125
4
# IMPORT LIBRARIES import math # INITIALIZE NUMBER TO BE FACTORIZED num = 600851475143 def eliminate_prime(x, y): # This function divides x to y as long as x is divisible by y. # Therefore, the returned value is not divisible by y anymore. while x % y == 0: x /= y return (y, int(x)) if __name...
b299117090dc24dcce3f6bea12af13d54d145c46
aunal16/project_euler_sols
/p5/python/p5.py
1,900
3.890625
4
# # IMPORT LIBRARIES import numpy as np # # GLOBAL VARIABLES # This sets the range from 1 to limit (including) limit = 20 # This holds the (max) number of the dividers of the numbers in the range dividers = np.zeros(limit) # # FUNCTIONS def is_prime(x): """ This function checks whether x is prime or not and r...
b032b8f5643243c858a409985a3b273c1539213b
sanyapalmero/adventofcode2020
/day08/main.py
2,042
3.515625
4
from copy import deepcopy def read_file(): with open("input.txt") as f: return f.read().splitlines() NOP = "nop" ACC = "acc" JMP = "jmp" def part_1(): acc = 0 commands = read_file() index = 0 history = [] while True: if index in history: break his...
57825ecf21db7e9116c102b888c818c450bfdcee
Sravaniram/pythonprogramming
/reverse a string by removing vowels.py
157
3.5625
4
a=int(input()) s=str(input()) b=[] for x in s: if(x!=('a'or'e'or'i'or'o'or'u')): b.append(x) print(b) b.reverse() print(b) c=''.join(b) print(c)
b0bfdd0cc93d1bc5771e77ac7583c600d7debe85
Sravaniram/pythonprogramming
/N numbers sum.py
71
3.640625
4
N=int(raw_input()) sum=0 for x in range (1,N+1): sum=sum+x print(sum)
b60c5b69b64f747b0e8006ac22b56979d6f16198
Sravaniram/pythonprogramming
/mirror list or not.py
108
3.640625
4
s=int(input()) a=input().split() l=input().split() if(sorted(l)==a): print("yes") else: print("no")
a1198b858b9cb3a90a5a30df03534e4600ee82bc
Sravaniram/pythonprogramming
/number of spaces in a line.py
128
3.65625
4
n=input() count=0 for x in range(0,len(n)): if(n[x]==" "): count=count+1 else: count=count print(count)
af32610cfb1f192e45604264c62425e9b3399e8c
Sravaniram/pythonprogramming
/string or sentence to camel case.py
201
3.59375
4
str=input() a=list(str) b=[] b.append(a[0].upper()) for x in range(1,len(a)): if(a[x]==' '): b.append(a[x]) a[x+1]=a[x+1].upper() else: b.append(a[x]) print(''.join(b))
7ca4a21d339cf2d606b3155fbeba5229d3fea1cb
Sravaniram/pythonprogramming
/nhellos.py
60
3.515625
4
N=int(raw_input()) for x in range (1,N+1): print("Hello")
a69446d990d426053c7ffdd9952d47bd1587ab36
Sravaniram/pythonprogramming
/commom subsequence.py
119
3.78125
4
n=input() m=input() a=[] for x in n: if(x in m and x not in a): a.append(x) k="".join(map(str,a)) print(k)
3c6b77f899858e87509c817fdfbddc27f7b3a83b
Sravaniram/pythonprogramming
/lab test.py
270
3.515625
4
x=int(input()) x1=list(map(str,input().split())) for s in x1: if(s=='0' or s=='78' or s=='4'): print("+") if(s[len(s)-2:len(s)]=='35'): print("-") if(s[1]=='9' and s[len(s)=='4']): print("?") if(s[0:3]=='190'): print("*")
ff2ce8310e97169f2ce1c210899915efdfe4f07c
Sravaniram/pythonprogramming
/element with index.py
112
3.734375
4
n=int(input()) m=[] for x in range(0,n): m.append(int(input())) for x in range(0,n): print(m[x],x)
fa7b8772b7b723fba5a689fe8570d6544e0c332a
Sravaniram/pythonprogramming
/fibonacci series.py
148
3.625
4
f=int(input()) a=[] a.append(1) a.append(1) for x in range(2,f): a.append(a[x-1]+a[x-2]) for x in range(0,len(a)): print(a[x]," ")
02b5f75dd3137d16861d4c71ffbaf2540763aa4a
Sravaniram/pythonprogramming
/sawping using bitwise operator.py
79
3.5625
4
a1=int(input()) b1=int(input()) a1=a1^b1 b1=a1^b1 a1=a1^b1 print(a1) print(b1)
5c22f3e5094ddaa18391ba146a7631fd58e785a6
Sravaniram/pythonprogramming
/balancing ().py
160
3.546875
4
a=str(input()) c=0 for x in range(0,len(a)): if(a[x]=='('): c=c+1 if(a[x]==')'): c=c-1 if(c==0): print("yes") else: print("no")
a6db5e777e30a9fd3710243e96b00c9cfb334fde
Sravaniram/pythonprogramming
/is vowel present in string or not.py
204
3.75
4
a=str(input()) c=0 for ex in a: if((ex=='a'or ex=='e'or ex=='i'or ex=='o'or ex=='u')or(ex=='A'or ex=='E'or ex=='I'or ex=='O'or ex=='U')): c=c+1 if(c>0): print("yes") else: print("no")
a6e3fd4e1631653c6f8a871ebabc9bd0eecc8c3a
Sravaniram/pythonprogramming
/cheking camlecase or not.py
231
3.625
4
l=input() c=-1 k=0 if(l[0]>="A" and l[0]<="Z"): c=c+1 for x in range(0,len(l)): if(l[x]==" "): k=k+1 if(l[x+1]<="Z" and l[x+1]>="A"): c=c+1 if(k==c): print("yes") else: print("no")
03115db2f95b1c5246addd34c4ed3afc2bd51f03
Sravaniram/pythonprogramming
/num is divisible or not.py
126
3.640625
4
s=int(input()) c=0 for x in range(1,s+1): if(s%x==0): c=c+1 if(c!=0): print("yes") else: print("no")
48c96af41173a1679594dc4be7672a16a4920003
EnriicJuuaan/Practica
/Practica7.py
132
3.921875
4
numero = input("Escribe un numero") if ((float(numero)%2) == 0): print("Par") elif ((float(numero)%2) >0): print("Impar")
152e5ae714e7a182e282959794b800ddd5da086a
Ronish9165/pythonProject
/main.py
119
3.9375
4
length=int(input('enter the length:')) breadth=int(input('enter the breadth:')) area =length*breadth print(area) a = 10
5ff34591cc90acb825c43f35807938ea0d8f570c
Balzzanar/IOCT
/tools/sensors-test.py
687
3.5
4
#!/usr/bin/env python import RPi.GPIO as GPIO import time print GPIO.RPI_INFO print GPIO.VERSION # physical pins on GPIO board: TemprPin = 36 ObstaclePin = 37 def setup(): GPIO.setmode(GPIO.BOARD) GPIO.setup(ObstaclePin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(TemprPin, GPIO.IN, pull_up_down=GPIO.P...
d4b24eb86d236eb7e5b22330755c5803dc8d4e63
harshitbhat/Code-In-Place
/Assignments/014.khansoleAcademyOP.py
754
3.90625
4
""" TODO: Write a description here """ import random def main(): totalCorrect = 3 correct = 0 while True: firstNumber = random.randint(10,99) secondNumber = random.randint(10,99) ans = firstNumber + secondNumber print(f'What is {firstNumber} + {secondNumber}?') use...
bfc7c104625216568c42dad8ff89e491869ccc78
harshitbhat/Code-In-Place
/Worked Examples/042.dog_years.py
152
3.71875
4
def main(): age = int(input('Enter an age in human years: ')) print(f'That\s {age * 7.18} in dog years!') if __name__ == "__main__": main()
4f16d9788deadc0600e28b93b40e9e731cb916a6
Koutarouu/ProcessingProjects
/fractalTree/fractalTree.pyde
834
3.609375
4
angle = 0 def mouseWheel(event): global angle if event.count<1: angle= angle + 0.1 if angle<(2*PI) else 2*PI else: angle= angle - 0.1 if angle>0 else 2*PI def setup(): size(500, 500) def draw(): background(183, 233, 255) strokeWeight(4) stroke(216, 201,...
f1c07b96173da1cb225b6774359575c07afc03ac
YunjinJo/PythonProject1
/Day4/list0101_2.py
766
3.640625
4
import tkinter import datetime def key_down(e): key_c = e.keycode label1['text'] = 'keycode ' + str(key_c) #keycode 값으로 label1을 변경 key_s = e.keysym label2['text'] = 'keysym ' + key_s #keysym값으로 label2 변경 root = tkinter.Tk() #윈도우 객체 생성 root.geometry("400x200") #윈도우 크기 지정 root.tit...
8a81a67dad68f690099e1e4f435c44a990b96ed4
khadeejaB/Week10D2A2
/questionfile.py
749
4.3125
4
#In this challenge, a farmer is asking you to tell him how many legs can be counted among all his animals. The farmer breeds three species: chicken = 2 cow = 4 dog = 4 #The farmer has counted his animals and he gives you a subtotal for each species. You have to implement a script or function that returns the ...
359824127dd9b48c34a2df72f7f21fd85077d9ff
Armin-Tourajmehr/Learn-Python
/Number/Fibonacci_sequence.py
950
4.28125
4
# Enter a number and have the program generate # The Fibonacci sequence number or the nth number def Fibonacci_sequence(n): ''' Return Fibonacci :param n using for digit that user want to calculator Fibonacci: :return sequence number as Fibonacci : ''' # Initialization number a = 1 b =...
7d6df544ae614235cd5c0238cbfaaaaca8350e6b
Armin-Tourajmehr/Learn-Python
/Number/Get_pi.py
864
4.21875
4
# Getting pi number # Use Nilakantha formula from time import sleep # Calculate Pi Number def calc_pi(num): Pi = 3 op = 1 for n in range(num): if n % 2 == 0 and n > 1: yield Pi Pi += 4 / ((n) * (n + 1) * (n + 2) * op) op *= -1 def valid_number(): while T...
e8099e7b6abba7970bf842a1b1beb64ad0052292
Armin-Tourajmehr/Learn-Python
/Text/Get_Data_From_Text/dict.py
525
3.5625
4
# search in data & computing number of date import string fh = input('Enter file : ') try: romeo = open(fh) rd = dict() for line in romeo: line = line.rstrip() line = line.translate(line.maketrans('', '', string.punctuation)) line = line.lower() word = line.split() f...
758cd2af087f72b113028e2f7d8f2501482a9be2
hustshawn/try_memo
/2015/abstrac.py
742
4.03125
4
from abc import ABCMeta, abstractmethod class Shape(object): __metaclass__ = ABCMeta @abstractmethod def area(self): pass @abstractmethod def perimeter(self): pass class Rectangle(Shape): def __init__(self, width, hight): self.width = width self.hight = hight super(Rectangle, self).__init__()...
84be038aeba9543e38c4abf9cf3c5854dcb568d4
hustshawn/try_memo
/2016/play_str_captialize.py
175
3.9375
4
apple = "www.apple.com" print(apple.upper()) # Captialize the first chara of the string. print(apple.capitalize()) # Capitalize first chara of each word print(apple.title())
ba373e058ab961a46146d4a8088e848a019de6ec
hustshawn/try_memo
/2016/decorators_class.py
1,433
4.03125
4
### To learn how decorators work def log(func): def wrapper(*args, **kwargs): print "call %s(): " % func.__name__ print "Do something in the wrapper" return func(*args, **kwargs) return wrapper @log def now(): """ comments""" print "2015-04-01" now() print "the now() func name is " + now.__name__ def log...
c64ac69d915f54109e959d046f6317348650a460
evan-nowak/other
/generic/date_range.py
2,881
4.53125
5
#!/usr/bin/env python """ ######################### Date Range ######################### :Description: Generates a date range based on starting/ending dates and/or number of days :Usage: Called from other scripts :Notes: The function needs exactly two of the three arguments to work Wh...
f75f53636c66c613bc8f7d0553091d814f446138
nusrathfathima/TwitterTextCaptureAndAnalysis
/twitter_analysis.py
4,887
3.875
4
import operator from datetime import datetime # # Uncomment below block of code if you want to dynamically generate the text document by entering a search string and running twitter.py # import twitter # output_file_path = twitter.INPUT_FILE_PATH n=int(input("Enter number of records to be displayed: ")) # For now, we...
08f8d2d2014f8412f61110e6d9ae4179c03eafc2
Sangeetha-Naresh/class97
/countwords.py
176
3.96875
4
introstr=input("enter your intro:") print(introstr) chars=0 words=1 for i in introstr: chars=chars+1 if i==' ': words=words+1 print(chars) print(words)
13434a92b0014538ba6851927e1b85ea8d71be59
latos/love-letter
/dumb.py
1,080
3.53125
4
from game import Player, Move, targetting_cards class Dumb(Player): """ Minimal legal move player, frequently suicides unnecessarily """ def get_brain_name(self): return 'dumb' def new_game(self, initial_card, other_players): self.current_card = initial_card self.others = other_players def de...
0a5f2461b362405b244867ba8a8b44c21a363e51
ferdiansahgg/Python-Exercise
/workingwithstring.py
493
4.34375
4
print("Ferdi\nMIlla") print("Ferdi\"MIlla") phrase = "Ferdiansah and MilleniaSaharani" print(phrase.upper().isupper())#checking phrase is uppercase or not, by functioning first to upper and check by function isupper print(len(phrase))#counting the word print(phrase[0])#indexing the character print(phrase.index("F"))#ph...
8a9975897303c245eded2998da971ea75028f81e
kuninagakura/Princeton_Facebook
/pickleReader.py
299
3.546875
4
# Kuni Nagakura # pickleReader.py # Tool for reading pickled files import pickle graphList = pickle.load(open("PrincetonGraph2.p", "rb")) # print graphList names = pickle.load(open("PrincetonNames2.p", "rb")) for key in graphList: print names[key] + "\n" print [names[fID] for fID in graphList[key]]
a2dca0bf04a36a77213202eb7de546171f787c1e
vokeven/CourseraPythonHSE
/Week1-3/Номер числа Фибоначи.py
319
3.8125
4
A = int(input()) k = 1 fibNum1 = 0 fibNum2 = 1 fibNumN = 0 if A == 0: k = 0 print(k) elif A == 1: k = 1 print(k) else: while A > fibNum2: k += 1 fibNumN = fibNum2 + fibNum1 fibNum1, fibNum2 = fibNum2, fibNumN if A != fibNumN: print(-1) else: print(k)
6a1e3617c7e6b4ef433e633341063c1b919edcaf
vokeven/CourseraPythonHSE
/Week5/Количество различных элементов.py
416
3.515625
4
# Дан список, упорядоченный по неубыванию элементов в нем. # Определите, сколько в нем различных элементов. def differenceElem(xList): numX = 1 for i in range(len(xList)-1): if xList[i] != xList[i+1]: numX += 1 return numX xList = list((map(int, input().split()))) print(differenceEle...
a48ea391d7de87384845b0a65551389eefd52835
vokeven/CourseraPythonHSE
/Week1-3/Цвет клеток шахматной доски.py
198
3.59375
4
A = int(input()) B = int(input()) C = int(input()) D = int(input()) X2 = (A - C)**2 % 2 Y2 = (B - D)**2 % 2 if (X2 == 0 and Y2 == 0) or (X2 != 0 and Y2 != 0): print('YES') else: print("NO")
a0ce6c064221e080fed017636092d7b12b4c2583
vokeven/CourseraPythonHSE
/Week5/Переставить в обратном порядке.py
732
4.0625
4
# Переставьте элементы данного списка в обратном порядке, # затем выведите элементы полученного списка. # Эта задача отличается от предыдущей тем, что вам # нужно изменить значенияэлементов самого списка, # поменяв местами A[0] c A[n-1],A[1] с A[n-2], # а затем вывести элементы списка подряд. def reverseList(xList): ...
3afce4b9d45fdbacdf45cb7420dcf220d0b8ea0d
vokeven/CourseraPythonHSE
/Week4/Сложение без сложения.py
191
3.9375
4
def sum(a, b): if a > 0: return sum(a - 1, b) + 1 elif b > 0: return sum(a, b - 1) + 1 else: return 0 a = int(input()) b = int(input()) print(sum(a, b))
c060ea5fe7048691d6b54a10eca63df6de5e3669
vokeven/CourseraPythonHSE
/Week6/sortOlymp.py
804
4
4
# В олимпиаде участвовало N человек. Каждый получил определенное # количество баллов, при этом оказалось, что у всех участников # разное число баллов. Упорядочите список участников олимпиады # в порядке убывания набранных баллов. def sortMan(xList): newList = [] for member in xList: FIO = member.split...
0781e7f8d050c82d66f1ff372f32dab4352e2deb
vokeven/CourseraPythonHSE
/Week5/Вставить элемент.py
1,037
3.609375
4
# Дан список целых чисел, число k и значение C. # Необходимо вставить в список на позицию с индексом k # элемент, равный C, сдвинув все элементы, имевшие # индекс не менее k, вправо. # # Поскольку при этом количество элементов в списке увеличивается, # после считывания списка в его конец нужно будет добавить # новый эл...
f981ee6cd8c2e03455c175c61da5ed4f0f5e4592
vokeven/CourseraPythonHSE
/Week5/Сумма факториалов.py
308
3.765625
4
# По данному натуральному n вычислите сумму 1!+2!+3!+...+n!. # В решении этой задачи можно использовать только один цикл. n = int(input()) sumN = 0 fct = 1 for i in range(1, n+1): fct *= i sumN += fct print(sumN)
1c551beeccfec0ad0cc3b2bd248d851ba1143536
vokeven/CourseraPythonHSE
/Week5/Больше своих соседей.py
477
3.703125
4
# Дан список чисел. Определите, сколько в этом списке элементов, # которые больше двух своих соседей и выведите количество таких элементов. def isBigger(xList): numX = 0 for i in range(1, len(xList)-1): if xList[i-1] < xList[i] > xList[i+1]: numX += 1 return numX xList2 = list(map(int...
e8c074732b92584016cb97760de0bfe8d510c6c7
vokeven/CourseraPythonHSE
/Week1-3/Исполнитель раздвоитель.py
176
3.703125
4
A = int(input()) B = int(input()) X = A while X != B: if X % 2 == 0 and X // 2 >= B: X = X // 2 print(':2') else: X = X - 1 print('-1')
b396d9daba3b8c8da73d6bddc8cf4059a3b2acfa
vokeven/CourseraPythonHSE
/Week5/Циклический сдвиг вправо.py
462
3.890625
4
# Циклически сдвиньте элементы списка вправо(A[0] # переходит на место A[1], A[1] на место A[2], ..., # последний элемент переходит на место A[0]). def rightShift(xList): a = xList[-1] for i in range(len(xList)-1, 0, -1): xList[i] = xList[i-1] xList[0] = a return xList newList = list((map(int...
2f5be2458c46bae1e1dfbb8c824f340353713f5c
scoleman01/GitFit
/strength.py
949
3.609375
4
# Class for stregnth subclass of exercise from exercise import Exercise from random import randint class Strength(Exercise): def __init__(self,duration=15, bodyGroup='Total Body' , reps=None, sets=None, exerciseType='Free Weight'): Exercise.__init__(self, duration, bodyGroup) if reps is None: ...
8e3b31eed9df2d48a95ad8acf48899dd761738f5
yaseen-ops/python-practice2
/15forLoop.py
652
3.96875
4
for letter in "Lenin": print(letter) print("--------------") players = ["Dhoni", "Kohli", "Rohit"] for player in players: print(player) print("-------------") for index in range(5): # Prints the range between 0 & 5 but not 5 print(index) print("--------------") for index in range(2, 5): # Prints the range...
c984c502d22f8a4bb96ec6a19cf4df3bb59619b5
yaseen-ops/python-practice2
/21readFile.py
535
3.8125
4
employee_data = open("employee_file.txt", "r") # r=read; w=write; a=append; r+=read/write # print(employee_data.readable()) # Check the file is readable or not # print(employee_data.read()) #Read the whole file # print("-------------------") # print(employee_data.readline()) # Read by lines, prints the first line and...
d17d862ebd5e5f3705a868607c7c255fe4b44dce
yaseen-ops/python-practice2
/13while_loop.py
276
4.1875
4
i = 1 while i <= 5: print(i) # i = i + 1 # OR i += 1 print("Done with Loop") print("---------------------------------") i = 1 while i <= 5: print(i) if i == 4: print("Loop gonna end") # i = i + 1 # OR i += 1 print("Done with Loop")
6de2e90b4bfde6b5bce9329541c33c95dddba1e8
shahafs/Debugger
/learner/Planner/mcts/Node.py
6,094
3.75
4
__author__ = 'amir' import random, Queue from math import sqrt, log from random import sample class Node(object): COLORS = { 1: 'red', 2: 'yellow', 3: 'orange', 4: 'green', 5: 'blue', 6: 'purple' } def __init__(self, parent, action, state, player, game=No...
24a668f62481bcfcf7d09d452e257887e1157019
watchout401/Data-Structure-
/py_prog_files/python.py
316
3.75
4
def perfectnum(Number): Sum = 0 for i in range(1, Number): if(Number % i == 0): Sum = Sum + i return Sum Number = int(input(" Please Enter any Number: ")) Sum = perfectnum(Number) if (Sum == Number): print(" %d is a Perfect Number" %Number) else: print(" %d is not a Perfect Number" %Number)
b70e2b1af4305fc1e4b72d759f679b60658f913a
watchout401/Data-Structure-
/py_prog_files/delete_even_from_list.py
303
3.546875
4
def delete_starting_evens(lst): lst1 =[] num1 = 0 i=0 length = len(lst) for num in lst: if(num%2 != 0): num1=i+1 break else: i = i+1 for num1 in range(length): lst1 = lst[num1] return lst1 print(delete_starting_evens([4,8,10,11,12,15])) print(delete_starting_evens([4, 8, 10]))
9feafb55990ac3ec1d73d490642a3c6e1ac4226d
oakeyc/azure-cli-interactive-shell
/azclishell/command_tree.py
3,034
3.90625
4
class CommandTree(object): """ a command tree """ def __init__(self, data, children=None): self.data = data if not children: self.children = [] else: self.children = children def get_child(self, child_name, kids): """ returns the object with the name...
a0a8a02f861a5c79fdbe491b98ede334f4376405
Ifo0/Soft-uni
/Week3_Exercises.py
4,120
3.5
4
# Zadacha 1 # time_a = int(input()) # time_b = int(input()) # time_c = int(input()) # # total_time = time_a + time_b + time_c # # if total_time < 60: # print('0:' + f'{total_time}'.zfill(2)) # elif total_time >= 60 and total_time < 120: # print('1:' + f'{total_time % 60}'.zfill(2)) # else: # print('2:' + f'...
58cf533e9db98016709bf85e28171c22324c069c
Ifo0/Soft-uni
/Final_Exam.py
3,074
3.625
4
# Zadacha 1 # group_size = int(input()) # carabins = int(input()) # ropes = int(input()) # pikels = int(input()) # dds = 1.2 # # to_pay = group_size * (carabins * 36 + ropes * 3.60 + pikels * 19.80) * 1.2 # print(f'{to_pay:.2f}') # Zadacha 2 # import math # absence_days = int(input()) # food_in_kg = int(input()) # fi...
cb337e373538f51989f6799cf9bb2d9cda7fb366
treyhakanson/pile
/GraphTheory/grid-search.py
1,441
3.640625
4
""" Is there a path starting in the upper left hand corner that follows walkable spaces (1s) to the goal point (9)? """ grid = [["1", "1", "1", "#", "#", "#", "#", "#", "#", "#"], ["1", "1", "#", "#", "1", "#", "#", "#", "#", "#"], ["#", "1", "#", "#", "1", "#", "#", "#", "#", "#"], ["#", "1", ...
b7bfd61daed62ab2383b90ad064f9999c5f82262
treyhakanson/pile
/HackerRank/Algorithms/Implementation/birthday_chocolate.py
165
3.640625
4
# https://www.hackerrank.com/challenges/the-birthday-bar/problem def solve(values, day, month): total = 0 return total print(solve([1, 2, 1, 3, 2], 3, 2))
d5a7b6132bcee56810d6686b849e90d23cfb3d0b
treyhakanson/pile
/AI/application/Part 2 - Regression/Section 4 - Simple Linear Regression/simple_linear_regression2.py
1,224
3.984375
4
"""Simple linear regression over salary data.""" import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from matplotlib import pyplot as plt data = pd.read_csv('math.csv') x = data.iloc[:, :-1].values y = data.iloc[:, 1].values x_train, x_test, y_tra...
6ad9fef555266395dd764c63b1ad42237833d93a
treyhakanson/pile
/Databases/PostgreSQL/python_and_postgresql_example.py
951
3.515625
4
# NOTE: this is a basic overview of how to interact # with PostGreSQL using the python library psycopg2; # This file assumes knowledge of python. # import psycopg import psycopg2 as pg2 # establish a connection to the database; # default user will be postgres unless otherwise # specified conn = pg2.connect(database='...
06a7ba285403e2a2819eb90ba6da21caf9f893f1
dhineshperiyasamyk/dhineshp
/beginset2-20.py
88
3.609375
4
r=int(input()) p=[] for i in range(1,6): result=i*r p.append(result) print(*p)
8b4aaa28544857541dac0b89a73f2a9c1e8ca4a7
dhineshperiyasamyk/dhineshp
/exp8.py
86
3.6875
4
h=int(input()) if(h>0): sum=0 while(h>0): sum=sum+h h=h-1 print(sum)
3549dea7a20231d37d72d50213cbff1b81530a9f
eerotpt/Python
/loto_0.py
317
3.890625
4
def loto(): num = input ("Täisarv 0-9 :") check = 5 if num.isdigit(): if int(num) < check: print("väiksem") loto() elif int (num) > check: print("suurem") loto() else: print("niiongi") else: print("number!!!") loto() loto()
bc1a7b388b669474e04d201de77c9eaaba750086
ArpanMahatra1999/Numpy
/ravel.py
146
3.671875
4
import numpy as np a = np.zeros(8) arr3d = a.reshape((2,2,2)) #remember double brackets in zeros and reshape arr = arr3d.ravel() print(arr)
d28f22c24c9ffff6056ef22940213d66d4b885c4
osho-agyeya/sts-examples
/sandbox-py/Function.py
301
3.953125
4
def add(x=0,y=0): return x+y ''' def add(x,y,z): // this one is used return x+y+z ''' print(add()) print(add(10)) print(add(y=9)) print(add(10,20)) print(add(y=20,x=19)) #print(add(10,20,30)) def sum(*args): summ=0 for i in args: summ+=i return summ print(sum(23,4))
58cf9f656c086287588fab2dab4484a4f7dcf6c5
Todai88/python_beyond_the_basics
/03-closures-and-decorators/own-stuff/sort_by_last_letter.py
417
3.96875
4
## Here I will show how to use a local function def sort_by_last_letter(list_of_words): """ @param list_of_words: a list containing words @return: the passed list sorted on their last character. """ def last_letter(s): """ :param s: a string :return: the last character in...
4cde7e10edd338f71d57f3266a07368b28b607d3
Todai88/python_beyond_the_basics
/03-closures-and-decorators/tracer.py
691
4
4
""" Remember that a decorator requires a callable and returns a callable In this case we are using the class function __call__ to return a reference to a local function called wrapper. Wrapper returns the calling function (the one using decorator) and prints its arguments if the instance variable _enabled is True. ""...
5b1a66203e2b703ac88011adc2fbf302bcdbfd7e
gaybro8777/python-101-games
/lib/games/acey_ducey.py
2,379
4.0625
4
import random from .. import common from .. import term VERSION = '0.0.3' def CardString(card): """Converts a card value (13*suit + number) to a display string.""" if (card / 13) < 2: color = term.BOLD_RED else: color = term.BOLD_WHITE return (color + ('2', '3', '4', '5', '6', '7', '...
de826b657e9d41f616c4e024d1816e8b8921ceee
lemonzoe/web-scraping-with-python
/d1/class3.py
2,453
3.609375
4
from urllib.request import urlopen from bs4 import BeautifulSoup html=urlopen("http://www.pythonscraping.com/pages/warandpeace.html ") bs0bj=BeautifulSoup(html,"html.parser") # 通过BeautifulSoup对象, # 可以用findAll函数抽取只包含在<span class="green"></span>标签里的文字 nameList=bs0bj.findAll("span",{"class":"green"}) # bs0bj.tagName只能获取页面...
085a05cef659f9e6e875a8cae5e9d553fae659b4
iakz/py_work
/quanzhan/mingpianguanli/cards_tools.py
2,889
3.625
4
#!/usr/bin/env python # coding:utf8 import sys reload(sys) sys.setdefaultencoding('utf8') # import input # 记录所有名片字典 card_list = [] def show_menu(): print "*" * 50 print "欢迎使用【名片管理系统】V1.0\n" print "\t1、新建名片\n\t2、显示全部\n\t3、查询名片\n\n\t0、退出系统" print "*" *50 def new_card(): # 新增名片 print "-" * 50 # print "新增名片" nam...
6dab654cd75f37fd93a34c0cf162681b00cf3576
khorns/RenameFiles
/renameF.py
1,172
3.609375
4
import shutil, os, re from pathlib import Path # Path of a current directory path = os.getcwd() path = path + "\Random3" NFileName = "Moon" # def renameFile(): allFile = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))] # allFile = os.listdir(path) i = 1 # allFile.sort() all...
fd352777dac8a28af80176126588a445f3965624
therikshak/ProgrammingLanguages
/iterator/iterator_challenge.py
609
3.53125
4
import re class Regex: def __init__(self, regex_str, str): self.str = str self.regex_str = regex_str self.reg_list = re.findall(regex_str, str) def __iter__(self): self.match_number = 0 return self def __next__(self): if self.match_number < len(self.reg_li...
4da01426ec852c5441c312d44e95216b9e8c3a32
umeshyadav99/Data_Store-file-based-_freshworks
/source_code.py
2,304
3.796875
4
import threading from threading import* import time data_store={} #'data_store' is the dictionary in which we store data #for create operation def create(key,value,timeout=0): if key in data_store: print("error: this key already exists") #error message else: if(key.isalpha()): ...