blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f94603ebca85b7b5827e2cdc6b2b6ed806ca1d59
lavi09/Strings-problems
/lengthoflongestsubstring.py
743
3.828125
4
# -*- coding: utf-8 -*- """ Created on Sat May 18 00:33:09 2019 @author: Lavi """ def lengthOfLongestSubstring( word): # Initially we can go as far to the left as we want left_most_valid = 0 longest = 0 last_seen = {} for i, letter in enumerate(word): if letter in last_seen:...
0639ab32c302b6ff793f4649d1c74175613132be
JonathonRT/Dungeon
/Dungeon/dungeon_level.py
1,849
3.546875
4
##This file handles the leveling system import dungeon_stats import random ##Level check compares current experience to the required experience, and acts accordingly. def level_check(): if dungeon_stats.exp >= dungeon_stats.tnl: print ("Congratulations! You have reach level ", dungeon_stats.level + 1, "!")...
8b93b16f4bb8b315b7508d538d6a6faff30757b9
Kapsule98/cryptography
/dh.py
461
3.578125
4
print("Choose P and G") P = int(input()) G = int(input()) print("Choose Private key selected by Alice(a)") a = int(input()) print("Choose private key selected by Bob(b)") b = int(input()) x = (G**a) % P y = (G**b) % P print("Value computed by Alice and sent to Bob : ",x) print("Value computed by Bob and sent ...
2aaed974b37ff8c32192ce874f8fbf1be59d7fc2
jinnygym/Prepro-Python
/Power.py
195
4
4
"""Power of X""" def main(): """main""" num = int(input()) for i in range(num//2): print(i* " " + "\\") for k in range(num//2): print(((num-1)-k)*" " +"/") main()
3250d096bccbd3a5531ad060e205c80571bc4f49
santosh241/Windary
/Python/ClimbingStairs.py
663
3.9375
4
# -*- coding: UTF-8 -*- # You are climbing a stair case. It takes n steps to reach to the top. # # Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? # # Note: Given n will be a positive integer. # # Python, Python 3 all accepted. class ClimbingStairs: def climbStairs...
400090f2c10493b805ad048fbf632e3372e40f94
renumokalkar/Python_14_july
/listoperation.py
811
3.5625
4
print("THIS IS TASK 1") num=[1,2,5,4,10,5] num1=[] num2=[] for i in num: if i%2==0: num1.append(i*50) print("num1" ,num1,end='') for i in num: if i%2!=0: num2.append(i*50) print("\nnum2",num2,end='') print('\n') print("\nTHIS IS TASK 2") l1=[234,556,233,454,1221,3243] l2=lis...
04596beefdbf26bc908fcd3e0d3cb48f285636bf
malder85/-_-
/Homework/homework6.py
3,464
3.53125
4
# 1. Дан список строк my_list. Создать новый список в который поместить # элементы из my_list по следующему правилу: # Если строка стоит на нечетном месте в my_list, то ее заменить на # перевернутую строку. "qwe" на "ewq". # Если на четном - оставить без изменения. # Задание сделать с использованием enumerate. my_lis...
4b6f14fc9ab512474c7215a75b387588286a5275
jeremy-ph/python-ex
/python_example/python_ex13.py
734
3.515625
4
import pandas as pd # 계절별 서울/부산 지역 온도 데이터 정의 temperatures = [[3.3, 34.5, 14.2, -10], [7.1, 32.1, 10.7, 2]] seasons = ['Spring', 'Summer', 'Fall', 'Winter'] regions = ['Seoul', 'Pusan'] # 데이터프레임 객체 생성 data = pd.DataFrame(temperatures, index=regions, columns=seasons) # 데이터프레임 객체의 데이터 출력 print(data) print("=" * 50) pri...
147d143b511e2f9971b392a41829d1e955231cef
Havdynge/Oblig-1
/Exercise 1 (more programming problems)/1-2.py
406
4.40625
4
from math import pi x = input("Enter 'c' for circle or 's' for sphere") r = int(input("Enter a radius: ")) if x == "c": print(f"Area of the circle: { pi * r ** 2:.2f}") print(f"Circumference of the circle: { 2 * pi * r:.2f}") elif x == "s": print(f"Volume of the sphere: {(4 / 3) * pi * r**3:.2f}") print(f"surface...
2130320b4c4ed91332925099c96b2b06d8117c9e
Dountless/Python
/Basic Projects/Dictionary/Mydictionary by Database(sqlite).py
3,622
4.09375
4
import sys import sqlite3 Title="-:WELCOME TO DOUNTLESS DICTIONARY:-" print(Title.center(len(Title)+100,"-")) #connect sqlite to database and creat table db=sqlite3.connect("Dictionary.db") cur=db.cursor() cur.execute("CREATE TABLE IF NOT EXISTS WORD_MEANING_DATA(ID INTEGER PRIMARY KEY AUTOINCREMENT,WORD TEXT,MEANING...
a1e3704aa1c7f1976c7a81168758db68802a0d80
jen222/interviewanswer
/answer/fun3.py
741
3.765625
4
# 将字符串 s 拆分成两个字符串 s1、s2,其中 s1 只包含字母,转换为小写,以 [a-z] 排序,s2 只包含数值,升序排序 def chaifen(): s = "aAsnr3id2d4b6gs7DZsf9e1AF" #将字符串转化为小写 s = s.lower() s1_list = [] s2_list = [] for i in s: #判断元素是否为数字,是添加到s2中,反之添加到s1中 if i.isdigit() == True: s2_list.append(i) ...
ed8139c994b381a79c548c6374dd213f64368e76
srikanthpragada/PYTHON_21_SEP_2020
/demo/funs/fun_as_params.py
188
3.75
4
def add(a, b): return a + b def mul(a, b): return a * b def operation(a, b, fun): print(fun(a, b)) operation(10, 20, add) operation(10, 20, mul) # operation(10, 20, len)
13f15eaa8924fab5eb2266bf1e767e2f8c9c2e0c
RCoon/CodingBat
/Python/String_1/extra_end.py
353
4.3125
4
# Given a string, return a new string made of 3 copies of the last 2 chars # of the original string. The string length will be at least 2. # extra_end('Hello') --> 'lololo' # extra_end('ab') --> 'ababab' # extra_end('Hi') --> 'HiHiHi' def extra_end(str): return str[-2:] * 3 print(extra_end('Hello')) print(extra_e...
870b41251723c9a48c3f99d8edd7898421825f30
enchantress085/Python-Basic
/Strings.py
1,149
4.40625
4
print("""============================= =====================================""") a='I am a single quote string' b="I am a double quote atring" c="""I am a triple quote string""" print(a) print(b) print(c) print("""============================= =====================================""") a='I am a single quote\'s s...
195c7b868e8c731a478f6a01e757ff3515d56585
aligg/advent-of-code-2019
/day6.py
1,684
3.84375
4
def file_to_map(): f = open("day6input.txt", "r") contents = f.readlines() orbits = dict() for line in contents: line = line.strip() line_list = line.split(")") if line_list[0] in orbits: orbits[line_list[0]].append(line_list[1]) else: orbits[line_...
f8ae75a409b94a110ecf2d01ff2da8c1baf83d25
servandomiguel/Tareas-Python
/tarea1.py
2,233
4.21875
4
#!/usr/bin/python # -*- coding: utf-8 -*- #UNAM-CERT def encuentra_palindromo(cadena): """ Funcion que encuentra el palindromo mas grande dentro de una cadena. Devuelve una cadena con el palindromo La forma de utilizarse: encuentra_palindromo(cadena) donde: cadena debe ser una cadena ...
3df9ebd5a37e1155669f35c0034b6861fdc4a5cb
pedropenna1/Exercicios-Python
/exercicio 3.py
181
3.796875
4
numero1 = int(input('Digite um valor:')) numero2 = int(input('Digite mais um valor:')) Soma = numero1 + numero2 print('A soma entre {} e {} vale {}'.format(numero1, numero2, Soma))
ef47ae7b8b3d845ab83a3ceb6cdca281eb19f527
rydens/python-1
/lor.py
2,506
4.0625
4
"""This is my Lord of the Rings Quiz. I happen to be listening to music from it as I write this.""" import colors as c from utils import ask def right(): print(c.magenta + 'You are correct! :D' + c.reset) def wrong(): print(c.blue + 'Nope, sorry. :(' + c.reset) intro = c.green + ''' Welcome to Ryan's Lord o...
d06c6c50d08fc1854db5e679208a43559c640d30
luzlyherrera/Ejercicios-de-repaso
/Ejercicio68.py
234
4.09375
4
# Escribir un programa que mediante una funcion calcule el resultado de restar el doble de un numero a su cuadrado def resultado(num): resta=2*num-pow(num,2) print(resta) resultado(num=int(input("Ingrese un numero: " )))
06ab2f0a4c017e9113106cf30c9c8146c5c9c4de
algorithm005-class02/algorithm005-class02
/Week_03/G20190343020227/LeetCode_50_0227.py
802
3.5625
4
class Solution(object): #暴力法,超时了,没有出奇迹 def myPow(self, x, n): """ :type x: float :type n: int :rtype: float """ res = 1 if n > 0: for i in range(n): res = res * x elif n < 0: n = -n for i in range...
e4c59fc354d5b470881cf8849fa47a4f3a9751ca
shreyashetty207/python_internship
/Task 4/Prb 3.py
167
3.671875
4
# Create a tuple and convert tuple into list #initialize tuple a = (True, 28, 'Tiger') #tuple to list b = list(a) #print list print(type(b)) print(b)
b679e67776ec5ddf16917f65e322a7e2fc79d643
rafaelperazzo/programacao-web
/moodledata/vpl_data/59/usersdata/161/49034/submittedfiles/testes.py
184
3.65625
4
b=int(input('numero:')) soma=0 b=x for a in range(0,b+1,1): b=b//10 b=n for i in range(1,n,1): x=x%10 x=r soma=soma+r*(2**i) print(soma)
7f53ddd2ed4f8e9171146279cbed78cd913994e7
K4H3NY4/SkaeHub-Developer-Program-Boot-Camp
/Day 2/Question6.py
380
3.875
4
# Create a Python project to perform some simple statistics on a list of values from statistics import mean print('Enter Values separated by a comma') data_value = input() processed_list = data_value.split(',') print(processed_list) print('MAX',max(processed_list)) print('MIN',min(processed_list)) print('List Leng...
955dc45d6f6ce25fc05e78bfbea06125fb2fd783
oguztimurtasdelen/PerformanceAnalysisTechnology
/driver.py
9,401
3.84375
4
""" Izmir University of Economics Faculty of Engineering Project Name: Performance Analysis Technology Lecture: FENG 498 - Graduation Project II Supervisor: İlker KORKMAZ Project Group: Ömer EROĞLU - Fatih KOCA - Oğuz Timur TAŞDELEN """ import csv # importing the csv module import re # importing regex import random ...
e1a10d6e37de99f78c483724cb3353c0279012dd
ChinaChenp/Knowledge
/interview/interview_python/mianshixinde/lesson1/1.2.py
1,106
3.671875
4
#字符串包含 #给定两个分别由字母组成的字符串A和字符串B,字符串B的长度比字符串A短。请问,如何最快地判断字符串B中所有字母是否都在字符串A里? #为了简单起见,我们规定输入的字符串只包含大写英文字母,请实现函数bool StringContains(string &A, string &B) #比如,如果是下面两个字符串: #String 1:ABCD #String 2:BAD #答案是true,即String2里的字母在String1里也都有,或者说String2是String1的真子集。 #如果是下面两个字符串: #String 1:ABCD #String 2:BCE #答案是false,因为字符串String2里的E字...
6abd1c9d4bb828376215bc50d6920be9671c2ba8
sabdj2020/CSEE-5590---Python-DeepLearning
/ICP4/NaiveBayes-ScikitLear.py
1,131
3.8125
4
# libraries import pandas as pd from sklearn.naive_bayes import GaussianNB from sklearn.model_selection import train_test_split # glass data set with pd.read_csv in pandas Library data = pd.read_csv('DataSet/glass.csv') # select columns predictors in data set x = data[['RI', 'Na', 'Mg', 'Al', 'Si', 'K', 'Ca', 'Ba', '...
00bfe2dc5cd744c4e257a117ef0cbb4e162ad562
alabliuk/HackerRank
/Python/Print_Function.py
184
3.71875
4
# https://www.hackerrank.com/challenges/python-print/problem if __name__ == '__main__': n = int(input()) x = int(1) while x <= n: print(x, end='') x += 1
53cac77514d230f8b470a317564adf5375947a4f
AMProduction/Python-HW2
/task_3.py
357
3.90625
4
""" Task 3 Author: Andrii Malchyk v.1.0 """ print("Please, enter the number: ") input_number = input() sum = 0 if int(input_number) > 0: for number in input_number: if int(number) % 2 != 0: sum += int(number) else: continue else: print("The invalid input num...
447d0d268cff8609866ed2436cabd32082214bd7
TiMusBhardwaj/pythonExample
/python-and-mongo-master/Quiz/container-with-most-water.py
544
3.875
4
# https://leetcode.com/problems/container-with-most-water/ from typing import List class Solution: def maxArea(self, height: List[int]) -> int: start =0 end = len(height)-1 max_water =0 while start < end: max_water = max(max_water , (end-start)*min(height[start], height[...
dceec0fcf438139774872a7b164d205b9aa673c6
Suhang1014/Py_DataStructure_Algorithms
/笔试/lilis/2.py
2,054
3.875
4
# _*_ coding:utf-8 _*_ class Node: def __init__(self, data, parent=None, lchild=None, rchild=None): self.data = data self.parent = parent self.lchild = lchild self.rchild = rchild class BinarySearchTree: def __init__(self): """初始化根节点""" self.root = None def...
d0e72341ac19ebc428718baff1d86838293e3a96
ShayLn/py-fighter
/screens/pause.py
3,692
3.703125
4
''' Pause Screen Pause screen - This screen is displayed on top of the game when player presses escape during the game, and enters the pause menu. Each button is attached to a function, resume and quitToMainMenu output a string which is interpreted by the screens loop, wheres quitgame just kills the game. The reaso...
62c8144b11ac305bb9738645fc389c97cefc4fb9
YuLili-git/leetcode_offer
/剑指 Offer 33. 二叉搜索树的后序遍历序列.py
823
3.8125
4
#输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历结果。如果是则返回 true,否则返回 false。假设输入的数组的任意两个数字都互不相同。 #参考以下这颗二叉搜索树: # 5 # / \ # 2 6 # / \ # 1 3 #示例 1: #输入: [1,6,3,2,5] #输出: false #示例 2: #输入: [1,3,2,6,5] #输出: true  class Solution: def verifyPostorder(self, postorder: List[int]) -> bool: def recur(i, j): if i...
c84437d4b1402ea70799edf794b9ae06acadbf7d
michelrandahl/CodeEvalSolutions
/Python3/TrailingString.py
389
3.921875
4
import sys import re def trailingString(line: str): linesplit = line.split(',') sentence = linesplit[0] word = linesplit[1] if re.search(word + "$", sentence): print(1) else: print(0) test = "Hello CodeEval,CodeEval\n" trailingString(test) with open(sys.argv[1], 'r') as test_cas...
855d752cb7c1a4a7206e94d2da085c84791e5a1f
ChangxingJiang/LeetCode
/0701-0800/0747/0747_Python_2.py
426
3.59375
4
from typing import List class Solution: def dominantIndex(self, nums: List[int]) -> int: m = max(nums) if all([m >= 2 * n for n in nums if n != m]): return nums.index(m) else: return -1 if __name__ == "__main__": print(Solution().dominantIndex([3, 6, 1, 0])) ...
7f4e4565b6ae0c9f1b499218adc607399d7fdad9
CarlosNLP/SQL_Python
/01_SQL_Basics/02_sql_insert.py
1,394
3.859375
4
import sqlite3 # Path and opening database db_path = "database/fifa2019_players.db" conn = sqlite3.connect(db_path) cur = conn.cursor() # Table name: players # Columns/Fields: Name, Age, Nationality, Overall, Club, Value, Wage, PreferredFoot, WeakFoot, SkillMoves cur.execute('SELECT * FROM players') # selecting all ...
17715396335a8eaf5ef6d46984a87c5e16e78b5b
coquelin77/PyProject
/leetcode/I though I have idea/217.py
378
3.78125
4
class Solution: def containsDuplicate(self, nums): nums_single = set(nums) if len(nums)!=len(nums_single): return True return False if __name__ == '__main__': nums1=[1,2,3,4,4,5,6,6,6,7,7,8,8,8,8,8,9] nums2=[1,2,3,4,5,8,9] a=Solution() p=a.containsDuplicate(nums=n...
abef3c6a2d6dbb716da747e4aa60ad8f093debf2
kjh618/KAIST-Tutoring-2019F-Public
/Week8/letter_frequency_solution.py
447
3.546875
4
alphabet = 'abcdefghijklmnopqrstuvwxyz' file = open('wikipedia_color.txt', 'r', encoding='utf-8') content = file.read().lower() frequencies = {} for letter in alphabet: frequencies[letter] = content.count(letter) frequencies_sorted = [] for (key, value) in frequencies.items(): frequencies_sorted.append((val...
4d99bb9f1f5446f3337cb83611c868f44713ffb5
Swapnil-ingle/data_structures_and_algorithm
/data_structures/stacks/stack.py
1,041
4.25
4
class Stack: def __init__(self, size): self.size = size self.stack = [None] * size self.head = -1 def push(self, element): # Check if stack is full if (self.head >= self.size - 1): print("Cannot add element - stack is full!") else: self.he...
9d1bbb4f3e477a4617549e0aa546d20f55b47097
apulgarr/CCI_solutions
/CCI_problems/linked_lists/2_8.py
349
4.03125
4
from linked_list import Linked_list #Find the node where the LL gets into a loop #Time complexity: O(n) def get_loop(node): elements = {} while node: if node.value not in elements: elements[node.value] = True else: return node.value node = node.next ret...
6594e146b056298e7486845e0ae9876fa18b8eec
dyq666/sanji
/util/third_numpy.py
737
3.59375
4
__all__ = ( 'weighted_choices', ) from fractions import Fraction from typing import List, Union import numpy as np Num = Union[int, float] def weighted_choices(population: list, weights: List[Num], k: int = 1) -> list: """无 replace 的权重随机. 此外: - 如果想用有 replace 的权重随机, 使用 `rando...
760144d1f08a4e3ee1afcda3ce12a2d161bae666
zhengxiaocai/codewars
/py036_Find_the_divisors.py
513
3.984375
4
# https://www.codewars.com/kata/544aed4c4a30184e960010f4/train/python def divisors(integer): result = [i for i in range(2, integer) if integer % i == 0] return result if result else f'{integer} is prime' def divisors_best(integer): # TODO:这个有点猛 return [i for i in range(2, integer) if integer % i == ...
9bb5d986abbf12068edfeb6c53b48e87a4c467de
carloslvm/learning-python
/book_exercise/crash/Chapter 3: Introducing Lists/Guest List.py
1,254
4.375
4
#!/usr/bin/python3 #Exercise 3.4: Invitation #List of guests guest = ['Ana', 'Maria', 'Saori', 'Naomi'] #Invitation message print ('Hello ' + guest[0] + ',' + ' Would you like to come to dinner?') print ('Hello ' + guest[1] + ',' + ' Would you like to come to dinner?') print ('Hello ' + guest[2] + ',' + ' Would you l...
33b00c82e52c84fac7fd2883858bc3671b844f83
ktissan13/ICS3U0
/Lesson/For loop for Strings.py
256
4.125
4
# For loop for strings # ICS3U0 # Mr Veera # 16 Nov 2017 vowel=0 phrase=input('Give a word or phrase: ') for letter in phrase: print(letter) if letter in 'aeiou': vowel+=1 print(vowel)
3172c8a2a2fca62945cbd7e1fa12a1af5902458a
JuliaBrazolim/AprendendoPython
/PythonBrasil/EstruturaSequencial/temperatura.py
162
3.984375
4
# -*- coding: utf-8 -*- F = float(input('Insira a temperatura em Farenheit: ')) C = (5 * (F-32) / 9) print('\n A temperatura em Celsius é de ', round(C, 1))
624c2e62d064ddffc71c52f2422a945631c94c61
kwintasha/jeu-du-pendu
/le jeu du pendu/pendu.py
4,593
3.703125
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 10 09:13:03 2019 Jeu du Pendu """ from random import choice mystery_word = "" # Mot à trouver partial_word = "" # Mot recherché letter = "" # Caractère saisie par le joueur try_nb = 0 # Nombre d'essaie words_list = list() # Tous les mots disponibles go = T...
a69f2a01dc86c5dbaccc14fce4580677363aaeed
lshi0335/MSITM6341
/Attendance/maximum_difference.py
651
4.375
4
def max_diff_int(int_list): # Check if all members in the list are integers for num in int_list: if not num == int(num): print('Error: At least one of the values in the input list is not an integer.') quit() # Stop excuting the function if any value in the input list is...
2892fc8b5d803274f4dc57dbb4e78cca6732b255
vincepmartin/leetcode
/python/26-remove-duplicates-sorted-array/solution2.py
489
3.546875
4
class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ i = 0 for j in range(1, len(nums)): if nums[i] != nums[j]: i += 1 nums[i] = nums[j] return i + 1 s = Solution() t...
d82c12c6f441558b2e2fec14bdf45ba0b0d83959
sp-shaopeng/leetcode-practice
/1137.py
454
3.640625
4
class Solution(object): def tribonacci(self, n): """ :type n: int :rtype: int """ if (n == 0) : return n if( n < 3) : return 1 ptr = 0 ptr1 = 1 ptr2 = 1 for i in range(3, n + 1) : v ...
027fd5383b566165dd8b9d026da7faaecc9c05e1
ww35133634/chenxusheng
/ITcoach/算法+数据结构/程序设计/设计模式/设计模式/singleton.py
449
3.8125
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # Date: 2018/12/1 from abc import abstractmethod, ABCMeta class Singleton: def __new__(cls, *args, **kwargs): if not hasattr(cls, "_instance"): cls._instance = super(Singleton, cls).__new__(cls) return cls._instance class MyClass(Singlet...
dfe005ce2aa84a4bce404e779e4c84e0b682894b
yagrariksa/PBO-Teori
/081911633046_overriding_Nov14.py
2,509
3.5625
4
class Vehicle: def start(self): print("Vehicle start code") def stop(self): print("Vehicle stop code") class Car(Vehicle): def __init__(self, nbOfSeats): self.nbOfSeats = nbOfSeats def getNbOfSeats(self): return self.nbOfSeats class BendaBulat(): def __init__(se...
4daa8719d1fedc242669d069663b5cbf534b5c52
GavinPHR/code
/phase4/606.py
595
3.75
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def tree2str(self, t: TreeNode) -> str: if not t: return "" left = self.tree2str(t.left) right = self.tree2str(t....
04ae479f3bd7e5f5d06b7566a4e3cc4d9a51e349
eyelivermore/pythonlianxi
/py/批量修改文件名.py
673
3.71875
4
import os def rename(path): n = 1 #获取文件夹里的全部文件名,存入列表 filelist=os.listdir(path)#该文件夹下所有的文件(包括文件夹) for files in filelist:#遍历所有文件 Olddir=os.path.join(path,files);#原来的文件路径 if os.path.isdir(Olddir):#如果是文件夹则跳过 continue filename=os.path.splitext(files)[0];#文件名 ...
969d9ed680f15c0bed95f2286c0a8039f2e70a95
echendjou/Thanksgiving-dinner-data
/Basics-Copy1.py
3,547
3.515625
4
# coding: utf-8 # In[ ]: import pandas as pd data = pd.read_csv("thanksgiving.csv", encoding="Latin-1") data.head() # In[ ]: data.columns # In[ ]: data["Do you celebrate Thanksgiving?"].value_counts() # In[ ]: data = data[data["Do you celebrate Thanksgiving?"] == "Yes"] # In[ ]: data["What is typica...
682a6501a96e3e577fe56d7fd8cec7cdb5fa3d33
Shubham-Coader/python
/beginner_python/09-nested-loops.py
2,960
4.40625
4
########## NESTED FOR LOOP PT2 ########### #The previous section had this loop. #The only thing we did was print j and a new line. for i in range(4): for j in range(5): print(j, end=" ") print() #go to next line #Review this and make sure you understand what is going on. #We could also say what ite...
6a10e3952c127004994055f6f9f3efdb5f946cd7
devskyfly/programming
/Python/pipenv/container.py
213
3.5
4
class Container: list = [] def __init__(self): pass def addItem(self, item): Container.list.append(item) def print(self): for itm in self.list: print(itm.val)
02f42cd01a76e3946b88a34a58c62898c38d03ef
ItanuRomero/PythonStudyPrograms
/ProgramsToRead/FinalProject3Module/menu_functions/__init__.py
1,331
3.53125
4
from interface import * def create_menu(): create_line() create_title(f' MENU PRINCIPAL ') create_line() menu_options() create_line() opcao_usuario = input_option() return opcao_usuario def menu_options(): print(f'{insert_cores("amarelo")}1 - ' f'{insert_cores("amarelo clar...
d575e0106837b206934fbd094c841e12686de14a
PranaKnight/Dominando-Python
/Exceções.py
266
3.8125
4
#Tratamento de exceções from random import randint N = int(input("Digite N: ")) Total = 0 i = 1 while i <= N: x = randint(1, 50) print("Valor {} gerado = {}".format(i, x)) Total +=x i += 1 print("\nSoma dos valores gerados = {}".format(Total))
f39c9231b54515ad3c4daa42a792e60c431c4dfd
mscbalakrishnan/bigP
/IntellPython/src/OOPS/Employee.py
1,020
4.15625
4
class Employee: 'Common base class for all employees' empCount = 0 def __init__(self, name, salary, age): self.name = name self.age = age self.salary = salary Employee.empCount += 1 def showCount(self): print ("Total Employee %d" % Employee.empCount) def...
b84a0a12ac606862916526960cdf1c9656dffdf6
thisisvarma/python3
/blog_learning/operators/arithmeticOperators.py
320
4.3125
4
print(''' Arithmetic operators Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication etc. ''') x=10 y=100 print("x + y = ",x+y) print("x - y = ",x-y) print("x * y = ",x*y) print("x / y = ",x/y) print("x // y = ",x//y) print("x % y = ",x%y) print("x ** y =",x**y)
fb380f2c4d2fdb24918e6824e6a5e1adb17f843d
beauxmadscientist/introcompsciedx
/count7.py
208
3.5
4
def count7(N): ''' N: a non-negative integer ''' if N == 0: return 0 elif N % 10 == 7: return 1 + count7(N / 10) else: return count7(N / 10) print count7(717)
e26b8aa781a2fda568f5a0c1350871c9bb1213f6
vincent-landolfi/Python-Exercises-2
/ex3.py
1,937
4.15625
4
from container import * def banana_verify(source,goal,container,moves): ''' (str,str,Container,list of str) -> bool Takes the source word and uses the moves list as instructions as to what to do with the container. The goal of the function is to make sure that the ending word is the goal word. >...
d7402c8acdbabde7edc86ff03efce5f9779cf9f7
atrn0/atcoder
/ABC/101/D.py
90
3.765625
4
import math for i in range(int(input())): print(int(str(i%9+1)+'9'*math.floor(i/9)))
dd2ca5243597dbce7b28c7bb9f65d652168730e7
moontree/leetcode
/version1/1163_Last_Substring_in_Lexicographical_Order.py
2,071
3.796875
4
""" Given a string s, return the last substring of s in lexicographical order. Example 1: Input: "abab" Output: "bab" Explanation: The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab". Example 2: Input: "leetcode" Output: "tcode"...
b4044d7d2e22926eff027d4ded85d3d8afa35e70
chmikhail/Python_Lesson
/Lesson03/Task01.py
648
4.0625
4
# 1. Реализовать функцию, принимающую два числа (позиционные аргументы) и выполняющую их деление. # Числа запрашивать у пользователя, предусмотреть обработку ситуации деления на ноль. def division(x, y): try: return x / y except ZeroDivisionError: return "Делить на ноль нельзя" one_input = i...
73493daaf4b97a2e68276061e33a4fe731716a7b
Haedt406/python
/python fun/vauhns/Final.py
2,096
4.0625
4
#+-------------------+ #| A Stranger | #| Final Exam | #+-------------------+ ##---Question One---## import turtle def drawSquare(cecil, length): for aLine in range (4): cecil.forward(length) cecil.left(90) def startProcess(cecil, length, amount): for aSquare in rang...
60a9381b3c0cfa1bd283485be7eed6c136a6d07a
tgctis/CSCI630
/HW5/posterior.py
4,013
3.703125
4
import random import matplotlib.pyplot as plt # Generates the dataset using randint, writes to a file to be later read from; or to memory if temporary=1. def gen_dataset(temporary, name='tmp', size=100): """ Generates a data set :param temporary: 1 if themporary data set, no saving :param name: Name o...
bbf58ea9eeb7cd898bf47d4e2336f87eff0f80f2
jmloewen/snippets
/leet/designTictactoe/desginTictactoe.py
1,509
3.609375
4
#This is bad and slow and i feel bad for making this. class TicTacToe(object): def checkForWinner(self, row, col, player): playerScoreCheck = player * len(self.board) if sum(self.board[row]) == playerScoreCheck: return True #sum col long way, because apparently im a fucking ret...
fdfc58caf6f7d1d2d87a995c7bdf818ed49537c4
maylonsrodrigues/pythonfundamentals2
/Aulas/Aula2.py
1,818
3.703125
4
# var = str (input('digite um valor')) # texto = 'esse texto é texto' # # texto.upper() # # #split print (texto.slip('')) # # texto.captalize() # # texto.lower() # lista = ['abacaxi', 'banana', 'maça', 1, 2, 3] # print (lista[3]) # #ista.append [] # #lista.pop(0) # #lista.remove() # #lista.sort() # # tupla # valo...
d76b439be1d51903f32433b71c6df44c2d837b87
synapsecode/Google-Foobar
/2_2 - En Route Salute.py
2,812
3.59375
4
""" En Route Salute =============== Commander Lambda loves efficiency and hates anything that wastes time. She's a busy lamb, after all! She generously rewards henchmen who identify sources of inefficiency and come up with ways to remove them. You've spotted one such source, and you think solving it will help you buil...
b270c01662323bf568bfbed786199cb173cc4c99
hunsoo0823/python_study
/40BinarySearch.py
534
3.765625
4
def binarySearch(start, end, target, array): if start > end: return None mid = (start + end) // 2 if array[mid] > target: return binarySearch(start, mid-1, target, array) elif array[mid] < target: return binarySearch(mid+1, end, target, array) else: return mid n, ta...
1d6fe5f90e7f93e450a0a420fcf4dc9534940ddf
swarnim0308/Python-and-Machine-Learning
/Moviebook.py
621
3.515625
4
l1=[] for i in range(1,101): l1.append(i) print() j=0 j=int(input(" 1. Book Seat \n 2. Exit \n Choice :::::")) while(j!=2): for i in l1: print(i,end="\t") if i%10==0: print() seat=int(input("Enter seat to book : ")) if seat in l1: #s_idx=l1.index(seat) l1[seat-1]="Booked" ...
a7e574da1c882944b0d8b8d9ee996e40b178235d
wanjirushee/math-module
/index.py
254
4.25
4
# created by sheliza wanjiru. from math import sqrt as square_root print(" squareIT! ") num = float(input(" Enter a number and find square root!\n")) square=str((square_root(num))) print("\n Your square root is " + square + " ! ")
28e6e72b9f2beeb9f0f203ababffaca26cbcfa56
sonyjagatap/MedhaTraining
/Himangi/Assignments/ipAddress.py
723
4.28125
4
#for IP adress pattern I searched up on internet and find many complicated things. #A few of the things I could understand were: 1. It has four sets of three digits #ranging from 0-255,except the first set, it can not start with 0 value or 0 as #first digit. 2. Each set is seperated by a '.' import re input1 = raw...
77e005a24dd26facc79bf1f678fbf45f361191d6
maz222/Auto-Complete
/Trie.py
2,978
4.09375
4
#value - the char/string associated with the node #isEnd - whether the node is terminal or not #weight - used to sort results if applicable class TrieNode: def __init__(self, value, isEnd=False, weight=0): self.value = value self.isEnd = isEnd self.children = {} self.weight = weight ...
9dc427c1a5c65a4e4fcca8164c4d0269969466e3
anis-byanjankar/python-leetcode
/two-sum.py
2,432
3.984375
4
# https://leetcode.com/problems/two-sum/ # # Given an array of integers, return indices of the two numbers such that they add up to a specific target. # # You may assume that each input would have exactly one solution. # # Example: # Given nums = [2, 7, 11, 15], target = 9, # # Because nums[0] + nums[1] = 2 + 7 = 9, # ...
92e0e98b01822615d69ce691e3a3b868e26edd92
damiati-a/Primeiros-projetos
/1 - sistema_de_login.py
369
3.875
4
# Sistema simples de login feito com Python usuario = str(input('Digite seu nome de usuario: ')) senha = input('Digite sua senha: ') if usuario == 'José Maria' and senha == '1234': print('Seja Bem vindo Sr(a) {} !'.format(usuario)) else: print('<ERROR>\nO nome de usuário ou senha estão inválidos') ...
29a922c101fd54ae6966e80c609737c7b6e54f44
cesarsst/PythonProjects
/PythonExercicios/ex047.py
197
3.84375
4
# Crie um programa que mostre na tela todos os numeros pares # que estão no intervalo entre 1 a 50 print('Numero pares entre 0 e 50') for c in range(2, 51, 2): print(c, end=' ') print('Fim.')
7043dc52940ea97d2bd5de6e896b9daedce82fa9
saberholo/exercise
/largest_square.py
886
3.671875
4
import numpy as np l, w = np.random.randint(1, 100, (2,)) print("Length:{}\nWidth:{}".format(l, w)) mat = np.random.randint(0, 2, (l, w)) for row in mat: print(row) def find_largest_square(mat): res = 0 l, w = mat.shape if mat.sum() > 0: res += 1 else: return 0 for i in r...
038e9a4ec097458518b4c68e780244be9f87ae41
Rohan2596/Mytest
/functionspr.py
755
3.90625
4
def printme(str): print(str) return printme("I am fist call to user to be defined") printme("Again calling to the smae function") def changeme(mylist): mylist.append([1,2,3,4]) print("values inside the function", mylist) return mylist=[10,20,30]; changeme(mylist); print("Values outside the function:",mylist) de...
c9ee7417ab707be0ffde6032cd1c115144677b0f
prdraco/Robert-Padar
/Python/Basic Codes/module 8-for loops/for loops-2.py
391
4.03125
4
# You can look at the loop values within the loop for steps in range(4): print(steps) # if you want, you can start counting from 1 for steps in range(1,4): print(steps) # if you want, you can tell the loop the step value for steps in range(0,50,10): print(steps) # you can tell the loop what values exactl...
ed58a2d6ef0550c0795c0a27e2bf37647fd2b71c
fechu/SAE_Project_2_Tests
/iTeam_test/simple2.py
181
3.625
4
def main(x): if (x>0): y = a() + b() return y elif (x==-3): return 0 else: return b()-a() def a(): return 1 def b(): return 2 def expected_result(): return [0,3,1]
47042cb983f963a0350767b3d607bbaefeae53cd
adam-suwei/python
/1 基础/10 if elif 条件判断.py
1,179
4.3125
4
#注意冒号和缩进 age = 14 if age>=18: print(' your age more than 18 ',age) else: print('your age is less than 18 ',age) # elif的嵌套 age = 8 if age >= 18: print('more than 18 : ', age) elif age >= 16: print('more than 16 : ', age) print('more than 16 : ', age) elif age >= 12: print('go home boy! : ', ...
4e5765bd3b42ae19de4eb14da24c306b3ea887b7
gnsaddy/Python
/numericTypeConversion.py
339
4.25
4
# coercing integers to floats and vice versa # We can convert one type of number into another. This is also known as coercion. a = 100 print(a, " is a type of ", type(a)) print("now convert inot int ", float(a)) # convert integer into float b = 19.12 print(b, " is a type of ", type(b)) print("now convert in...
40c1d0ab69258b8f4c4a2110d6851240cb4e2170
hyperaeon/python
/FirstPythonProject/LambdaTest.py
297
3.59375
4
__author__ = 'hzliyong' #coding=utf8 print("中国") sum = lambda arg1, arg2: arg1 + arg2 print("相加后的值:",sum(10, 20)) print("相加后的值:",sum(21,33)) def sums(arg1,arg2): total = arg1 + arg2; print("和:",total); return total total = sums(323,333) print(total)
c9a30210478cd36b81ac6b36f117f75342f0d482
ConradLIu14/GeekUniversityAlgorithm
/week1/s88合并两个有序数组.py
728
3.75
4
from typing import List class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. """ if n == 0: return nums1 if m == 0: nums1[:] = nums2 curr = m+n - 1; n_p = n - ...
495edbcebb7ff496629191f5837a8eb7ca9a33a3
Veletronic/Computer-Sci
/AdvancedGuessingGame.py
5,608
4
4
import random Lives = 0 Diffselected = 0 def mainmenu(): #Main menu module global Diffselected #Allows this var from difmenu() to be retrieved start = 0 while start == 0: Userinput = int(input("""MAIN MENU 1.PLAY GAME 2.SELECT DIFFICULTY 3.EXIT """)) if Userin...
2ea22b1860f255dbed34426e075cb77c2bf5bc9c
jincurry/LeetCode_python
/665_Non-decreasing_Array.py
1,934
4.0625
4
# Given an array with n integers, your task is to check if it could become # non-decreasing by modifying at most 1 element. # # We define an array is non-decreasing if array[i] <= array[i + 1] holds for every i (1 <= i < n). # # Example 1: # Input: [4,2,3] # Output: True # Explanation: You could modify the first 4 to 1...
36c4496be4fe981ecd2bc9449fe36f6f70c65535
gocersensei/pythonWorkout
/restaurant.py
1,044
4.1875
4
MENU = {'sandwich': 10, 'tea': 7, 'salad': 9} # Defines a constant dict with item names (strings) and # prices (integers) def restaurant(): total = 0 while True: # Keeps asking the user for input, until an explicit # “break” from the loop order = input('Order: ').strip() # Gets...
f35ad56c6e7a7195e8d1a7bb5ad19324255b8e0e
sidv/Assignments
/Neethu/Aug23/even_list.py
112
3.796875
4
print("Generate list of even number for 10 to 50 range.") print(list(x for x in range(10, 50+1) if x % 2 == 0))
234684196b763af6f58fe787dfae2c684c6be94d
Psyche-mia/UR5_Demo
/game_test/tic_tac_toe.py
5,233
3.578125
4
import random def printBoard(s): print(" "+s[1]+" | "+s[2]+" | "+s[3]) print(" "+s[4]+" | "+s[5]+" | "+s[6]) print(" "+s[7]+" | "+s[8]+" | "+s[9]) print() def getPlayerMove(s): while True: pmove = int(input("Your turn. Make your move (1-9):")) if s[pmove]=='-': ...
d4033a0b593d164bb7e31bdbee59b00fc5825ec6
Delightkc/top100codes
/greatestoftwo.py
161
4.0625
4
num1=int(input()) num2=int(input()) if(num1>num2): print(num1," is greater") elif(num1<num2): print(num2," is greater") else: print("both are equal")
adfd009f443fbb58ffcd1bab85600a06ada05776
martaniblett/PythonWeek
/TripleScienceScore.py
571
4.3125
4
biology_grade = float(input("Please input biology grade: ")) chemistry_grade = float(input("Please input chemistry grade: ")) physics_grade = float(input("Please input physics grade: ")) score = int((biology_grade+chemistry_grade+physics_grade)/3) # print ("Average score", score) if biology_grade < 40 or chemistry_gra...
3edf6b1f74caf9d2cf51d02c70e4432615b32bf4
patrickjsmirnov/leetcode
/tasks/how-many-numbers-are-smaller-than-the-current-number.py
472
3.71875
4
# https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/ def smaller_numbers_than_current(nums): arr = [0] * 101 for n in nums: arr[n] += 1 num_smaller = [arr[0]] for i in range(1, len(arr)): num_smaller.append(num_smaller[-1] + arr[i]) ans = [] f...
44c86b609afff344940bc56f893050934c890df0
manuelvsousa/fp-labs
/lesson03_solved/3.py
91
3.65625
4
def area_circulo(r): return r*r*3.14 r=float(input("Raio: ")) print(area_circulo(r))
c8cc38ddb225ee21a97017947c885d0c60975a7a
camdnnn/Travelling_Salesperson
/shapes.py
21,023
3.609375
4
import math import random import itertools from sklearn.cluster import AgglomerativeClustering import pygame # function that calculates the distance between two circles def get_distance(circle1, circle2): return math.dist(circle1.get_center(), circle2.get_center()) def inverse_color(color): col...
93c76d9a1ada4216a7ca8a57ff7997cc527420f9
andprogrammer/crackingTheCodingInterview
/python/chapter1/8/solution.py
1,732
3.546875
4
import unittest import copy def print_matrix(matrix): num_of_rows = len(matrix) for i in range(num_of_rows): print("".join(str(matrix[i]))) print("---------------------------") def copy_matrix(matrix): num_of_cols = len(matrix[0]) num_of_rows = len(matrix) new_matrix = [] for i i...
180d4aae18f5eaea84b873890eadaf7d74c3b7a8
aaron-dev20/Python-Practice-Programs
/OOPractice.py
366
3.65625
4
class Dog(): def __init__(self,breed,name,tail): #attributes #take in argument #assign using self.attribute_name self.breed = breed self.name = name #expected boolean self.tail = tail my_dog = Dog(breed='Malamute',name='Thor',tail=True) type(my_dog) ...
d70d5fd17a3d12f754214c6c3a28b699cd008e93
varunpsr/python-ds
/doubly-linked-list.py
1,441
4.0625
4
class Node: def __init__(self, value): self.value = value self.next = None self.previous = None def __str__(self): if self is not None: return str(self.value) else: return "None" class DoublyLinkedList: def __init__(self): ...
2daa990301a5deb96acce7bfc57319ab6b38619b
Rohitharohi/pythonprograms
/python_collections/list/list_demo.py
644
4.34375
4
# 1.KEEPS ORDER == stored in continous locations # 2.SUPPORT DUPLICATION # 3.HETEROGENIOUS # 4.NESTING IS POSSIBLE # 5.MUTABLE # list=[1,2,3,4,5,12,0,1,2] # print(list) # print(type(list)) # for i in list: # print(i) # l=[1,2,3,4,"hello",0,2,34,1,True] # print(l) # to create empty list list = [] list.append(8) ...
a5a64275d6496921d2a077bb5baff915341982d2
mabinm/Semaphores
/2_dance_mixer.py
3,876
3.5
4
#Final commit #Dance mixer problem with 2 leaders and 5 followers #2_dance_mixer.py - MP3 -Assignment 2 #This program was run using Python 3.4 and was executed using command prompt #Code present online was referred to for understanding purposes #Algorithm followed: #Start off the leader and follower threads #what they...