blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6247c722c7739ce70935c92ba99490b671eb2671
mariamvaid/hello-world
/CIS2348/homework01/main.py
597
3.984375
4
# Mariam Vaid # 1477614 from datetime import date def calculate(current, birthdate): today = current age = today.year - birthdate.year - ((today.Month, today.Day) > (birthdate.month, birthdate.day)) return age a = 1981 b = 9 c = 21 print("Birthday Calculator") print('Current Day') m = int(input('Month:...
721c5bd7fe52995136b1f4efe45343188977c517
nzrfrz/praxis-academy
/novice/01-02/defvals.py
391
4.09375
4
# Default value only evaluated at function scope i = 5 def f(arg = i): print(arg) i = 8 f() print("") # Passing arguments on subsequent call def g(a, L = []): L.append(a) return L print(g(1)) print(g(2)) print(g(3)) print("") # Without subsequent call def h(a, L = None): if L is None: L =...
cf6ebf138298a88a6871f64e411db626b8c7a586
vishrutkmr7/DailyPracticeProblemsDIP
/2022/07 July/db07272022.py
988
4.1875
4
""" This question is asked by Google. A company is booking flights to send its employees to its two satellite offices A and B. The cost of sending the ith employee to office A and office B is given by prices[i][0] and prices[i][1] respectively. Given that half the employees must be sent to office A and half the employe...
82eb8e5b0416938d32fc49c221a4d18cf78a2bb1
cjrzs/MyLeetCode
/最小基因变化.py
1,320
3.65625
4
""" coding: utf8 @time: 2020/11/22 17:09 @author: cjr @file: 最小基因变化.py https://leetcode-cn.com/problems/minimum-genetic-mutation/ """ from typing import List from collections import deque class Solution: def minMutation(self, start: str, end: str, bank: List[str]) -> int: set_bank = set(bank) coun...
72dd9fb89bf88a26bf7795cf68103f6e74f0afaa
NeroSong/algorithm-exercises
/leetcode/206-反转单链表.py
3,566
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' 反转单链表,Reverse Singly-linked List 非常直观的题目,反转后返回头结点。 考察对链表的理解程度。 有遍历新建法和逐步调换法两种思路,前者整体反转,后者逐个反转。 逐个反转,又有双指针和递归两种方式。 最优解法为双指针法。 ''' # 单链表定义 class ListNode: def __init__(self, x): self.val = x self.next = None # 遍历新建 # 最直观的思路:先遍历获取所有值放在栈中,然后从栈中弹出创...
038435c01bc3ffbade2bfc76139baa4b0442d6da
dquiroga10/CS241
/Project2/Linked_List.py
9,663
4.09375
4
class Linked_List: class __Node: def __init__(self, val): # declare and initialize the private attributes # for objects of the Node class. # TODO replace pass with your implementation self.val = val self.prev = None self.next = None def __init__(self): # declare ...
d717181eb0be943ae62d614622a9cc91803440b2
Daniel-Barrera-D/Python-Curso
/Listas/ListasIntro.py
82
3.5625
4
#Introduccion a listas array = [1,2,8,5,-11] array.sort(reverse=True) print(array)
6383a32c33ebca430a652a0daafb426d148c6be6
Jules-Boogie/auditingdatasets
/Parsing a Datetime Object/funcs.py
2,688
4.5
4
""" Functions for parsing time values from text. While these functions are similar to functions found in the assignment, they are missing timezone information. The next exercise will modify these functions to make them compatible with the assignment. Author: Juliet George Date: 9/7/2020 """ from dateutil.parser im...
a46fc446087d8cf49c628fcbf2c5030fb86ed94d
shuchita28/Migration_Demo
/piechart.py
4,842
3.96875
4
import matplotlib.pyplot as pt import pandas as pd data = pd.read_csv('/Users/shuchitamishra/Desktop/Prod-Migration/Cron Job 15_03-Table 1.csv') print(data) result = data.groupby('Status')['Status'].count() print(result) pt.axis('equal') pt.pie(result, colors = ['red','yellow','green'], labels = ['Failure','Ski...
76a64ae72d1383ccdd00eb6dfa832e4b15477f49
pandapranav2k20/Python-Programs
/Lab 1b/Limits.py
2,320
3.6875
4
# By submitting this assignment, I agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Name: PRANAV VEERUBHOTLA # Section: 504 # Assignment: LAB1B-2 # Date: 8 AUGUST 2019 from math import * #function number...
b3e3f092976d32a8ac7e01c33e087c1f30f073f6
wwlee94/online-coding-tutor
/app/example/python/recursive.py
125
3.84375
4
# -*- coding:utf-8 -*- # 반복문 예제 x = 5 y = 10 z = x * y print ("HELLO WORLD") for i in range(10): print (z * i)
ea02f618794aeb094fd06b30053e526928bc7dc9
JeandsGomes/testes_Interface_Grafica_PQT5
/Resolucao_do_Exercicio/cadastro.py
408
3.609375
4
class Cadastro(): def __init__(self): self._lista_pessoas = [] def cadastra(self,pessoa): existe = self.busca(pessoa.cpf) if(existe == None): self._lista_pessoas.append(pessoa) return True return False def busca(self,cpf): for lp in self._lis...
be45dc514393f4b122494dc87eca4af83ef3862a
Knimisha/Python_Basics
/NMK_Condition handling_Task2.py
508
4.03125
4
# program to check whether a number is divisible by 5 and 11 or not class div(): def division(self, inputA): if(inputA % 5 == 0 and inputA % 11 != 0): print("Number divisible only by 5") elif(inputA % 5 != 0 and inputA % 11 == 0): print("Number is divisible by 11") ...
b207f2fea6351ce7a6ff43cea4117a29dad4f254
amey438/Lecture0
/Code in Place/Search Engine/createindex.py
5,844
3.953125
4
from Searchengine import format_clean_string def create_index(filenames, index, file_titles): #MILESTONE 2 """ This function is passed: filenames: a list of file names (strings) index: a dictionary mapping from terms to file names (i.e., inverted index) (...
e78bcf6923ca133c295bbee31c7fe3f8a165ce32
Nyhilo/codebits
/py/GregoryLeibniz.py
989
3.609375
4
import time import sys sys.setrecursionlimit(5000) def main(): print("This may take up to 30 seconds. Please be patient...") # iteration_factor = 50000000 iteration_factor = 4500 start = time.time() pi = crunchPi(iteration_factor) end = time.time() print(f'Pi calculated to ...
734bbe95e6d50350bf4580d4518b09643496c88b
spirali/rain
/python/rain/common/labeled_list.py
5,314
3.53125
4
import collections class LabeledList(collections.MutableSequence): """ List data structure with additional optional unique labels for items. Supports all list operations except `sort` (in general `collections.MutableSequence`). Indexing `l[x]` accepts either an integer, slice or a label. Modi...
0f18e8fa28f9c6681ddd6ae341257484c668cac5
lein-hub/python_basic
/test/class.py
1,826
3.890625
4
# class Student: # name = '동재' # def __init__(self, name): # self.name = name # print("I'm", name) # def say_hello(self): # print('Hello') # @classmethod # def create_student(cls, name): # return cls(name) # s1 = Student('ABC') # s1.say_hello() # Student.say_hel...
3afe24b7cb7162f07b8e1b0c5d088ae61cb6eab6
Awright919/Data-Programming-1
/Lab4b/lab4b-2.py
602
4.03125
4
def computeGrade(userInput): if userInput < 0.0 or userInput > 1.0: print("Bad Score") elif userInput >= 0.9: print("A") elif 0.9 > userInput >= 0.8: print("B") elif 0.8 > userInput >= 0.7: print("C") elif 0.7 > userInput >= 0.6: print("D") ...
b59b22390ad44c779396142fea350089af11bf59
iibanezgordon/TicTacToe
/tictactoe.py
1,492
4
4
# -*- coding: utf-8 -*- """ Initial Version of a Tic Tac Toe Game By Iker Ibanez Started 05/05/2017 """ import tictactoefunctions from IPython.display import clear_output repeat = False Victory = False replay = True while replay : Board, Players, player, status = tictactoefunctions.inicio() while not Victor...
6b3de84186539637524335c985b67d727a92b54c
javix64/WebScraping_Vinted
/array.py
343
3.6875
4
class PC(): def __init__(self, pa1, pa2, pa3): self.pes1 = pa1 self.pes2 = pa2 self.pes3 = pa3 def __repr__(self): return str(self.__dict__) arr = [] arr.append(PC('a', 'b', 'c')) arr.append(PC('d', 'e', 'f')) arr.append(PC('g', 'h', 'i')) arr.append(PC('j', 'k', 'l')) for ele ...
6484c5837d6dff831a67738c04e4ccf1610f850f
HankRobot/NEM-Python
/Workshop 1/Fun Encryptions and stuff/Substitute.py
1,091
4.21875
4
#this is the code for substitute() procedure # rules: 1) substituted are left without capital or lowered case, 2)non-substituted letters are then upper cased Alphabet1 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] Alphabet2 = ['A','B','C','D','E','F','G','H'...
ffc83535eb0ee82d015261bd0ddcc386fbb12b0f
1475963/tictactoe
/tk_draw.py
4,564
3.6875
4
# module to draw things with tkinter from tkinter import * import board_properties as Config import consts as Consts DEBUG = False def get_instance(): ''' Returns a Tkinter instance for future Tkinter calls ''' return Tk() def clickHandler(event, pBoard): if DEBUG: print('click at x : (%d), y ...
c626e52b3786330596e1d5f59a4a8ae8bd33536d
rishabhostwal7/Python
/packageML01/Practical15.py
408
4.03125
4
'''for num in range(1, 11): print(num) if num == 5: break else: print("This is the else block of for loop") while False: print("Inside while block") else: print("This is the else block") ''' alpha = input("Enter alphabet to search : ") for ch in "INDIA": if ch==alpha: ...
1268919021644fb363b68f6fd84a659b5e5c88c7
jxhangithub/lintcode
/Array/403.Continuous Subarray Sum II/Solution.py
1,099
3.5625
4
class Solution: """ @param: nums: An integer array @return: A list of integers includes the index of the first number and the index of the last number """ def continuousSubarraySumII(self, nums): # write your code here if not nums or len(nums) == 0: return [-1, -1] ...
d5eba2130d06bde28f0c1b585945b953143f3267
10brink/py3_programming
/Python Functions, Files, and Dictionaries/week-1/Assement files and dict.py
2,094
4.34375
4
''' Q-1. The textfile, travel_plans.txt, contains the summer travel plans for someone with some commentary. Find the total number of characters in the file and save to the variable num.''' with open("travel_plans.txt","r") as file: file_char=file.read() num = len(file_char) print(num) file.close...
1844b07adad2d718d252915debdbc0e8e80a6a86
tnakaicode/python-cfd
/lessons_src/14_Step_11.py
12,867
3.765625
4
#!/usr/bin/env python # coding: utf-8 # # Text provided under a Creative Commons Attribution license, CC-BY. All code is made available under the FSF-approved BSD-3 license. (c) Lorena A. Barba, Gilbert F. Forsyth 2017. Thanks to NSF for support via CAREER award #1149784. # [@LorenaABarba](https://twitter.com/LorenaA...
a6ec7b9ace8e0e4d34d944e8ebf295c0f0faa0b5
mextier/PythonCommon
/dateTime_.py
945
3.84375
4
""" https://www.youtube.com/watch?v=RjMbCUpvIgw https://www.youtube.com/watch?v=eirjjyP2qcQ """ from datetime import datetime from datetime import timedelta from datetime import date from datetime import time print(datetime.now()) d = datetime(1970,10,5) print(d) orddate=d.toordinal() print(datetime.fromordinal(...
b5d05b987bcfdc9c88591ddf23ced9c82a5af786
frankye1000/LeetCode
/python/Palindromic Substrings.py
588
4.1875
4
"""Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. Example 1: Input: "abc" Output: 3 Explanation: Three palindromic strings: "a", "b", "c". Example...
9322cb2e4b17953c4716b603135bd6b495b6b4e4
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/hndkay004/question3.py
245
4.21875
4
import math a=2 b=math.sqrt(2) while (2/b)!=1: a*=2/b b=math.sqrt(2+b) pi= round(a,3) aprx="Approximation of pi:" print(aprx,pi) r=eval(input("Enter the radius:"'\n')) A=a*r*r Area= "Area:" print(Area,round(A,3))
8cabc9659dbdcd06703142060737b758f179f598
LeeWooil/OpenCV_Study
/OpenCV_Practice_9.py
893
3.5625
4
import numpy as np import cv2 as cv img = cv.imread('Son.jpg') # access a pixel value by its row and column coordinates. px = img[100,100] print(px) # accessing only blue pixel blue = img[100,100,0] print(blue) # modify the pixel value img[100,100] = [255,255,255] print(img[100,100]) #accessing RED value img.item(...
36ad34b48e7b3fa1cf5cbf8a3b512009f6595aa1
chenxu0602/LeetCode
/1203.sort-items-by-groups-respecting-dependencies.py
3,035
3.6875
4
# # @lc app=leetcode id=1203 lang=python3 # # [1203] Sort Items by Groups Respecting Dependencies # # https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies/description/ # # algorithms # Hard (45.94%) # Likes: 119 # Dislikes: 27 # Total Accepted: 3.1K # Total Submissions: 6.8K # Testcase Examp...
7b75fac667d4ef1d34103fe9869c993787734b96
PeturOA/2021-3-T-111-PROG
/assignments/files_and_exceptions/advanced/join_two_files.py
972
3.90625
4
def main(): file_name_a = input("First file: ") file_name_b = input("Second file: ") file_a = open(file_name_a, "r") file_b = open(file_name_b, "r") print(join_text_files(file_a, file_b)) def join_text_files(file_a, file_b): result = "" lines_a = read_all_lines(file_a) lines_b = r...
eaf0c5885b33e3c67a1107779aa0a15be997ea44
ArunBE6/arun
/hunter_set2_1.py
120
3.53125
4
import sys, string, math line1 = input().split(' ') line2 = [] for s in line1 : line2.append(s[::-1]) print(*line2)
0d8bc0882fbc50462bbda50cdf1e4571047506e7
vslinko/diofant
/problems/754/main.py
234
3.53125
4
def double_gen(s): i = 1 l = len(s) while i < l: yield int(s[i-1]+s[i]) i += 1 s = "" for i in range(1, 1001): s += str(i*i) g = double_gen(s) print "answer is %d" % sum((1 for i in g if i % 2 == 0))
9e4b81f3987d41874df109a7ccffaa78b29f8bdd
tennyson-mccalla/PPaItCS
/6.11.py
228
3.6875
4
def squareEach(nums): for i in range(len(nums)): nums[i] = nums[i] ** 2 return nums def main(): l = [8, 16, 19, 14, 18] print(l) print("The squares of the above are {}".format(squareEach(l))) main()
9ac02551496fcc12f2475f0524ec1191cea59fba
DloBagari/python_scripts2
/venv/Dict_Sets/word_index.py
1,519
3.828125
4
from sys import argv, exit import re from collections import defaultdict def word_index(filename, pattern): """find location of a pattern in each line in a file, using dictionary""" result = {} word_reg = re.compile(pattern) with open(filename, encoding="utf-8") as f: for line_number, line in ...
58a85bb51aca2a628f3586f1e7c2a95d19abdfec
CodingDojoDallas/python_oct_2017
/harshilp/Fundamentals/multiplicationTable.py
186
3.578125
4
for i in range(13): if i == 0: y = "x" else: y = str(i) for j in range(1,13): if i != 0: j = j * i y += " " + str(j) print y
592dc520f99bd030d2507089abcb61cb32cadd71
YuanXianguo/Python-Interview-Master
/100Cases/1-50/num46输入退出.py
285
3.734375
4
"""题目:求输入数字的平方,如果平方运算后小于 50 则退出。""" f = 0 while True: num = eval(input("输入数字,平方小于50则退出:")) f = pow(num,2) if f < 50: break else: print("输入数字结果是:{}".format(num))
b7d00925ac783cd183f499b1f22190044e1a0a76
CaitlinChalk/python
/machine_learning/machine_learning_training.py
3,220
3.671875
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 27 13:15:19 2020 @author: matcc introduction to machine learning, from Python training course """ import os import numpy as np import pandas as pd import statsmodels.api as sm from sklearn import linear_model from sklearn.model_selection import train_test_split from mat...
61069f7b5ab485accf4e9ed133fd67b1ca338b43
mattlehrer/exercism
/python/yacht/yacht.py
1,290
3.953125
4
""" This exercise stub and the test suite contain several enumerated constants. Since Python 2 does not have the enum module, the idiomatic way to write enumerated constants has traditionally been a NAME assigned to an arbitrary, but unique value. An integer is traditionally used because it’s memory efficient. It is a...
65cb4c4f8715e3dc0f5f2fe51771a33209e55af3
marcoscocacode/Regression-Models
/Simple Linear Regression.py
1,189
3.828125
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 3 14:41:27 2020 @author: Marcos_Coca_F. """ # Regressions # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Assets/Salary_Data.csv') x = dataset.iloc[:, :-1].values y = da...
cdbc2bf7515d701554bd38936f41033d9f4b6173
zadraleks/Introduction_in_Python_7-8_grades
/Lesson 1-7/1-7-6.py
581
3.984375
4
#Вы уже знакомы с термином "факториал", однако предыдущее наше решение не идеально – оно считает факториал только #одного числа. Модифицируйте вашу программу из задачи "18!" таким образом, чтобы она принимала на вход натуральное #число n и печатала значение выражения n! a = int(input()) factorial = 1 for i in range (2...
b88f06ed0fbc88eb82c612f0258aa4a658645b25
syarifhilmi/robotik_raspberrypi_2021
/praktek-3/module_keypad/keypad_board.py
1,047
3.75
4
import RPi.GPIO as GPIO import Keypad #import module Keypad ROWS = 4 # number of rows of the Keypad COLS = 4 #number of columns of the Keypad keys = [ '1','2','3','A', #key code '4','5','6','B', '7','8','9','C', '*','0','#','D' ] rowsPins = [29,31,33,35]...
95abe6e876efc9480d9eca03076ec295b870d095
error-hacker/Python-Games
/Guess the Number Game.py
1,449
4.03125
4
#Guess the Number Game import random no=random.randint(1, 15) guessno=0 print("Hello There! \nWhat's your Name?") name=input() print(name,",I am thinking of a number between 1 and 15 in my processor.\nTake a guess!") for guessno in range(5): guess=int(input()) if guessno==0: if guess<no: pri...
8a98492bf595ae249edf08a99bd7524810d2440a
DemiD223/hometask12
/task1.py
679
4.15625
4
class Animal: def talk(self): pass class Dog(Animal): def talk(self): print("woof woof") class Cat(Animal): def talk(self): print("meow") def animal_talk(animal: Animal): animal.talk() # Task 1 """ Method overloading. Create a base class named Animal with a method called...
950221391148263afe12ffc0d8170ca6ef306ff0
gabriellaec/desoft-analise-exercicios
/backup/user_151/ch49_2020_09_30_21_08_35_482182.py
136
3.59375
4
def inverte_lista(x): i = len(x) j = i y = [] while j < i: y.append(i-1) j = j - 1 return y
9f81d65ac192c179024d38727facef658102875a
vishal1565/30-Days-of-Code
/day25.py
548
3.984375
4
import math t = int(input()) for _ in range(t): n = int(input()) root = math.sqrt(n) limit = math.floor(root) + 1 if n == 1: print("Not prime") elif n == 2: print("Prime") else: if n%2 == 0: print("Not prime") else: flag = Tru...
c0950dbe2b37140fa144eee114a1461a60ca04f7
bberton-ciandt/python-course
/hello-world/variables.py
729
4.03125
4
a = 12 b = 3 print(a + b) print(a - b) print(a * b) # print as a float by default print(a / b) # print as an integer print(a // b) print(a % b) for i in range(1, a // b): print(i) parrot = "Norwegian Blue" print(parrot) print(parrot[0]) print(parrot[3]) print(parrot[-1]) print(parrot[0:9]) print(parrot[:9]) print...
49b9d471ff3ae2abbdaa131cc9969fab7f73d1b5
moni310/if_else_questions
/month.py
198
4.25
4
month=int(input("enter the number")) if month==30: print("january,march,may,july,september,nomvember,december") elif month==31: print("april,june,agust,octomber") else: print("feburary")
e3b725496844726464323d4c2feb70c5d496310c
ChangxingJiang/Python-DM-Homework-W1-W3
/Day-10/Exercise-09-周栩睿/print_number.py
552
3.546875
4
from threading import Thread from time import sleep def print_number(): for i in range(1,11): print(i) sleep(0.5) def main(): start = print_number() t1 = Thread(target=print_number()) t1.start() t2 = Thread(target=print_number()) t2.start() t3 = Thread(target=print_number()) ...
9129f2149d459f978866759cb8e7eae93893c53a
borko81/python_fundamental_solvess
/examples/exam_12_08_2020/Memory_Game.py
985
3.65625
4
elements = input().split() moves = 0 while True: line = input() if line == 'end': break f, l = map(int, line.split()) moves += 1 if f < 0 or f >= len(elements) or l < 0 or l >= len(elements) or f == l: print('Invalid input! Adding additional elements to the board')...
392475e4c5678ea5ed0d45b856830c76a321e97b
abruption/Python
/branching_loop_03.py
1,004
3.875
4
# 반복문 cont. # for 변수 in range(변수 시작값, 끝값, 증감값): # 짝수 출력 for n in range(2, 11, 2): print(n) for n in range(1, 11): if n % 2 == 0: print(n) # step에 감소식 for n in range(10, 0, -1): print(n) # 문자열의 문자 출력 words = 'I love python' for word in words: print(word, end=' ') print() # 리스트 원소 출력 words =...
6f09c1b6c9a43dbc11c6880486787fc5adfea9cf
boy56/LeetcodeAlgo
/20210308.py
1,042
3.640625
4
# 百度-商业场景营销研发部-机器学习-二面 # 1、插入新值、删除最新、返回已存储空间中数据最大值 time_stack = [] # 按照时间插入 # value_list = [] # 按照值进行排列 max_value = -10000 # tmp.append() def insert(value): # O(1) 插入 time_stack.append(value) if value > max_value: max_value = value # tmp.pop() def delete(value): time_stack.pop() # O(n) 修改max ...
d01afe9a4a00ffb2c57eaccac64352c7b0908cf5
chaichai1997/python-algorithm
/array_find_min_k.py
1,089
3.84375
4
# -*- coding: utf-8 -*- # author = "chaichai" """ 在数组array中找出第k小的值 输入: array, low 起始下标、high右边界下标 输出:第k小的值 """ def find_min_k(array, low, high, k): i = low j = high # 边界初始点 ref = array[i] while i < j: # 大于ref位于ref的右边 while i < j and array[j] >= ref: j -= 1 # 更新子数...
c56d9f502906bfdac7e41cd339f5591c066b60e0
ShawnHan1993/EC602
/1 homework/changlong/w1a_limits.py
808
3.765625
4
# AUTHOR ShenHan shawnhan@bu.edu # AUTHOR ChanglongJiang cljiang@bu.edu Table = "{:<6} {:<22} {:<22} {:<22}" def Largest_Unsigned_Int(bytes): result = 2**(8*bytes)-1 return result def Minimum_Signed_Int(bytes): result = -2**(8*bytes-1) return result def Maximum_Signed_Int(bytes): result = 2**(8*...
5783298d2381774b43b03e3207b988b9c08b050c
ZoranPandovski/al-go-rithms
/math/highest_common_factor/cpp/hcf.py
1,018
4.21875
4
#A python program to determine the highest common factor of positive integers only. def hcf(x, y): #set the highest common factor to 1 hcf = 1 #To check if one of the number is divisible by the other if x % y == 0: return y #iterate within half the range of one of the ...
59ab6bd56d85944c1d20f2dc3cfdf13d40c076e1
koushikgsun/OOHS_2021_HOLIDAY_HW_Key
/18.py
132
3.6875
4
a = -10 b-20 if a > 0 and b < 0 : a+=1 elif a < 0 and b < 0 : a-=1 elif a < 0 and b > 0 : b-=1 else: b-=1 print(a,b)
4e592398e26231977c742069b8749093e3cf7f2b
MRog40/python-p2p-cards
/cards.py
5,427
4.1875
4
import random """ This class is just a list for holding cards """ class Cards: # __init__ -> Class instantiation, no arguments def __init__(self, cards = None): if cards is None: self.cards = [] elif isinstance(cards, list): self.cards = cards # __str__ -> ...
e1788a1100e99d7d8bea5767a96844e555949417
TataMoskovkina/GeekUniversity
/Алгоритмы и структуры данных на Python/HW_3_task_5.py
679
3.921875
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 18 01:05:39 2019 @author: moskovkina 5. В массиве найти максимальный отрицательный элемент. Вывести на экран его значение и позицию в массиве. """ from random import randint n = int(input("Введите длинну массива: ")) nums = [randint(-20, 10) for i in range(n)] max_neg_...
2e9625289b8f9df754215959931ea025d7590bd0
DaryaKatalnikova/Structured-programming
/занятие 1/Ex10.py
212
3.5625
4
ch=(str(input("Введите символ"))) s=['0','1','2','3','4','5','6','7','8','9'] sum=0 for i in range (0,len(s)): if (ch==s[i]): sum=sum+1 if (sum==1): print("yes") else: print("no")
fb78f371d15a3fc0bb73acec17ab167a3b4a2c54
xtakacsx/bitesofpy
/149/words.py
624
3.90625
4
def sort_words_case_insensitively(words): """Sort the provided word list ignoring case, and numbers last (1995, 19ab = numbers / Happy, happy4you = strings, hence for numbers you only need to check the first char of the word) """ # sorted_words = sorted(words, key=str.lower) # new_list = ...
94f7e2815ae439df77a89d94cc3965875f0099bb
Eroica-cpp/LeetCode
/253-Meeting-Rooms-II/Python/Solution02.py
1,484
3.90625
4
#!/usr/bin/python """ ============================================================================== Author: Tao Li (taoli@ucsd.edu) Date: Aug 8, 2015 Question: 253-Meeting-Rooms-II Link: https://leetcode.com/problems/meeting-rooms-ii/ ==========================================================================...
661bcdb41995fe994e93f614a7b12fde22d06a19
Calliso/Crypto-04
/Crypto/utils/symmetric.py
1,830
3.578125
4
from cryptography.fernet import Fernet, InvalidToken class Symmetric: """ symmetric cryptography functions """ def __init__(self): self.key = '' self.create_key() def create_key(self): """ creates random key Returns: key: Random generated key ...
cc633a14d4b9de20e133afbf1fa4551b37b72a24
Jennifer0606/Codewares
/8kyu/sum_mixed_array.py
760
3.796875
4
""" https://www.codewars.com/kata/57eaeb9578748ff92a000009/train/python Given an array of integers as strings and numbers, return the sum of the array values as if all were numbers. """ # my solution def sum_mix(arr): result = 0 for i in range((len(arr))): result += int(arr[i]) return result # b...
ddc9270b88a64af1f2b20f9a8573958b59899de6
J-pcy/Jffery_Leetcode_Python
/Easy/479_LargestPalindromeProduct.py
735
4.09375
4
""" Find the largest palindrome made from the product of two n-digit numbers. Since the result could be very large, you should return the largest palindrome mod 1337. Example: Input: 2 Output: 987 Explanation: 99 x 91 = 9009, 9009 % 1337 = 987 Note: The range of n is [1,8]. """ class Solution(object): def l...
0cad4d13094dd441c4b8356e44528c147eac9d37
tuantvk/python-cheatsheet
/src/tools/image/convertTif2Jpg.py
725
3.515625
4
import os from PIL import Image from glob import glob """ Example tree file convert: NAME_FOLDER + B - file.tif - file.tif + C - file.tif - file.tif + D """ NAME_FOLDER = "file_tiff" # change name folder here dir_path = os.path.dirname(os.path.realpath(__file__)) + "/" + NAME...
e2da4d1999919af0e33ff6587dca27ae1708e9b5
davidbezerra405/PytonExercicios
/ex050.py
190
3.953125
4
soma = 0 for c in range(0, 6): num = int(input('Informe {}º número inteiro: '.format(c+1))) if (num % 2) == 0: soma += num print('Soma dos número pares: {}'.format(soma))
5fc2668bba922d6961b975b90d62e020d873f226
MCrank/learn-python
/Section2/2.5-UserInput.py
437
4.28125
4
# Firstname, M. Lastname first_name = str(input("Please enter your firstname: ")) middle_name = str(input("Please entre your middle name: ")) last_name = str(input("Please enter your last name: ")) first_name = first_name.capitalize() middle_name = middle_name.capitalize() last_name = last_name.capitalize() name_for...
ac3e9693e267c46d74846b502a92856032cb011e
AbantikaJena/School-Class-notes
/Ass_Ch5_PrQue8.py
254
3.875
4
# Assignment Ch5 File Handling # Que 8 # display all records with line/record number def readfile(x): f=open(x,"r") rn=0 for i in f.readlines(): rn+=1 print(rn,i) x=input("Enter the file name : ") readfile(x)
7354a1df4bc66be2c0b2bafa1b09c08765092561
kebingyu/python-shop
/leetcode/miniumu-depth-of-binary-tree.py
1,004
4.03125
4
""" Difficulty: Easy Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. """ # Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = Non...
6a43bb2e4860d723a3c365b436f0dd6b5d024a5e
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/space-age/fc6f9be238a649c0a46098719542bc27.py
1,369
3.734375
4
#!/usr/bin/env python """ Earth: orbital period 365.25 Earth days, or 31557600 seconds Mercury: orbital period 0.2408467 Earth years Venus: orbital period 0.61519726 Earth years Mars: orbital period 1.8808158 Earth years Jupiter: orbital period 11.862615 Earth years Saturn: orbital period 29.447498 Earth years...
42f330afbe767e5190cc95419153fb771a81af0a
Yonimdo/Python-Intro
/Files/35/ex_35_old.py
623
3.5
4
def parse_commands(filename): x, y = 0, 0 # --- WRITE YOUR CODE HERE --- # infile = open(filename,"r"); for line in infile: split = line.split(' ') if split[0] == "North": y += int(split[1]) elif split[0] == "South": y -= int(split[1]) ...
1080cf99aa47bd43211c2f4de77955c37289ebf6
gabrielsantos2000/hackerrank-30-days-of-code-python
/day_1_data_types.py
452
3.71875
4
# Task # To complete this challenge, you must save a line of input from stdin to a variable, # print Hello, World. on a single line, # and finally print the value of your variable on a second line. # Difficulty: Easy # Score: 30 # challenge link: https://www.hackerrank.com/challenges/30-data-types/problem i = 4 d = 4...
9f65494392def731c360cfaed84796883f9e0966
missArthas/LeetCode
/PythonVersion/easy/Q504Base7.py
436
3.53125
4
class Solution(object): def convertToBase7(self, num): """ :type num: int :rtype: str """ result="" t=num if(num==0): return "0" if(num<0): t=-num while(t>0): result=result+str(t%7) t=t/7 if(num<0): result=result...
b84d262e8535c53f00953f5fdca9c81d5cd83e44
rafaelperazzo/programacao-web
/moodledata/vpl_data/7/usersdata/138/4480/submittedfiles/esferas.py
212
3.859375
4
# -*- coding: utf-8 -*- from __future__ import division A=input('digite A:') B=input('digite B:') C=input('digite C:') D=input('digite D:') if A==B+C+D and B+C==D and B==C: print('S') else: print('N')
12a26d365c958784cc689ff5b9a785eb9045a55d
pocokim/algo
/python/elice/chapter2/training/4_isAnagram.py
1,553
3.78125
4
def isAnagram(str1, str2): # # 풀이 1 : 리스트 소팅 # str1List = list(str1) # str2List = list(str2) # str1List.sort() # str2List.sort() # return str1List == str2List dic1 = {} for ch in str1: dic1[ch] = int(dic1.get(ch,'0')) + ...
b279e864d72410222a5c1caeacf61ed193bf3a23
learlinian/Python-Leetcode-Solution
/66. Plus One.py
541
3.546875
4
class Solution(object): def plusOne(self, digits): i = len(digits) - 1 if digits[i] != 9: digits[i] += 1 else: digits[i] = 0 while i-1 >= 0 and digits[i-1] == 9: digits[i-1] = 0 i -= 1 i -= 1 ...
b98fe8cb5447611e4051bcc1aecde8f808955096
KratiYounes/Kilometer_Converter
/script.py
149
4
4
print("Veuillez entrer la distance en Miles : ") miles = input() kilometers = miles * 1.609344 print("La distance en kilometre : ") print(kilometers)
504b69413d591a0954adf84684d9c98abc00cb5f
Hellofafar/Leetcode
/Medium/186.py
1,698
4.09375
4
# ------------------------------ # 186. Reverse Words in a String II # # Description: # Given an input string , reverse the string word by word. # Example: # Input: ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"] # Output: ["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"] # # Note: # A wo...
1deb52595eba6f7c66658597accaf3e931be377f
saurabh-kumar88/leetcode
/july2020/Day31_Climbing_Stairs.py
534
3.703125
4
class Solution: def climbStairs(self, n: int) -> int: # base cases # this problem is same as fibonacci sequence """ 1 : [1] --> only one way 2 : [1,1], [2] --> 2 ways in n = 2 steps 3 : [1,1,1], [1,2], [2,1] --> 3 ways 4 : --> there will be 5 ways """ if(n == 0): return ...
3c8a6e5d621a278c1f0bb877e65963687f99e593
Gordana13/fizzbuzz-km-to-miles
/km to miles.py
539
3.8125
4
# -*- encoding: utf-8 -*- print("Pozdravljeni, to je pretvornik km v milje.") km = float(raw_input("Prosim, vnesite kilometre: ")) miles = km * 0.62137 print "%s km ima %s milj. " % (km, miles) vprasanje = raw_input("Ali želite narediti novo pretvorbo, da ali ne? ").lower() while vprasanje == "da": km = float(ra...
3ce354f07e015c3764a205ce7fa5d1d0b64a07e4
Wilson194/Angry-tux
/angrytux/model/Observering/ChangeManager.py
1,777
3.703125
4
from ..Singleton import Singleton class ChangeManager(metaclass=Singleton): """ Change manager is class for managing observer pattern. This class register and unregister all observers and objects and notifying all objects """ def __init__(self): self.__observation_map = {} def regi...
e18cbac4a69f14ac6cac29a3abd0423e1f2a8235
aduV24/python_tasks
/Task 6/shopping.py
701
4.21875
4
#Reques item names from user item1 = input("Enter name of first item: ") item2 = input("Enter name of second item: ") item3 = input("Enter name of third item: ") print() #Request item prices from user print("Enter the price for each item below in two decimal places:") price1 = float(input("Item1: ")) price2 = float(in...
54beabdb6db0767e926d9201fcbf03a2fe51773d
rbodduluru/PythonCodes
/Palindrome.py
593
4.40625
4
# #!/usr/bin/python # Python program to check if the word is a palindrome or not def palindrome(string1): list1=list(string1) len1=len(list1) i=0 n=len1 while i<= n: if list1[i] == list1[n-1]: flag=0 else: flag=1 break...
aba1b2a84e00e9ad0c7ff08dd25bda27e413e6a5
henrymwestfall/course-scheduler
/csv_writer.py
580
3.578125
4
import csv def write_file(filename, raw_results): ordered_results = [] for i in raw_results: ordered_results.append([i["Name"], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]]) header = ["Student Name", "Period 1 Course Code", "Period 2 Course Code", "Period 3 Course Code", "Period 4 Course Code", ...
1f842999bf1813c625bd1f3a7dcbb3c5db0b833a
conorpreston13/python_practice
/code/algorithms_sort/recursion_mini-projects.py
1,301
4.15625
4
# Countdown Timer ============================================================== print('Countdown Timer') import time def recur_countdown(n): if n == 0: return n else: print(n) time.sleep(1) return recur_countdown(n-1) # ITERATIVE SOLUTION # def iter_countdown(n): # while ...
8daf85742f122990d2fe21f5ff56fc67149efd29
dpinezich/appe_uzh_hs_19
/solutions/ex_12.py
364
3.59375
4
import json address_book_dict = {} while True: name = input('Name: ') if name == 'exit': break else: phone = input('Phone: ') address_book_dict[name] = phone address_book_file = open('address_book.txt', 'w') address_book_json = json.dumps(address_book_dict) address_book_file.write(...
ae596765aa43f12d4751642f3f11b93c2cb137f2
sowmyamanojna/BT3051-Data-Structures-and-Algorithms
/quiz1/class_set.py
539
3.5625
4
class Set(): def __init__(self, val=[]): self._value = val self._value = self.get_unique() def get_unique(self): uvals = [] for i in self._value: if i not in uvals: uvals.append(i) return uvals def __sub__(self, other): n = max(len(self._value), len(other._value)) result = Set() result._val...
353b8fd64e0ea087d7dcab3cf74f91825ab488f6
shashankbhor/machinelearning
/ClaimFilingProbability/ClaimPredictionANN.py
2,437
3.5625
4
# -*- coding: utf-8 -*- """ @author: Shashank """ import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('insurance.csv') X=dataset.iloc[:,0:7].values y=dataset.iloc[:,7:8].values #Encoding categorical variables from sklearn.preprocess...
14ca04616c3b9b10081bc566c4724c2ba86a53be
bmksimons/Encryption_algorithms
/encryption/rsa.py
1,737
3.546875
4
import random from cipher import Cipher from crypto_utils import modular_inverse, blocks_from_text, text_from_blocks, generate_random_prime class RSA(Cipher): def __init__(self): super().__init__() self.keys = self.generate_keys() self.encrypting_key = self.keys[0] self...
2ca80b0b9ce2c49bcf8fc407d65202792bc0f08b
fuguohong/algs
/alg-1/4.py
1,252
3.78125
4
# coding=utf-8 """ p220 一组排列(或是排名)就是一组N个整数的数组,其中0到N-1的每个数都只出现一次。两个排列之间的Kendall tau距离就是在两组数列中顺序不同的数对的数目。 例如a = { 0, 3, 1, 6, 2, 5, 4 } ,b = { 1, 0, 3, 6, 4, 2, 5 },Kendall tau就是4, 因为就是求两个排列之间的逆序{ 0,1 },{ 3,1 },{ 2,4 },{ 5,4 },一共为4对,故Kendall tau距离为4。 """ def distance(arr1, arr2): arrlen = len(arr1) assert arrl...
93f6bab6e218f884eca25834a45f8ea57a49a6c0
inkri/Machine-Learning
/ML_Python/Matplotlib.py
2,675
3.859375
4
#Load import matplotlib.pyplot as plt #Plot(x vs y Axis) plt.plot([1,2,3,4,5],[5,7,4,6,8]) plt.show() #Legends, Titles, and Labels with Matplotlib import matplotlib.pyplot as plt x = [1,2,3] y = [5,7,4] x2 = [1,2,3] y2 = [10,14,12] plt.plot(x, y, label='First Line') plt.plot(x2, y2, label='Second Line') plt.xlabel('Pl...
f68bfbdc5dc0fc07ab994d2c12fbc3c2b9168a01
sts-sadr/tensorflow_weather_tutorial
/multiNeuronRNN.py
2,737
3.671875
4
#!/usr/bin/python import os import matplotlib from matplotlib import pyplot as plt import numpy as np import tensorflow from tensorflow import keras #Hands-on machine learning chapter 15. let's make a RNN that's really just a single neuron. def make_waves(batch_size, steps): t = np.linspace(0, 1, steps) off1, o...
9025f87f4039cbe1e9a615a8312f10368d635155
0011010000110010/codenames-turn-creator
/codenames/main_game/codenames-the-game.py
4,458
3.8125
4
""" @author [jokerock] @create date 2020-02-01 12:25:14 @modify date 2020-02-07 19:27:42 @desc [creating random new-turns for a game called "codenames"] """ import random # ! for "random" import numpy as np # ! creating matrix and calculations # ? for seperating code blocks and improving readability. def basic_deco...
ea925eb81bbcf3deef0f0201ea7fdafee8654c61
dmr8230/UNCW-Projects
/CSC131-Python/Chp 6 - Bouncing Balls.py
3,271
3.90625
4
#========================================================================== # PROGRAM PURPOSE:... Ch6-1 Modified Ch6 M2/3 # AUTHOR:............ Rowe, Danielle # COURSE:............ CSC 131-006 # TERM:.............. Spring 2019 # COLLABORATION:..... I looked up the random.choice(colors) through stack overflow # WO...
33853ec53e6c877a52d977c486e0eedb5a79b8fc
donaldmenezes/Solving-Problems-with-Python
/goodrich/Chapter_1/P-1.30.py
300
4.25
4
def count_divide_2(num): """ Assumes num is a positive integer Returns the number of times num has to be divided by 2 to get a value less than 2 >>> count_divide_2(10) 3 """ i = 0 while num > 1: num = num // 2 i = i + 1 return i
7961ed9fccc54d98ae719f2fa5695615c3c71a09
95275059/Algorithm
/53_maximum-subarray.py
1,970
3.875
4
""" 53.最大子序和 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 解题思路:除了一般解法,还有分治法 """ class Solution(object): def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int 暴力划窗,复杂度O(n^2) """ if not nums: return None else: maxnum...
d88a5de9853c0f073f8f5c29cd2e1505397e2af5
sunzehui/MyCodebak
/PythonCode/algorithm/数组的包含.py
356
3.984375
4
# 题目:输入两个字符串str1和str2 # 判断str1中的所有字符是否都存在于str2中 str1 = "abc" str2 = "abfbewrhc" def fun(): for i in (str1): f = True for j in (str2): if j == i: f = False if f: print("False") return print("True") fun()
648ca0baf1b4b8443f5f267f440e1e03b0829649
kavinxin/wenjian
/usuallyPackage/xiancheng/xiancheng2018100505.py
1,427
4.28125
4
#线程属性的使用 import time import threading def loop1(in1): print("loop1 run is",time.ctime()); print("loop1 is canshu",in1); time.sleep(4); print("loop1 end is",time.ctime()); def loop2(in1,in2): print("loop2 run is",time.ctime()); print("loop2 is canshu",in1, in2); time.sleep(2); print("lo...
743cb3177b16c793d1d7f6a206dfe61c8cee901b
williamsmichael/edX_MIT_cs_python
/l6p2.py
815
4.21875
4
# ---------------------------version 1 def oddTuples(aTup): ''' aTup: a tuple returns: tuple, every other element of aTup. ''' # Your Code Here if len(aTup) <= 1: return aTup return aTup[0::2] # ---------------------------version 2 def oddTuples(aTup): ''' aTup: a...