blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7547ab07f270bb036e40909b605d791e50ba80a9
Mayankjh/Python_tkinter_initials
/tkinter5.py
431
3.890625
4
#message-box from tkinter import* import tkinter.messagebox root = Tk() #tkinter.messagebox.showinfo("Window Title","Did you know that you just fired a message") answer = tkinter.messagebox.askquestion("Question","Are you Human?") if answer == "yes": tkinter.messagebox.showinfo("Congrats","You are ...
60fedbbc138c539bf2a8f10d745a40c76d052d23
PetrPrazak/AdventOfCode
/2015/03/aoc2015_03.py
652
3.875
4
# http://adventofcode.com/2015/day/3 from __future__ import print_function def walk(visits, data, start): x, y = 0, 0 for i in range(start, len(data), 2): direction = data[i] if direction == '^': y -= 1 elif direction == '<': x -= 1 elif direction == '>'...
00f97d58d2bea9e25f51b159207c0773cba67c3e
buurro/interviews
/solutions/algorithms/fibbonacci.py
259
4.21875
4
''' Problem: Generate the nth Fibonacci number without using recursion. ''' def fibonacci(n): result = [1, 1] for index in range(2, n): result.append(result[index-1] + result[index-2]) return result[-1] test = 8 print(fibonacci(test))
3061cd6619e1d5647dbc947f45a78aedd18f07b3
GeorgiTodorovDev/Python-Fundamental
/08.Exercise: Data Types and Variables/04.sum_of_chars.py
137
3.984375
4
n = int(input()) result = 0 for num in range(1, n + 1): letter = input() result += ord(letter) print(f'The sum equals: {result}')
91d3103e25dc8c8d56f89cd704ace8213128eb20
salamwaddah/nd004-1mac
/Strings & Lists/substrings.py
394
3.9375
4
# Write your code here def is_substring(needle, haystack): for index in range(len(haystack)): if (haystack[index:index + len(needle)] == needle): return True return False # Below are some calls you can use to test it # This one should return False print(is_substring('bad', 'abracadabra'))...
ba6e2dfa786feb92e60c09243db0497c432e94ba
Tekorita/Cursopython
/funcionesymodulos.py
703
4.09375
4
def suma(): """MUestra la suma de dos numeros ingresados""" a = int(input("Ingrese un numero entero: ")) b = int(input("Ingrese un numero entero: ")) print(a + b) def resta(): """MUestra la resta de dos numeros ingresados""" a = int(input("Ingrese un numero entero: ")) b = int(input("Ingrese un numero entero: "...
e69ef5134868c347be51920862b136b8a8ffd0c4
Yoatn/codewars.com
/Ones and Zeros.py
851
3.84375
4
# -------------------------------------------------- # Programm by Yoatn # # Start date 29.12.2017 22:55 # End date 00.00.2017 00:00 # # Description: #Given an array of one's and zero's convert the equivalent binary value to an integer. # # Eg: [0, 0, 0, 1] is treated as 0001 which is the binary representat...
f1ad08337e9c15767fc633b886425f44d3fbdaaf
Tanima02-eng/Python_PES_SET1
/Question_18_topgear.py
859
4.34375
4
#18.Using loop structures print numbers from 1 to 100. and using the same loop print numbers from 100 to 1 (reverse printing) #a) By using For loop #b) By using while loop #c) Let mystring ="Hello world" #print each character of mystring in to separate line using appropriate loop structure. print ("Printing 1 t...
a7e2f66b9714fb688017df2e68926c9882b5c3f2
Amaayezing/ECS-10
/FinalProject/word_search_solver.py
6,836
3.890625
4
# Maayez Imam & Raghav Dogra 12/15/17 # Word Search Solver Program def pack_num(a, b): pack = "({0}, {1})".format(str(a), str(b)) return pack def word_search(): filename = input("Enter the name of the file that contains the word search: ") print_text(filename) word_search_puzzle = [] words_t...
c7e31840db849efe2f5f2ca64c0e7e0cc27af6a7
emersonrs01/faculdade.Python
/27_03/exercicio03.py
95
4
4
y=int(input("qual e o valor de y: ")) r=0 r2=0 for x in range(1,y+1): r=x*y print(y)
274c0a8e9001f383b91a00e9379e54abdc8f5962
MohaimenH/python3-tutorial
/_arithmeticSeq.py
344
4.0625
4
def arithSeq(a: int, d: int, n: int = 5) -> int: #n=5 is the default value "Print an arithmetic sequence of length 'n', starting at 'a', with common difference 'd'." last = a + (n-1) * d for x in range (a, last+1, d): print(x) start = 3 diff = 3 length = 5 arithSeq(start, diff, length) # print(a...
161fe22760805ab6d492b85ee4da6b3586301fbf
peace20162/Algorithm_Lab
/lab1/GCD2.py
978
3.609375
4
import time def prime_factors(n): i = 2 factors = [] x = abs(n) while i * i <= x: if x % i: i += 1 else: x //= i factors.append(i) if x > 1: factors.append(x) elif x==1: factors.append(1) else: factors.append(None) ...
2fa6006d46e117990f57544cd9a4eb01869e3eb7
amcfague/euler
/problem146.py
569
3.796875
4
import numpy as np numbers = [1, 3, 7, 9, 13, 27] def summation(n): n2 = n ** 2 l1 = [n2 ** num for num in numbers] l2 def primesfrom2to(n): """ Input n>=6, Returns a array of primes, 2 <= p < n """ sieve = np.ones(n/3 + (n%6==2), dtype=np.bool) sieve[0] = False for i in xrange(int(n**...
180c64e6a5aa861c00b235b23cdf913fe19cb2b8
Huxhh/LeetCodePy
/jianzhioffer/33VerifyPostorder.py
730
3.6875
4
# coding=utf-8 # author huxh # time 2020/3/27 4:27 PM # O(n^2) O(n) def verifyPostorder(postorder): def back(i, j): if i >= j: return True l = i while postorder[l] < postorder[j]: l += 1 m = l while postorder[l] > postorder[j]: l += 1 ...
08053dfef96cfa3d96cada36b42b9ad40a411c32
Patrickrrr007/First_time_upload_from_Mac
/function.py
747
3.828125
4
#function 函式/功能 #function是用來收納程式碼的 #他是個功能 #def 函式名稱(): # 內容 #level1 def washermashine(): print('請按開始') print('按強度') print('洗的種類') washermashine() print('\n') #level2 多參數parameter def wash(dry): print('請按開始') print('按強度') print('洗的種類') if dry: print('烘乾') print('需要十分鐘喔') wash(True) wash(False) print('\...
4826dcee0ba0c2c1874f65f2c348a9795d4cf3b8
Carmenliukang/leetcode
/算法分析和归类/树/二叉搜索树的范围和.py
2,092
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 给定二叉搜索树的根结点 root,返回值位于范围 [low, high] 之间的所有结点的值的和。   示例 1: 10 / \ 5 15 / \ \ 3 7 18 输入:root = [10,5,15,3,7,null,18], low = 7, high = 15 输出:32 示例 2: ...
0daeb20563ca047cd6f46a1add8da61a6d74e0f4
meetgadoya/leetcode-sol
/problem1160.py
3,910
3.9375
4
''' Example 1: Input: words = ["cat","bt","hat","tree"], chars = "atach" Output: 6 Explanation: The strings that can be formed are "cat" and "hat" so the answer is 3 + 3 = 6. Example 2: Input: words = ["hello","world","leetcode"], chars = "welldonehoneyr" Output: 10 Explanation: The strings that can be formed are "h...
08b34ff9fb3b651464f6cd8ae8a25531f95fada9
ataicher/learn_to_code
/careeCup/towers.py~
1,080
3.8125
4
#!/usr/bin/python -tt import sys import time from stacksheaps import Stack def create_sorted_stack(n): s = Stack() for i in range(1,n+1): s.push(str(i)) return s def stackPrint(stacks): print 'stack0: ', stacks[0] print 'stack1: ', stacks[1] print 'stack2: ', stacks[2], '\n' def move(stacks,i,j,m,to...
bee193cc4f5c273a9b33995c344ff32166af998a
90Nitin/LeetCode
/Closed Questions/isPowerOfTwo_v1.py
285
3.859375
4
__author__ = 'nsrivas3' def isPowerOfTwo(n): if n == 0: return(False) if n == 1: return(True) counter = 0 while(counter==0 and n!=1): counter = n%2 n = int(n/2) if n==1 and counter==0: return(True) else: return(False) print(isPowerOfTwo(32))
3900026e3381a9325bf906f535890e230ce056f3
tzzs/dy2018
/dy2018/test.py
183
3.53125
4
from PIL import Image w = 50 # 宽度 h = 37 # 高度 img = 'dl.png' im = Image.open(img) im = im.resize((w, h), Image.NEAREST) # print(im.getpixel((20, 20))) a = [1,2,3] print(*a)
e23a61b27b557364330cc15a04f1c210f96e124b
reemaamhaz/DiseaseNameEntityRecognition
/test.py
2,600
3.5
4
import sys, string #open the results and the answer key for evaluation data = open(sys.argv[1]).readlines() answer_key = open(sys.argv[2]).readlines() #create dictionaries of sentences and BIO tags sent_id = 0 sentences = {} bio_list = {} #create empty lists for BIO tags and the words in each sentence bio_tags = [] ...
2ab7db72bbedb171da2aec2cd116ff45de036177
dansoh/python-intro
/python-crash-course/exercises/chapter-10/10-12-favorite-numbers-remembered.py
798
3.859375
4
import json def number_check(): """Check if favorite number already exists.""" filename = 'favorite_number.json' try: with open(filename) as f_obj: favorite_number = json.load(f_obj) except FileNotFoundError: return None else: return favorite_number def record_number(): """Prompt for fa...
c55ab5e32f9716c3fc547d502a724fe418febd00
glaucodasilva/PythonURIJudge
/1008.py
142
3.59375
4
func = int(input()) ht = int(input()) valor = float(input()) salario = ht * valor print("NUMBER =", func) print("SALARY = U$ %1.2f" % salario)
e5fe95848b6a5b9194b9b49b3dd2579d1cf80efc
Ruchitghadiya9558/python-program
/collection/list/list1.py
123
3.78125
4
mylist=[10,20.1,"a","hello"] #print(mylist) #print(mylist[2]) for i in mylist: print(i) del mylist[2] print(mylist)
507d31c972c179a709eb01a4acd23b98e4bb96b2
cnkumar20/LeetCode
/python/powxy.py
261
4.0625
4
def pow(x,y): if(y==0): return 1 if(y==1): return x if(y<0): return 1/pow(x,abs(y)) if(y%2==0): r = pow(x,y/2) return r*r else : r = pow(x,(y-1)/2) return r*r*x print(pow(3,-3))
869e3ef5109539768ea14ba0473760b7508658d9
shreykuntal/My-other-Python-Programs
/programs/Dharacharya formula(complex).py
334
4.28125
4
import cmath print (("note:please enter values of fraction and root in decimal form").upper()) a=float(input("Enter value of 'a': ")) b=float(input("Enter value of 'b': ")) c=float(input("Enter value of 'c': ")) d=(b**2)-(4*a*c) e=(-b-cmath.sqrt(d))/(2*a) f=(-b+cmath.sqrt(d))/(2*a) print ("roots are:".upper()) ...
4c39878f32fdb0185a709ed9fb7ee191012ae574
mathvfx/Notebooks
/Python/data_structures/maps_and_sets/test_UnsortedMaps.py
542
3.515625
4
#!env python3 from random import randrange from ADT_ListMaps import UnsortedMap def test_maps(): my_map = UnsortedMap() my_map["greet"] = "Hello world" my_map["age"] = 243 my_map["place"] = "SF" my_map["country"] = "United States" my_map["animal"] = "eagle" print(f"LEN: {len(my_map)}") ...
04f76fb77d7b4b86e9e44eb996fa0951e839a011
LeeHeejae0908/python
/Day03/set_basic.py
1,235
3.65625
4
''' *집합 (set) - 집합은 여러 값들의 모임이며, 저장순서가 보장되지 않고 중복값의 저장을 허용하지 않는다 - 집합은 사전과 마찬가지로 {}로 표현하지만 , key:value 쌍이 아닌 데이터가 하나씩 들어간다는 점이 사전과 다르다 - set()함수는 공집합을 만들기도 하며, 다른 컬렉션 자료를 집합 형태로 변환할 수도 있다. ''' #[] list(), tuple(), {} dict(), set() names = {'홍길동', '김철수', '박영희', '고길동', '홍길동'} print(type(names)) print(names) for x ...
f4e78b4a11335bb0e3dc56fa5a05b6f2edb54d52
EmersonBraun/python-excercices
/cursoemvideo/ex047.py
274
3.921875
4
# Crie um programa que mostre na tela todos os números pares # que estão no intervalo entre 1 e 50 print('Números pares entre 1 e 50:\n') for c in range(1, 51): if c % 2 == 0: print(' {:2} '.format(c),end='') if(c % 10 == 0): print('\n')
5cca28d986c17282514f7679fd560c6636999364
sskrs/CNSS-Projects
/Cryptography/subject_1/otp.py
3,083
3.5625
4
import random import string def encryption(file): f = open(file, 'r') file_contents = f.read() message = file_contents # Μετατρέπουμε το plaintext που πήραμε στην είσοδο σε ascii m = [ord(c) for c in message] # Υπολογίζουμε το μήκος του plaintext σε ascii # θα το χρειαστούμε για να δημιουργ...
12afb7a762fa7c00fa2c480cf029d00e35020b42
emilieberges/pythonProject
/exercice2.py
2,436
4.125
4
# -*-coding:Utf-8 -* # print("hello") # En utilisant des boucles while lorsque le nombre d'itérations n'est pas connu et des boucles for lorsque le nombre d'itérations est connu : # # 1. Écrire un algorithme qui demande un entier positif, et le rejette tant que le nombre saisi n’est pas conforme. # # i = -1 # while (i ...
48514e765b3a19947c7056197e9bac63626c6a62
theskinnycoder/python-lab
/week2/a.py
418
4.1875
4
''' 2a. Write a program to get the number of vowels in the input string (No control flow allowed) ''' def get_number_of_vowels(string): vowel_counts = {} for vowel in "aeiou": vowel_counts[vowel] = string.count(vowel) return sum(vowel_counts.values()) input_string = input('Enter any string : ') p...
a5a434260106a952466b5ef1eaa825496a053cc5
Yokeshthirumoorthi/Data-Validation
/crash_data_validation/reader.py
10,441
3.53125
4
#!/usr/bin/env python import pandas as pd pd.set_option('display.width', 200) pd.set_option('display.max_columns', 35) pd.set_option('display.max_rows', 200) # nrows : int, default None # nrows is the number of rows of file to read. Its useful for reading pieces of large files df = pd.read_csv('crashdata.csv', nrows=N...
97d9efc9bdc662a7ca4a5dbffbe78d0069f451c5
Ing-Josef-Klotzner/python
/_monk_and_his_unique_trip.py
3,496
4.03125
4
from sys import stdin from collections import defaultdict as dd # Python3 program to implement Disjoint Set Data Structure. class DisjSet: def __init__ (self, n): # Constructor to create and initialize sets of n items n += 1 # 1-indexed self.rank = [1] * n self.parent = [i for i ...
db4eba5e54bf1d91293b63bcd144a9ec9efc328a
balasaranyav/python_programs
/program15.py
224
4.125
4
#Write a program to calculate sum of digits of a number. def sum(n): value = 0 while (n > 0): value = value + (n % 10) n = n // 10 return value n = int(input("Enter value: ")) print(sum(n))
ef2bd61e631e8923c32710f51413b1dd6170790f
imn00133/algorithm
/LeetCode/May20Challenge/Week1/day4_number_complement.py
422
3.6875
4
# https://leetcode.com/problems/number-complement/ # Solved Date: 20.05.05. def find_complement(num): index = 1 while num >= (1 << index): index += 1 ans = num ^ ((1 << index) - 1) return ans def main(): print(find_complement(0)) print(find_complement(1)) print(find_complement(5)...
b0fa6359d8a9fa0efa1a1fa72bae4dc31d0f7718
mgiolando/SoftwareDesign
/chap11/homophone.py
1,455
4.28125
4
from pronounce import read_dictionary def is_homophone(word_a,word_b,saying): """ This function checks to see if two words are both homophones and in the list saying word_a: string word_b:string saying: dictionary returns: bool""" #is in pronounce? if word_a not in saying or word_b not in saying: return False...
a6c1adb6f74ec9fc1667f3fe463a24ed72206296
aartikansal/PythonFundamentals.Exercises.Part1
/full_name.py
190
3.859375
4
#print ("hello world") #firstName = "Aarti" #for x in range (500): # print (firstName) last_Name ="Kansal" first_Name= "Aarti" full_Name= first_Name + " " + last_Name print(full_Name)
8efd69dae6e0f0c6b3ad10404f6bd041125a4698
tarekFerdous/Python_Crash_Course
/004.Working with Lists/0.4.10.ex.py
286
4.1875
4
#slices games = ['cricket', 'football', 'tennis', 'badminton', 'table tennis'] print('The first three items in the list are: ') print(games[:3]) print('Three items from the middle of the list are: ') print(games[1:4]) print('The last three items in the list are: ') print(games[-3:])
a72055ef3a8963dc3dbfd735f0d472bd87b491c5
VincentPauley/python_reference
/13_python_comparisson_operators.py
283
3.609375
4
#!/usr/bin/python # EQUALITY print( 3 == 3 ) # true # NOT EQUAL print( 4 != 4 ) # false # LEFT OPERAND GREATER print( 4 > 1 ) # true # LEFT OPERAND LOWER print( 6 < 8 ) # true # GREATER THAN OR EQUAL TO print( 32 >= 32 ) # true # LESS THAN OR EQUAL TO print( 4 <= 3 ) # false
130a82f2615f927ccbb4c4dc9d42f68d224390e7
Johnny-QA/Python_training
/Python tests/variables_methods.py
310
3.65625
4
my_variable = 50 string_variable ="Cent" #print(my_variable, string_variable) ## Method creation #def multiply_method(num1, num2): # return num1 * num2 #result = multiply_method(5, 3) #print(result) def return_42(): a = 42 return a def my_method(a, b): return a * b print(my_method(2, 4))
bda3873801dcdb946d78ac6c1df6e9225a66f45d
yonicarver/ece203
/Lab/Lab 3/preditorprey.py
1,066
3.828125
4
import math print 'Enter the rate at which prey birth exceeds natural death >', defaultA = 0.1 A = float(raw_input() or defaultA) print 'Enter the rate of predation >', defaultB = 0.01 B = float(raw_input() or defaultB) print 'Enter the rate at which predator deaths exceeds births without food >', defaultC = 0.01 C...
262c5a250d3935286fbd5fc6bc4cdcbc42efbded
alm4z/mlp-mnist
/activations.py
2,278
3.53125
4
import numpy as np class Activation(object): """ Interface for activation functions (non-linearities). """ def __init__(self): self.state = None def __call__(self, x): return self.forward(x) def forward(self, x): raise NotImplemented def derivative(self): ...
9c15ff4fe6798bd1e3e8c90f9712de58253550de
DevParapalli/SchoolProjects_v2
/1_greet.py
264
4.1875
4
""" Write a program to enter name and display as Hello, Name. """ def greet(): _name = input("Enter Your Name:") print(f"Hello {_name}") return f"Hello {_name}" if __name__ == "__main__": greet() __OUTPUT__ = """ Enter Your Name:Dev Hello Dev """
99fd18637c775da2d32751062eeda93824de852b
sven-oly/OsageText
/wordsearch.py
22,456
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Starting with # https://codereview.stackexchange.com/questions/98247/wordsearch-generator from __future__ import print_function #from builtins import range #from builtins import object import itertools import logging import random import sys from random import randint ...
0b941327c10837c48a21313dd56684479a70e4f7
huweitao/PythonScripts
/ReplaceString.py
489
3.546875
4
#-*- coding: UTF-8 -*- import sys def replaceString(oldOne,newOne,path): print("Replace %s to %s in %s" % (oldOne,newOne,path)) content = '' with open(path, 'r') as f: content = f.read().replace(oldOne,newOne) # print content if len(content) > 0: with open(path, 'w') as f: f.write(content) def main(oldOne...
9de7b014aef2986a0ff6865e49360c76df99ef4f
blueweiwei/webGuolu
/src/test.py
11,207
3.53125
4
round(a, 3) def form1(self): self.data['0']['C4']=round((0.124*self.data['0']['C3']*100)/(100+0.124*self.data['0']['C3']),3) self.data['0']['C8']=round((100-self.data['0']['C4'])*self.data['0']['C7']/100,3) self.data['0']['D8']=round((100-self.data['0']['C4'])*self.data['0']['D7']/100,3) ...
9fb66acdcfb1f4a07a2a948e87d9ffdec6665d42
challeger/leetCode
/模拟面试/leetCode_159_地下城游戏.py
2,369
3.640625
4
""" day: 2020-09-11 url: https://leetcode-cn.com/problems/dungeon-game/ 题目名: 地下城游戏 一些恶魔抓住了公主(P)并将她关在了地下城的右下角.地下城是由 M x N 个房间组成的二维网格. 我们英勇的骑士(K)最初被安置在左上角的房间里,他必须穿过地下城并通过对抗恶魔来拯救公主. 骑士的初始健康点数为一个正整数.如果他的健康点数在某一时刻降至 0 或以下,他会立即死亡. 有些房间由恶魔守卫,因此骑士在进入这些房间时会失去健康点数(若房间里的值为负整数,则表示骑士将损失健康点数); 其他房间要么是空的(房间里的值为 0),要么包含增加骑士健康点数的魔法球(若房...
cf38bbcbf57707b6f9e4255da2bcc0414cb4ea79
SWHarrison/CS-1-3
/call_routing_project/decimal_search_tree.py
6,885
3.75
4
import pickle, time class DecimalTreeNode(object): def __init__(self, data): """Initialize this Decimal tree node with the given data.""" self.data = data self.nexts = [None] * 10 def __repr__(self): """Return a string representation of this Decimal tree node.""" retur...
8c73f517e974f3c44227c4bc82a3f6a45d56359e
yuanguLeo/untitled1
/CodeDemo/shangxuetang/com.shangxuetang/func_04.py
437
3.671875
4
#!/usr/bin/env python #_*_coding:utf-8_*_ import time import math def test01(): start = time.time() for i in range(10000000): math.sqrt(30) end = time.time() print("test01()耗时为:{0}".format((end-start))) def test02(): a = math.sqrt start = time.time() for i in range(10000000): ...
ecf01ed0a9fb62072101b59b24b417fbdf8dfe1a
whitefang82/simple_Python
/lesson20.py
379
4.09375
4
#Password """while True: print("Enter your age: ") age = input() if age.isdecimal(): break print("Only number!")""" while True: print("Enter your Password: ") password = input() length = len(password) print(length) if password.isalnum() and length >= 6: break pr...
23d2821b1c07c338ac94fc5ad96dab96d5d3a27b
Sidhrth/NNproject
/fourlevelFP.py
1,142
3.875
4
import numpy as np #example is housing prices # X input variables - size, age, distance to market X = np.array(([100, 20, 3000], [400, 5, 100], [240, 10, 1000]), dtype=float) y = np.array(([300], [900], [500]), dtype=float) # Feature scaling X = X/np.amax(X, axis=0) y = y/1000 class Neural_Network(object): def ...
873daae0513be4c7dee7336e139c90ff550a7195
christinalycoris/Python
/factorial_while.py
250
4.09375
4
n = int(input("Please enter a number: ")) counter = 0 product = 1 i = 1 while i <= n: product = product * i counter += 1 if i > n: break print(i, end=" × ") i+=1 print("END") print("The product of " + str(n) + "! is " + str(product) )
6256575470f52184c33241ffdb44053e633e4791
sheikhusmanshakeel/leet_code
/strings/3.py
1,092
3.65625
4
# https://leetcode.com/problems/longest-substring-without-repeating-characters/ def longest_substring(s): if not s: return 0 if len(s) == 1: return 1 seen = dict() longest_length = 0 for c in s: if seen.__contains__(c): if longest_length < len(seen): ...
2c8f7a232e4908299da31bcd54cd2531e8df6746
Roberick313/First-project
/The_class.py
19,774
4.0625
4
import getpass class Main: def __init__(self, number=None, array=None, first_number=None, second_number=None, operand=None, word=None, parameter=None, my_input=None...
19a5dcfea56f7993f664745b66f7e1964c5457a4
stwobe/dropboxcopy01
/1Python/Python3/02_first_scripts_4/Fibonacci/fibo5.py
332
3.59375
4
import time def fib(n): # write Fibonacci series up to n a, b = 0, 1 while b < n: print(b) a, b = b, a+b print(b*a) print((b*b*b)*b*b) time.sleep(0.005) print() #fib(1000565656) #this is a module to be imported into another program - or uncomment above line to run ...
58b9e43550d8e9ae779936b7f34fdbb9c87118f4
rafhaeldeandrade/learning-python
/4 - Estruturas de Repetição em Python/exercicios/ex09.py
403
3.9375
4
""" Faça um programa que leia um número inteiro N e depois imprima os N primeiros números naturais ímpares. """ qtd = int(input('Quantos números deveremos imprimir: ')) qtd_impar = 0 if qtd <= 0: print('Digite um valor maior que 0.') else: for i in range(1, qtd * 3): if qtd_impar == qtd: b...
1bb257ed62a3c4992647b895d09aed07f6965b5a
nlpet/codewars
/Puzzles/array_packing.py
1,747
4
4
u""" Simple Fun #9: Array Packing Task You are given an array of up to four non-negative integers, each less than 256. Your task is to pack these integers into one number M in the following way: The first element of the array occupies the first 8 bits of M; The second element occupies next 8 bits, and so on. Return...
9d49c5489ad5e4fdb6d03aed88326f0dc45c4301
ShikhaShrivastava/Python-core
/OOP Concept/Instance Variable.py
1,316
4
4
class Student: def __init__(self, name, marks, subject): self.name = name self.marks = marks self.subject = subject def disp(self): self.city = "Mumbai" # accessing def disp2(self): print(self.name) print(self.marks) print(self.gender) ...
5c329b82d2f915342270e5c741005671c631da66
Luisa2017/my-first-blog
/provaSALUTI2017.py
136
3.75
4
name = 'Sonia' if name == 'Ola': print('Ciao Ola!') elif name == 'Sonia': print('Ciao Sonia!') else: print('Ciao anonimo!')
a288c5702a6e04fd3ed4843d818fedb441d40e6a
martinamagdy/python-challenge
/PyBank/main.py
2,375
4.09375
4
import csv import os #function for taking csv file and do budget calculation def budget(filepath): totalmonths=0 totalamount=0 #read csv file with open(filepath,newline='') as csvfile: csvreader=csv.reader(csvfile,delimiter=',') #skip the header next(csvreader,None) ...
a8ee1bba897ef78f1f8ba2521b9622a16b1da2e6
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_97/1767.py
1,607
3.640625
4
#Program : Recycled Number, Google code jam problem C #Author : Santhosh Unnikrishnan #email : santa001@gmail.com #date : 14th April 2012 IN_FILE_NAME = "C-small-attempt.in" OUT_FILE_NAME = "C-small-attempt.out" TEMP_FILE_NAME = "temp.txt" def get_number_of_recycled_numbers(A, B): ''' This function will ret...
123e27f26ba69c362d48e61c1cc47fe29d6930f6
StarshipladDev/PythonDungeon
/mainjam.py
22,904
3.78125
4
""" Starshipladdev- (21/10/19) This is a highschool python project I created back in 2015. It is a simple text-based dungeon explorer. Horrible commenting will be left as is. """ #colours-snow,honeydew,midnight blue,firebrick,light blue, #IntVar(),StringVar(),Label, font= ("font,size"), Var.set(set),textv...
4c93af3f8352776f1c4bd7c1126cd86a9fff005d
theChad/ThinkPython
/chap5/fermat.py
571
4.15625
4
# Exercise 5.2 import math # 4.2.1 def check_fermat(a, b, c, n): if n > 2 and a**n + b**n == c**n: print("Holy smokes, Fermat was wrong!") else: print("No, that doesn't work.") # 4.2.2 def fermat_inputs(): print('Please input positive integers to check Fermat\'s theorem.') # Use input...
368854265b4395352e15b1142d91d5cd59420b4e
ishantk/Enc2019B
/venv/Session22.py
652
3.828125
4
import numpy as np arr = np.arange(10, 51, 3) print("arr is:",arr) print("type of arr is:",type(arr)) print("shape arr is:",arr.shape) print("Size of arr is:",arr.shape[0]) # Access Elements print(arr[1]) print(arr[-1]) # Slicing print(arr[3:]) print(arr[:5]) print(arr[3:5]) slices = slice(1, 10, 2) # -> 1, 3, 5, 7...
f676669bcefe7c00698ce0e3c29066d8525f0999
huyngopt1994/python-Algorithm
/bigo/day-1-dyanimic-array-string/problem-518A.py
617
3.8125
4
# http://codeforces.com/problemset/problem/518/A # We just think compare a string like a number, understand the special case to cover this . import string reference_string = list(string.ascii_lowercase) s = list(input()) t = input() len_number = len(s) result = "" is_good = False for index in range(len_number - 1, -...
a6c7f1ccd1dcb58d1c81b83260d1e0bc6e010635
Talha-Ahmed-1/DSA-Labs
/Talha Ahmed (18B-024-SE) Lab # 6.py
2,740
3.84375
4
#!/usr/bin/env python # coding: utf-8 # In[15]: # A class ArrayStack: def __init__(self,size): self.size=size self.data=[0 for i in range(size)] self.top=0 def isEmpty(self): if self.top==0: return True else: return False def Push(self,value...
c3ef9650b2dace1393c92fe319215d7880b8072b
aviolette/aoc2020
/day8/puzzle8.py
1,265
3.625
4
from elves import striplines def run_program(program): line_num = 0 visited = set() acc = 0 while line_num not in visited and line_num < len(program): instruction, value = program[line_num] visited.add(line_num) jump = 1 if instruction == "acc": acc += int(v...
9ca3788f2ae33035312a6b6022cf338606df1aae
MarcGroef/CSVM
/PSO/param_tester.py
2,725
3.921875
4
import abc import time class ParameterTester(object): """ The ParameterTester class provides an interface for tester classes that can evaluate the parameters generated by the ParameterGenerator class. """ __metaclass__ = abc.ABCMeta ################ ## Properties ## ################ ...
162c65f5351374c09c3b9e21517af0b2399240a1
zmunro/advent_of_code_2020
/advent3_part2.py
1,342
3.75
4
from typing import List input_trees = [] with open("files/advent3_input.txt", "r") as in_f: for line in in_f.readlines(): input_trees.append(line.strip()) class Spot: row: int col: int def __init__(self, row: int, col: int): self.row = row self.col = col class TreeGrid: ...
9f756e9e1a298a6db48677a2f48fefbabbf30aba
PAYNE1Z/python-learn
/luffycity-s8/第一模块_开发基础/第2章 _数据类型_字符编码_文件操作/列表copy.py
2,076
3.6875
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- # # Author: Payne Zheng <zzuai520@live.com> # Date: 2019/4/28 # Location: DongGuang # Desc: do the right thing import copy name = [['pony', 'dong'], 'jack', 'robin'] print("########### name: %s\n" % name) name1 = name print("###>>> name1 = name") print("======...
8b3b835822de39f98d4bfb1af53640c569815c28
odinfor/leetcode
/pythonCode/No401-450/no434.py
718
3.796875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/5/11 4:04 下午 # @Site : # @File : no434.py # @desc : class Solution: def countSegments(self, s: str) -> int: if not s or len(s) == 0: return 0 is_dc_start, num = False, 0 for i in s: if i != " " ...
c9efb93bbd7132589f8f0d0b4a63286871e85d83
Xaraxx/curso_Python3
/basics/listCom.py
509
3.703125
4
#List Comprenhention # Is method for resume your code and makeit more readable pares = [] for i in range(1, 31): if i % 2 == 0.0: pares.append(i) print(pares) # List Comprenhention # note: you have to remember this sintax pares2 = [i for i in range(1, 31) if i % 2 == 0 ] print(pares2) cuadrados = {} fo...
618c7d255cb21394cd8db6bca3920c3d5426684f
Fastwriter/Pyth
/Daulet Demeuov t1/D.py
417
4.0625
4
#STUDENT: Daulet Demeuov #GROUP: EN1-C-04 #TASK: Task1 proble D #Description: Write program that reads N. Prompts N float numbers and finds MAXIMUM, MINIMUM and MEDIAN value between them. d=int(input('Enter N: ')) import statistics list=[] for n in range(d): n=float(input('Enter number: ')) list.append(n) p...
e1a7a552daa30dfe7f75366544803506000ae735
RickBahague/python-solutions
/03_builtins/file.py
1,531
4.28125
4
# task 6 def step1(): ''' Writes a string to a file. Always remember to close the file handle. You can check the results by opening the file with any text editor. ''' file = open('myfile.txt', 'w') file.write("hello") file.close() def step2(): ''' Opens the loremipsum file fr...
8ace49362f88d5f5b44f915405c40f804d2e4e9f
nsk324/TIL
/남수경/0821/fibo.py
491
3.890625
4
# def factorial(n): # if n <= 1: # return 1 # else: # return n*factorial(n-1) # # def fibo(n): # if n ==1 : # return 1 # if n ==0: # return 0 # else: # return fibo(n-1)+fibo(n-2) def fibo1(n): global memo if n >=2 and len(memo) <=n : #계산되었는지 안 되었는지 li...
b1ab266fa72e1bfc8f51105ffa103ea0cd2b67b5
youkx1123/hogwarts_ykx
/python_Recordedlesson/Python_Basis/020day3.py
2,433
4.25
4
""" 列表的基本使用 一、列表(list类型) 1、在python是用中括号表示(和其他语言中的数组看起来差不多) 2、例子:[11,22,33,‘python’] 3、列表中可以存储任何类型的数据 4、空字符串 s1=‘’ <class 'str'> 5、空列表 li = [] <class 'list'> 6、列表和字符串(后续会讲的元组,有一个公共操作):切片和索引取值 """ li = [11, 1.3, True, '788', [11, 22]] print(li) s1 = '' li = [] print(type(s1), type(li)) ''' 二、索引(下标) 1、列表里的每个数...
5af7e79fb22f4f557e8a75d318332c2f46bc267f
fis-jogos/ep1-shape
/actors/aircraft.py
1,692
3.75
4
import shared.constants as C class Aircraft: """ This class represents the aircraft controlled by the user. """ def __init__(self, actor): self.actor = actor self.positionX = C.MINIMAL_X self.positionY = C.HEIGHT / 2 self.acceleration = 0 self.shape = 'circle' ...
af76497612f1c9cc55361e29052adca9219fa7fd
ginnyyang/MyPython
/learning_process/itertools_test.py
956
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #计算圆周率可以根据公式 #利用Python提供的itertools模块,我们来计算这个序列的前N项和 #itertools模块提供的全部是处理迭代功能的函数,它们的返回值不是list,而是Iterator,只有用for循环迭代的时候才真正计算。 import itertools def pi(N): ' 计算pi的值 ' # step 1: 创建一个奇数序列: 1, 3, 5, 7, 9, ... digits=itertools.count(1,2) # step 2: 取该序列的前N项: 1, 3, 5, 7, 9, ......
3e2aae48a4e139dcecca2d3bb3e4e20c8dc635bb
awong05/epi
/find-the-k-largest-elements-in-a-BST.py
1,184
4.28125
4
class BSTNode: def __init__(self, data=None, left=None, right=None): self.data, self.left, self.right = data, left, right """ A BST is a sorted data structure, which suggests that it should be possible to find the k largest keys easily. Write a program that takes as input a BST and an integer k, and retu...
e0d1b4c37b1ef78c86be6f3d3b20d5dcf838ad99
yash-khandelwal/python-wizard
/Complete Developer Course 2021/basics/operators.py
235
3.921875
4
# augmented assignment operator some_value = 5 # augmented assignment cannot be used while declaring a variable some_value = some_value + 2 # simple assignment print(some_value) some_value += 2 # augmented assignment print(some_value)
3e5ae70cecb96047fcd6cd7dfe9ffab3589b6871
gkanishk44/Python-Projects
/stackimplementation.py
298
3.53125
4
from collections import deque stack = deque() stack.append('a') stack.append('b') stack.append('c') print('Initial stack:') print(stack) print('\nElements poped from stack:') print(stack.pop()) print(stack.pop()) print(stack.pop()) print('\nStack after elements are poped:') print(stack)
8045e2648ba548139212c68f8c936e0d781fc512
AbhiShake1/Hangman
/Hangman.py
885
3.84375
4
from random_word import RandomWords import ASCIIList as hangmen secretWord = str(RandomWords().get_random_word()).lower() #to stringify even when it returns None game = "-" * len(secretWord) game = game[:0] + secretWord[0] + game[0 + 1:] game = game[:3] + secretWord[3] + game[3 + 1:] #hint at 1st and 3rd words print...
7bd14638fcc8ef0f31a11fb563925274e986a83a
lampkid/jingwuyuan-python
/codec/__init__.py
552
3.515625
4
# -*- coding=utf-8 -*- import traceback def setDefaultEncodingUTF8(): import sys reload(sys) sys.setdefaultencoding('utf-8') def codecText(text, coding='utf-8'): textType = type(text) if textType is int: text = str(text) if textType is not unicode: try: text = ...
13f752495099eafb7431aea275120bf7742ae593
zysymu/Metodos-Computacionais-da-Fisica
/Métodos B/12-estabilidade_pontos_fixos.py
546
3.515625
4
import matplotlib.pyplot as plt import numpy as np plt.style.use("ggplot") lamb = [0.5, 2, 3, 3.2, 4] x = np.linspace(0,1) def f(x): return l*x*(1-x) def g(x): return f(f(x)) #ciclo 2 def h(x): return g(g(x)) #ciclo 4 plt.ylim(0,1) for l in lamb: plt.plot(x, x, linestyle="--") plt.plot(x, f(...
52f3ba154ae3f135c6a45d9875bb0b688326a217
sky-183/42ai_python_bootcamp
/day00/ex07/filterwords.py
1,727
4.3125
4
# **************************************************************************** # # # # ::: :::::::: # # filterwords.py :+: :+: :+: ...
293e7adf1da8915212331fe095e900d0660e9877
iApotoxin/Python-Programming
/60_EcepFinally.py
256
3.546875
4
try: fh = open("myfile", "r") fh.write("This is my file for exception handling!!") except: print("IO Error with File") else: print("Written content in the file successfully") finally: print("This file is closed completely")
4eaa27e28ff35c7a8f6cdc1fe519af6688049012
budavariam/advent_of_code
/2017/23_1/code.py
6,710
4.0625
4
""" Advent of code 2017 day 23/1 """ from argparse import ArgumentParser import re from collections import defaultdict, deque class Instruction(object): """ Instruction for the parser """ @staticmethod def parse(line): """ Create the proper instance for the parser """ return OPERATION[line...
a6b4edcabb259befe9a3e11f310111a873dc38d9
uCognitive/Python-Beginner
/src/while loop/check prime number.py
377
4.0625
4
num = int(input("Enter number to check: ")) # user inpit i = 2 #loop variable initialization p = 0 # conitional variable while i < num: if num%i == 0: #check p = p+1 # if condition become true then change the value of variable p i = i +1 #loop increament if p == 0: # if value of p is not change then it ...
f74416b179acac639c73cfe8a0e2d3938e874c0a
tuseto/PythonHomework
/week2/2-List-Problems/sum_numbers.py
266
4.0625
4
n = int(input("Enter n: ")) count = 1 numbers = [] result = 0 while count <= n: number = int(input("Enter number: ")) numbers = numbers + [number] count += 1 for num in numbers: result = result + num print("The sum is: " + str(result))
9e121f56559fc8da2424c605841a8e4a2be947a2
radekkania/python-projects
/src/algorithms/pattern_search/pattern_search_algorithm.py
7,142
3.59375
4
"""by radoslaw kania""" class SundaySearch: """Sunday pattern search algorithm. """ def _matches_at(self, text, index, pattern): for i in range(len(pattern)): self._counter += 1 if text[index + i] != pattern[i]: return -1 return index def __init__(...
68b4f7a3c409b3cb9fd92b0e1b95dffe8cea1729
AdamZhouSE/pythonHomework
/Code/CodeRecords/2975/60691/248001.py
91
3.796875
4
str1 = input("input a string:") list1 = list(str1) list1.sort() s = "".join(list1) print(s)
818008bac140c37d20dbdbaf46ea1ffa547a2a03
alex8937/CS61A-The-Structure-and-Interpretation-of-Computer-Programs
/lec/lec11/linked_list.py
1,075
3.921875
4
empty = 'empty' def link(head, rest = empty): assert is_link(rest), 'rest is not a linked list' return [head, rest] def is_link(s): return s == empty or (len(s) == 2 and is_link(s[1])) def head(s): assert is_link(s), 'head only applies to linked list' assert s != empty, 'empty list has no head' ...
9d66a8ae68552fdd598b7c9c9f2dd97c09f2f542
marvance/MIT-OCW-problemsets
/mit60001/ps4/ps4c.py
9,610
3.625
4
# Problem Set 4C # Name: <your name here> # Collaborators: # Time Spent: x:xx import string from ps4a import get_permutations ### HELPER CODE ### def load_words(file_name): ''' file_name (string): the name of the file containing the list of words to load Returns: a list of valid words. Words...
1e7451dfe7910eaac2abb7847adecd39b20534f2
JDer-liuodngkai/LeetCode
/offer/40-最小的k个数.py
4,146
3.890625
4
""" 输入整数数组 arr ,找出其中最小的 k 个数。例如,输入4、5、1、6、2、7、3、8这8个数字,则最小的4个数字是1、2、3、4。 不要求按顺序输出 """ from typing import List # def quick_sort2(arr): # if len(arr) < 2: # return arr # # left, right = [], [] # mid = arr[len(arr) // 2] # arr.remove(mid) # # for v in arr: # if v <= mid: # ...
b5920d757099c82a445968a3ec820256906846e3
Ericmanh/cac_ham_python
/CacHamToanHoc/ham_time.py
235
3.796875
4
# Hàm time gồm clock và time from time import clock print("enter your name:", end="") start_time =clock() name = input() print("nhập name") elapsed = clock() - start_time print(name, "it took you", elapsed ,"second to repond")
89b2eba528ea05816b56830c2057f568c9f5ca89
gracerichardson0/Functions
/examscore.py
242
3.953125
4
n = 0 total = 0 exam = int(input("Enter exam (-1 to quit)")) while exam != -1 : total += exam n +=1 exam = int (input ("Enter exam (-1 to quit)")) if n > 0 : print ("Average: ", total/n) else : print ("No exams entered")
387363a8892d50a37cccdebe13635949120768a5
ODYTRON/Challenge-Modules-Classes-Error-Handling-And-List-Comprehension
/First Class example in python.py
1,884
4.4375
4
# First Class example in python. the example is a dataset which has to do # with NFL suspensions # Class name class Suspension(): # Initial function , initiated with self and a key word to archive columns # note that you set columns # you call positions of a single arbitrary row for the moment , then it will be specif...
23370a55d7322338154cb1e60eb57121efcf3cdc
energy-in-joles/Advent-of-Code-2020-Solutions
/Day10/Day10.py
2,741
3.796875
4
from math import factorial def main(): with open('test.txt', 'r') as file: joltages = sorted([int(joltage.strip()) for joltage in file]) # Part 1: count number of j_dff of 1 and 3 and multiply j_1 = j_3 = 0 in_j = 0 # input joltage diff_lst = [] joltages.insert(0, in_j) # add to the front j...
0d8aa04f331936c62772491130c4150638cca531
vivian2943/01
/23 w_for.py
177
3.90625
4
for i in range(0,3): a = input('輸入密碼:') if a == 'key': print('登入') else: print('錯誤,剩餘嘗試次數為'+ str(2 - i))