blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
7b73a9dde0dccdaf19434419c4ce16387f099588
hyrdbyrd/ctf-route
/public/tasks-content/code.python.py
124
3.53125
4
def encrypt(text): key = len(text) res = [] for i in text: res.append(ord(i) + (ord(i) % key)) key += 1 return res
a3dd8e793dba43fdc1f0c05044e9751e46daf6ed
joanamcsp/leetcode-python
/perfect_number.py
392
3.5625
4
import math class Solution: def checkPerfectNumber(self, num): """ :type num: int :rtype: bool """ if num <= 0: return False divisors = [div for div in range(1,int(math.ceil(math.sqrt(num)))) if num % div == 0] divisors.extend([num // div for div...
d1a1cdab267d500a7ff27780a56f13f548a29a6b
VeraMendes/lambdata_DS8
/lambdata_veramendes/functions.py
462
3.875
4
""" utility functions """ import pandas as pd import numpy as np TEST_DF = pd.DataFrame([1,2,3,4,5,6]) def five_mult(x): """multiplying a number by 5 function""" return 5 * x def tri_recursion(k): """recursion of a value""" if(k>0): result = k + tri_recursion(k-1) #...
427707409b4897dea8ae9fd913944ac23a2feb03
russjohnson09/sentential-logic
/sentential.py
3,123
4.15625
4
#!/usr/bin/env python """ Main Methods ----------------------------------- The following are all of the methods needed to apply logic rules and confirm that a Hilbert style proof is correct. Arguments given to each method are the line number of the statement and any line numbers needed to check for validity. ---- ...
b733f8bd4a9d664973423240f106c8d252cdf13b
Adi7290/Python_Projects
/chschs.py
6,228
3.6875
4
Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> for i in range(0,100): if i%2==1: print(i) elif i%2 ==0: pass i=i+1 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 3...
5c5199249efa2ba277218ed47e4ae2554a0bbf7e
Adi7290/Python_Projects
/improvise_2numeric_arithmetic.py
660
4.21875
4
#Write a program to enter two integers and then perform all arithmetic operators on them num1 = int(input('Enter the first number please : \t ')) num2 = int(input('Enter the second number please :\t')) print(f'''the addittion of {num1} and {num2} will be :\t {num1+num2}\n the subtraction of {num1} and {num2} will b...
4cc7aabb1e5e2b48cc90c607acce1b67f9fac93d
Adi7290/Python_Projects
/Herons formula.py
350
4.28125
4
#Write a program to calculate the area of triangle using herons formula a= float(input("Enter the first side :\t")) b= float(input("Enter the second side :\t")) c= float(input("Enter the third side :\t")) print(f"Side1 ={a}\t,Side2 = {b}\t,Side3={c}") s = (a+b+c)/2 area=(s*(s-a)*(s-b)*(s-c))**0.5 print(f"Semi = ...
ea0b627a1ee97b93acd9087b18e36c3fa5d10b4d
Adi7290/Python_Projects
/singlequantity_grocery.py
942
4.1875
4
'''Write a program to prepare a grocery bill , for that enter the name of items , quantity in which it is purchased and its price per unit the display the bill in the following format *************BILL*************** item name item quantity item price ******************************** total amount to be paid ...
4303d8cef8cb2db91a035f228e311f265873c29c
Adi7290/Python_Projects
/sum_arithmetic.py
210
3.875
4
"""Write a program to sum the series 1+1/2+....1/n""" number = int(input('Enter the number :\t')) sum1=0 for i in range(1,number+1): a = 1.0/i sum1=sum1+a print(f'The sum of 1+1/2...1n is {sum1}')
2b786c15f95d48b9e59555d2557cc497d922d948
Adi7290/Python_Projects
/Armstrong_number.py
534
4.40625
4
"""Write a program to find whether the given number is an Armstrong Number or not Hint:An armstrong number of three digit is an integer such that the sum of the cubes of its digits is equal to the number itself.For example 371 is the armstrong number since 3**3+7**3+1**3""" num = int(input('Enter the number to che...
57aef9d462a85029bc3e2bd58909ee7267d5f7d1
turamant/ToolKit
/PyQt_ToolKit/PushButton/pushbutton_1.py
1,582
3.578125
4
""" PushButton часто используется, чтобы заставить программу делать что-то, когда пользователю просто нужно нажать кнопку. Этот может начинать загрузку или удалять файл. """ import sys from PyQt5.QtWidgets import QWidget, QGridLayout, QPushButton, QApplication """ -= SIGNALS -= Одна из общих функ...
0c111ad94df47ec95d63a25d1f2f208994da4894
Mariano92m/commonTecInfo2016
/EjerciciosdeFunciones/EjerR-Func.py
381
3.6875
4
def prime (x): prim=True res=1 for y in range (2, x-1): if x%y==0: prim=False if (prim==True): for y in range (1, x+1): res= res * y print res else: for y in range (1, x): if y < 1000: if x%y==0: print y Seg=(raw_input("Desea ingresar otro numero? S/N ")).upper() if Seg == "S": x=in...
bbde6653d2ecfc5f88b88fdd486cb9b7f3c2f7b7
Mariano92m/commonTecInfo2016
/EjerciciosdeFunciones/EjerM-Func.py
178
3.921875
4
def rango(L1,L2,x): if(L1<=x and x<=L2): print("Se encuentra dentro del rango") elif(L1>x): print("Se encuentra a la izquierda") else: print("Se encuentra a la derecha")
ce600e5d9e467ece05d83bc117e4c0b71f001c53
Mariano92m/commonTecInfo2016
/Ejercicios de Estructuras Secuenciales/S1.py
166
3.703125
4
print ("Situacion 1") Nac = int (input("Fecha de Nacimiento:")) Fut = int (input("Fecha a Futuro:")) resultado = Fut - Nac print ("Tu edad en esa Fecha:", resultado)
bc1882e40e3063c0c24e2fcc8ad1f6e7862c6301
Mariano92m/commonTecInfo2016
/Examen Juegos/ElCaminoDelGigante.py
1,857
3.90625
4
print ("*********************************************************************") print (" El camino del gigante designed by /commonTec: real game engineering/") print ("*********************************************************************") print(" ") print(" ...
d72c45554eb24913e774a7ce1bf716428bc089d2
Mariano92m/commonTecInfo2016
/Ejercicios de Estructuras Repetitivas/R1.py
812
3.953125
4
sIni=0; transaccion=True while transaccion==True: print("----------------------0---------------------") print("Bienvenido señor!") print("Si desea realizar un deposito presione 1") print("Si desea realizar un retiro presione 2") pedido=int(input("Presione uno de los numeros y luego enter: ")) if(pedido==1): a...
438bbaf5e4ab15eaeb4dc8cfa320bc2efff2c699
Mariano92m/commonTecInfo2016
/Ejercicios de Estructuras Condicionales/C2.py
315
3.984375
4
v1=int(input("Agrega un valor: ")); v2=int(input("Agrega un valor: ")); v3=int(input("Agrega un valor: ")); promedio=(v1+v2+v3)/3 if(v1>promedio): print("%s es mayor que el promedio"%(v1)); if(v2>promedio): print("%s es mayor que el promedio"%(v2)); if(v3>promedio): print("%s es mayor que el promedio"%(v3));
9d73cbb02966e689c21fa90b5afa888b190c2456
Mariano92m/commonTecInfo2016
/EjerciciosdeFunciones/EjerI-Func.py
176
3.65625
4
def tipo(k): sum=0 for x in range (1,k-1): if (k%x==0): sum=sum+x if sum==k: return ("perfecto") elif sum < k: return ("deficiente") else: return ("abundante")
5d3eaa8f3c83e461a73884e67a4eafacf24044d8
kamyu104/GoogleCodeJam-2016
/Round 1A/rank-and-file.py
774
3.578125
4
# Copyright (c) 2016 kamyu. All rights reserved. # # Google Code Jam 2016 Round 1A - Problem B. Rank and File # https://code.google.com/codejam/contest/4304486/dashboard#s=p1 # # Time: O(N^2) # Space: O(N^2), at most N^2 numbers in the Counter # from collections import Counter def rank_and_file(): N = input() ...
bfd09acba86e48a9aca78e9c2fb7ad9b5f63dd32
Dami-Lapite/guess-the-song
/guessTheSong.py
2,297
3.5
4
import random import os import pygame import tkinter as tk from tkinter.filedialog import askdirectory def prompt(count, playTime, answer): if count == 3 : prompt_text = input("No more music \n\nType a for answer \n\nType q for quit\n\n") if prompt_text == "a": print("\n...................
023270d8f656b3949d6d95c8e3c423a2f94f66de
phuang7008/machine_learning
/Calculate_LR.py
1,643
3.5
4
#!/usr/bin/python from statistics import mean import numpy as np import random #xs = np.array([1,2,3,4,5,6], dtype=np.float64) #ys = np.array([5,4,6,5,6,7], dtype=np.float64) # here we are going to generate a random dataset for future usage def create_dataset(num, variance, step=2, correlation=False): val = 1 ...
816ca748495fb1b1f8dac3444233b19329738dcf
neuronalX/esn-lm
/esnlm/readouts/logistic.py
5,460
3.515625
4
""" This module defines the different nodes used to construct hierarchical language models""" import numpy as np from esnlm.utils import softmax from esnlm.optimization import newton_raphson, gradient, hessian class LogisticRegression: """ Class for the multivariate logistiv regression. Para...
b45c2f73e4c932c428e95e963b5b50a93cc5f80a
Realdo-Justino/infosatc-lp-avaliativo-01
/exercicio-18.py
114
3.640625
4
volume=float(input("Insira um valor em metros cubicos ")) litros=volume*1000 print("O valor em litros é",litros)
d26f22245aa20f0fdfaf0bb1900fa1f5a9e759d2
dcxufpb/unidade-1-exercicio-09-python-antonia-exe
/cupom.py
2,611
3.5
4
# coding: utf-8 def isEmpty(value: str) -> bool: return (value == None) or (len(value) == value.count(" ")) class Loja: def __init__(self, nome_loja, logradouro, numero, complemento, bairro, municipio, estado, cep, telefone, observacao, cnpj, inscricao_estadual): s...
5b972c19cb57573030b07f0d87949d4647b6c3bc
jeremysen/Python_Trip_Project
/Software/filter_suitable_service.py
2,115
3.5625
4
# -*- coding: utf-8 -*- ''' @Description: This file is used to generate suitable service for customer @Author: Shanyue @Time: 2019-10-02 ''' import pandas as pd def add_range_air(price,air_down,air_up): ''' Add range for air line :param price: price in df :param air_down: air_down :pa...
52999cf0bd784008f72c1b7469a5833acdb40749
gladguang/python-study
/study/笔记_python函数基础.py
2,667
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #**************************** 函数 ************************* ''' 我们知道圆的面积计算公式为: S = πr2 当代码出现有规律的重复的时候,你就需要当心了,每次写3.14 * x * x不仅很麻烦, 而且,如果要把3.14改成3.14159265359的时候,得全部替换。 有了函数,我们就不再每次写s = 3.14 * x * x,而是写成更有意义的函数调用s = area_of_circle(x), 而函数area_of_circle本身只需要写一次,就可以...
836a7d1ef29a0c1bf1e530af5ffaffa8921a659b
gladguang/python-study
/study/7for_in循环.py
1,579
3.640625
4
# 计算1加到100之和 sum = 0 # 先初始化变量sum for a in range(1,101): # range(1,101)取大于等于1小于101的整数 ,即循环取1到10整数 sum += a # sum += a 等价于 sum = sum + a print(sum) # 打印和 ''' range(stop): 0~stop-1 range(start,stop): start~stop-1 range(start,stop,step): s...
56518fed8c3d23112f342a9e64337de4188da23e
razerboot/DataStrcutures-and-Algorithms
/python/sort_stack.py
252
3.6875
4
stack = [] def is_empty(stack): return len(stack)==0 def last(stack): if is_empty(stack): return False return stack[-1] def pop(stack): if is_empty(stack): return False return stack.pop(-1) def sort(stack):
eae0408ff5aa53a85d3e80e67443aaa30823a625
razerboot/DataStrcutures-and-Algorithms
/python/k_small_sorted_matrix.py
1,415
3.640625
4
# finding kth smallest element in row wise and column wise sorted matrix # complexity of k*(m+n) where m is row length and n is column length def adjust(matrix,x,y): n=len(matrix) m=len(matrix[x]) while(x<n and y<m): minx,miny = x,y leftx,lefty=x+1,y rightx,righty=x,y+1 if l...
2b8d249fbfa4d7edc6b4b1c466a31768418146a5
razerboot/DataStrcutures-and-Algorithms
/python/practice_llist_1.py
1,097
3.953125
4
class Node: def __init__(self,data): self.data = data self.next = None class llist: def __init__(self): self.head = None def is_empty(self): return self.head==None def add_node(self,data): temp = Node(data) temp.next = self.head self.head = temp...
fe0de4706937c31a0bb80b395dd15aa7d19241f3
razerboot/DataStrcutures-and-Algorithms
/python/count_sort.py
515
3.65625
4
def count_sort(arr): a = arr[min(arr)] b = arr[max(arr)] arr1 = {} # creating a count array for i in range(a,b): if arr[i]<=b and arr[i]>=a: if arr[i] in arr1: arr1[str(i)] += 1 else: arr1[str(i)] = 1 return arr1 #modifying count ar...
192ed0c3f624ef44e4be6a588c8fe8b4b7c8967e
razerboot/DataStrcutures-and-Algorithms
/python/max_heap_sort.py
1,406
3.8125
4
import math def max_heapify(arr,i,N): largest = i left = 2*i right = 2*i+1 if left<=N and arr[left]>arr[largest]: largest = left if right<=N and arr[right]>arr[largest]: largest=right if i!=largest: arr[i],arr[largest]=arr[largest],arr[i] max_heapify(arr,larges...
c3ef17c89a84060229e21c19f3c923f783e1d17f
razerboot/DataStrcutures-and-Algorithms
/python/bs_tree.py
5,099
3.703125
4
class Node(): def __init__(self,key): self.left = None self.right = None self.val = key class BST(): def __init__(self): self.head=None def insert(self,head,key): if key>head.val: if head.right==None: head.right=Node(key) else...
9290cc0f2726d048b125d78b6b8bc83a11f97d74
R-aryan/Basics-Data-Structures-And-Algorithms
/Arrays/Anagram_Check.py
731
4.0625
4
''' Problem - Given two strings s1 and s2, check if both the strings are anagrams of each other. An anagram of a string is another string that contains same characters, only the order of characters can be different. For example, “abcd” and “dabc” are anagram of each other. ''' from collections import Counter def c...
08a84913a2e0a9de0789aeb099a6ffc7a2b94f7a
R-aryan/Basics-Data-Structures-And-Algorithms
/stacks and Queues/dqueue.py
862
3.71875
4
class Dqueue(object): def __init__(self): self.items=[] def isEmpty(self): return self.items==[] def addFront(self,num): self.items.append(num) print("{} Added at front successfully..!".format(num)) def addRear(self,num): self.items.insert(0,num) ...
0e9880512bebfff94a020bf37ea1adedbad5d70d
Hollow667/Python-Crash-Course
/Lastname_greet.py
195
3.84375
4
pretty = "*" name = input("Enter your name: ") school = input("What school do you go to?") print(pretty *70) print("\tHi, " + name + ", " + school + " is a great school") print(pretty *70)
85a6612754425c4b01800d97166616c6fcb296e4
byronlara5/python_analyzing_data
/module_1/three.py
1,490
4.09375
4
import pandas as pd file = '/home/byron_lara/PycharmProjects/analyzing_data/venv/module_1/cars.csv' # Creating DataFrame with the Cars file df = pd.read_csv(file) # List of headers for the CSV File headers = [ "Symboling","Normalized-losses","Make","Fuel-type","Aspiration","Num-of-doors","Body-style", "Driv...
94d50aa6f1e74abbd70d07494e2b3df47fb1bc20
amyq7526110/python
/python1/while.py
1,899
3.515625
4
#!/usr/bin/env python3 import os import readline a=os.popen('echo 1').readline() print(a) os.system('ls') # 循环概述 # • 一组被重复执行的语句称之为循环体,能否继续重复, # 决定循环的终止条件 # • Python中的循环有while循环和for循环 # • 循环次数未知的情况下,建议采用while循环 # • 循环次数可以预知的情况下,建议采用for循环 # while循环语法结构 # • 当需要语句不断的重复执行时,可以使用while循环 # while ...
74bd3483814ac5ccf695c5df2fe7fee7a826ee7e
amyq7526110/python
/python1/xvlist.py
1,414
4
4
#!/usr/bin/env python3 # 序列 # 序列类型操作符 # 序列操作符 作用 # seq[ind] 获得下标为ind的元素 # seq[ind1:ind2] 获得下标从ind1到ind2间的元素集合 # seq * expr 序列重复expr次 # seq1 + seq2 连接序列seq1和seq2 # obj in seq 判断obj元素是否包含在seq中 # obj not in seq 判断obj元素是否不包含在seq中 # 内建函数 # 函 数 含 义 # list(i...
163314ac51a6e2c90fddc5a9da703cd00391aa27
amyq7526110/python
/python6/zb4.py
1,094
3.53125
4
#!/usr/bin/env python3 import os import time start = time.time() print('Start...') pid = os.fork() if pid: print('in parent..') print(os.waitpid(-1,1)) # 挂起 time.sleep(20) else: print('in child') time.sleep(10) end = time.time() print(end - start) # 使用轮询解决zombie问题 # • 父进程通过os.wait()来得...
0e206114f148e603d7e0a233aa46fa3e6bfca7d0
amyq7526110/python
/python1/else.py
266
3.765625
4
#!/usr/bin/env python3 # else语句 # • python中的while语句也支持else子句 # • else子句只在循环完成后执行 # • break语句也会跳过else块 sum10 = 0 i = 1 while i <= 10: sum10 += i i += 1 else: print(sum10)
6c135e2c9a64ba6083c31ea591caaf1974ba6a0b
amyq7526110/python
/python4/toy.factory4.py
2,322
3.5625
4
#!/usr/bin/env python3 # 构造器方法 # • 当实例化类的对象是,构造器方法默认自动调用 # • 实例本身作为第一个参数,传递给self class BearToy: def __init__(self,name,size,color): "实例化自动调用" self.name = name # 绑定属性到self 上整个类可以引用 self.size = size self.color = color # 创建子类(续1) #• 创建子类只需要在圆括号中写明从哪个父类继承即可 # 继承 # ...
b4590355111ceb038ccf9732c54cf66e4e83fee8
amyq7526110/python
/python4/jingtff.py
451
4.03125
4
#!/usr/bin/env python3 class Date: def __init__(self,year,month,date): self.year = year self.month = month self.date = date @staticmethod def is_date_valid(string_date): year,month,date = map(int,string_date.split('-')) return 1 <= date <=21 and 1 <= month <= 12 and y...
1ddc769f2b667a16f412974597748cf09b7c1832
amyq7526110/python
/python1/fibs.py
302
3.75
4
#!/usr/bin/env python3 def fib(x): fibo = [0,1 ] for i in range(x-2): fibo.append(fibo[-1]+fibo[-2]) print(fibo) #fibs(10) #febo(6) #febo(10) print(__name__) # 保存模块名 # 当模块直接执行是__name__的值为__name__ # if __name__ == '__mian__': fib(10)
34a8045d00851db70682202a13250056e1c691f6
MoonRaccoon/CS101
/while_loops.py
95
3.625
4
def print_numbers(a): while(x != a): x = 0 x = x + 1 print x
5ae1dd1fb039661776c36210caee4d8a191ef53d
MoonRaccoon/CS101
/range.py
586
3.71875
4
def bigger(a, b): if a > b: return a else: return b def smaller(a, b): if a < b: return a else: return b def biggest(a, b, c): return bigger(a, bigger(b, c)) def smallest(a, b, c): if biggest(a, b, c) == a: med = smaller(b, c) return med if...
4e406529eac6ea82a9ea111bd67afcbe5ca2bd69
Viniuau/meus-scripts
/math.py
900
4.09375
4
print("Digita um número ae meu consagrado") x = int(input("Número 1 é esse: ")) y = int(input("Número 2 é esse: ")) print("Prontinho, agora escolhe o que tu quer fazer com eles") print("1 - Somar") print("2 - Subtração") print("3 - Multiplicação") print("4 - Divisão") escolha = int(input("Seu comando: ")) while(escolha...
503700558831bf7513fc8987bb669f0e17d144c0
deepika7007/bootcamp_day2
/Day 2 .py
1,301
4.1875
4
#Day 2 string practice # print a value print("30 days 30 hour challenge") print('30 days Bootcamp') #Assigning string to Variable Hours="Thirty" print(Hours) #Indexing using String Days="Thirty days" print(Days[0]) print(Days[3]) #Print particular character from certin text Challenge="I will win" print(challenge[...
5571025882b22c9211572e657dd38b1a9ecdfa74
martinkozon/Martin_Kozon-Year-12-Computer-Science
/Python/extra_sum_of_two.py
342
4.1875
4
#Program which will add two numbers together #User has to input two numbers - number1 and number2 number1 = int(input("Number a: ")) number2 = int(input("Number b: ")) #add numbers number1 and number2 together and print it out print(number1 + number2) #TEST DATA #Input 1, 17 -> output 18 #Input 2, 5 -> output 7 #Inp...
fa98a79e66cd7e8575c857dabad5877c3b78cd87
martinkozon/Martin_Kozon-Year-12-Computer-Science
/Python/06_input-validation.py
816
4.25
4
#User has to input a number between 1 and 10 #eg. if user inputs 3, the result will be as follows: 3 -> 3*1=3, 3*2=6, 3*3=9 #ask a user to input a number number = int(input("Input number between 1 and 10: ")) #if the input number is 99 than exit the program if number == 99: exit() # end if #if the number isn't t...
1165adb6c5f681f38ee8fc21eda598f9ace811fe
martinkozon/Martin_Kozon-Year-12-Computer-Science
/Python/Python Prep and Worksheet practice/CarPark.py
812
3.96875
4
carPark = [ [0,0,0,0,0,0], [0,0,0,0,0,0], [0,0,0,0,0,0], [0,0,0,0,0,0], [0,0,0,0,0,0], [0,0,0,0,0,0], [0,0,0,0,0,0], [0,0,0,0,0,0], [0,0,0,0,0,0], [0,0,0,0,0,0], ] #always ask the user for input while True: row = int(input("Row location (1 to 10): ")) - 1 # -1 because arrays start from 0 positi...
726a2e884e1ea29daf0c322c6c9d7051e0735a1a
martinkozon/Martin_Kozon-Year-12-Computer-Science
/Python/pass_by_reference_or_value.py
204
3.578125
4
def proc1(x, y): x = x - 2 y = 0 print(x, y) #result is 6,0 #end procedure #main program m = 8 n = 10 proc1(m ,n) print(m, n) #result is 8,10 #by val: x - immutable #by ref: y - mutable
5453ba2f4a55d71966633f1e2236982b4177e7ae
MyHealthyHair/Week7
/guests.py
114
3.71875
4
name = input("enter your name: ") filename = 'guest.txt' with open(filename, 'w') as f: f.write(name)
a0a908c5a23b2a5f2c73753fb526d3c006076b7a
RF0606/CISC327_PROJECT
/qa327/app.py
13,484
3.640625
4
import csv import time import re status = False user_name = '' user_email = '' user_password = '' balance = -1 accFile = open('accounts.csv', 'r+') ticketFile = open('tickets.csv', 'r+') accReader = csv.reader(accFile) ticketReader = csv.reader(ticketFile) location_arg = open('frontend_locations.txt', 'r').readline(...
f51967bcf553fce95358287bbbec086d9551f58f
KUMAWAT55/Monk-Code
/Hackerrank/Python/Integer-comes-in-all-sizes.py
270
3.78125
4
# Enter your code here. Read input from STDIN. Print output to STDOUT a=int(raw_input()) b=int(raw_input()) c=int(raw_input()) d=int(raw_input()) if 1<=a<=1000: if 1<=b<=1000: if 1<=c<=1000: if 1<=d<=1000: print pow(a,b)+pow(c,d)
d6e2926f246dc78f660d0f156d763e4a4202aa3d
KUMAWAT55/Monk-Code
/Hackerrank/Python/Loops.py
200
3.78125
4
# Enter your code here. Read input from STDIN. Print output to STDOUT #input converting to integer n=int(raw_input()) if 1<=n<=20: i=0 while i<n: print i*i i=i+1
4f2cac94170db764aa3dacd2ca2dc11671fc0c7d
KUMAWAT55/Monk-Code
/Hackerrank/Algorithms/A_Very_Big_Sum.py
167
3.515625
4
#----------> PYTHON 3 <---------- import sys sum=0 n = int(input().strip()) arr = input().strip().split(' ') for i in range(0,n): sum=sum+int(arr[i]) print (sum)
e0c5f15e87b35d74bd3256cc70124ecb3cca737d
KUMAWAT55/Monk-Code
/HackerEarth/Basic-Programming/Palindromic String.py
148
3.609375
4
n=raw_input() if 1<=len(n)<=100: c=''.join(reversed(n)) if n==c: print "YES" else: print "NO"
ec26668740975b3d929b8114eaa5bd9845582967
JohntyR/Day18_Turtle
/newmain.py
557
3.71875
4
import turtle as t from shape import Shape from random import randint screen = t.Screen() timmy = t.Turtle() screen.colormode(255) timmy.shape("turtle") timmy.color("dark magenta") timmy.pensize(10) timmy.speed("fastest") timmy.penup() def gen_random_colour(): r = randint(0, 255) g = randint(0, 255) b = ...
15e022eb2fbc2d17ee9dd7787a5c301d43dbb89a
GitLeeRepo/PythonNotes
/basics/sort_ex1.py
777
4.59375
5
#!/usr/bin/python3 # Examples of using the sorted() function # example function to be used as key by sorted function def sortbylen(x): return len(x) # List to sort, first alphabetically, then by length a = [ 'ccc', 'aaaa', 'd', 'bb'] # Orig list print(a) # Sorted ascending alphabetic print(sorted(a)) # sorte...
8da7f3ba63ae287850cb95fdaf6991da36855947
GitLeeRepo/PythonNotes
/basics/python_sandbox01.py
1,833
4.1875
4
#!/usr/bin/python3 # Just a sandbox app to explore different Python features and techniques for learning purposes import sys def hello(showPrompt=True): s = "Hello World!" print (s) #using slice syntax below print (s[:5]) #Hello print (s[6:-1]) #World print (s[1:8]) #ello wo print (s[1:-4]...
867fcd25f4325f61306ee3c2540981fa3d8653d2
GitLeeRepo/PythonNotes
/basics/tuples_ex1.py
280
3.796875
4
#!/usr/bin/python3 person = ( 'Bill', 'Jones', '(999)999-9999' ) single = ( 'justone', ) # note the trailing comma # assign to individual variables first_name, last_name, phone = person print(person) print(first_name, last_name, phone) print(single) # tuple with one element
1ab70f1a5c8b75a9a72c42b72a9e5121fe6d8f0b
gatinueta/FranksRepo
/python/chess.py
358
3.703125
4
class Board: def __init__(self): self.b = [ [None] * 8 for i in range(8) ] def set(self, c, piece): self.b[c.col][c.row] = piece def __str__(self): s = '' for col in self.b: for row in col: s += str(self.b[col][row]) s += "\n" r...
6e6841ad28295804712aa997f1486ecdf2f0db4e
gatinueta/FranksRepo
/python/bodyguards.py
342
3.53125
4
import fileinput import re for line in fileinput.input(): line = '.' + line + '.' ms = re.finditer('[A-Z]{3}[a-z][A-Z]{3}', line) for m in ms: # print(m.group()) print(line[m.start()-1:m.end()+1]) if not line[m.start()-1].isupper() and not line[m.end()].isupper(): print('...
ae0ea94137c2b1c80943742de3edcee0685099b9
PoroTomato99/Python_Crash_Course
/palindrome.py
249
3.78125
4
message = "abc123" a = "" reversed_a = "" for c in message: print(f"this is => {c}") a = a + c print(f"this is a => {a}") reversed_a = c + reversed_a print(f"this is reversed_a => {reversed_a}") print(a) print(reversed_a)
fcda0d855c24a95ba0b1c667a5d40b536742eafd
xueyinjun/Learn-Python-The-Hard-Way
/ex31.py
1,030
3.859375
4
#encoding =utf-8 print ("You enter a dark room with two doors. Do you go through door #1 or door #2") door = input(">") if door == "1": print("There's a agin bear here eating a cheese cake.What do you do") print("1. Take the cake") print("2.Scream at the beat") bear = input(">") if bear=="1": print(...
40d301b151cbc2b146c2e880539c8aa38e70a3ab
ecastillob/project-euler
/001 - 050/46.py
1,251
3.890625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: """ It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 2×12 15 = 7 + 2×22 21 = 3 + 2×32 25 = 7 + 2×32 27 = 19 + 2×22 33 = 31 + 2×12 It turns out that the conjecture was false. What is...
0ffe4f4ec06484dd0cfeecee9158c693c5ce24ce
ecastillob/project-euler
/101 - 150/104.py
1,159
3.9375
4
#!/usr/bin/env python # coding: utf-8 # # Problem [104](https://projecteuler.net/problem=104): Pandigital Fibonacci ends # The Fibonacci sequence is defined by the recurrence relation: # # $$ F_n = F_{n−1} + F_{n−2}, \mathrm{where} \ F_1 = 1 \ \mathrm{and} \ F_2 = 1. $$ # # It turns out that $F_{541}$, which contai...
26a820a4654a0ae290874fb48bff92f22ebbfbf6
ecastillob/project-euler
/001 - 050/12.py
4,012
3.609375
4
#!/usr/bin/env python # coding: utf-8 # In[5]: def get_divisores(N): divisores = [] for i in range(1,N+1): if N%i==0: divisores.append(i) return divisores # In[6]: get_divisores(28) # In[12]: N = 7 suma = int(N*(N+1)/2) suma # In[18]: def get_cantidad_divisores(N): div...
66d407d714258a6aceea8e800a10ba5994af040a
ecastillob/project-euler
/101 - 150/112.py
1,846
4.40625
4
#!/usr/bin/env python # coding: utf-8 """ Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a positive ...
3e99069ad82eed7cd473865c13af5584f2ce9467
ecastillob/project-euler
/051 - 100/56.py
552
3.5
4
""" A googol ($10^{100}$) is a massive number: one followed by one-hundred zeros; $100^{100}$ is almost unimaginably large: one followed by two-hundred zeros. <br> Despite their size, the sum of the digits in each number is only 1. Considering natural numbers of the form, $a^b$, where a, b < 100, what is the max...
86b37e269f4b6d38ba7c04312c37446a5d690a4f
Qausain/PIAIC-Q-1
/PIAIC 8 If else statements.py
229
3.9375
4
#If statements a= 100 b= 200 if a<b: print("a is less than b") print("Hello A") print("Hello B") print("Help python") if b<a: print("b is less than a") # this block will not be executed print("Pakistan")
3e08723fb5d96d9bb3570cf0157fdf7da1d38428
liujieliewang/Python
/fibs.py
164
3.796875
4
#Python 3.5.2 fibs = [0,1] n = input("请输入求第几位数:") n = int(n) for i in range(n-1): fibs.append(fibs[-1]+fibs[-2]) print(fibs) print(fibs[-1])
28083881cf61c01eecd51f82f8162052ca533e07
shivanand217/some-useful-scripts
/email_crawler.py
400
3.609375
4
import requests import re #url = str(input('Enter a URL: ')) url = 'https://blog.anudeep2011.com/20-by-25/' website = requests.get(url) html = website.text links = re.findall('"((html|ftp)s?://.*?)"', html) emails = re.findall('([\w\.,]+@[\w\.,]+\.\w+)', html) # list print(len(emails)) print("\n...
0daa2d8b4bcf20bc8ebc25b059e62ef920065d5f
al0fayz/python-playgrounds
/fundamental/14-class.py
467
3.875
4
#example class in python class siswa: #this like constructor in other programming def __init__(self, name, city): #this like this in other language self.name = name self.city = city #create object siswa_object = siswa("bento", "Jakarta") print(siswa_object.name) print(siswa_object.city...
9bb69fee060d1b2704b37388080cc2488b447c0c
al0fayz/python-playgrounds
/mysql/4-select.py
584
3.5
4
import mysql.connector db = mysql.connector.connect( host="localhost", user="root", password="", database="python_example" ) con = db.cursor() con.execute("SELECT * FROM customers") myresult = con.fetchall() for x in myresult: print(x) print("==========================================") # select...
6a442bcbc6464c0e325b859b78633111ae48a649
al0fayz/python-playgrounds
/fundamental/1-variabel.py
1,045
4.3125
4
#example variabel in python x = 5 y = 2 kalimat = "hello world" kalimat1 = 'hai all!' print(x) print(y) print(kalimat) print(kalimat1) a , b , c = 1, 2, 3 text1, text2, text3 = "apa", "kabar", "indonesia?" print(a, b, c) print(text1, text2, text3) result1 = result2 = result3 = 80 print(result1, result2, result3) ...
cfcbe016443d6a8fa6bd958d56d8e49705269b81
al0fayz/python-playgrounds
/fundamental/6-tuples.py
726
4.3125
4
#contoh tuples """ tuples bersifat ordered, tidak bisa berubah, dan dapat duplicate """ contoh = ("satu", "dua", "tiga", "tiga") print(contoh) #acces tuples print(contoh[0]) print(contoh[-1]) print(contoh[1:4]) #loop tuples for x in contoh: print(x) #check if exist if "satu" in contoh: print("yes exist") #...
2eca24e3b6f7fa52f1e1ab9bd8fd20f6d2e46e3d
aaryanredkar/prog4everybody
/project10.py
158
4.25
4
number = int(input("print number:")) for i in range(2,number+1,2): print(i,"is even") for i in range( 1,number+1,2): print (i, "is odd number")
7643854c54690814e2744e3cd80bc02ec02770e1
aaryanredkar/prog4everybody
/L1C2_Fibonacci.py
229
4.28125
4
Value = int(input("Please enter MaxValue for Fibonacci sequence : ")) print ("The fibonacci sequence <=",Value, "is: ") a, b = 0, 1 temp = 0 print ("0 ") while (b <= Value): print (b) temp = a+b a = b b = temp
2dc3ba209e1100f597f27cc5d1315b4fc3685da5
aaryanredkar/prog4everybody
/week 8/assign.8-1.py
277
3.578125
4
fname = raw_input("Enter file name: ") fh = open(fname) dic = dict() for line in fh: words = line.split() for word in words: if word not in dic: dic[word] = 1 else: dic[word] += 1 print dic
d3ac42b901175baf2807d756b15f868b39127910
aaryanredkar/prog4everybody
/turtlehexagon.py
307
3.953125
4
from turtle import * setup() x = 0 # Use your own value y = 0 # Use your own value length = int(input("What is the length:")) def hexagon (size_length): #penup() pendown () forward(size_length) right (60) goto (x, y) for _ in range (6): hexagon (length) exitonclick ()
920758fd9645d01fbdd33081223eb1e7601945f0
aaryanredkar/prog4everybody
/project 8.py
209
3.890625
4
age = int(input("Enter age:") password = 12music12 if age <18: print = ("You are a minor") if age >= 18: input("Enter password:") password if elif sum<= 79:
2ff8327e1670af39e6ba1a6f2e7af471982cfe5c
aaryanredkar/prog4everybody
/userdev3.py
167
4.21875
4
n = int(input("Give me the highest number to print all the digits divided by three:")) for number in range(1,n + 1): if number % 3 == 0: print(number)
3ef7c91a7f379e5b8f4f328c0e79a9238d6bce08
aaryanredkar/prog4everybody
/project 2.py
327
4.3125
4
first_name = input("Please enter your first name: ") last_name = input("Please enter your last name: ") full_name = first_name +" " +last_name print("Your first name is:" + first_name) print("Your last name is:" + last_name) print ("Your complete name is ", full_name) print("Your name is",len(full_name) ,"characters ...
5c5352f4e10a55c33a50dd66527cf91fc5a86c80
aaryanredkar/prog4everybody
/L1C7_Game.py
734
3.984375
4
import random guessesLeft = 15 userName = input("Please enter your Name :") number = random.randint(1, 1000) print("Hello", userName, "I'm thinking of a number between 0 and 1000.") while guessesLeft > 0: print("You have", guessesLeft, "guesses left") guess = int(input("Guess a number : ")) guessesLeft =...
cc1b8fc6d0f4e662d71b70d165ab884599af0b16
aaryanredkar/prog4everybody
/challenge.py
242
4.03125
4
n = int(input("Enter the Nth number divisibleby 3")) count= 1 i=1 while(True): if(i%3==0): if count==n: print(n,"number divisibe l by 3 is:",i) break else: count= count + 1 i = i +1
9f70df178dfbe74702e47c2c0725a6ac74674080
aaryanredkar/prog4everybody
/week 8/8-2.py
424
3.578125
4
fname = raw_input("Enter file name: ") fh = open(fname) dic = dict() for line in fh: if line.startswith('From'): t=line.split() email = t[1] if email not in dic: dic[email] = 1 else: dic[email] +=1 bigcount = None bigemail = None for email,count in dic.items(): if bigcount i...
073db0007183aa65c945b3f27b8772260f405922
aaryanredkar/prog4everybody
/nameentnormal.py
153
4.125
4
name = input("Please enter your name: ") print("Hello, "+name + "!") print("Let me print you name %s times. " %len(name)) for i in name: print (name)
8973346ceee21cfc1423ab6426fb167d9151cb5d
Daniel-Fingerson/Shrimp-Code
/Shrimp-Master/sensor.py
2,669
3.578125
4
# Module: sensor.py import random import time from log import log from LTC2448 import read import spidev from bokeh.plotting import figure class Sensor: """ A sensor object handles the following tasks: - Reading the mcp sensor data - Logging the data - Plotting the data with Bokeh Args...
eafcad4e44d090ddae3e7d70b1c721d6aa245936
adambemski/book_think_in_python
/official_solutions/unstable_sort.py
1,692
4
4
"""Moduł zawiera przykładowy kod powiązany z książką: Myśl w języku Python! Wydanie drugie Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey Licencja: http://creativecommons.org/licenses/by/4.0/ """ from __future__ import print_function, division import random def sort_by_length(words): """Sor...
7444d3eccfc49c602480ca9af1830ac9ce6aea36
adambemski/book_think_in_python
/official_solutions/birthday.py
1,775
3.734375
4
"""Moduł zawiera przykładowy kod powiązany z książką: Myśl w języku Python! Wydanie drugie Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey Licencja: http://creativecommons.org/licenses/by/4.0/ """ from __future__ import print_function, division import random def has_duplicates(t): """Zwraca ...
2c47ae82f1c5cc12c56b24859cb57fd9e4a03b22
adambemski/book_think_in_python
/official_solutions/pronounce.py
1,046
3.578125
4
"""Moduł zawiera przykładowy kod powiązany z książką: Myśl w języku Python! Wydanie drugie Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey Licencja: http://creativecommons.org/licenses/by/4.0/ """ from __future__ import print_function, division def read_dictionary(filename='c06d'): """Wczytuj...
69771e69ce38cd6bc15148c13530adb910e45582
adambemski/book_think_in_python
/official_solutions/anagram_sets.py
2,276
3.578125
4
"""Moduł zawiera przykładowy kod powiązany z książką: Myśl w języku Python! Wydanie drugie Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey Licencja: http://creativecommons.org/licenses/by/4.0/ """ from __future__ import print_function, division def signature(s): """Zwraca sygnaturę danego łań...
25dc7432ddf8c869b07985676fc8b64b469391ba
adambemski/book_think_in_python
/official_solutions/rotate_pairs.py
1,019
4.03125
4
"""Moduł zawiera przykładowy kod powiązany z książką: Myśl w języku Python! Wydanie drugie Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey Licencja: http://creativecommons.org/licenses/by/4.0/ """ from __future__ import print_function, division from rotate import rotate_word def make_word_dict()...
b377a25068e901361ff9d78c3db9ca8655c0f5b0
takapy0210/nlp_2020
/chapter1/ans_08.py
549
3.890625
4
""" 与えられた文字列の各文字を,以下の仕様で変換する関数cipherを実装せよ. 英小文字ならば(219 - 文字コード)の文字に置換 その他の文字はそのまま出力 この関数を用い,英語のメッセージを暗号化・復号化せよ. """ def cipher(text): ret = ''.join(chr(219-ord(c)) if c.islower() else c for c in text) return ret text = 'Never let your memories be greater than your dreams. If you can dream it, you can do it.' ...
9a1acec7ad9c2abb154a47e525c1510f2a178dad
takapy0210/nlp_2020
/chapter1/ans_06.py
798
3.65625
4
""" “paraparaparadise”と”paragraph”に含まれる文字bi-gramの集合を,それぞれ, XとYとして求め, XとYの和集合,積集合,差集合を求めよ.さらに,’se’というbi-gramがXおよびYに含まれるかどうかを調べよ. """ def generate_ngrams(text, n_gram=2): ngrams = zip(*[text[i:] for i in range(n_gram)]) return list(ngrams) text1 = 'paraparaparadise' text2 = 'paragraph' X = generate_ngrams(text...
d86670a431aaf17b7fbbf662783604b944ae75a5
takapy0210/nlp_2020
/chapter1/ans_09.py
776
3.890625
4
""" スペースで区切られた単語列に対して,各単語の先頭と末尾の文字は残し, それ以外の文字の順序をランダムに並び替えるプログラムを作成せよ. ただし,長さが4以下の単語は並び替えないこととする. 適当な英語の文(例えば”I couldn’t believe that I could actually understand what I was reading : the phenomenal power of the human mind .”) を与え,その実行結果を確認せよ. """ import random text = 'I couldn’t believe that I could actually understan...
8ac7bda5a983d7a9864ed73dd5b7f1e6aa15259c
takapy0210/nlp_2020
/chapter1/ans_03.py
423
3.625
4
""" “Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.” という文を単語に分解し,各単語の(アルファベットの)文字数を先頭から出現順に並べたリストを作成せよ. """ text = 'Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.' ret = [len(i.strip(',.')) for i in text.split()] print(ret)
e42fa8594a78de70dce53c3a2550f7343db7164e
aalex/quessy_alexandre_test
/quessyalexandre/linesoverlap.py
862
3.609375
4
#!/usr/bin/env python """ Line overlapping utilities. """ def _is_within(value, range_min, range_max): ret = False if value >= range_min and value <= range_max: ret = True return ret def linesoverlap(line1, line2): """ Checks if two lines on an axis overlap. """ if type(line1) != ...