blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
b00639462737fce6440a481c232abbd3ce6abf91
ccirelli2/mutual_fund_analytics_lab_sentiment_analysis
/scripts/functions_decorators.py
1,413
3.65625
4
""" Decorator functions for this program """ ############################################################################### # Import Python Libraries ############################################################################### import logging; logging.basicConfig(level=logging.INFO) from functools import wraps from...
1a076304c384df34684971effecc69c702342683
jarroba/Curso-Python
/Casos Prácticos/6.2-math_stirling.py
565
3.6875
4
import math # 1 num = 100 primera_parte = math.sqrt(2 * math.pi * num) segunda_parte = math.pow(num/math.e, num) # == (num / math.e) ** num resultado = primera_parte * segunda_parte print("Por fórmula de Stirling: {numero}!= {resultado}".format(numero=num, ...
a4644a5aa54ed966e76a12b18651173ba15682f9
jarroba/Curso-Python
/Casos Prácticos/5.5-funcion_return_none_espacio.py
234
3.59375
4
# 1 def espacio(velocidad, tiempo): resultado = velocidad * tiempo # 2 if resultado < 0: return None else: return resultado # 3 tiempo_retornado = espacio(120, -10) print(tiempo_retornado)
34b47f5f402c625167dd07b74dde3a50af7abb3e
jarroba/Curso-Python
/Casos Prácticos/4.15-tuplas.py
497
3.875
4
# 1 tupla1 = ("manzana", "rojo", "dulce") tupla2 = ("melocotón", "naranja", "ácido") tupla3 = ("plátano", "amarillo", "amargo") print(tupla1) # 2 lista_de_tuplas = [] lista_de_tuplas.append(tupla1) lista_de_tuplas.append(tupla2) lista_de_tuplas.append(tupla3) # 3 for fruta, color, sabor in lista_de_tuplas: print...
042b6738c14747adbe173d1b09239927f92d2aa9
binit-singh/python-datastructures
/3_fibonacci_number/fibonacci_last_digit.py
581
4.0625
4
# Uses python3 def get_fibonacci_last_digit_naive(n): if n <= 1: return n previous = 0 current = 1 for _ in range(n - 1): previous, current = current, previous + current return current % 10 def get_fibonacci_last_digit_fast(n): if n < 1: return 1 previous_last = ...
688f45329b2e7371b61189f3cd3b2d5a77d3a0f5
codacy-acme/pythest
/main.py
1,029
3.640625
4
import httpoxy def square(a): """item_exporters.py contains Scrapy item exporters. Once you have scraped your items, you often want to persist or export those items, to use the data in some other application. That is, after all, the whole purpose of the scraping process. For this purpose Scrapy provides a collec...
843061e943b25fa172636d9f77017ea2294aa96d
ramza007/Password-Locker
/credentials-test.py
2,276
3.765625
4
import unittest from credentials import Credentials class TestCredentials(unittest.TestCase): ''' test class that defines test cases for the credentials class ''' def setUp(self): ''' set up method that runs before each test case ''' self.new_credentials = Credenti...
4885fd3b53635d85138d7987793f5159eab172bd
charboltron/artificial_intelligence
/genetic_8_queens/genetic_alg_8_queens.py
8,873
3.546875
4
#%% import sys import random import math import numpy as np import matplotlib.pyplot as plt test_boards = [[2,4,7,4,8,5,5,2],[3,2,7,5,2,4,1,1],[2,4,4,1,5,1,2,4],[3,2,5,4,3,2,1,3]] #constants/twiddle factors num_iterations = 10000 def print_board(board): for i in range(8, 0, -1): print('\n') for ...
470d83e0c57151a4ac54e15c22a5a36befc592c5
JansherKhantajik/Python
/first program.py
613
4.03125
4
#print a program which input number from user and you will give 5 guess to equvalate with your answer print("Word of Guess Number, Input Your Guess that You have five chance") guess = int(input()) i=0 while (True): if (guess <15): print("Please Enter more then",guess) break elif guess <20 and gu...
409ef68a67f735a647f22040ad7c1086cd991de2
sleevewind/practice
/0217/列表的复制.py
133
3.71875
4
# 可变类型和不可变类型 a = 12 b = a print('a={},b={}'.format(hex(id(a)), hex(id(b)))) # a=0x7ff95c6a2880,b=0x7ff95c6a2880
0b8fd9d19b5e21325b8499480ed594c2a33a9740
sleevewind/practice
/0217/列表的排序和反转.py
396
4.0625
4
# sort()直接对列表排序 nums = [6, 5, 3, 1, 8, 7, 2, 4] nums.sort() print(nums) # [1, 2, 3, 4, 5, 6, 7, 8] nums.sort(reverse=True) print(nums) # [8, 7, 6, 5, 4, 3, 2, 1] # sorted()内置函数, 返回新的列表, 不改变原来的列表 print(sorted(nums)) # [1, 2, 3, 4, 5, 6, 7, 8] # reverse() nums = [6, 5, 3, 1, 8, 7, 2, 4] nums.reverse() print(nums) #...
f889d7e66bf7bd2b2dd2647cf64cdfe91189052e
sleevewind/practice
/0217/列表的增删改查.py
1,466
3.5625
4
# 操作列表, 一般包括 增删改查 heroes = ['镜', '嬴政', '露娜', '娜可露露'] # 添加元素的方法 # append heroes.append('黄忠') print(heroes) # 在列表最后面追加 # insert(index, object) 在指定位置插入 heroes.insert(1, '小乔') print(heroes) newHeroes = ['狄仁杰', '王昭君'] # extend(iterable) 添加可迭代对象 heroes.extend(newHeroes) print(heroes) # 删除元素 pop print(heroes) # ['镜', '...
bb22aef9984883cee87a02c39b509e7d496a4107
innovatorved/python-recall
/py51-python-cahching-by-funtools.py
386
3.578125
4
# python3 py51-python-cahching-by-funtools.py import time from functools import lru_cache @lru_cache(maxsize = 3) # save last 3 value def sleep_n_time(n): time.sleep(n) return n if __name__ == "__main__": print(sleep_n_time(3)) # it create an cahe for this same def for for reducing time and sp...
2c55330c7204f8bceaa6eed1e9533f05a6e18b1e
innovatorved/python-recall
/py40-access-specifier-public-private.py
918
3.796875
4
# Access Specifier # public # protected # private class Student: public_var = "this variable is public" _protected_var = "this is private var" __private_var = "this is private var" def __init__(self ,public , protected , private): self.public = public self._protected = prot...
a32d740aaec9947b0f5b7d64a72a47f10a28718a
innovatorved/python-recall
/py49-genrators-ex1.py
288
3.609375
4
# python3 py49-genrators-ex1.py n = 10 def fib(a=0 , b = 1): for x in range(n): yield (a+b) a , b = b , b+a a = fib(0,1) print(a.__next__()) print(a.__next__()) print(a.__next__()) print(a.__next__()) print(a.__next__()) print(a.__next__())
8207d31429cc76165b8136f1c186f7d0f39bd62b
innovatorved/python-recall
/py20 - enumeratefin.py
522
3.90625
4
#enumerate function a = ["ved" , "Prakash" , "Gupta" , "hello"] i = 1 for item in a: #print(item) if i%2 != 0: print(f"item {item}") i+= 1 #with enumerate function print(enumerate(a)) # Output : <enumerate object at 0x000002452601E700> print(list(enumerate(a))) # Output : [(0, '...
7d828ae6dabb5d3283927d7ec88800acd45164d2
innovatorved/python-recall
/py6 - list.py
643
3.671875
4
# List Name = [ "Ved Gupta" ," Ramesh Prasad" , "Anand Kumar" "Shrish Guptas" , "Rishi sharma" ] Age = [20,56,89,12,45] print(type(Name),type(Age)) # Age.sort() print(Age) print(sum(Age)) print(min(Age)) print(max(Age)) print(len(Age)) Age.reverse() print(Age) Age.sort() print(Age) new = sorte...
7f71835bcdea55a10aef9e2602161ea23d979484
innovatorved/python-recall
/start-dynamic/fibonachi-sequence.py
138
3.65625
4
# python3 fibonachi-sequence.py def fib_seq(n ,a=0,b=1): if n != 0: print(a+b) fib_seq(n-1 ,b,a+b) fib_seq(5)
382a67dd059c8a7b93b9e01bfeacc25424f32307
innovatorved/python-recall
/py17 - Fabonachi Sequence.py
306
3.71875
4
# Fabonachi Sequence # find fabonachi sequene def fab(n,a = 0 , b = 1): if n > 0: c = a+b print(c) fab(n-1,b,c) a = int(input("How much No . of sequence you want to find :")) fab(a) """ How much No . of sequence you want to find :10 1 2 3 5 8 13 21 34 55 89 """
d393755ca2b2661c053f02573f582213d0bd1f32
innovatorved/python-recall
/py48-genrators-yield.py
574
4.0625
4
# python3 py48-genrators-yield.py """ Iterable : __iter__() or __getitem__() Iterator : __next__() Iteration : """ # genrators are iteraators but you can only iterate ones def range_1_to_n(n) : for x in range(1 , n): yield x print(range_1_to_n(10)) num = range_1_to_n(10) print(num.__n...
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