blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2c4619eae992331fb8566e593d3bfd57eaaceeb0
mjdall/leet
/medium/all_permutations.py
1,037
4
4
def permute(self, nums): """ Given a list of numbers, returns all possible permutations of the numbers. :type nums: List[int] :rtype: List[List[int]] """ if not nums: return [] permutations = [] self.backtrack(permutations, nums, []) ...
8f67d863c9edae98a5a44daf5c826381c9e4a873
vinayvarm/programs
/fun.py
162
3.703125
4
'''def add(a,b): c=a+b return c var=add(20,60) print(var)''' n= int(input("enter number")) if n>0: print('positive') else: print('negative')
e1b3aef3632d92313ea3c3506bcffeb8a4c69edc
eunj00/2020-Python-Code
/ch04/04-06nestedmenu.py
635
3.640625
4
category=int(input('원하는 음료는? 1.커피 2.주스')) if category==1: menu= int(input('번호 선택? 1.아메리카노 2.카페라떼 3.카푸치노')) if menu==1: print('1.아메리카노 선택') elif menu ==2: print('2.카페라떼 선택') elif menu ==3: print('3.카푸치노 선택') else: menu=int(input('번호 선택? 1.키위주스 2.토마토주스 3.오렌지주스')) ...
bd3ef0f070984405fdf429073cd5708f7015d157
sbmarriott/nltk
/chapter2.py
3,867
3.5625
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 15 22:13:37 2017 @author: Sarah Beth Marriott """ import nltk, random from nltk import FreqDist from nltk.corpus import gutenberg, state_union, brown # Question 2: Use the corpus module to explore austen-persuasion.txt. How many word tokens does this book have? How many ...
a96445740403bf4d285acd07630522e02733818b
JITproject/DotDesktop
/gui.py
3,272
3.625
4
from Tkinter import * import Image class Application(Frame): def say_hi(self): print "hi there, everyone!" def TerminalToggle(self): if (self.terminal('relief')[-1] == 'sunken'): self.terminal(relief='sunken') else: self.terminal(relief='sunken') def StartupToggle(self): if (self.sno...
2ef48d6a10b020b5f1857db68217455d7531ec04
lizhihui16/aaa
/pbase/day17/shili/instance_method.py
756
3.953125
4
#示意为Dog类添加吃,睡,玩等实例方法,以实现Dog对象的相应行为 class Dog: '''这是一种可爱的小动物''' def eat(self,food): '''此方法用来描述小狗吃的行为 ''' print('id为%d的'%id(self),end='') print('小狗正在吃',food) def sleep(self,hour): print('id为%d的小狗睡了%d小时'%(id(self),hour)) def play(self,a): print('id为%d的小狗正...
48c22b24c909aaa7b6ad02cb8d97c849c3afe5c0
cyberbono3/leetcode
/amazon/N-queens.py
1,718
3.640625
4
class Solution(object): def solveNQueens(self, n): """ :type n: int :rtype: List[List[str]] """ def safe_place(r, c, choices): find_safe = True for row, col in choices: if row + col == r + c or row - c...
7218d340a71525890f581c0b2c3f43cd6127a983
j-rewerts/practice-problems
/misc/parse-input/main.py
111
3.671875
4
n = int(input()) values = list(map(int, input().split())) for value in values: print("Value " + str(value))
00c7a2238c832cf2c7a5b826feb4820d183b9d1e
charliechocho/py-crash-course
/pets.py
313
3.75
4
def my_pet(pet_type = 'alien', pet_name = 'ET'): """display pet and its name""" print(f"I have a {pet_type.title()}!") print(f"\tMy {pet_type.title()}'s name is {pet_name.title()}\n") pet_type = input("Vad har du för husdjur? ") pet_name = input("Vad heter ditt djur? ") my_pet(pet_type, pet_name)
3bd9d61fc116cb3feb0689fe82a49e8b0b6a545a
AntZuev/CourceraPython
/lesson3#.py
3,089
3.734375
4
'''a = float(input()) b = float(input()) c = float(input()) p = (a + b + c) / 2 s = (p * (p - a) * (p - b) * (p - c)) ** (1 / 2) print('{0:.6f}'.format(s)) n = int(input()) i = 1 s = 0 while i <= n: s += 1 / i ** 2 i += 1 print('{0:.6}'.format(s)) x = float(input()) x = x - int(x) print('{0:.6f}'.format(x)) ...
b8e075a8c0918e7bc5d5d233cbdaea6b9f547bf2
corey-marchand/401-py-data-structures
/array_reverse/array_reverse.py
239
4.21875
4
numbers = [0, 1, 2, 3, 4, 5, 6] def reverseArray(array): L = len(numbers) for i in range(int(L/2)): n = numbers[i] numbers[i] = numbers[L-i-1] numbers[L-i-1] = n print(numbers) reverseArray(numbers)
5b9869bdbb836e5740b05167de17b0d2ab13b9b5
Hemangi3598/p22.py
/p9.py
159
4.40625
4
# wapp to read an integer # and print if its even or odd num = float(input("enter your num = ")) if num % 2 == 0 : print(" even") else: print(" odd")
d41118e24cbfaa932646ad7cb529268e5c5cfb96
basilkjose/Python-coding
/selection sort.py
369
3.515625
4
# SELECTION SORT def selectionsort(seq): for start in range(len(seq)): minpos=start for i in range(start,len(seq)): if seq[i] < seq[minpos]: minpos=i (seq[start],seq[minpos])=(seq[minpos],seq[start]) return seq result=se...
aa0a2daee6cb9e5638bc09f0b115d04401c0191a
odom-data-science/data-science-portfolio
/foodscanner/db_2019/module_utils/scoreRegression.py
3,733
3.9375
4
import numpy as np import pandas as pd from sklearn.preprocessing import LabelEncoder from sklearn.preprocessing import OneHotEncoder def scoreClassif(y_true, y_pred): """Computes a classification score by setting the threshold of y_true, then determines whether the learning algorithm predicted well or not (0...
ef44c86fe58a9d296e5897834f340da6dea7b1bd
Jay54520/Learn-Algorithms-With-Python
/011-数值的整数次方/v1/test_power.py
582
3.8125
4
# -*- coding: utf-8 -*- import unittest from power import Solution s = Solution() class Test(unittest.TestCase): def test_positive(self): got = s.Power(2, 3) want = 8 self.assertEqual(got, want) def test_zero(self): got = s.Power(2, 0) want = 1 self.assertEq...
359c62f4ef2566cc4912f20e468944c5883bb3d2
samuei/Schoolwork
/EECS-565/Lamb_Samuel_Miniproject_1.py
1,069
3.578125
4
#Samuel Lamb #Miniproject 1 #2/9/2015 #Python 2.7.5 def vigenere(text, key): alphabet = ['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'] text = text.lower() text = text.replace(' ','') key = key.lower() key = key.replace(' ','') outtext =...
b1167e506e1efe57a9735982f503dbed3be1fc29
dcastrocs/CursoPython
/Mundo 2/ex051.py
215
3.84375
4
termo = int(input('Digite o primeiro termo: ')) razao = int(input('Digite a Razão: ')) decimo = termo + (10 -1 ) * razao for c in range(termo, decimo+razao, razao): print('{}'.format(c), end='-> ') print('Fim')
ea1452112eb638b25e8deadf70f83be1152ebbbf
ImCabbage/CS501
/HW1/3.py
464
3.875
4
#!/usr/bin/python # This is a simple program on calculating alphabetic character. # It is No.3 problem in HW 1 import sys L = list(sys.argv[1]) # transfer to string to list Result = [0]*26 for x in L: # classification if str.isalpha(x) == 1: y = str.lower(x) y = ord(y)-9...
8ba8e66542edc91f82aa79472e64d764fd8e9bf5
gabi15/VPython_labs
/laby8/lab8_ex3.py
2,286
3.71875
4
"""In this program the ball is bouncing from the box's walls and changes color to the color of a touched wall""" from vpython import * import random scene = canvas(width=800, height=580) wallL = box(pos=vector(-5,0,0), size=vector(0.3, 10, 10), color=color.red) wallR = box(pos=vector(5,0,0), size=vector(0.3,10,10), ...
e5ecb91314441c57f444d37d36e7d5aa9235cc6d
nadendlachandana/Training_Progress
/python practice/functions.py
667
3.84375
4
import math # 1 def spam(): # print eggs print("Eggs!") spam() # 4 def power(base, exponent): result = base ** exponent print("%d to the power of %d is %d." % (base, exponent, result)) power(37, 4) # 6 def cube(number): return number ** 3 def by_three(number): if number % 3 == 0: ...
a51b02bc2b27e6ab61438a1d1e4adda345dd3f05
keigorori/python-plots
/trials.py
1,563
3.515625
4
# -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt def set_display(fig, ax): """ 表示周りの設定 Parameters ---------- fig : Figure 対象のFigure ax : Axes 対象のAxes """ # 枠線を非表示 ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False)...
a341317b9e0d63eac28fe355321a9fa85da62eec
beckysx/python_basic
/数据类型转换&运算符/运算符.py
899
4.09375
4
""" 1. 算数运算符 arithmetic operator 1.1 / 除 1.2 // 整除 floor division 1.3 % modulus 2. comparison operator 3. logical operator and or not 4. assignment operator 复合赋值 = += -= *= 5. bitwise operator & | Bitwise operators act on operands as if they were strings of binary digits. They operate bi...
44067dfaf0c0bbd0108547dde14513a28b2a208f
skhlivnenko/Python
/Yarmak_course/L02X2_input.py
155
4.0625
4
USD = input("How much USD do you want yo change?\n") RATE = input ("What is rate?\n") UAH = USD*RATE print "You'll get {} UAH for {} USD".format(UAH, USD)
b514152dc7c918d32eb339285376ba4ab9810e64
tiagoleonmelo/ia
/python_practice/one/ex1.py
1,949
3.890625
4
# Funçoes para processamento de listas def size_lista(lista, i=0): if lista==[]: return 0 return 1 + size_lista(lista[1:]) def sum_list(lista): if lista == []: return 0 return lista[0] + sum_list(lista[1:]) def listContains(element, lista): if lista == []: return False ...
424a63a43d76be014f10d70d232327921a0da761
bernardosequeir/CTFSolutions
/HackerRank/10DaysOfStats/Day2_BasicProbability.py
172
3.6875
4
i = 1 j = 1 below_or_equal = 0 while (i <= 6): while (j <= 6): if(i + j <= 9): below_or_equal += 1 j += 1 i += 1 print(below_or_equal)
24986ccd766bdf2eba79f3265fdbee17847d7dcd
YutoTakaki0626/My-Python-REVIEW
/fileIO/file_write.py
316
3.75
4
with open('writing_file.txt', mode='w') as f: # truncatedされる:byte=0に切り詰める f.write('You can write contents here\n') f.write('new write() doesn`t break no') print('You can add a new row using "file" parameter', file=f) print('new print() method breaks the row for you!!', file=f)
bbf0bb4f6bbb36887acd2d1dfde839cf4b7c98a0
lidianxiang/leetcode_in_python
/二分查找/50-Pow(x,n).py
788
3.734375
4
""" 实现 pow(x, n) ,即计算 x 的 n 次幂函数。 示例 1: 输入: 2.00000, 10 输出: 1024.00000 示例 2: 输入: 2.10000, 3 输出: 9.26100 示例 3: 输入: 2.00000, -2 输出: 0.25000 解释: 2-2 = 1/22 = 1/4 = 0.25 """ class Solution: """利用二分查找思想,每次记录连乘的次数count,每次倍乘""" def myPow(self, x, n): def re_binarySearch(x, n): if n < 1: ...
46f6252a29d89caf0fcc61fe8ce55ffd57a7dfdf
akankshanayak2111/Practice_problems
/anagram_of_palindrome.py
698
4.125
4
def is_anagram_of_palindrome(word): """Is the word an anagram of a palindrome?""" # add count of characters to a dict # check if all the values in the dict are divisible by 2 except one, return True # else False letter_count = {} for letter in word: if letter not in letter_count: ...
4dda03277d5a1b0270fcd1dfa2bc19f2a03b18dc
DrGaster/Friday
/Jarvis Mark 2/Name_Identify.py
419
3.515625
4
user = input("What is your name? ") class Jarvis: def __init__(self, user): self.user = user def intro(self): print("Hello", self.user + ", ", "I'm Jarvis") def assist(self): cmd = True while cmd: cmd = input("What can I do for you? ") if cmd ==...
40e23b4bb089617d9adfa7c00517319bf21a0d3b
palmtree5/Applications
/guess/guess.py
2,088
3.5625
4
# Import random from the standard library so we can pick random numbers. import random from discord.ext import commands class Mycog: """My custom cog that does stuff!""" def __init__(self, bot): self.bot = bot @commands.command(pass_context=True) async def guess(self, ctx): ...
476f844b30b5d07c4852cd66cf55d0592be3df8e
Susan-Wangari/python
/password.py
324
3.9375
4
x = str(input('Please Enter username: ')) username = "kay" password = "1234" if x == username : y = str(input ('Enter password: ')) if y == password : print(len(y)) # print(x.upper()) print(y.replace('1', '2')) print(y) print(username[1:]) else: print("wrong username")
d9a522734da8c2a76fb0c8ea33a0f833361462b6
Marlenqyzy/PP2
/week1/w3school/70.py
196
3.953125
4
thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } for x in thisdict.values(): print(x) for x in thisdict.keys(): print(x) for y, x int thisdict.items(): print(y, x)
e5978b9991036fc2900599c67891afec29e3a83d
MacLure/Code-Wars-Solutions
/Python/8 kyu - Filter out the geese.py
212
3.78125
4
geese = ["African", "Roman Tufted", "Toulouse", "Pilgrim", "Steinbacher"] def goose_filter(bird): def not_goose(x): return True if x not in geese else False return list(filter(not_goose, bird))
d20dc55f51db35a161fb070bbc9ba00404616eab
Lmanea25/gitjenkinsIntegration
/Loops.py
11,611
3.8125
4
# import os # # # # import selenium # # a =200 # # b =30 # # c=500 # # if a > b: print("a is greater than b") # # print("A")if a > b else print("=") if a==b else print("B") # # if a>b and c>a: # # # print("Both conditions are true") # # pass # # # # x =41 # # if x > 10: # # print("Above ten,") # #...
95c9a2ca9ce9110f8526421f1da56983268ecff5
Alichegeni/codes
/BMI.py
746
4.15625
4
w = int(input("please insert your weight in kilogram: ")) h = int(input("please insert your height in centimeter:")) H = ((h/100)**2) BMI = (w / H) if w == 0: print("you can not be zero kg! please enter your weight correctly") if w != 0: if BMI < 18.5: print("your BMI is:", BMI, "you are und...
631836d8bac619c500e2331eeda2d0ea801dd3a0
wekesa/Weather
/weather.py
2,260
3.6875
4
#Author -Wekesa Victor #import regex library import re DATA_FILENAME = "weather.dat" class WeatherSpread: def __init__(self): print "This program finds the row with the maximum spread in the weather.dat file, \n where spread is defined as the difference between MxT and MnT \n" #logic to open the fi...
620067c2939f5eece85a52efa414b0be39fc2fd8
surut555/basicpython
/function.py
843
3.5625
4
# การสร้างฟังก์ชันแบบไม่มีการ return value def hello(name): print(f"hell {name}") # สร้างฟังก์ชันแบบมีการ return Vauue def area(width, height): total = width*height return total # เรียกใช้งานฟังก์ชัน hello() hello("surut") # เรียนใชังานฟังก์ชัน area() print(area(2, 3)) print(area(5, 3)) print(area(58.2...
a4183508dc90738b5759bb8be953fb4eed887af4
bachiraoun/machinelearning
/utils/Collection.py
34,335
4.03125
4
# standard libraries imports from random import random as generate_random_float from random import randint as generate_random_integer # external libraries imports import numpy as np def is_number(number): """ check if number is convertible to float. :Parameters: #. number (...
89c1c943d3fad59ec6e8c0cb2f31b11b90f0bd0a
Santiago-Gallego/holbertonschool-higher_level_programming
/0x10-python-network_0/6-peak.py
826
4
4
#!/usr/bin/python3 """Finds a peak in a list of unsorted integers""" def find_peak(list_of_integers): """Finds a peak in list_of_integers""" if list_of_integers is None or list_of_integers == []: return None lo = 0 hi = len(list_of_integers) mid = ((hi - lo) // 2) + lo mid = int(mid) ...
b1f2e780aced33505537702651111e080efe3cd2
madmanmoon93/learning
/BonAppetit.py
691
3.953125
4
# Anna and Brian are sharing a meal at a restuarant and they agree to split the bill equally. # Brian wants to order something that Anna is allergic to though, and they agree that Anna won't pay for that item. # Brian gets the check and calculates Anna's portion. You must determine if his calculation is correct. #...
0ebbc007ca58849eba17c1d492a5e23849cf935f
leguims/Project-Euler
/Problem0007.py
1,588
3.859375
4
Enonce = """ 10001st prime Problem 7 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? """ import EulerTools # Iterator style class PrimeNumber: def __init__(self, rank=1): self.current = 2 self.index = rank def __ite...
181742d4dacff79e51101de20c82b0fe3fc08036
lawaloy/Practice
/mergeSortedArr.py
386
4
4
def mergeSortedArr(arr1, arr2): if not arr1 and not arr2: return arr1 if not arr2: return arr1 if not arr1: return arr2 if arr1[0] < arr2[0]: return [arr1[0]] + mergeSortedArr(arr1[1:], arr2) else: return [arr2[0]] + mergeSortedArr(arr1, arr2[1:]) ...
c12055ece24e1fcfd3bc3dd43db6cf930a83f242
JayWu7/Code
/leetcode_110.py
896
3.765625
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 isBalanced(self, root: TreeNode) -> bool: # dfs, 递归,分别计算左、右子树的深度,然后根据深度差,判断左右子树是否是平衡二叉树,利用val来存储深度值 def helper(nod...
f81e349419029b412f8cd73679a1e8373da39772
MilindShingote/Python-Assignments
/Assignment8_3.py
549
3.90625
4
from threading import * def OddList(Arr1): iSum=0; for j in Arr1: if Arr1[j]%2!=0: iSum=iSum+Arr1[j]; print("The Addition of Odd Number",iSum); def EvenList(Arr1): iSum=0; for k in Arr1: if Arr1[k]%2==0: iSum=iSum+Arr1[k]; print("The Addition of Even Number",iSum); def main(): No=int(input("Enter ...
db2c0016238582cfb822d9be4f08c7cd9b55b534
egbeyongtanjong/MIT_Data_Analysis_2020
/Lecture_notes/Lecture2.py
2,823
3.75
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 7 22:48:44 2020 @author: Egbeyong Lecture 2, problem set#0 """ #********************************************************************* """ #Printing name and date of birth DOB = input("Enter your date of birth:") print("**",DOB) name = input("Enter your last name:") pri...
c17c00b82d55f053e66cb2c936b8d45abd7d85b3
jianjian198710/PythonStudy
/chapter2/In.py
138
3.625
4
permission="rw" print "w" in permission print "x" in permission users=["Tom","Mary","Peter"] print raw_input("Enter you name: ") in users
b4cc38cdd819fd27c9986df1a053ad2025d25206
ChHarding/python_ex_2
/ex_2_task_1.py
2,638
3.84375
4
# Python refresher exercises 2 - task 1 # Write and test a function is_valid_email_address(s) that evaluates string s as a valid email address # Returns: tuple of 2 elements (res, err): # res contains the result (None or error code) # err contains an error string ("seems legit" for None, a short er...
477414897d96731432e56536ffb3a96a0552c33b
Lutshke/Python-Tutorial
/functions.py
537
4.25
4
"i will show you how to create functions" # a function will return a value or will execute a certain part of code # we instaciate a function with the keyword "def" def test(): # your code will compile return # we can call this funtion now with test() # this function will now be called # for...
3eb9a713d22019140d149d09307df22cc4f69f0a
erazo-janet/math_with_python
/perfect_number.py
674
3.984375
4
#!/bin/python #In number theory, a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the integer itself n = int(input("Enter any number: ")) sum = 0 # For loop is used to calculate all divisors of the number n entered by the user, and sum the divisors to check...
2b5f5388b94212519e4603fc4e0f0dec2be8110c
rclamb27/Python-build-in-data-types
/part-1/mult3or5.py
698
4.21875
4
#!/usr/bin/env python3 # # Ryan Lamb # CPSC 223P-03 #2020-9-16 #rclamb27@cus.fullerton.edu """Ouputs the sum of all multiples of 3 or 5 below 10000000""" def main(): """Takes the multiples of 3 and 5 and sums them""" total_nums = int(input('Please input a range of numbers below 1000000: ')) print('You cho...
fdf5d59ed7ddd3699e3bff34025cf5478550b47c
aletcherhartman/pong.py
/Old Files/importmath.py
2,731
3.921875
4
import pygame # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) pygame.init() # Set the height and width of the screen size = [700, 500] screen = pygame.display.set_mode(size) pygame.display.set_caption("Instruction Screen") # Loop until the user clicks the c...
28d3c49313c81a22bd9e88cd790db620c180c992
xiaoqianchang/DemoProject
/sample/datatype/dictionary_test.py
2,371
4.09375
4
#!/usr/bin/python3 # Dictionary(字典) dict_test = {} # 创建空字典 dict_test['one'] = "1 - 菜鸟教程" dict_test[2] = "2 - 菜鸟工具" tinydict = {'name': 'runoob', 'code': 1, 'site': 'www.runoob.com'} print(dict_test['one']) # 输出键为 'one' 的值 print(dict_test[2]) # 输出键为 2 的值 print(tinydict) # 输出完整的字典 print(tinydict.keys()) # 输出所有键 p...
30a2c6a8ef9207c4649974f5ed88986d82226736
JaySurplus/online_code
/leetcode/python/52_n_queens_ii.py
2,433
3.828125
4
""" 51. N-Queens The n-queens puzzle is the problem of placing n queens on an n*n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.'...
7feae3673f98de06b57434e03c5b179e78f61bc7
bopopescu/python-practice
/pycharm/telusko/anonymous-function.py
208
4.15625
4
#--- Anonymous functions can be denoted with lambda function f = lambda a : a*a result = f(5) print(result) #---- Adding 2 numbers using lambda function f = lambda a,b : a+b result = f(3,4) print(result)
0abc5140faeef6a1fe16ee6469840cde76483dfe
mxmiramontes/Python-Programs-
/WeatherDataSQL.py
2,021
3.65625
4
import sqlite3 as lite import sys try: cnxn = lite.connect('weather.db') #connecting to weather.db & returns an object of type, .db exisits in the current working directory print("Databse opened successfully") crsr = cnxn.cursor() #cursor- is the workhorse of database processing supports the excute() m...
669c7e1d2a2c8988fb5830ee71859047c6f20d26
EnochEronmwonsuyiOPHS/Y11Python
/StringSliceChallanges03.py
200
3.96875
4
#StringSliceChallanges03.py #Enoch firstname = str(input("Enter your first name in lower case")) lastname = str(input("Enter your last name in lower case")) s = " " print(firstname + s + lastname)
53b0d6b6bfaebc3d33cad040944b6b21d0927d49
b4824583/HungarianMethod
/Function.py
2,860
3.71875
4
import numpy as np #----------------------------建立畫線矩陣 def build_draw_line_matrix(): draw_line_matrix=np.zeros((4,4)) draw_line_matrix=draw_line_matrix.astype(int) return draw_line_matrix #------------------------------- 如果發現所有的零都已經被劃線了則,則跳出迴圈。 def if_there_is_no_zero_in_matrix_than_break(display_zero_matr...
0265906c8ef85fdcabf71334bfaa6c677652925c
amitagrahari2512/PythonBasics
/Iterator/Iterator.py
408
4.375
4
print("List have provide a function called iter(listObject)") print("Then we can use iteratorObj.__next__() method to print next value") print("Or we can use next(iteratorObj) to print next value") nums = [2,10,4,17] it = iter(nums) print("it.__next__() : ",it.__next__()) print("it.__next__() : ",it.__next__()) print...
d6ba9590e1c05432479285e206396f41d4f1a986
maokaiqi/learn_Python_Hard_Way
/ex5.py
2,294
3.5625
4
# -- coding:utf-8 -- my_name = 'Zed A. Shaw' my_age = 35 # not a lie my_height = 74 # inches my_weight = 180 #lbs my_eyes = 'Blue' my_teeth = 'White' my_hair = 'Brown' print "Let's talk about %s." % my_name print "He's %d inches tall." % my_height print "He's %d pounds heavy." % my_weight print "Actually that's not to...
7c256c7daabe94193b1b1abe352d8976b74ea71a
taka16a23/.pylib
/confirm/confirmobj.py
3,830
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- r"""confirm -- DESCRIPTION """ from abc import ABCMeta, abstractmethod from userinput import UserInputer, ConsoleUserInput import Tkinter import tkMessageBox class Confirm(object): r"""Confirm Confirm is a object. Responsibility: """ __metaclass__ = ...
6f5e77d6d0af445e02116f7a505eaa49eb90afb2
Aasthaengg/IBMdataset
/Python_codes/p03719/s406138597.py
89
3.53125
4
a,b,c = map(int,input().split()) ans = 'No' if(a <= c <= b): ans = 'Yes' print(ans)
a9132db6b465ee95d0cf245c21be447031ae5b16
speed785/Python-Projects
/Class Operations.py
505
3.796875
4
#Coded by : James Dumitru class Operations: def __init__(self, num1, num2): self.num1 = num1 self.num2 = num2 #Mutator methods def addtion(self, num1, num2): result = num1 + num2 return result def subtraction(self, num1, num2): result = num1 - num2 retur...
f328e19b0f3f2c775dc1918c73f1722d3fb05fb7
Kalebu/Bootcamp
/Bootcamp Day 1/prime.py
664
3.90625
4
def prime(n): if n == 0: return [] elif type(n) is not int: raise TypeError elif n<0: raise ValueError # Create a list with the first prime number lst = [2] # Test each number for primeness, starting with 3 testNum = 3 while True: prime = True ...
a689e361a6001ee5b645ddea23fea1dd3d41018d
rafa-santana/Curso-Python
/Aula 07/ex08.py
159
3.78125
4
n = float(input('Digite um valor em metros:')) print('O valor em centímetros é: {:0f}'.format(n*100)) print('O valor em milimetros é: {:0f}'.format(n*1000))
90d322b30932958ece705c842b53efbf91e20999
egemzer/intro2programmingnanodegree
/Movie Website/triforce.py
866
3.796875
4
import turtle #draws a triforce def draw_triforce(): window = turtle.Screen() window.bgcolor("white") index = 0 triangles = 4 #there are 4 triangles in a triforc sides = 3 deg = 120 zelda = turtle.Turtle() zelda.shape("turtle") zelda.speed(1) zelda.color("orange") zelda.penc...
c2346fe756797425511aaf0343203babd1847d57
deepbsd/OST_Python
/ostPython4/test_subdictclass.py
955
3.875
4
#!/usr/bin/env python3 # # # test_subdictclass.py # # Lesson 6: Using Exceptions Wisely # # by David S. Jackson # 7/24/2015 # # OST Python4: Advanced Python # for Pat Barton, Instructor # """ Tests the subdictclass.py program. """ from subdictclass import SubDict import unittest class ...
332a566c000bd64bf20dbad6bc42f61936ded1ed
abhishek436/Data_Structure
/Singly_Linked_List/sum_two_linkedlist.py
1,827
3.984375
4
class Node: def __init__(self,data): self.data = data self.next = None class linkedlist: def __init__(self): self.head = None def insert(self,data): new_node = Node(data) if(self.head is None): self.head = new_node return else: ...
8c82054673b1fe7a642ca334dd629c66ddd3d839
DanielMalheiros/geekuniversity_programacao_em_python_essencial
/Exercicios/secao06_estruturas_de_repeticao/exercicio46.py
754
4.15625
4
"""46- Faça um programa que gera um número aleatório de 1 a 1000. O usuário deve tentar acertar qual o número foi gerado, a cada tentativa o programa deverá informar se o chute é menor ou maior que o número gerado. O programa acaba quando o usuário acerta o número gerado. O programa deve informar em quantas tentativas ...
99647b0e7db2d239165ab80ff5fd145b85c76839
iandioch/CPSSD
/ca117/lab1.2/pi_12.py
152
3.515625
4
from math import pi import sys n = int(sys.argv[1]) last = str(pi)[n+1] if str(pi)[n+2] >= '5': last = str(int(last) + 1) print(str(pi)[:n+1] + last)
eb13f90228ba3f29a4e6e9d85a4ca2a272468271
riyabhatia26/Code
/convert complex numbers to Polar coordinates.py
178
3.859375
4
# Python code to implement # the polar()function # importing "cmath" # for mathematical operations import cmath # using cmath.polar() method num = cmath.polar(1) print(num)
1ea46afb58f3220516d08578747a8e5a7e411943
gaoshang1999/Python
/interview/insight.py
903
3.6875
4
import random a = [1 , 2, 3] def f(a): a.append(4) f(a) # print(a) # A = [ random.randint(0,9) for _ in range(10)] # print(A) def intersecttions(A, B, C): for a in A: if a in B and a in C: yield a # return True return None A = [ random.randint(...
a7206457fd0f66281c599c4fddf79b3e549ff2d4
stevecatt/week1python
/dictionarys.py
2,487
4.25
4
#gonna create a task list #task ={} tasks = [] def view_all_tasks(): for task in tasks: #print(task) #for key,value in task.items(): # print out the index number of the task in user type stuff by adding 1 # end "=" keeps it on the same line # prints tasks by index +1 th...
6bc310de4b15e5721aa0c229f08812570a0f0f6d
shrutikabirje/Python-Programs
/p5.py
449
4.21875
4
Given a two list. Create a third list by picking an odd-index element from the first list and even index elements from second. l1= [3, 6, 9, 12, 15, 18, 21] l2= [4, 8, 12, 16, 20, 24, 28] l3= [] l4=[] l5=[] for i in range (len(l1)): if i%2!=0: l3.append(l1[i]) print("odd elements in list 1:",l3) for j in r...
58affb9bb758929fca566fbd68e664627437aa09
wolskey/cornway_game_of_life
/main.py
4,826
3.96875
4
import random import time def generate_empty_board(x,y): """ generates matrix x rows y columns filled with zeros :param x: n of rows :param y: n of columns :return: lists of lists of zeros """ board = [[0]*y for i in range(x)] return board def generate_initial_population(board, ...
3cf9e0168a7c7b2bdb01ab3d1fda1680b240713c
wulfebw/algorithms
/scripts/search/ucs.py
1,499
3.6875
4
import priority_queue import search_algorithm class UCS(search_algorithm.SearchAlgorithm): """ Djikstra's Time: O(nlgn) where n is states between start state and goal state in shortest path, lgn factor from the priority queue operations (heapify) """ def solve(self, problem): done = set()...
ee4e5c6479d2561885b458d7c41d8c47243c2aa6
albertojr/estudospython
/ex030.py
140
4.03125
4
numero = int(input('Digite um numero inteiro: ')) if numero%2 == 0: print('Esse numero é Par') else: print('Esse numero é Impar')
b176cce32f1589f3ccb37c632ca8591c7bc8c9c9
andreafresco/Project-Euler
/p010.py
910
3.96875
4
# # Solution to Project Euler problem 10 # Copyright (c) Andrea Fresco. All rights reserved. # # https://projecteuler.net/problem=10 # https://github.com/andreafresco/Project-Euler # def Is_prime(n): # check if the number n is prime assert n > 0 i = 2 # we restrict the search of prime numb...
715e90abb2a58a997fc1bd3a02abcc8d81d581cf
fadia-hussain/final-project
/python-final-project.py
567
3.90625
4
# final-project # Fadia Hussain import random students = ["Hasan", "John", "Amira", "Salma", "Ashley", "Peter","Omar", "Shehnaz","Claudio", "Kaie","Mariam", "Rubel", "Mishika", "Fadia"] length = len(students) print("The number of students in this class is: ",length) print("And now they will be separated into groups...
bcdb4ca7db6ba63a1566be6ed9ca72cfe8441425
aanchal1234/Assignment1
/assignment17.py
2,138
4.65625
5
#1Write a python program using tkinter interface to write Hello World and a exit button that closes the interface. import tkinter from tkinter import * import sys root=Tk() root.title("my app") root.geometry("250x250") root.minsize(200,200) root.maxsize(300,300) l=Label(root,text="Hello World!",width=25,font='20') l.p...
38dd8d776eb5eba1fbd89a7bb70f20329f4e1080
KevinChen1994/leetcode-algorithm
/problem-list/Tree/687.longest-univalue-path.py
950
3.890625
4
# !usr/bin/env python # -*- coding:utf-8 _*- # author:chenmeng # datetime:2021/2/4 15:54 # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def longestUnivaluePath(se...
862975cb6685d97ba6ac2047673c4df8d8b55aa3
jhaze420/smiesznepsy
/fhfhfhfhfhf.py
202
3.59375
4
for j in range(1, 5): print("***") for k in range(1,5): print(k * "*") for l in range(1,5): print((4-l)*" " + l*"*") for m in range(1,5): print((4-m)*" " + m*"*" + (m-1)*"*")
3422311f0acf9faeee7c0a9468d81fedb045a4e4
Anjualbin/workdirectory
/Functional programming by sajay/nested dictionary accessing values.py
823
3.765625
4
users={ 1000:{"acconu_num":1000,"password":"user1","balance":3000}, 1001: {"acconu_num": 1001, "password": "user2", "balance": 4000}, 1002: {"acconu_num": 1002, "password": "user2", "balance": 5000}, 1003: {"acconu_num": 1003, "password": "user3", "balance": 6000} } # Check for username and password ...
f49da0f4c21f50ee607b7e4e0b46c1a3ff7128f2
ashiqcvcv/guvi
/DS/task01.py
8,701
3.734375
4
''' 3Sum Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not contain duplicate triplets. Example: Given array nums = [-1, 0, 1, 2, -1, -4], A solution set is: [ [-1,...
cf1c5c63a9b04b7f1cb51c0232acbac58f561e8e
DamonZCR/PythonStu
/47Tkinter/Toplevel顶级窗口/26-Toplevel顶级窗口.py
522
3.578125
4
from tkinter import * """Toplevel (顶级窗口)组件类似于Frame组件,但Toplevel组件是一个独立的顶级窗口, 这种窗口通常拥有标题栏、边框等部件。 何时使用Toplevel组件? Toplevel组件通常用在显示额外的窗口、对话框和其他弹出窗口上。""" root = Tk() def create(): top = Toplevel() top.title("Damon") msg = Message(top, text="现在是晚上23点39分!") msg.pack() Button(root, text="创建顶级窗", command=cr...
4499f609e08b7ee993b16db444e47f252b2d1ec9
gitlearn212/My-Python-Lab
/Aac/cross_numbers.py
271
4.09375
4
num = input(" Enter an odd length number: ") length = (len(num)) for row in range(length): for col in range(length): if row==col or row+col ==length-1: print(num[row], end=" ") else: print(" ", end=" ") print(" ")
c866b83580f5f775e9a24b9f9fec288600365e7e
bayanijulian/robot-arm-path-analyzer
/transform.py
9,030
3.515625
4
# transform.py # --------------- # Licensing Information: You are free to use or extend this projects for # educational purposes provided that (1) you do not distribute or publish # solutions, (2) you retain this notice, and (3) you provide clear # attribution to the University of Illinois at Urbana-Champaign # # Cr...
2ed9e63e724c0faf7be94505a150aa7cb4532b09
CNieves121/lps_compsci
/class_samples/4-9_classes/studentStorer.py
850
3.921875
4
class Student(object): """ Encapsulates a Student, their gpa and college app list. """ def __init__(self, name, gpa, fav_snack): self.name = name self.gpa = gpa self.fav_snack = fav_snack self.collegelist = [] def getSnack(self): return self.fav_snack class College(object): """Encapsulates a school."...
72abac35e521d7c612e8684c44ee2a916da36239
Surbhi-Golwalkar/Python-programming
/loop/sum of square and cube.py
207
4.03125
4
n=int(input("Enter no. upto which you want to add:")) sum=0 i=1 while(i<=n): sum = sum + (i*i) #sum= sum+(i*i*i) i = i+1 print("Sum of square of no. is",sum) #print("Sum of cube of no. is",sum)
a325618e8ac6a5b5fdd61fd45d03095b05e858ad
rohankk2/hackerrank
/Cracking the coding Interview/hashtablesicecreamparlor.py
809
3.546875
4
def whatFlavors(cost, money): index1=0 index2=0 i=0 m={} for ele in cost: try: m[ele]=m[ele]+1 except: m[ele]=1 for ele in cost: index1=ele; try: if(m[money-index1]>=1): flag=1 if(money-index1==index...
d0901d4a188d77e1261d2336856ab27ae3d8df13
momado350/tow_int_sum
/tow_num_sum.py
1,272
4.1875
4
# define the function that takes an array of ints ang a target number that is sum of two ints def tow_num_sum(arr, target): # sort the array arr.sort() # we want to start from the beginning of the array and move towards the end leftindex = 0 # we also want to determine where to stop rightindex =...
9765d97890708ad90aa79dc6246f1892d91ada0f
Serikaku/Treinamento-Python
/CursoemVideo/ex010.py
134
3.921875
4
x = float(input('Digite quantos reais você possui na carteira: R$')) print('Você pode comprar US${:.2f} Dólares'.format(x / 3.27))
20513ebc3d5d15eec23a1f8c0eaf820367e1379d
VuThiThuyB/vuthithuy-labs-c4e22
/lab3/hw/Turtle_2.py
70
3.734375
4
def sum(a,b): print("Sum :",a,"+",b,"=",a+b) a = 2 b = 3 sum(a,b)
86db09f5aa57dcf34db75a1fa15439be4b746948
tectronics/bogboa
/mudlib/world/money.py
1,340
4.15625
4
# -*- coding: utf-8 -*- #------------------------------------------------------------------------------ # mudlib/world/money.py # Copyright 2009 Jim Storch # Distributed under the terms of the GNU General Public License # See docs/LICENSE.TXT or http://www.gnu.org/licenses/ for details #------------------------...
12813ddf1d5b952ef6dccf7ea7fa191f68cabb41
joeyscl/Programming_Challenges
/Sorting & Searching/largestIntervals.py
679
3.90625
4
from copy import deepcopy ''' given an array of integer pairs (as tuple or list), minimize the number of overlapping or consecutive ones. Test Input: [4, 8], [3, 5], [-1, 2], [10, 12] Test ouput: [-1, 8], [10,12] ''' def func(pairs): pairs = sorted([sorted(pair) for pair in pairs]) res = [] curr = deepcopy(pairs...
36bedf0ccadf7af9995137290b08f5ca63db2b84
pbhuss/ProjectEuler
/problems/p037.py
624
3.5625
4
from util.factorizer import PrimeGenerator def truncations(x): s = str(x) result = set() for i in range(len(s)): result.add(int(s[:i + 1])) result.add(int(s[i:])) return result def main(): truncatable_primes = [] prime_gen = PrimeGenerator() while len(truncatable_primes) ...
f50381d5f9f18629d45de661a47ab49cd8d54312
nicander2708/NicanderChance_ITP2017_Exercise4
/exercise4.py
210
3.953125
4
def recursive(x): try: if x == 1: return 1 else: return x * recursive(x-1) except (RecursionError, TypeError): return None num = recursive(5) print(num)
463382e1bf43c844d7888fc5b2eaa1bf0bf95f24
jkcadee/A01166243_1510_labs
/Lab03/doctests.py
575
3.625
4
import doctest def base_divisor(inputted_value, divisor): """Divides the first parameter by the second. >>> base_divisor(4, 2) 2 >>> base_divisor(2, 1) 2 """ quotient = inputted_value / divisor return int(quotient) def base_remainder(divisor_remainder, modulo): """Calculates the...
eb7988c142c3c3d207b2ec384d1825de474ecf87
FlintHill/SUAS-Competition
/UpdatedSyntheticDataset/SyntheticDataset2/ElementsCreator/circle.py
955
3.609375
4
from PIL import ImageDraw, Image from SyntheticDataset2.ElementsCreator import Shape class Circle(Shape): def __init__(self, radius, color): """ Initialize a Circle shape :param radius: radius in pixels :type radius: int :param color: color of shape - RGB :type co...
3bdfb913f9e2620794c2c00952a190120dc803dc
tanvir362/Python
/turtle_random_walk.py
1,549
3.984375
4
import turtle as tl import random import time STEP_LENGTH = 30 tl.speed(1) tl.left(90) def walk1(): for i in range(1000): angle = random.randrange(0, 360, 45) # print(turn) # if turn == 0: # tl.forward(STEP) # elif turn == 1: # tl.left(90) # tl.f...
c9a545552cf1dd1e2b901285b4b3631979de939d
isisbinder/python_challenge
/level_5.py
334
3.546875
4
#!python3 # Level 5 import urllib from urllib import urlopen PICKLE_SOURCE = "http://www.pythonchallenge.com/pc/def/banner.p" page_source = urlopen(PICKLE_SOURCE).read() import pickle pick = pickle.loads(page_source) new_text = '' for line in pick: new_text += ''.join([char * times for char,times in line]) + '\n' p...