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
665ba4de4b55bc221d03af876d0c17a9d3b6e602
dspec12/real_python
/part1/chp05/5-2.py
928
4.46875
4
#!/usr/bin/env python3 #Write a for loop that prints out the integers 2 through 10, each on a new line, by using the range() function for n in range(2, 11): print("n = ", n) print("Loop Finished") """ Use a while loop that prints out the integers 2 through 10 (Hint: you'll need to create a new integer first; ther...
c3506cef0152d2e0d576bc7416f44b181c746471
DimaShtoda/python
/list_defenition.py
302
3.703125
4
int_list = [1,2,3,5] char_list = ['a','b','z','x'] empty_ist = [] print('Numbers:', int_list) print('Chars:', char_list) print('Empty list:', empty_ist) list_from_range = list(range(5)) print("From range:", list_from_range) list_from_string = list('a string') print('From string:', list_from_string)
b6577cec148888124fb9a32549db26fdf2d6a687
Crashdowne/Python
/UdemyProjects/LearnPython/moreDataTypes.py
2,605
3.96875
4
''' More work from Udemy ''' # Calculating acceleration v =25 # Final velocity u = 0 # Initial velocity t = 10 # Time a = (v - u)/t # Calculate acceleration print a # Conditionals if a == 2: print "True" if not a == v: # Equivalent to != print "a /= v" if a != 15: print "derp" # <= , >=...
6dc535054b5a5c81a7a124b864ffeaca47ffe0d7
NithishKumar-coder/python-programming
/pattern.py
204
4.09375
4
for i in range (0,6): for j in range(0, i + 1): print("*", end=' ') print("\r") for i in range (6, 0, -1): for j in range(0, i -2): print("*", end=' ') print("\r")
dde9efb8feb42e95d85d33b1ae6202cf3a92448a
NithishKumar-coder/python-programming
/another pattern.py
103
3.578125
4
for i in range (7,0,-2): for j in range(0, i + 1): print("*", end=' ') print("\r")
84b48b3eb68b8af1a508b71053cff8f0b9bfeead
krucx/Dynamic-Programming
/floyd_warshall_apsp.py
1,326
3.5625
4
adj_matx = [] V = int(input('Enter the number of vertices : ')) for i in range(V): adj_matx.append(list(input().strip().split())[:V]) for i in range(V): for j in range(V): if adj_matx[i][j] == 'INF': adj_matx[i][j] = float('inf') else: adj_matx[i][j] = int(adj_matx[i][j]) def floyd...
1e6aba46347bc53f8abe7a864d239759a1fd6f91
Coryf65/Python-Basics
/PythonBasics.py
807
4.1875
4
#Python uses Snake Case for naming conventions first_name = "Ada" last_name = "Lovelace" print("Hello," + first_name + " ") print(first_name + " " + last_name + " is an awesome person!") # print() automatically adds spaces print("These", "will be joined", "together by spaces!") # Python will save vars like JS kinda...
c8799a82d96c4e2268663abd19bb2ee3578c10e1
facunava92/1ro_Sistemas
/AED/Fichas/Ficha 02 - [Estructuras Secuenciales]/Guía de Ejercicios Prácticos - Ficha 02/3_EcuacionDeEinstein.py
486
4.15625
4
#!/usr/bin/python #La famosa ecuación de Einstein para conversión de una masa m en energía viene dada por la fórmula: #E = mc^2 #Donde c es la velocidad de la luz cuyo valor es c = 299792.458 km/seg. Desarrolle un programa que lea el valor una masa m en kilogramos y obtenga la cantidad de energía E producida en la co...
055c85850dc8ca3356c4659ad534008cccb01a25
facunava92/1ro_Sistemas
/AED/Fichas/Ficha 01 - [Fundamentos]/Guía de Ejercicios Prácticos - Ficha 01/4_UltimosDigitos.py
637
4.15625
4
#!/usr/bin/python #¿Cómo usaría el operador resto (%) para obtener el valor del último dígito de un número entero? ¿Y cómo obtendría los dos últimos dígitos? Desarrolle un programa que cargue un número entero por teclado, y muestre el último dígito del mismo (por un lado) y los dos últimos dígitos (por otro lado) [Ayu...
d89d435eb702cf86699e003bbbfa28b155072279
facunava92/1ro_Sistemas
/AED/Fichas/Ficha 03 - [Tipos Estructurados Básicos]/Guía de Ejercicios Prácticos - Ficha 03/7_CalculoPresupuestario.py
896
3.828125
4
#!/usr/bin/python #En un hospital existen 3 áreas de servicios: Urgencias, Pediatría y Traumatología. El presupuesto anual del hospital se reparte de la siguiente manera: # Área Presupuesto # Urgencias 37% # Pediatría 42% # Traumatología 21% #Cargar por teclado el monto del...
59c6cb19254ee552b82bff8fc133095338bf65e0
mingxiaoh/chainercv
/chainercv/transforms/image/flip.py
616
4.0625
4
def flip(img, y_flip=False, x_flip=False, copy=False): """Flip an image in vertical or horizontal direction as specified. Args: img (~numpy.ndarray): An array that gets flipped. This is in CHW format. y_flip (bool): Flip in vertical direction. x_flip (bool): Flip in horizont...
9665ecaa98612904da33051da31916abbabac1b8
mingxiaoh/chainercv
/chainercv/transforms/point/translate_point.py
906
3.984375
4
def translate_point(point, y_offset=0, x_offset=0): """Translate points. This method is mainly used together with image transforms, such as padding and cropping, which translates the top left point of the image to the coordinate :math:`(y, x) = (y_{offset}, x_{offset})`. Args: point (~nump...
fab55b740a839da12f24867d0adbe9ca78d8aac4
ovo-6/samples
/coding-challenge/count.py
394
3.515625
4
import re, sys word_counts = dict() with open(sys.argv[1], 'r') as f: for line in f: words = re.findall("\w+", line) for word in words: word = word.lower() if word in word_counts: word_counts[word] += 1 else: word_counts[word] = 1...
7352aaae61a7e930125201ccb52738efbfaeb40b
asovic/BlackJack
/Black_Jack.py
5,561
3.578125
4
""" Created on Fri Jul 5 18:42:09 2019 Author: Andrej """ import random suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs') ranks = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace') values = {'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'S...
39fd3459d962f689c6d2b7210132fb1aebe7dcfa
su2009/Python_finance
/Beautiful_soup_2.py
488
3.6875
4
https://pythonprogramming.net/navigating-pages-scraping-parsing-beautiful-soup-tutorial/?completed=/introduction-scraping-parsing-beautiful-soup-tutorial/ import bs4 as bs import urllib.request source = urllib.request.urlopen('https://pythonprogramming.net/parsememcparseface/').read() soup = bs.BeautifulSoup(source,'...
17611086343a271c41c77c866aa80230deea7350
syn2018/Python_MD_scripts
/Sethna/IterateLogisticHints.py
4,401
4.4375
4
"""Basic functionality for iterated maps""" import scipy import pylab # ***** Shared software, # ***** used by ChaosLyapunov, InvariantMeasure, FractalDimension, and # ***** PeriodDoubling exercises. def f(x, mu): """ Logistic map f(x) = 4 mu x (1-x), which folds the unit interval (0,1) into itself. ...
a34cd770b77bd0737edeee2c304cea955d0f6371
syn2018/Python_MD_scripts
/Sethna/RandText.py
3,974
4.5625
5
# # See RandText.html # in http://www.physics.cornell.edu/sethna/StatMech/ComputerExercises/ # import random def read_file_into_word_list(filename): """The text file can be opened using the "open" function, which returns a file object (named here as "inputFile"): inputFile = open(filename, 'r') See ...
4e9e64484dadbdca35e2a1a4335f90ecf6c41094
maribelacosta/wikiwho
/structures/Paragraph.py
1,317
3.546875
4
''' Created on Feb 20, 2013 @author: maribelacosta ''' class Paragraph(object): ''' classdocs ''' def __init__(self): self.hash_value = '' # The hash value of the paragraph. self.value = '' # The text of the paragraph. self.sentences = {} # Dictionary of sentences...
2e44d990b17959b141cb21d8523ee0d68aafb5bf
jessicabreedlove/CS1400_Walkers
/main.py
2,813
4.0625
4
""" Name: Jessica Reece Project 6 April 2021 """ from math import hypot, sqrt import statistics as stat from turtle import * from random import choice import sys def main(): command_prompt = sys.argv if len(command_prompt) < 4: print("Not enough arguments") step_list = list(m...
d06d4a5fb17a6bde934c33cc20d4632a1e9e561a
johnny-581/CCC
/2019/Junior/J5.py
1,432
3.703125
4
# Attempted Recursion "NOT WORKING" from collections import OrderedDict sub_rule_map = OrderedDict() for l in range(3): rule_input = raw_input().rsplit() sub_rule_map[rule_input[0]] = rule_input[1] output_line_spec = raw_input().rsplit() S = int(output_line_spec[0]) I = output_line_spec[1] F = output_line_sp...
0c5a3d759e35484f5ce19bca49ec331c84e23fc8
wleddy/jumpstat
/date_utils.py
3,522
3.65625
4
"""Some date utilities""" from datetime import datetime from pytz import timezone def local_datetime_now(time_zone=None): """Return a datetime object for now at the time zone specified. If tz is None, use the tz name in app.config else use the local time per the server""" if time_zone == None: ...
29337e528e288c6ce1c96382c9edea5bfb642388
jnkhazza/python-challenge
/Pybank/main.py
2,298
3.890625
4
import os import csv #Pulling in the CSV csvpath = os.path.join('Resources', 'budget_data.csv') with open(csvpath) as csvfile: budget_data = csv.reader(csvfile, delimiter=',') print(budget_data) csv_header = next(budget_data) # print(f"{csv_header}") #Storing the data into new lists dates ...
e4657118cf9403837443452d1aa609bb6c501743
kimmy1993/algorithm
/python/binary_tree.py
3,202
3.921875
4
import time import random import queue class Tree_Node(object): tree_data = None left = right = None def __init__(self): self.tree_data = None self.left = self.right = None def insert(self,Node,data): if Node== None: Node = Tree_Node() Node.ins...
0f1175f665158e1a02c2e892356a86a57ada27de
Simander/python3-blackjack
/Card.py
651
3.515625
4
class Card: cardCount = 0 colourNames = ['hearts', 'diamonds', 'spades', 'clubs'] valueNames = ['ace', '2', '3', '4', '5', '6','7', '8', '9', 'knight', 'queen', 'king'] def __init__ (self, colour, value): self.colour = colour self.value = value @...
6f50c21db326d27e48041deeb3f6eeedb403b139
charul97/nltk_basics
/6_Lemmatizer.py
631
3.75
4
# A very similar operation to stemming is called lemmatizing. The major difference between these is, as you saw earlier, stemming can often create non-existent words. # package- nltk.stem, libraries - WordNetLemmatizer from nltk.stem import WordNetLemmatizer lemmatizer= WordNetLemmatizer() print(lemmatizer.lemmati...
cbee6d4a19be3a90157a1b75d678ce384439473b
gnetanel/python-basic-coding
/listFunctions.py
1,079
3.765625
4
def list_func(): print("in func1 of list functions module") my_list = ['one', 'two'] my_list2 = list(('x, y', 'z')) my_list2.append('w') print(my_list2) print(my_list) print("Printing list in loop") for i in my_list: print("i=" + i) my_list.append('three') print(my_list...
b3bbc0fdc7b71540cfe19a59dadd3944a79e2db8
romanfh1998i/UdacityCs101
/p5-4.py
365
3.671875
4
def jungle_animal(animal, my_speed): if animal == 'zebra' : print "Try to ride a zebra!" elif animal == 'cheetah' and my_speed >115:print "Run!" elif animal == 'cheetah' : print "Stay calm and wait!" else : print "Introduce yourself!" #jungle_animal('cheetah', 30) #>>> "Stay calm and wait!" #jungle_ani...
e87442c36a09c80bd07758d4f4f66022b4494c7a
romanfh1998i/UdacityCs101
/p4-4.py
373
3.671875
4
def set_range(a,b,c): def bigger(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): return -biggest(-a,-b,-c) max=biggest (a,b,c) min=smallest(a,b,c) return max-min ...
9a16c17fbfd8e580ecb81f176f2cf02178f7ea90
Sruthy-CB/Python_Training
/multiplication.py
134
3.96875
4
def mul(n): for i in range(1,11): print n,"*",i,"=",n*i num=input("enter a number:") print "Multiplication table of",num mul(num)
5add5f30ea6a1d64a7514dbbd08bdb2f143d60aa
Austindlux/Project-Euler
/21.py
1,146
4
4
"""Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers. For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; t...
0d52bd924ad63b72a57029385b19d97b0aeaba88
Qinua/python_study
/基础-变量_操作符_循环/for_while.py
690
3.609375
4
for name in ['zhangsan','lisi','wanglaowu','jingjing']: print(name) if name == 'jingjing': print('我的最爱{0}出现了'.format(name)) else: print('同学我们不约,不约,同学请自重') else: print('别的都不是我同学,不会再爱了') for i in range (1,11): if i%2==1: continue print('{0}是偶数'.format(i)) break for i...
d3a4450b6f659620ef85463cc1167fb74035985a
sayancoding/Days-Code
/RecursionBacktracting/index.py
230
3.8125
4
def powerSet(mainString,curr,index): if(len(curr) == len(mainString) or index == len(mainString)): return print(curr) for i in range(index,len(mainString)): curr = curr + mainString[i] powerSet(mainString,curr,i)
361f90710342e0d888a7fedd5599df71757c687c
JesseAldridge/yc_still_good
/data_collection/_0_parse_date.py
987
3.890625
4
import re, datetime def month_name_to_int(month_name): return { 'jan': 1, 'feb': 2, 'mar': 3, 'apr': 4, 'may': 5, 'jun': 6, 'jul': 7, 'aug': 8, 'sep': 9, 'oct': 10, 'nov': 11, 'dec': 12, }[month_name.lower()[:3]] def parse_date(date_str): if not date_str: retu...
2ce60f8a8b75b2544dbfe4e67c855a730ace089c
Shareyar007/Weather_APP
/weather_app.py
2,201
3.703125
4
import tkinter as tk from PIL import Image, ImageTk from weather_api import weather_information def open_weather_icon(icon): #set weather icon size = int(information_frame.winfo_height()*0.30) img = ImageTk.PhotoImage(Image.open('./img/'+icon+'.png').resize((size, size))) weather_icon.delete("all") ...
6eeb8bf68eeb0713e477617dc4c37b8c9f98e83a
aurimrv/src
/aula-07/turtle-01.py
607
4.1875
4
import turtle from math import sqrt L = input("Tamanho do lado: "); N = input("Quantidade de quadrados: "); L = int(L) N = int(N) pen = turtle.Pen() A = L*L soma = A cont = 2 # desenhando quadrado pen.forward(L) pen.left(90) pen.forward(L) pen.left(90) pen.forward(L) pen.left(90) pen.forward(L) while cont <= N:...
f1413d8e37a67401916ac368544712ac4f870f8c
apocalypse2002/myprograms
/partition.py
337
3.59375
4
def partition(arr): n=len(arr) x=arr[n-1] j=0 i=j-1 for j in range(j,n-2): if(arr[j]<=x): i=i+1 temp=arr[i] arr[i]=arr[j] arr[j]=temp temp=arr[i+1] arr[i+1]=arr[n-1] arr[n-1]=temp myarr=[2,8,7,1,3,5,6,4] partition(mya...
e8a41dd07f93e3226bcc2d61e1ec49beefe8a707
wmqpwmm/investigate-texts-and-calls
/Task1.py
1,232
3.71875
4
""" 下面的文件将会从csv文件中读取读取短信与电话记录, 你将在以后的课程中了解更多有关读取文件的知识。 """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ 任务1: 短信和通话记录中一共有多少电话号码?每个号码只统计一次。 输出信息: "There are <count> different te...
f87459f065074f8f9388005f0a7473041465ff74
satani99/Data-Structures-and-Algorithms
/linkedlist.py
1,501
3.953125
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList(): def __init__(self): self.head = None self.tail = None def append(self, data): new_node = Node(data) if self.head == None: self.head = new_node self.tail = self.head self.length = 1 else: self.ta...
92710df13ff836ccdb6a1e439ce7a77092b84183
RobbieNesmith/Code-Challenge
/newBoCodeCodingChallenge.py
814
3.640625
4
def odometer(arr, change): pos = len(arr) - 1 while pos >= 0 and change != 0: sum = arr[pos] + change if sum < 0: change = sum else: change = sum // 10 arr[pos] = sum % 10 pos = pos - 1 if change == 1: arr[0] = 1 tests = [{"input": [4,3,9,5], "output": [4,3,9,6]},...
1b80a9bc6a2677239711db29cbad32b32b2d6cb5
guillaume-havard/sim-usine-velo
/Code/sbsim.py
22,780
3.5
4
""" Utilitaires pour la modelisation et la simulation. References: * http://python.org/ * http://docs.python.org/tutorial/ * http://docs.python.org/reference/ * http://docs.python.org/library/ * http://www.pythonware.com/library/tkinter/introduction/ """ import math impor...
dafad847911a9e9eb7dc5e84b9b8d6a1ebc6b7a5
JoseMelNet/selenium_con_python
/typos.py
2,062
3.796875
4
# This script validates that the text on the website is equal to an expected text # Steps: #1. Enter to https://the-internet.herokuapp.com/ #2. Select "Typos" - This module simulate can change a line text when we recharge the website #3. Find the text with typo import unittest from selenium import webdriver # TestCas...
64afd35e36fdd171a7807debc3edf4286ab4c673
GabrielaPRocha/ExerciciosPython
/testinho.py
12,008
4.1875
4
#x= int (input('digite um numero')) #y=int(input('digite um segundo numero ')) #z= x+y #print('a soma entre {0} e {1} vale {2}'.format(x, y ,z)) #--------------------------------------------------------------------- # SUCESSOR E ANTECESSSOR #x= int (input('digite um numero')) #y= x+1 #z=x-1 ...
ccbfb5490fb5110e5740087eb197d8aada501eec
chadleRui/python_game_practce
/oop_practice/cups.py
768
3.546875
4
#定义杯子父类 class Cups: #定义杯子常有的属性 def __init__(self): self.xingzhuang="圆形" self.meizhuang="方形" #定义加入装水方法 def zhuangshui(self,water): print(f"装了{water}毫升水") #定义保温杯继承杯子父类 class BaowenCups(Cups): #保温杯也有跟父类一样的属性 def __init__(self): super().__init__() #保温杯特有的保温方法 ...
5dffbbd4774757d8fc34c7ddcf0fb38b608215d1
aygulmardanova/python-start
/hw3/digit_recognition.py
3,961
3.671875
4
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data # To plot the figure of accuracy values acc_values = [] mnist = input_data.read_data_sets('MNIST_data/', one_hot=True) def digit_recognition(): # Input x_1d = tf.placeholder...
10867c152dbeb854986c316fba18884e593874c4
DragonixAlpha/Kal
/Src/AdventureGame.py
5,890
4.03125
4
import time #Imports a module to add a pause #Figuring out how users might respond answer_A = ["A", "a"] answer_B = ["B", "b"] answer_C = ["C", "c"] yes = ["Y", "y", "yes"] no = ["N", "n", "no"] #Grabbing objects sword = 0 flower = 0 required = ("\nUse only A, B, or C\n") #Cutting down on duplication ...
6338ec300caac0b9eeb18103ec9d35d12bb5d61b
mohsin-siddiqui/python_practice
/lpth_exercise/MyRandomPrograms/areaOfCircle.py
238
4.21875
4
pi = 22/7 R = input("Please Enter the Radius of the Circle(in meter):\n") # R stands for Radius of the circle A = pi * float(R) ** 2 # A stands for Area of the circle print("The required Area of the circle is :",round(A),"square-meters")
210377f3361721b3bae3cb498d72b0fdfd4e741e
mohsin-siddiqui/python_practice
/lpth_exercise/ex_16-21/ex21.py
1,644
4.09375
4
def add(a, b) : print(f"ADDING {a} + {b}") return a + b def subtract(a, b) : print(f"SUBTRACTING {a} - {b}") return a - b def multiply(a, b) : print(f"MULTIPLYING {a} * {b}") return a * b def divide(a, b) : print(f"DIVIDING {a} / {b}") return a / b print("Let's do som...
de30fe178ae6671c8ee74ed062ba51e6f90bea79
mohsin-siddiqui/python_practice
/lpth_exercise/ex_1-15/unicodeDbCharacters.py
1,205
3.59375
4
# https://www.unicode.org/Public/UCD/latest/charts/CodeCharts.pdf # https://en.wikipedia.org/wiki/List_of_Unicode_characters # using ascii backspace(\b): #print("1234\b5678") # using characters from unicode character database(ucd) # \N{nameOfTheCharacter} #print(u"\N{DAGGER} ") #print(u"\N{DAGGER} " * 30) #print(u"\...
2a57e4ee436d3fad491679fc9da1b2a914adee43
sthpravin/diseasechecker
/checker/nn1.py
3,549
4.1875
4
''' X -> input to neural net Y -> actual output of neural net yHat -> observed output of neural net z2 -> weighted input to hidden layer a2 -> activation on the hidden layer input z2 a2b -> activation with addition of bias z3 -> weighted input to the output layer ''' import numpy as np x = np.l...
53967fe80d3c99869f7015da02d1ca0b7bbcf426
SIeviN/Examples
/Unique.py
596
4.03125
4
#!/bin/python3 #using data structures def unique(st): newst = set(st) if len(st) != len(newst): print("Not unique") else: print("Unique") #not using data structures def unique2(st): for i in st: value = i index = st.index(value) + 1 while(index ...
2da480faa0968c23b95f6d322332abd9622ac81a
ParalogyX/python-train
/mid_exam/9.py
170
3.609375
4
# -*- coding: utf-8 -*- """ Created on Sat Jul 4 18:23:35 2020 @author: Vladimir """ stuff = "iQ" for thing in stuff: if thing == 'iQ': print("Found it")
bb50cb90b4448b14f9c0659803f050135870aa8b
ParalogyX/python-train
/final_exam/problem4.py
889
3.8125
4
# -*- coding: utf-8 -*- """ Created on Fri Jul 31 16:56:47 2020 @author: Vladimir """ def primes_list_amount(N): ''' N: an integer Returns a list of prime numbers ''' result = [2] i = 2 while N > 0: isPrime = True for k in result: if i % k == 0: ...
f80e5d57e1100d0e4d0f9c583342bcf771d950c9
kiselevskaya/Bioinformatics
/genome_sequencing/assemble_genomes/k_d_mer_composition.py
688
3.5625
4
def k_d_mer_composition(text, k, d): composition = {} for i in range(len(text)-(2*k+d)+1): if text[i:i+k] not in composition.keys(): composition[text[i:i+k]] = [text[i+k+d:i+2*k+d]] else: composition[text[i:i+k]].append(text[i+k+d:i+2*k+d]) return dict(sorted(compos...
4647c8b0b50324810670c6332937a2ba9f2d3e9b
maxjacomette/SEII-Max
/Semana03/prog19.py
1,872
3.765625
4
li = [9,1,8,2,7,3,6,4,5] s_li = sorted(li, reverse=True) print('Sorted Variable:\t', s_li) li.sort(reverse=True) print('Original Variable:\t', li) ......................... PARTE 1............... tup = (9,1,8,2,7,3,6,4,5) s_tup = sorted(tup) print('Tuple\t', s_tup) di= {'name': 'Corey', 'job': 'p...
41c9edbb34832ccd2fc656a366bd89103b171e67
arl9kin/Python_data
/Tasks/file_function_questions.py
2,256
4.25
4
''' Question 1 Create a function that will calculate the sum of two numbers. Call it sum_two. ''' # def sum_two(a, b): # c = a + b # print (c) # sum_two (3,4) ''' Question 2 Write a function that performs multiplication of two arguments. By default the function should multiply the first argument by 2. Call it...
14e245822e7c253fdd1f30278e83ed1acb5073a1
mawhidby/python-client
/braid/transaction.py
2,601
3.5625
4
class Transaction(object): """ A transaction. This class uses the builder pattern, so that you can easily chain queries together, e.g.: >>> Transaction().create_edge(...).get_vertices(...) """ def __init__(self): self.payload = [] def _add(self, **kwargs): self.payload...
60db0b065781e5bea330ffdb1c819553e8d16797
ArsenalGang/dzdykes.github.io
/Solutions/decodeFun.py
2,463
3.765625
4
import string #pass decoded message returns a encoded message def encode(message, n): newMessage = '' mesArr = message.split(' ') for w in mesArr: for l in w: if ord(l) > 96 and ord(l) < 123: if ord(l) <= (96+n): lnew = ord(l)+(26-n) e...
dfe39f57cc55c83fa7ef757250eee1809afd0324
calebo117/DIP_A9
/src/Open_Close/Logical_Operators.py
584
3.671875
4
class LogicalOp: def logicalAND(self, input): for i in input: if i == 0: return 1 return True def logicalOR(self, input, ): for i in input: if i == 1: return 1 return 0 def logicalMAJ(self, input): false = 0 ...
348dc81dd001a621ab8fe2f5cf970a86981f6294
letugade/Code-Club-UWCSEA
/Python/Lesson01/Lesson01.py
508
4.21875
4
# Printing print("Hello world") # Variables a = 3 # Printing variables print("The value of a is", a) # User input name = input("What is your name? ") print("Hello", name) # Conditional statements if name == "Bob": print("Your name is Bob") elif name == "John": print("Your name is John") else: print("Your name is...
6e9e4da7e877104ea284d1cc64af67efb0730e65
letugade/Code-Club-UWCSEA
/Python/Lesson04/modulo6.py
132
3.953125
4
a = int(input("Enter the first number: ")) b = int(input("Enter the second number: ")) print("The sum mod 6 is", str((a + b) % 6))
0dd4ad3b1044154bda9917043f89780b1be2fe97
ccypitl/adventofcode
/20/elf_deliveries.py
1,153
3.75
4
#!/usr/bin/env python class DeliveryControl(object): def __init__(self): self.count = 0 def iterate_houses(self): while True: self.count += 1 elves = self.factors(self.count) yield House(self.count, elves) @staticmethod def factors(n): #...
43997fe750aa08f81dd1126384f5ec8ce8a7b73e
BlissChapman/python-start
/intermediate_tester.py
607
3.703125
4
''' DON'T CHANGE ANYTHING IN THIS FILE ''' import unittest from intermediate import Intermediate as intermediate # This creates an object with all the functions we created b = intermediate() class TestIntermediateMethods(unittest.TestCase): def test_dictionary(self): print('Test dictionary function') ...
ccadcba50ae1a099171f544eda6ce428647eef68
mayan5/pythonchallenge
/PyBank/main.py
1,255
3.640625
4
import os import csv csvpath = "Resources_budget_data.csv" with open(csvpath, newline='') as csvfile: csvreader = csv.reader(csvfile, delimiter=',') csv_header = next(csvreader) total_months = 0 total_revenue = [] monthly_profit_change = [] profit_loss_list = [] month_list = []...
d8fd66f43d8a296a435c9bc94d0c79a67249abc9
rmwenzel/project_euler
/p1/p1.py
286
4.15625
4
#!usr/bin/python import numpy as np def sum_multiples(n): """Sum multiples of 3 or 5 that are < n.""" def f(x): return x if (x % 3 == 0 or x % 5 == 0) else 0 return sum(np.array(list(map(f, np.arange(1, n))))) if __name__ == "__main__": sum_multiples(1000)
1f42534a911d2f4f5b166048963f06433ce106e6
ELJust/bao
/BAO.py
2,472
3.84375
4
# -*- coding: utf-8 -*- """ Run a game of BAO. """ from BAO_functions import turn from BAO_functions import pebbles_left from board import print_field from board import game_area from strategies import * from save import result_to_file def play_game(strategy_p1, strategy_p2, max_allowed_turn_count): """ The p...
c4afe223e57c5bbcd697d79ce293fc4d28a033cc
vivek-x-jha/Python-Concepts
/DataStrucsAlgos/dsa01_BigO/findMin.py
671
4.0625
4
from tools.utility import logtimer def main(): """ Finds the minimum number in a list findMin1: O(n^2) findMin2: O(n) """ n = 3 findMin1(range(10 ** n)) findMin1(range(10 ** (n + 1))) findMin2(range(10 ** n)) findMin2(range(10 ** (n + 1))) @logtimer def findMin1(array): """Finds min number in a list i...
a6ea31b591b9471b18ac67343d9a8b540bb47916
vivek-x-jha/Python-Concepts
/lessons/cs15_namedtuple.py
511
3.71875
4
def main(): """ Demonstrates how to use the namedtuple csvdata structure with regular tuples, it isn't obvious what the csvdata represents: blue = (0, 0, 255) could represent rgb, hue, saturation, etc... but dictionaries are mutable and lengthy to type: black = {'red': 0, 'green': 0, 'blue': 0} """ from col...
2eca15e98b7d171698683b66f78ccae423c9fdd6
vivek-x-jha/Python-Concepts
/lessons/cs13_decorators.py
980
3.921875
4
""" Python Tutorial: Decorators - Dynamically Alter The Functionality Of Your Functions https://youtu.be/FsAPt_9Bf3U """ from functools import wraps def decorator(func): """Decorator w/o @wraps DocString""" def wrapper(*args, **kwargs): """Wrapper w/o @wraps DocString (This should not be appearing)""" print('W...
5bc2ead9259f699053de317c62b911bc86f75e3f
vivek-x-jha/Python-Concepts
/lessons/cs14_decorators_args.py
713
4.3125
4
""" Python Tutorial: Decorators With Arguments https://youtu.be/KlBPCzcQNU8 """ def prefix_decorator(prefix): def decorator_function(original_function): def wrapper_function(*args, **kwargs): print(prefix, 'Executed Before', original_function.__name__) result = original_function(*a...
4c3720c963b01b9ae29e250821de0a0ab126d2a0
vivek-x-jha/Python-Concepts
/datacamp/intermed_python/ipy1_matplotlib/mpl_scatter.py
910
4.0625
4
import matplotlib.pyplot as plt import numpy as np from data import * """ Plot a scatter plot: gdp_cap on the x-axis, life_exp on the y-axis Make dots' size (s) vary with population size Change colors (c) to match col list Change opaqueness (alpha) to 80% Put the x-axis on a logarithmic scale """ plt.scatter(x=gdp_ca...
c4dbd9d2844c8189a362cfc9ad1c89a65a239e01
vivek-x-jha/Python-Concepts
/lessons/cs11_EAFP.py
1,264
3.6875
4
""" Python Tutorial: Duck Typing and Asking Forgiveness, Not Permission (EAFP) https://youtu.be/x3v9zMX1s4s """ def main(): """Compares result of 3 approaches below""" d = Duck() p = Person() for inst in d, p: bad(inst) better(inst) best(inst) print((dir(inst))) print('\n') def bad(thing): """Not Duc...
820240acbd4fea7365f1baf69cfa8db389f2874e
wangxuewen123/p1804
/上传/namelist.py
1,292
3.734375
4
name_list = [] while True: tong_xue_name = input("请输入你要保存的姓名: ") if tong_xue_name == "t": break name_list.append(tong_xue_name) print(name_list) print(name_list[3]) print(name_list[5]) print(name_list[8]) print(name_list[10]) name_list.sort() print(name_list) name_list.sort(reverse=True) print(...
bce8878ca1cdab8b7af7ef53bb4bf2b99107ee56
wangxuewen123/p1804
/上传/遍历练习.py
1,270
3.640625
4
# for循环 #def shuchu(): # tu1 = (1,2,3,) # for i in tu1: # while循环 #def da(): # tul = (1,2,3,) # while True: # print(tul[0]) # print(tul[1]) # print(tul[2]) # break #da() a=[] def ming() for i in a: name=input('请输入你要保存的姓名: ') age=input('请输入你要保存的年龄: ') ...
9b85f156f80dde7d7fccc2a251b3744447bfd014
Deadecho95/SMARTES
/Controller/localDataBase.py
2,164
3.53125
4
# --------------------------------------------------------------------------- # # Client to write and read file on the Raspberry PI # --------------------------------------------------------------------------- # import os.path import datetime # -------------------------------------------------------------------------...
5f910af81635b99ce50760c03989653f503f77b8
cooolallen/123-Stop
/random_comp.py
993
3.984375
4
import random def game_random(p): comp = random.randint(1,3) # computer random 1 ~ 3 if(p=='scissor'): # player: scissor if(comp==2): # player win, computer: paper result = 'win' elif(comp==3): # player lose, computer: stone result = 'lose' else: # tie, computer: scissor result = 'fair' ...
227013ece02639ec2566ad89bffd3f649b908ba2
artemkondyukov/rosalind_tasks
/LGIS.py
1,190
3.84375
4
def longest_increasing_subsequence(sequence): counts = [1] * len(sequence) path = [-1] * len(sequence) for i in range(1, len(sequence)): for j in range(0, i): if sequence[i] > sequence[j] and counts[j] >= counts[i]: counts[i] = counts[j] + 1 path[i] = j index = counts.index(max(counts)) result = []...
564cb1318d466a5eeb2fbe7a7825380de3227322
prasannakumar2495/QA-Master
/pythonPractice/samplePractice/IFcondition.py
786
4.3125
4
''' Created on 25-Dec-2018 @author: prasannakumar ''' number = False string = False if number or string: print('either of the above statements are true') else: print('neither of the above statements are true') if number: print('either of the above statements are true') elif not(string) and number: p...
54d32423f7e2f6deeb341a9799f444c53d502d40
ntyagi-dev/PythonStarter_byJoelGrus
/KeyConnectors.py
4,740
3.90625
4
# Grus, Joel. Data Science from Scratch . O'Reilly Media. Kindle Edition. # User Details users = [{ "id": 0, "name": "Hero" }, { "id": 1, "name": "Dunn" }, { "id": 2, "name": "Sue" }, { "id": 3, "name": "Chi" }, { "id": 4, "name": "Thor" }, { "id": 5, "name": "Clive" }, ...
5c2252aa3a09a3518282ca6ae984880da19a5b6d
zaurrasulov/Euler-Projects
/Euler9.py
318
4.21875
4
#This application prints the Pythagorean triplet in which a+b+c=1000 import math def Pythagorean_triplet(n): for b in range(n): for a in range(1, b): c = math.sqrt( a * a + b * b) if (c % 1 == 0 and a+b+c==1000): print(a, b, int(c)) Pythagorean_triplet(1000)
44e2394f6cb3ee9c5aff4770cb1e596dd08f5ed5
stebog92/acs
/ASC/tema1/tema/node.py
6,544
3.59375
4
""" This module represents a cluster's computational node. Computer Systems Architecture course Assignment 1 - Cluster Activity Simulation march 2013 """ import time from threading import * class Node: """ Class that represents a cluster node with computation and storage functionalities. ...
5d18c9ffe9bc46b0b5c6583e8058b64f43be187e
sis00337/BCIT-CST-Term-1-Programming-Methods
/06. Eleven Functions/phone.py
3,042
4.34375
4
""" Function 7 - Alphabetical Phone Number Name : Min Soo (Mike) HWANG Github ID : Delivery_KiKi """ def number_translator(): """ Prompt the user for 10-digit alphabetical phone number. The function also check if the user entered number in the right format. The user's input is case-insensitive and it mig...
41a1f099ff0c946cecbf152d0d8cac2a220307e8
sis00337/BCIT-CST-Term-1-Programming-Methods
/09. Yahtzee Game/yahtzee.py
47,613
3.875
4
""" Yahtzee Game Name : Min Soo (Mike) HWANG Github ID : Delivery_KiKi """ import random def EMPTY_SCORE() -> int: """ Return -1 to indicate a blank in a score sheet. :return: -1 """ return -1 def ZERO_SCORE() -> int: """ Return 0 to indicate score zero. :return: 0 """ re...
e8e8109d70be92486b88ba2aea5daea7c9730222
sis00337/BCIT-CST-Term-1-Programming-Methods
/09. Yahtzee Game/test_is_yahtzee.py
1,638
3.71875
4
""" COMP 1510 09. Yahtzee Game - Yahtzee Name : Min Soo (Mike) HWANG Student Number : A01198733 Set : F Github ID : Delivery_KiKi """ from unittest import TestCase from yahtzee import is_yahtzee class TestIsYahtzee(TestCase): def test_is_yahtzee_empty_score(self): player_score = {'Yahtzee': -1} ...
937b284e2295a7a43820a7c4b705d8c154d9d00b
sis00337/BCIT-CST-Term-1-Programming-Methods
/05. Regular Expressions/test_is_nakamoto.py
2,072
3.65625
4
from unittest import TestCase from regex import is_nakamoto class TestIsNakamoto(TestCase): def test_is_nakamoto_empty_string(self): name = '' expected = False actual = is_nakamoto(name) self.assertEqual(expected, actual) def test_is_nakamoto_first_name_uppercase(self): ...
ea1f557a5eee486e0afd435d1eb339dd40caad0e
sis00337/BCIT-CST-Term-1-Programming-Methods
/02. Three Short Functions/create_name.py
891
4.375
4
""" Author: Min Soo Hwang Github ID: Delivery_KiKi """ import random import string def create_name(length): """ Check if length of a name is less than or equal to 0. :param length: an integer that indicates the length of a name :return: the result of the function named create_random_name """ ...
bcf1f4b91e0e662d738a3f9de795e8e4eae2222b
JMazick/python-challenge
/PyBank/main.py
1,769
3.84375
4
import csv import os # Path to collect data from the Resources folder os.chdir("C:\\Users\\jazly\\OneDrive\\BOOTCAMP\\HOMEWORK\\WEEK-3") # Define the function and have it accept the 'PyBank' as its sole parameter PyBank = "00_Homework Assignments Instructions & Data_Week3_Instructions_PyBank_Resources_budget_data.csv...
9e80ca85c78c6ccba160eb3ce0a7e60ab1e49392
DavidAlen123/Radius-of-a-circle
/Radius of a circle.py
255
4.25
4
# -*- coding: utf-8 -*- """ Created on Tue May 11 07:15:17 2021 @author: DAVID ALEN """ from math import pi r = float(input ("Input the radius of the circle : ")) print ("The area of the circle with radius " + str(r) + " is: " + str(pi * r**2))
56d711b5e0a90c5e4af6201343c278befe1f3db2
garfieldnate/scratch
/format_germ_freq/make_toc.py
897
3.5
4
# add simple TOC to existing HTML file import sys def add_toc(lines): toc_lines = [] new_lines = [] entry_counter = 0 space_counter = 0 for line in lines: if "<div class='entry'" in line: entry_counter += 1 space_counter += 1 if space_counter % 50 == 0: space_counter = 0 new_lines.append(f'<sp...
5dcc049d86bf0e8e7cbff8600c89f26fd820090f
SheikhAnas23/DLithe_Python_Internship_Report
/day6/assingnment 3/prob2.py
55
3.546875
4
for i in range(int(input())): print(str(i+1)*int(i+1))
100cf26661e730aa38efa2852aaa63e87067bac4
4anajnaz/Devops-python
/largestnumber.py
460
4.375
4
#Python program to find largest number try: num1= input("Enter first number") num2= input("Enter second number"); num3= input("Enter third number"); if (num1>num2) and (num1>num3): largest = num1 elif (num2>num1) and (num2>num3): largest = num2 else: largest =...
c5864d32adc2646fe4f605e8c5c4d9e2f44342be
Werifun/leetcode
/tree/199. 二叉树的右视图.py
1,596
4.1875
4
""" 给定一棵二叉树,想象自己站在它的右侧,按照从顶部到底部的顺序,返回从右侧所能看到的节点值。 示例: 输入: [1,2,3,null,5,null,4] 输出: [1, 3, 4] 解释: 1 <--- / \ 2 3 <--- \ \ 5 4 <--- 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/binary-tree-right-side-view 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ # Definition for a ...
fb6243d1582229404e91b91dbcea5f98a093a67d
Werifun/leetcode
/tree/236. 二叉树的最近公共祖先.py
1,573
4.21875
4
""" 给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。 百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个节点也可以是它自己的祖先)。” 例如,给定如下二叉树:  root = [3,5,1,6,2,0,8,null,null,7,4]   示例 1: 输入: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1 输出: 3 解释: 节点 5 和节点 1 的最近公共祖先是节点 3。 来源:力扣(LeetCode) 链接:https://leetcode-...
bb1206b3d8b5e4ebd19ff4006b94e30572653541
ahmadraad97/py
/patches.py
3,268
3.59375
4
# 15 . Shapes # رسوم هندسية بالأمر matplotlib.patches # وهي تشتمل علي عدد من الاشكال : # Rectangle , Circle , Polygon , Ellipse , Arc # أمر Circle import matplotlib.patches as pat import matplotlib.pyplot as plt c = pat.Circle((0.5, 0.5),radius=0.1) ax = plt.axes() ax.add_patch(c) ...
5a4274b87e61c80a7bd8d200890db7b8de5a9b5e
ahmadraad97/py
/While.py
553
3.71875
4
n=int(input("input number:")) while n <= 10: print(n) n=n+1 print("done") while True: a=int(input("numbr?")) if a >15: print("yes") break else: print("no") print("end") n = int(input("input number ?")) while n<=100: print(n) print("Done") a ...
247c227467727c0613dcc9167bfdfb8d7a849fcf
ahmadraad97/py
/histogram.py
1,047
3.53125
4
# 6. Histogram import numpy as np import matplotlib.pyplot as plt import pandas as pd # وهو امر خاص بالتكتلات , سواء اعمدة او نقاط مثال بسيط data = np.random.randn(5000) plt.hist(data) # خصائص data = np.random.randn(5000) plt.hist(data, bins=50, normed=True, alpha=0.5,histtype='step',color='blu...
3b6e81254097ff2f79a5d73ba0d7718b849ff99c
ahmadraad97/py
/functions4.py
4,517
4.40625
4
# ومن الممكن اعطاء قيم افتراضية للدالة , بحيث يتم استخدامها اذا لم يتم تحديدها def power(m,n=3): print(m**(n)) power(3,2) # 9 # واذا لم يتم تحديدها تستخدم القيمة الافتراضية def power(m,n=3): print(m**(n)) power(3,) # 27 # وممكن اثناء استدعاء الدالة ان يتم عمل تحديد للارقام المعطاة def power(m,n)...
ef5939e7e56dc433bfb64e5b5ca8af3462e5e9ca
ahmadraad97/py
/py.str2.py
994
3.65625
4
a = "hello python" print(a[0:6:2]) # hlo(يتجاهل حرف ) print(a[:12:3]) # hlph print(a[0::4]) # hot print(a[::2]) # hlopto print(a[-1:5:1]) # hlopto print(a[-1:5:-1]) # nohtyp print(a[::-1]) # nohtyp olleh print(list(a)) # ['h', 'e', 'l', 'l', 'o', ' ', 'p', 'y', 't', 'h', 'o', 'n'] print(sorted(list(a...
03acbfba349f357b85d71f4ea0ad865a3a8fe1b1
Delcommune/initiationPython
/recap.py
2,107
3.921875
4
# I. Variables #boite qui contient une valeur (comme cellules Excell) var1 = 5 #nombre entier, integer number #integer var2 = 4.2 #nombre decimal, floating point number #float var3 = "bonjour" #chaine de caracteres, string #string var4 = True #bouleen #boolean var5 = ["bonjour", 5, 3.5] #liste (plusieurs valeurs ; el...
6852cf1faeb34ea71d6be26b9f1f5bb23617b367
murnana/ManteraStudio-ReadingCircle-DeepLearningFromScratch
/source/myModules/activator.py
679
3.546875
4
import numpy as np def step_function(x): """ 入力xに対し、0 <= x の時は 0, x > 0 の時は1を返却する ステップ関数 Parameters ---------- x: numpy.ndarray 入力xの配列 """ y = x > 0 return y.astype(np.int) def sigmoid(x): """ シグモイド関数 Parameters ---------- x: numpy.ndarray ...
4c3179b9e0046bf4a6f908728a84899f9f3685e3
ZR0W/Beginner-Python-Project-Collection
/snake/snake_w-turtle.py
4,337
3.78125
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 15 19:51:01 2019 @author: Rowland Zhang """ # imports import turtle import time import math import random class Coordinate: def __init__(self, x, y): # two dashes self.x = x self.y = y def getX(self): return self.x def getY(self): ...