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
0dbfe08ed9fd0f87544d12239ca9505083c85986
mpsacademico/pythonizacao
/parte1/m004_lacos.py
1,641
4.15625
4
# codig=UTF-8 print("FOR") # repete de forma estática ou dinâmica animais = ['Cachorro', 'Gato', 'Papagaio'] # o for pode iterar sobre uma coleção (com interador) de forma sequencial for animal in animais: # a referência animal é atualizada a cada iteração print(animal) else: # executado ao final do laço (exceto com...
3c1cb160109928256565bf8da415a600d56c41f1
ghostlypi/thing
/CeasarCypher.py
540
3.9375
4
def encrypt(user_input): myname = user_input bigstring = "" for x in range (len(myname)): bigstring = bigstring + str(ord(myname[x])+3).zfill(3) x = 0 encrypted = "" while x < len(bigstring): charnumber = bigstring[x:x+3] x = x + 3 charnumber = int(charnumber) ...
c55551fc0fb4c59bfed84131f404f9b462487691
PhenixI/programing-foundation-with-python
/useclasses/drawflower.py
707
4.03125
4
import turtle def draw_rhombus(some_turtle,length,angel): for i in range(1,3): some_turtle.forward(length) some_turtle.left(180-angel) some_turtle.forward(length) some_turtle.left(angel) def draw_flower(): window = turtle.Screen() window.bgcolor('white') angie = turtle...
52830b84ae5750d5f1b39142770c8efaba5e8f41
fastestmk/python_basics
/list_comprehension.py
2,374
3.625
4
# multiple input using list comprehension # a, b, c = [int(i) for i in input().split()] # print(a, b, c) # List as input using list comprehension # my_list = [int(i) for i in input().split()] # print(my_list) # for x in my_list: # print(x, end=" ") # 4*4 Matrix as input # matrix = [[int(j) for j in input().split()] ...
5cc5a1970d143188e1168d521fac27f4534f3032
fastestmk/python_basics
/dictionaries.py
441
4.375
4
# students = {"Bob": 12, "Rachel": 15, "Anu": 14} # print(students["Bob"]) #length of dictionary # print(len(students)) #updating values # students["Rachel"] = 13 # print(students) #deleting values # del students["Anu"] # print(students) my_dict = {'age': 24, 'country':'India', 'pm':'NAMO'} for key, val in my_dict....
aedfec35a3c19b30bc0ec285d7a652b4b340da89
Temesgenswe/holbertonschool-higher_level_programming
/0x0B-python-input_output/13-student.py
1,302
3.953125
4
#!/usr/bin/python3 """Module creates class Student""" class Student: """Student class with public instance attributes Instance Attributes: first_name: first name of student last_name: last name of student age: age of student """ def __init__(self, first_name, last_name, age):...
07cd0f2a3208e04dd0c34a501b68de19f692c35a
Temesgenswe/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
364
4.3125
4
#!/usr/bin/python3 """Module defines append_write() function""" def append_write(filename="", text=""): """Appends a string to a text file Return: the number of characters written Param: filename: name of text file text: string to append """ with open(filename, 'a', encoding="UTF...
86e76c7aa9c052b23b404c05f57420750a5029b7
Temesgenswe/holbertonschool-higher_level_programming
/0x06-python-classes/103-magic_class.py
751
4.4375
4
#!/usr/bin/python3 import math class MagicClass: """Magic class that does the same as given bytecode (Circle)""" def __init__(self, radius=0): """Initialize radius Args: radius: radius of circle Raises: TypeError: If radius is not an int nor a float ""...
d7378fd0f3ba0e609add78cc4e57919029736c9e
craymontnicholls/Booklet-3-
/Save-the-Change/main.py
370
3.765625
4
def SaveTheChange(Amount): NearestPound = int(Amount) + 1 if int(Amount) != Amount: return NearestPound - Amount else: NearestPound = Amount Price = 1.20 Savings = SaveTheChange(Price) print("Debit -purchase: £{:.2f}".format(Price)) print("Debit - Save the change: £{:.2f}".format(Savings)) print("Credit...
5a42b0695ea0a6d04e00ebce4a443f10dd0a6a61
SeniorJunior/Tic-Tac-Toe
/Board.py
1,417
3.953125
4
#Tic Tac Toe class Board: def __init__(self, square1 =' ', square2=' ', square3=' ', square4=' ', square5=' ', square6=' ', square7=' ', square8=' ', square9=' '): self.square1 = square1 self.square2 = square2 self.square3 = square3 self.square4 = square4 self.squa...
cac6b62dea819d2135dea643743f4ad8ea617888
LorenzoChavez/CodingBat-Exercises
/Logic-1/sorta_sum.py
259
3.734375
4
# Given 2 ints, a and b, return their sum. # However, sums in the range 10..19 inclusive, are forbidden, so in that case just return 20. def sorta_sum(a, b): sums = a + b forbidden = 10 <= sums < 20 if forbidden: return 20 else: return sums
d3e203ffb4eac1ffe1bd1776de5f06220b81b6c1
LorenzoChavez/CodingBat-Exercises
/Warmup-1/sum_double.py
231
4.15625
4
# Given two int values, return their sum. Unless the two values are the same, then return double their sum. def sum_double(a, b): result = 0 if a == b: result = (a+b) * 2 else: result = a+b return result
dcdf2af82b901689753f9e158f009d274ce81580
LorenzoChavez/CodingBat-Exercises
/Logic-2/make_chocolate.py
490
4.03125
4
# We want make a package of goal kilos of chocolate. # We have small bars (1 kilo each) and big bars (5 kilos each). # Return the number of small bars to use, assuming we always use big bars before small bars. # Return -1 if it can't be done. def make_chocolate(small, big, goal): big_needed = goal // 5 if big_need...
9ddb20de902048ec957738f121f50212d3f2bd32
LorenzoChavez/CodingBat-Exercises
/Warmup-1/near_hundred.py
276
3.84375
4
# Given an int n, return True if it is within 10 of 100 or 200. # Note: abs(num) computes the absolute value of a number. def near_hundred(n): result = 0 if abs(100 - n) <= 10 or abs(200 - n) <= 10: result = True else: result = False return result
f884cb7d78aca6efb6943ebc2f7ed4194b0357c3
Pradas137/Python
/Uf2/modulos/funciones.py
256
3.859375
4
def division_entera(): try: dividendo = int(input("escrive un dividendo")) divisor = int(input("escrive un divisor")) return dividendo/divisor except ZeroDivisionError: raise ZeroDivisionError("y no puede ser cero")
a39e8f210577397f71242d2b3b841d4fe31e1656
Pradas137/Python
/Ejercicios_año_pasado/Ejercicios_teoria/Ejercicio4.py
113
3.609375
4
def suma(l): if (len(l) == 0): return 0 return l[0] + suma(l[1:]) lista = [1,2,2,2] print(suma(lista))
9fd1b66731c91a03576bb198733f7b6e803210ef
Pradas137/Python
/Ejercicios_año_pasado/Ejercicios_teoria/Ejercicio2.py
174
4.125
4
def producto(num1, num2): if num2 == 1: return num1 elif num2 == 0 or num1 == 0: return 0 else: return(num1+producto(num1, (num2-1))) print(producto(0, 3))
13e493fdf614c4d1f92f8db7cdddeee4fcc79b32
Pradas137/Python
/Ejercicios_año_pasado/Ejercicios_teoria/Ejercicio3.py
353
3.921875
4
def fibonacci(n): if n>2: return fibonacci(n-2)+fibonacci(n-1) else: return 1 print(fibonacci(12)) def fibonacci1(n): if n>=10: b=0 while (n>0): b=b+n%10 n=n//10 return fibonacci1(b) else: ...
7ce2d175697104c3df72fd437f9fe01fc0ed5053
alxanderapollo/HackerRank
/WarmUp/salesByMatchHR.py
1,435
4.3125
4
# There is a large pile of socks that must be paired by color. Given an array of integers # representing the color of each sock, determine how many pairs of socks with matching colors there are. # Example # There is one pair of color and one of color . There are three odd socks left, one of each color. # The number...
c9b5f7671742610dc86e6812456e9f645d4188e5
hliaskost2001/hliaskost
/ask8.py
493
3.5
4
import urllib.request import json url="https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH,LTC&tsyms=EUR&e=CCCAGG" r=urllib.request.urlopen(url) html=r.read() html=html.decode() d=json.loads(html) file = input("File name: ") f = open(file, 'r') f = f.read() f = json.loads(f) thisdict = { "BTC"...
ecd071980258a704fcae77516c9dbc10a45cc99b
PinkyJangir/Loop.py
/strongnumber.py
221
3.9375
4
num=int(input('enter the number')) sum=0 temp=num while temp>0: f=1 i=1 rem=temp%10 while i<=rem: f=f*i i=i+1 sum=sum+f temp=temp//10 if sum==num: print('yes it is strong number',num) else: print('not strong')
145a65c095d3414341ca36072b3dd527bca51d75
PinkyJangir/Loop.py
/len.py
73
3.59375
4
name=input('ebter the nimber') i=0 c=0 while i<len(name): c=c+1 i=i+1 print(c)
34bd3210423fd7cbfceeea84b10aa34785aeaf6f
archanaburra/adventOfCode
/day-2/day-2-solution.py
1,338
3.65625
4
from functools import reduce ## part 1 f=open("input-day-2.txt", "r") phrases = f.read().split("\n")[:-1] # for testing only # phrases = ['abcdef','bababc','abbcde','abcccd','aabcdd','abcdee','ababab'] final_counts = {} final_counts['2'] = 0 final_counts['3'] = 0 def update_final_counts(value): if value in list(...
65f21dd571f901d1331499a0554c82229d24674f
vitor-santos430/aprendendo_ia
/rede_neural_perceptron.py
796
3.8125
4
# para o basilisco no futuro from random import * peso1 = random() peso2 = random() pesoBias = random() entrada1 = int(input("Entrada 1 => ")) entrada2 = int(input("Entrada 2=> ")) bias = 1 erro = 1 while erro != 0: if entrada1 == 1 and entrada2 == 1: resultadoEsperado = 1 else: resultadoEsper...
3b38c1507501d451d741da0daa812a4f63152941
kushagra65/Python-CLock-Project
/ANALOG CLOCK.py
2,034
4.28125
4
#import the essential modules import time# importing the time module import turtle #importing the turtle module from the LOGO days #---------------------------------------------------------------- #creating the screen of the clock wn = turtle.Screen()#creating a screen wn.bgcolor("black")#setting the backgroung color ...
71035e7d048dc71de2a400dcc9202dc8e571ee5f
07Irshad/python
/positivenumbers.py
190
3.9375
4
list1 = [12, -7, 5, 64,-14] list2 = [12, 14,-95,3] for number1 in list1: if number1 >= 0: print(number1, end = " ") for number2 in list2: if number2 >= 0: print(number2, end = " ")
06916a4349bdad38c95c99a3ecd91ffcec916c22
ivanrojo07/Python
/Generador de codigo intermedio.py
253
3.8125
4
def esOperador(c): if(c=='+'or c=='-' or c=='/' or c=='*'): return True else: return False fpos="ab*cd*+" pila=[] for c in fpos: print c if fpos[c]== esOperador(c): print pila: e
b59aa904adda89dbb88e022b3173a1d19efbcc58
ivanrojo07/Python
/Ébola Cinco punto uno.py
4,617
3.515625
4
# -*- coding: cp1252 -*- from Tkinter import * from time import sleep from math import * from random import * def distancia(x1, y1, x2, y2): return sqrt( pow( (x2 - x1), 2) + pow( (y2 - y1), 2) ) class Persona(): def __init__(self, c): self.numero = c self.sano = True self.vacunado = F...
a45f6b8edd8e288b56ea0fb3c8e36aabac6057b0
bvinothraj/progp
/p7/source/p7.py
234
3.75
4
def createMyList(arr1): ''' #P7: Given an array of integers, which may contain duplicates, create an array without duplicates. ''' n_obj = {} for i in arr1: n_obj[i] = 0 return list(n_obj.keys())
16705cb5b02ce15d7fa6f30db54514a32af07d06
stevencfree/raspberryPi
/python/trafficLight.py
690
3.828125
4
from time import sleep import RPi.GPIO as GPIO #gives us access to the GPIO pins GPIO.setmode(GPIO.BCM) #sets the pin numbering system we want to use green = 27 #set variables for the pin numbers driving each LED yellow = 22 red = 17 GPIO.setup(green, GPIO.OUT) #configure GPIO pins to output mode GPIO.setup(yellow...
4255bda81982abadac9f18f2cbeddd4650140c55
whalespotterhd/YAPC
/YAPC.py
1,394
3.96875
4
#!/usr/bin/python import time #####VARIABLES##### """ list of pokemon you which to evolve format: pokemon, # of pokemon, # of candies, candy needed to evolve """ pokemon_list =[ ["Pidgey", 23, 99, 12], ["Rattata", 25, 87, 25] ] #####FUNCTIONS##### def pidgey_calc(pokemon_name, pokemon_amount, pokemon_candy, candy...
6dd0fdc233200217feb75ed152f99c8ac3b7c34f
morganstanley/testplan
/examples/PyTest/pytest_tests.py
4,724
3.671875
4
"""Example test script for use by PyTest.""" # For the most basic usage, no imports are required. # pytest will automatically detect any test cases based # on methods starting with ``test_``. import os import pytest from testplan.testing.multitest.result import Result class TestPytestBasics: """ Demonstrate...
68cfe56e1f5d2712f20888f05fe1fdf222fea993
WuLC/Beauty_OF_Programming
/python/chapter 2/2_2.py
1,904
3.734375
4
# -*- coding: utf-8 -*- # @Author: WuLC # @Date: 2016-05-14 01:31:44 # @Last modified by: WuLC # @Last Modified time: 2016-10-24 12:51:56 # @Email: liangchaowu5@gmail.com ############################################################### # problem1: caculate the number of 0 at the end of the number n! ###############...
1a503d1fa00f78450cce1cbaada145745ea5d17b
AaravAgarwal1/Project-110
/pro 110.py
2,013
3.546875
4
import plotly.figure_factory as ff import plotly.graph_objects as go import statistics import random import pandas as pd import plotly.express as px df=pd.read_csv("medium_data.csv") #reading the file data= df["temp"].tolist() #converting to list # fig= ff.create_distplot([data],["temp"],show_hist=False) ...
3ed3977bb968cc017b63049c9a9ea879d0184308
FDSGAB/Python-HackerRank
/Print Function.py
144
3.546875
4
if __name__ == '__main__': n = int(input()) for i in range (n+1): if (i==0): continue print(str(i), end="")
5f03a74b3ba7d060785ee6e329a428f52ed7188e
neung20402/Python
/week3/test2.py
311
4.0625
4
loop = int(input("กรุณากรอกจำนวนครั้งการรับค่า\n")) total = 0 for x in range(0,loop): num = int(input("กรอกตัวเลข : ")) total = total + num print("ผลรวมค่าที่รับมาทั้งหมด = ",total)
ab76e546874b2bce5ecd02890e8a1db5d44125eb
neung20402/Python
/week2/test7.py
1,491
3.65625
4
print(" โปรแกรมคำนวณค่าผ่านทางมอเตอร์เวย์ ") print("---------------------------------------") print(" รถยนต์ 4 ล้อ กด 1 ") print(" รถยนต์ 6 ล้อ กด 2 ") print(" รถยนต์มากกว่า 6 ล้อ กด 3 ") choose = int(input("\n เลือกประเภทยานภาหนะ : ")) four = [...
56b57bdd2fc048bd1f4feec420779d3193dc305a
ikramulkayes/University_Practice
/practice107.py
426
3.8125
4
def function_name(word): dic = {} count = 0 for k in word: if k.isdigit() or k.isalpha(): if k not in dic.keys(): dic[k] = [count] else: temp = dic[k] temp.append(count) dic[k] = temp count += 1 retur...
1ff6938b2332ff63f21894b59e39795061b8486c
ikramulkayes/University_Practice
/practice16.py
698
3.765625
4
dict1 = input("Enter a number: ") dict2 = input("Enter another number: ") dict1 = dict1[1:-1] dict1 = dict1.split(", ") dict2 = dict2[1:-1] dict2 = dict2.split(", ") lst = [] final = {} flag = True for i in dict1: m = i.split(": ") for k in dict2: j = k.split(": ") if m[0] == j[0]: l...
77bfa9039336ed579826500626f2018bc272bf7a
ikramulkayes/University_Practice
/practice74.py
252
3.921875
4
word1 = input("Enter a word: ") word2 = input("Enter a word: ") final = "" for i in word1: if i in word2: final += i for i in word2: if i in word1: final += i if final =="": print("Nothing in common.") else: print(final)
70becfda5c39f6de278654fb9a5e5b8d35c40f3f
ikramulkayes/University_Practice
/practice69.py
240
3.6875
4
def convert_to_list(square_matrix_dict): lst = [] for k,v in square_matrix_dict.items(): lst.append(v) return lst square_matrix_dict = {1 : [1,2,3] , 2 : [4,5,6] , 3 : [7,8,9] } print(convert_to_list(square_matrix_dict))
213049edd2f0c0e10bd8b781ae666840f44b6f09
ikramulkayes/University_Practice
/practice14.py
341
3.6875
4
color = input("Enter a number: ") sumr = 0 sumg = 0 sumb = 0 lst = [] for i in color: if i == "R": sumr += 1 elif i == "G": sumg += 1 elif i == "B": sumb += 1 if sumr > 1: lst.append(("Red",sumr)) if sumg > 1: lst.append(("Green",sumg)) if sumb > 1: lst.append(("Blue",sum...
27e40e90c22bd82f2b6b15c0522872277926cf95
ikramulkayes/University_Practice
/practice86.py
1,159
3.90625
4
try: word = input("Enter your equation: ") lst = ["+","-","/","%","*"] flag = True op = "" sum1 = 0 for i in word: if i in lst: op = i word = word.split(i) flag = False break if len(word) > 2: raise IndexError if flag: ...
fb2aab5142dbb35c7e8ed8da1b5db79ca4c52f79
ikramulkayes/University_Practice
/practice98.py
303
3.609375
4
rotate = int(input("Enter a number: ")) lst = [] for i in range(rotate): k = (input("Enter ID: ")) lst.append(k) dic = {} for i in lst: k = i[0:2] + "th" if k not in dic.keys(): dic[k] = [i] else: temp = dic[k] temp.append(i) dic[k] = temp print(dic)
20103fee91c007c5ae2bf3f744484d8439373bae
ikramulkayes/University_Practice
/practice65.py
603
3.625
4
def function_name(word): word = word.split() word = sorted(word) lst =[] for i in word: if i not in lst: lst.append(i) dic = {} for i in lst: count = 0 for k in word: if i == k: count += 1 dic[i] = count fdic = {} ls...
e3adaf7cbc084bc3f4582e57ba9229ab200c1639
ikramulkayes/University_Practice
/practice115.py
412
3.890625
4
#que no 3 def function_name(num1): count = 0 sum1 = "" for i in range(num1): if count == 0: sum1 += "A"*num1 + "\n" elif count == num1-1: sum1 += "#"*(num1-1) + "A"*num1 else: sum1 += "#"*count +"A" +"*"*(num1-2) + "A"+'\n' count += 1 r...
9df9246de021e02e56c66a6bd0de75e216927c6a
ikramulkayes/University_Practice
/practice63.py
321
3.5625
4
def function_name(word): #word = word.split() lst = [] for i in word: if i not in lst: lst.append(i) flst = [] num = 0 for i in lst: num = ord(i) temp = str(num)+str(i)+str(num) flst.append(temp) return(flst) print(function_name("pythonbook"))...
96eaaf367f434255625e9daf04e5e6ccc4cdb22b
ikramulkayes/University_Practice
/practice70.py
1,316
3.953125
4
def convert_to_diagonal(square_matrix_dict): lst = [] final = "" for k,v in square_matrix_dict.items(): lst.append(v) for i in range(len(v)): if i == len(v) - 1: final += str(v[i]) + "\n" else: final += str(v[i]) + " " print("Non-di...
1d46299408c1ab7d7d20edd1ba4b262d89e8c69b
lucaslima2018/LinguagemdeProgramacaoPython
/Desafio/usuario.py
520
3.546875
4
class Usuario: # matricula, nome, tipo (leitor ou redator), email (CRUD) def __init__(self, matricula, nome, tipo, email): self.matricula = matricula self.nome = nome self.tipo = tipo # Leitor ou Redator self.email = email # sobreescrevendo o __str__ - equivalente ao toStri...
22a96b0956aa4837591b645997a2651743da88dd
sanketmodi6801/first-project-
/fifteenth_health_managment.py
1,741
3.953125
4
# This is a Health managment program, which stores my diet and exercise details..!! from typing import TextIO def getdate(): import datetime return datetime.datetime.now() def logging_deit(): with open("sanket_diet.txt","a") as f: diet = input("Add some space before entering your diet : ") f....
ee4492b84507e8311614c571f5df40c17b170ad7
kleyton67/algorithms_geral
/uri_1032.py
855
3.796875
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- ''' Kleyton Leite Problema do primo jposephus, deve ser considerado a primeira troca Arquivo uri_1032.py ''' import math def isprime(n): flag = True if n == 2: return flag for i in range(2, int(math.sqrt(n))+1, 1): if(n % i == 0):...
b5e6a2ce6513df4d043cb5fe149d5573a5f2fb8c
hmhudson/user-signup
/crypto/caesar.py
762
3.953125
4
from sys import argv, exit from helpers import alphabet_position, rotate_character def encrypt(text, rot): rot_message = "" for i in text: if i.isalpha(): x = rotate_character(i, rot) rot_message += str(x) else: rot_message += str(i) return(rot_message) ...
fd8bf7ff5152280eb9942b2128ab29082df84432
ndtands/MachineLearning
/8.Logistic_Regression/test.py
188
3.5
4
import numpy as np x = np.array([[0, 3], [4, 3], [6, 8]]) print(np.linalg.norm(x, axis = 1, keepdims = True)) print(np.linalg.norm(x)) print(np.linalg.norm(x, axis = 0, keepdims = True))
4c8965f39e33753729e96142fa6e71c90d24b728
ililk/CUGSE
/数据结构课设/DataStructure/LintCode_easy/LinearList/insertionSortList.py
1,452
3.984375
4
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param: head: The first node of linked list. @return: The head of linked list. """ def insertionSortList(self, head): # write ...
e77ae27829c9f25024d0326b03503913dff0c543
Laurilao/cs50
/pset8/mario.py
700
4.03125
4
def main(): # Get user input while True: height = int(input("Height: ")) if height < 24 and height > 0: break rownumber = 1 # Keep track of current row, initially 1st # Iterate over desired height for i in range(height): # Print the pyram...
962a51fe87a6f273d69b4c3ba5792fc7835ef55a
hayatbayramolsa/Yapay-Zeka-Proje-Ekibi-Gt-
/UygulamaDersi1.py
4,712
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 18 13:02:27 2020 @author: Hp 840 """ Uygulama1: 1 ile 50 arasındaki tüm çift sayıları bir listede topla. # liste.append() listeye eleman ekleme *** Basit düşün! *** liste = [] for i in range(50): if(i % 2 == 0): liste.append(i) ...
f7cf5485d6767b504de12f472d9a4d5cf9035e6b
jgarciakw/virtualizacion
/ejemplos/ejemplos/comprehension1.py
386
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #____________developed by paco andres____________________ toys = ['Buzz', 'Rex', 'Bo', 'Hamm', 'Slink', ] len_map1 = {} for toy in toys: len_map1[toy] = len(toy) len_map = {toy: len(toy) for toy in toys} if __name__ == "__main__": print (len_map1) print ...
0a4c81ea0d6e66f6290e55978e9b3400d421ccd3
jgarciakw/virtualizacion
/ejemplos/ejemplos/texto.py
151
3.5625
4
cad1="a caballo regalado" cad2="no le mires el diente " cad1=cad1.upper() cad2=cad2.strip() cad1=cad1+" "+cad2.upper() print(cad1)
e783154304256165ff443159d4181209454d2e08
kanishk333gupta/Elementary-Signals-in-continuous-and-discrete-time
/Exponential signal.py
1,765
4.34375
4
#EXPONENTIAL SIGNAL import numpy as np #Importing all definitions from the module and shortening as np import matplotlib.pyplot as mplot #Shortening as mplot ,an alias to call the library name ###CONTINUOUS x = np.linspace(-1, 2, 100) # 100 linearly spaced numbers from -1 to 2 xCT ...
26864be554f52e6a3dc2cee5455de74599228579
angellovc/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-number_of_lines.py
355
4.15625
4
#!/usr/bin/python3 """ number_of_lines function module """ def number_of_lines(filename=""): """Get the numbers of lines into a text file Keyword Arguments: filename {str} -- [text file] """ with open(filename, mode="r", encoding="UTF8") as f: lines = 0 for line in f: ...
687e728de6afc1a57f322db9204a20957055b25c
angellovc/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
1,770
4.125
4
#!/usr/bin/python3 """ Matrix_divided functions module """ def matrix_divided(matrix, div): """ Make a division of all the elements into the matrix by a div number returns a new result list Args: matrix: matrix of dividends, just floats or integers are allowed div: that's represent the...
0665247c33469b1d96396ba065085a5a36b6f6d5
angellovc/holbertonschool-higher_level_programming
/0x0B-python-input_output/7-save_to_json_file.py
240
3.703125
4
#!/usr/bin/python3 """ sate_to_json_file module """ import json def save_to_json_file(my_obj, filename): """ save the json obj into a json file """ with open(filename, mode="w", encoding="UTF8") as f: json.dump(my_obj, f)
f0c1ca32d74b47203d48ebe82b5520069a1bdacc
angellovc/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-read_lines.py
515
4.21875
4
#!/usr/bin/python3 """ read_lines module """ def read_lines(filename="", nb_lines=0): """read and print n number of lines into a text file Keyword Arguments: filename {str} -- [text file] (default: {""}) nb_lines {int} -- [n lines to read] (default: {0}) """ with open(filename, mode="r...
60cc05902d464fbde315cef67dc852e5612a0849
angellovc/holbertonschool-higher_level_programming
/0x0A-python-inheritance/1-my_list.py
360
3.734375
4
#!/usr/bin/python3 """[MyList class module]""" class MyList(list): """[it Inherit from list the ability to make list and his methods] Arguments: list {[list class]} """ def print_sorted(self): """[this method print the list in a sorted way] """ sorted = self.copy() ...
13ecec23ce620311c11f33da1ba3bba90cbd7fec
angellovc/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/100-print_tebahpla.py
241
4.4375
4
#!/usr/bin/python3 """ print the ascii alphabet in reverse using upper and lower characters""" for lower, upper in zip(range(122, 96, -2), range(89, 64, -2)): print("{}{}".format(chr(lower), chr(upper)), end='') # print ascii numbers
7047a0e23e92e6a4fb43261c0e303bec4582f49c
jatkin-wasti/python_sparta_task
/sets.py
664
3.78125
4
# What are sets? # There is no indexing in sets therefore # Sets are UNORDERED # Syntax for sets is {"value1", "value2", "value3"} # Use cases: Data that needs to be stored for long periods of time but there is low demand to access it # Also useful for random sets of data e.g. lottery numbers # car_parts = {"wheels", ...
6aa9dfeb5ede40c08928e9244464db2babe22967
KMSkelton/leetcode
/PY/977-squares-of-sorted-arrays.py
340
3.515625
4
class Solution: def sortedSquares(self, A: List[int]) -> List[int]: return(sorted([i*i for i in A])) #this is the kind of question list comprehensions excel at. # the list comprehension is essentially a compressed version of a for loop # and it doesn't require a separate list for storage...
b430ec91b412c2e2896f303314d0bfb484356b80
peg-ib/Algorithms-and-data-structures
/module 5/BinarySearchTree.py
7,722
3.703125
4
import fileinput from collections import deque import re class TreeNode: def __init__(self, key, value): self.key = key self.value = value self.left = None self.right = None self.parent = None class BinarySearchTree: def __init__(self): self.ro...
4a39a59715d3e675e47fa9e0639a3a42963319d8
AugustRush/Python-demos
/demo.py
380
3.65625
4
#! /usr/bin/env python import urllib import urllib2 def getHtml(url): page = urllib.urlopen(url) html = page.read() return html def getHtml2(url): request = urllib2.Request(url) page = urllib2.urlopen(request) html = page.read() return html html = getHtml("http://tieba.baidu.com/p/2738151262") html2 ...
3ffc3da5daf3cff90d1edec928c96603f3c3137c
Tangogow/googleFormBot
/rd.py
2,758
4
4
import random def rd(choice, weight=[100], required=True): ''' Return random value in provided list. By default, if the default weight is [100] or if not any weight provided, it will the chance of outcome equally for each choice: ex: rd(['A', 'B', 'C']) => 100% / 3 => weight = ['33', '33', '33'] ...
70a97b65e8cb2c963b0ae981b52ae5b191743d57
emmaAU/CSC280
/Random.py
575
4.125
4
#import random #print(random.random) import math print(math) a = int(input('enter coefficient for x**2 ')) b = int(input('enter b: ')) c = int(input('what is c?: ')) disc = b**2 - 4*a*c if disc > 0: root1 = -b + math.sqrt(disc) / 2*2 print(root1) root2 = -b - math.sqrt(disc) / 2*2 print(root2) elif d...
78c1ab180bc7cf08dd7af9a28bcb49377840eaeb
madhan99d/python
/list implementation.py
2,159
3.859375
4
class node: def __init__(self,d): self.addr=None self.data=d class oper: def __init__(self): self.head=None def display(self): temp=self.head while (temp!=None): print(temp.data,"-->",end="") temp=temp.addr print("none") ...
57eb63f9f063deda592db8a58ebf420737f5f37c
etridenour/digitalCrafts
/classNotes/python/class7-2.py
2,516
4.3125
4
# class MyClass: # def SayHello(): # print("Hello there!") # MyClass.SayHello() class Person: def greet (self): #self points to object you are creating (ex. me, matt) print("Hello") me = Person() me.greet() matt = Person() matt.greet() # class MyClass: # Greeting = " " # lcass variable, ...
4db455f6dbb5e56a4453f50f967c122e0e9d3c03
etridenour/digitalCrafts
/test files/test4.py
143
3.6875
4
a = [1,2,3,4] b = [2,3,4,5] ab = [] #Create empty list for i in range(0, len(a)): ab.append(a[i]*b[i]) print(ab)
6d1e1a539c20dc7f23d9ac88c6bf61a5f4204153
Peteous/Web-API-Interaction
/Encode.py
3,799
4.21875
4
#urlEncode method encodes input following url encode rules for characters # url is the string you would like to encode # apiURL is an optional parameter for a string of the url of a web api, if you want to use one # paramNames is an optional list parameter containing the names of the parameters you want to encode # par...
f2ebfe3e808503702bcb7adf24b76b4e6ac8efe7
samarthjj/Tries-1
/longestWordinDict.py
1,625
4
4
from collections import deque class TrieNode(object): def __init__(self): self.word = None self.branches = [None] * 26 class Solution(object): # Time Complexity : O(nl) where n is the number of words and l is the average length of the words # Space Complexity : O(nl), where n is the number...
4738eefb49f7f4f759f3d2752aaf4bfb777d1242
ashrafatef/Prims-Task
/app.py
1,588
3.703125
4
import functools def get_all_prime_numbers_in_list (prime_numbers): p = 2 limit = prime_numbers[-1] + 1 while p*p < limit: if prime_numbers[p] != 0 : for i in range(p*p , limit , p): prime_numbers[i] = 0 p+=1 return prime_numbers def get_m...
6e6a78384301f229455a7b76dcd4e7f7d9ba9f25
reuben-dutton/random-color-memes-2
/themes/select_theme.py
661
3.5625
4
import sys import json import random ''' This file selects a random theme from the available ones and sets it to be the current theme. This does not take into account a theme vote. ''' name = sys.argv[1] # Load the themes. themes = json.loads(open(sys.path[0] + '/../json/themes.json').read()) # Select a...
4f7ff64e0ec87b80e8689e8d484f9c0cefd3fbdf
ParkerCS/ch18-19-exceptions-and-recursions-aotoole55
/recursion_lab.py
1,152
4.78125
5
''' Using the turtle library, create a fractal pattern. You may use heading/forward/backward or goto and fill commands to draw your fractal. Ideas for your fractal pattern might include examples from the chapter. You can find many fractal examples online, but please make your fractal unique. Experiment with the vari...
faf2835b5d09232c872f836318aebd7234eabff7
ThePhiri/league-table-calc
/table_generator.py
2,658
3.671875
4
class TableGenerator(object): def readFile(self, file): self.results = {} self.file = file with open(self.file, 'r') as file: for line in file: self.splitLine = line.split() self.team1 = self.splitLine[0] self.team2 = self.splitLine...
1a34eee26a90e17c5732db0d309769ab6e1c31ac
eliza3c23/CS325-Algorithm-HW2
/quickselect.py
1,312
3.984375
4
# Eliza Nip # Summer 2020 CS325 # 07/07/2020 # HW2 Q2 Quick select # Quick select # Ref from http://www.cs.yale.edu/homes/aspnes/pinewiki/QuickSelect.html?highlight=%28CategoryAlgorithmNotes%29 # Ref from https://stackoverflow.com/questions/36176907/implementation-of-the-quick-select-algorithm-to-find-kth-smallest-nu...
33d66c910897318e4f4241d719d936b3b2455d2f
peluza/holbertonschool-higher_level_programming
/0x10-python-network_0/6-peak.py
394
3.953125
4
#!/usr/bin/python3 """ finds a peak in a list of unsorted integers. """ def find_peak(list_of_integers): """find_peak Args: list_of_integers (list): list of unsorted integers. Returns: list: number peak in a list """ if len(list_of_integers) is not 0: list_of_integers...
5cfbd40a1f22c41890c8078c6b4d801c0844627c
peluza/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/0-square_matrix_simple.py
147
3.671875
4
#!/usr/bin/python3 def square_matrix_simple(matrix=[]): f = [] for i in matrix: f.append(list(map(lambda i: i*i, i))) return f
5bc5d1e5f51ce709331003e42ee710ed60a25b69
peluza/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
1,585
4.09375
4
#!/usr/bin/python3 """[2-matrix_divided] """ def matrix_divided(matrix, div): """matrix_divided(matrix, div) Arguments: matrix {list} -- the value is the list div {int]} -- the value is the int Raises: TypeError: matrix must be a matrix (list of list) of integers/floats ...
6efd603459989c8fa85b848c52d05a96a2ff8a74
peluza/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/3-say_my_name.py
719
4.5625
5
#!/usr/bin/python3 """3-say_my_name """ def say_my_name(first_name, last_name=""): """say_my_name Arguments: first_name {str} -- the value is the first_name Keyword Arguments: last_name {str} -- the value is the las_name (default: {""}) Raises: TypeError: first_name must...
2d9b4b049e01cc81b5f69f1bf874926b0548433b
362515241010/MyScript
/arithmetic.py
407
3.921875
4
a = 8 b = 2 print("Addition:\t" , a , "+" , b , "=" , a + b ) print("Subtraction:\t" , a , "-" , b , "=" , a - b ) print("Multiplication:\t" , a , "x" , b , "=" , a * b ) print("Division\t:\t" , a , "" , b , "=" , a / b ) print("Floor Division:\t" , a , "" , b , "=" , a // b ) print("Modulus:\t" , a , ...
598e5975a8494d9626ef46c69df30aefbae48efd
knareshk/Assignments
/try.py
401
3.8125
4
#print("iam trying how to use github") #print("iam try to add content from my meachine") #7. Write the higher order function reduce to calculate the total sum of first 30 odd values in the range of 1 to 100. import functools res = list(filter(lambda x: x % 2 == 1, list(range(0, 101)))) print(res) res = functools.redu...
198bc20bda17400236842baaf1457b030d07b724
jhorowitz16/CTCI_python
/BitManipulation.py
7,362
3.765625
4
# 5.1 - bit insertion with masks def bit_insertion(N, M, i, j): """ :param N: :param M: :param i: :param j: :return integer: 11 with 5 on M 2 10000010000 10011 insert at index 2 10000010000 10011 build right mask, and left mask 1s on the left ... and 1s on t...
bdec82bb0afa429bf2ace52c1d339294e7e12007
misaka-umi/Software-Foundamentals
/01 混杂/17 print the longest word in file.py
329
4.09375
4
filename = input("Enter a filename: ") f = open(filename,'r') pockage = f.readlines() num = [] for i in pockage : a = i.split() for j in a : num.append(j) len = len(num) max = 0 maxname = 0 for i in len : if max < len(num[i]) : max = len(num[i]) maxname = num[i] print("The longest wo...
bbd1072f2a5f859b44c7b4acd7daa5a7ae8b6c48
misaka-umi/Software-Foundamentals
/07 stacks/64 stacks-reverse sentence.py
1,846
4.125
4
class Stack: def __init__(self): self.__items = [] def pop(self): if len(self.__items) > 0 : a= self.__items.pop() return a else: raise IndexError ("ERROR: The stack is empty!") def peek(self): if len(self.__items) > 0 : return ...
389e3a18586388528e2c765e39c52c74ab4f0b2b
misaka-umi/Software-Foundamentals
/10 Hash Tables/82 LinkedListHashTable.py
3,959
3.75
4
class Node: def __init__(self, data, next_data = None): self.__data = data self.__next = next_data def __str__(self): return self.__data def get_data(self): return self.__data def get_next(self): return self.__next def set_data(self,data): self.__data ...
a6f963560d6427aae4c60dc4ae9f9cb71669ac0d
misaka-umi/Software-Foundamentals
/05 class/57 class1-QuadraticEquation.py
1,275
3.671875
4
import math class QuadraticEquation: def __init__(self, coeff_a = 1, coeff_b = 1, coeff_c = 1): self.__a=coeff_a self.__b=coeff_b self.__c=coeff_c def get_coeff_a(self): return self.__a def get_coeff_b(self): return self.__b def get_coeff_c(self): return...
eefc00ea54d6cb22976e3951ce51cf4b82d8d7b8
misaka-umi/Software-Foundamentals
/03 排序/42 选择排序.py
987
3.890625
4
def my_selection_sort(data): length = len(data) for i in range(0,length-1): min = data[i] number = i for j in range(i+1,length): if min > data[j] : number = j min = data[j] if i != number: tmp = data[number] dat...
1adbe782bd5800c2b48fd9e73979f0a1b5d672dd
misaka-umi/Software-Foundamentals
/01 混杂/25 访问元组并写入字典.py
660
3.59375
4
def get_tags_frequency(list_of_tuples) : dictionary = {} length = len(list_of_tuples) for i in range(0,length): if list_of_tuples[i][1] not in dictionary : dictionary[list_of_tuples[i][1]] = 1 else : num = dictionary[list_of_tuples[i][1]] num += 1 ...
0449c5b72a12527c1f9aadd46f490ddb6c93cd9e
misaka-umi/Software-Foundamentals
/01 混杂/18 句子中的单词按长度排序.py
459
3.5625
4
a=input("Enter a sentence: ") sentence = a.split() zidian={} keys=[] for i in sentence: if len(i) not in zidian: zidian[len(i)] = i.lower() elif i.lower() in zidian[len(i)]: pass else: zidian[len(i)]=zidian[len(i)]+" "+i.lower() for i in zidian: keys.append(i) keys.sort() for i i...
10e6235e1bffab9da6771291cff1706fb1980882
misaka-umi/Software-Foundamentals
/01 混杂/19 删除字符串中的字母.py
214
4.09375
4
def remove_letters(word1, word2): result = list(word2) for letter in word1: if letter in result: result.remove(letter) return ''.join(result) print(remove_letters('hello', 'world'))
31b9ceee52b271c41e05fa745910b64a109f299d
kailashsinghparihar/HangmanGame
/Problems (13)/Party time/task.py
232
3.578125
4
try: my_list = [] while True: my_list.append(input()) except EOFError: my = [] for i in my_list: if i != '.': my.append(i) else: break print(my) print(len(my))
4970527d3c2c27270e52c75435caf8bfe34707c3
chefong/8-Puzzle
/helpers.py
818
3.890625
4
# Prints the board state in a nice format def printState(board): for row in board: for tile in row: print(tile, end=" ") print() # Locates and returns a pair of (row, col) indices where the blank space is found def findEmptyIndices(board): for i in range(len(board)): for j in range(len(board[i]))...
ae31e06304c3bb248cca14eacb43d62ecec55433
inktechnkikov/Python
/Beginer/Lists/reverse.py
163
3.78125
4
towns = ["Berlin","Zurich","Sofia"] numbers = [2,3,4,1,0] # towns.reverse() numbers.sort() print(towns) print(numbers) sortTowns = sorted(towns) print(sortTowns)
5f34f34a2b3a138ca17f461d13d3e5de37886ffa
risentveber/Old-code
/combinatorics_with_python/py3.py
1,406
3.796875
4
# -*- coding: utf-8 -*- mass = [1, 1] #инициализируем для p(0) и p(1) def calculate_p(n): #функция для индуктивного вычисления p(n) global mass result = 0 i = 0 #счетчик суммы k = -1 #множитель отвечающий за (-1)^(i + 1) в началее рекуррентной суммы while True: k *= -1 #изменяем множитель ...