blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e0ff313215b9887b63edf95f08d4417a7b8aaddd
2flcastro/python-exercises
/solutions/2flcastro/beginner/seek_and_destroy.py
2,874
3.703125
4
# ---------------------------------- # Seek and Destroy # ---------------------------------- # You will be provided with an initial list (first argument) followed by one or # more arguments. Remove all elements from the initial list that are of the # same value as these arguments. # ---------------------------------- ...
b6ef0e64841a63b6131eb7a51820b22bb459f015
kenricktendi/Python3
/increasingsquares.py
269
3.5
4
from turtle import * #Set radius value to 50 speed(1) length = 50 penup() right(45) pendown() while length < 350: circle(length, 360, 4) penup() left(45) backward(35) right(90) forward(35) left(45) pendown() length = length + 50
0868a65b239d8cba7412fc65e4198182725bcc5f
Ilona098/Simple-Python-Programs
/palindrome.py
325
4.28125
4
# The program takes a number, word or sentence and checks whether it is a palindrome or not. a = input('Input a number, word or sentence:') list = [] for i in a: list.append(i) list.reverse() rev = "".join(list) if a == rev: print(rev, ' Is a palindrome ', a) else: print(rev, ' Is not a palindrome ',...
83a73922841a5b5f930c250f56c829c77979c66a
petebunting/rsgis_scripts
/Statistics/AverageTemporalData.py
13,465
3.546875
4
#! /usr/bin/env python ####################################### # A python script to average columns of # data by time (weekly, monthly, yearly) # # Email: petebunting@mac.com # Date: 13/09/2011 # Version: 1.0 ####################################### import os.path import sys import datetime from datetime import timed...
9b9a72b99d1aff04ae968ab1f364d34f79b1caa3
gtyagi777/Problem-Solving---Algorithms-
/different corresponding bits.py
1,167
3.53125
4
<<<<<<< HEAD def sumBitDifferences(arr,n): ans = 0 # Initialize result # traverse over all bits for i in range(0, 32): # count number of elements with i'th bit set count = 0 for j in range(0,n): x = arr[j] y = 1 << i z = x & y ...
2f950cd553a53505ca6218a3db161bb3bc23da46
maisun13/CS112-Spring2012
/hw08/math_funcs.py
1,274
4.1875
4
#!/usr/bin/env python import math #The point to point function (ptop) measures the distance between a point and #another using four number unput by the user def ptop((x1, y1), (x2, y2)): distance = math.sqrt((x2 - x1)**2 + (y2 - y1)**2 + (y2 - y1)**2) return distance #Gets four number from user input x1 = in...
703f2031b52bcc317fcb6b41442b65589310b291
martakedzior/python-course
/06-operations_on_files/operations_on_files_exercise6_by_Rita.py
1,676
3.796875
4
def can_be_card_number(user_input): if not len(user_input) in [13, 15, 16]: return False if not user_input.isdigit(): return False return True def is_visa(card_number): if card_number[0] == '4' and len(card_number) in [13, 16]: return True else: return False def...
7aa18760609646c61df46294fad6444638be1edb
kscanne/1070
/kaggle/baseline.py
826
3.78125
4
#coding: utf-8 import random, re, codecs random.seed() # returns random 0 or 1 def coin_flip(): return random.randint(0,1) print 'id,label' with codecs.open('test.tsv', 'r', 'utf-8') as f: patt = re.compile(ur"[A-ZÁÉÍÓÚa-záéíóú'-]+", re.UNICODE) for row in f: pieces = row.split("\t") sentence_id = piece...
954cbca8a3e5a6fe628044504c29833e91aacefb
shakeelDS/intro_to_python
/solutions/chapter_7/f_to_c_rounded.py
612
3.6875
4
# Update the function to round to 1 decimal place def rnd_fahrenheit_to_degrees_celsius(degrees_f): degrees_c = (5 / 9) * (degrees_f - 32) return round(degrees_c, 1) rnd_fahrenheit_to_degrees_celsius(81.3) # Note the round() function has to be in the return statement. # I can also save the output of round...
c7a850933eddf83f0697b2f6c2a09ffd88ffe247
erjan/coding_exercises
/three_consecutive_odds.py
476
4.03125
4
''' Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false. ''' class Solution: def threeConsecutiveOdds(self, arr: List[int]) -> bool: n = arr found = False for i in range(len(n)-2): n1 = n[i] n2 = n[i...
13a0cfe5a9c4bd5820b27620a1285ce33495ab5e
connor-mcshane/BattleShip
/BattleShip/text_parsing_helpers.py
1,285
3.59375
4
""" non class helper functions, could have moved them into another file """ def remove_comments_and_whitespace(input_str: str): """ :param input_str: :return: a string that has all the comments from the input file removed. """ return input_str.replace(" ","").split('//')[0] def parse_initial_sta...
ae13cecbf688c569880bb932bb4a5b4e7ae09e14
andyshen55/MITx6.0001
/ps1/ps1c.py
1,782
4.0625
4
def guessRate(begin, end): #finds midpoint of the given search range and returns it as a decimal guess = ((begin + end) / 2) / 10000.0 return guess def findSaveRate(starting_salary): #program constants portion_down_payment = 0.25 total_cost = 1000000 down = total_cost * portion_down_payment...
bdb1a016fb7dcc14804c189a8235e9c4fe1bc362
ksoftlabs/labsheets1001
/Sorting/Bubble Sort/Bubble Sort (using while loop).py
375
3.828125
4
list = [15,2,158,184,12,5413,216,3,2156,154,55] sorted=False count=0 while (not sorted): sorted=True for element in range (0,len(list)-1): count=count+1 if list[element] > list[element+1]: sorted=False temp=list[element] list[element]=list[element+1] ...
5d56cac630173f80036e65f41bb4c5ba1b8a0429
1131057908/yuke
/7.11/字典.py
3,395
3.53125
4
# 字典:也是python中内置的一种容器类型,字典是可变的也可以对字典增删改查的操作 # 字典的特点 # 字典是以'键-值'结构来储存数据,字典没有索引这个概念 键相对于列表中的索引 可以通过键对一个数据 # 进行增删改查 # 列表中索引值是唯一的 键也是唯一的 都不允许重复 # 字典是无序的,键-值 对的储存没有先后顺序,只需一个键对应一个值 # 声明一个空字典 dict1={} # 计算机内存中True=1,false=0 dict3中1与True发生键冲突 1 0 不能同时为字典的键 # 列表 字典不可当做键 元组可做键 因为通常情况下键不可变 但是列表 字典可变的,但是元组不可变的所以可做键 # 声明一个...
b0b01c37576d2f6a3721020be70043004d96ee05
LfjrB/python3
/ex009.py
171
3.9375
4
n = int(input('Digite um número a ser multiplicado: ')) i = 0 print('--------------------') while i <= 10: print('{} x {:2} = {}'.format(n, i, (n * i))) i = i + 1
e726d0d898cfcc26741b8f6c231454d28ec2829a
tristanjin/ML
/Crwaling/crawling/matplot.py
336
3.65625
4
import matplotlib.pyplot as plt import numpy as np x = [1,2,3] y = [1,2,3] plt.plot(x,y) plt.title("My plot") plt.xlabel("X") plt.ylabel("Y") #plt.savefig('pic.png') x = np.linspace(0, np.pi * 10, 500) fig, axes = plt.subplots(2, 1) # 2 graphs figures axes[0].plot(x, np.sin(x)) axes[1].plot(x, np.cos(x)) #fig.savefig...
3f65a24580ed767929bae5f8f3c74d4e6634846d
Mobius5150/C115_Logic_Analyzer
/testsolve.py
807
3.609375
4
from matrix import Matrix from solve import * """ Unit testing to make sure that the solver runs right during development. """ def test_function(f, inputcount): """ Analyse a given function with a single output, and print the resulting simplification """ M = Matrix(2**inputcount, inputcount+1) for row in rang...
c8a91456ce025727a7b11ca9f3f575139eeae4df
way2arun/datastructures_algorithms
/src/integers/bitwiseComplement.py
2,343
3.609375
4
""" Complement of Base 10 Integer Every non-negative integer N has a binary representation. For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on. Note that except for N = 0, there are no leading zeroes in any binary representation. The complement of a binary representation is the n...
8b9bea85fa0285cc948db8e254913a1dc270c67d
cooshko/PythonHomework
/算法/quick_sort.py
2,246
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Author : Coosh # @File : quick_sort.py from verify import * quick_loop_times = 0 def algorithm(l: list, *args, **kwargs): global quick_loop_times left = kwargs.get('left', 0) right = kwargs.get('right', len(l)-1) if right > left: i = left...
32c97e45cae18d7bc1ff1fd155ee1cb7328a7a2e
michal-cab/python-lessons
/geom_python.py
786
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ basic geometry showed with pygame """ import pygame background = (0,0,0) (wid, hei) = (640,480) screen = pygame.display.set_mode((wid, hei)) clock = pygame.time.Clock() loop = True pygame.display.set_caption('basic geometry') screen.fill(background) def draw_point(...
cfe09cba582ad6cdbfd8440b7fba6d263f12d1f8
rahuldbhadange/Python
/Python/__loop/_for loop/basic.py
1,444
4.78125
5
# Loops # Loops are a way to repeatedly execute some code. Here's an example: Galaxy = "Milky Way" planets = ["Sun - रवि/सूर्य", 'Mercury - बुध', 'Venus - शुक्र', 'Earth - पृथ्वी', 'Mars - मंगल/मंगळ', 'Jupiter - गुरू/बृहस्पति', 'Saturn - शनि', 'Uranus - अरुण', 'Neptune - वरुण', "Pluto - यम", "Moon...
9930acf4c7031128811b2354986c366dad7c4c10
4350pChris/AdventOfCode
/2018/2/main.py
860
3.90625
4
def getInput(): with open('2/input') as f: return f.readlines() def getOccurenceDict(line: str) -> dict: return {char: line.count(char) for char in line} def part1(): input = getInput() parsed = [getOccurenceDict(l) for l in input] two = [p for p in parsed if 2 in p.values()] three =...
c7eb82f257872147f7d92eda7ae43205c7bb672b
angiet30/ICTPRG-Python
/Python W5 quiz.py
1,475
3.765625
4
#values = [66,43,1,6,2,99,4] #for k in values: # if k < 10: # print(k) #DOB = input ("Date of Birth dd/mm/yyyy: ") #first_split, last_split = DOB.find("/"), DOB.rfind("/") #day = DOB[:first_split] #month = DOB[first_split+1:last_split] #year = DOB[last_split+1:] #print("Day: ",day) #print("Month: ",month) #...
ee9b02a57aac8a52be176de61957203c91ff0cec
aggy07/Leetcode
/1000-1100q/1043.py
1,119
3.8125
4
''' Given an integer array A, you partition the array into (contiguous) subarrays of length at most K. After partitioning, each subarray has their values changed to become the maximum value of that subarray. Return the largest sum of the given array after partitioning. Example 1: Input: A = [1,15,7,9,2,5,10], K ...
be2fdb9f0699af775247ad180cdb539643ba79e0
intuited/labelxml
/dump.py
2,082
3.640625
4
"""Various routines to dump the price data. These use an 'options' object as constructed by the main argument parser. """ class DataValidationError(Exception): pass def process_page(page): """Validates and processes a page in dictionary format.""" page_numbers = page['Page Number in .odt Source'] if ...
529d44fc160f1441ea964429a79cbd2a9ca926b6
Crazy-Jack/Flight-Price-Tracker
/tracker.py
5,299
4.25
4
""" 1. Define terminology: 1) plan: a plan is an instance of a Plan class. Each plan has the following attributes: Time(a Time instance which has 2 attributes, Departure time and Landing time), Location(a Location instance which has 2 attributes: Departure place and the Landing place), Price-range(also a instance w...
82eb292302ba537910c4fb57b9085d747962d6c5
SERC-L1-Intro-Programming/python-examples
/week4/coin_flip_streaks.py
1,181
3.96875
4
# Possible solution to coin flip streaks exercise. # Program generates series of coin flips and checks for streaks of heads or tails # in that series. import random FLIPS = 100 STREAK_LENGTH = 6 EXPERIMENTS = 10000 def coin_flip(): ''' function returns a random "H" for heads or "T" for tails ''' if rando...
45abd246c0c02a2668f01d6fc6c44bd21733b345
animal104/Python_Samples
/Python-by-Gladdis/Chapter 5/SaineMichaelM03_Ch5Ex12.py
3,377
4.4375
4
#Mickey "Plegius the Wise" Saine #SDEV 140 # This program is designed implement a function named max that accepts two integer values as arguments and returns the value that is greater of the two #27 September 2020 import time import datetime import math def intro(): #Create my first fu...
c5d3410ba72391e12687c314abf7cfa6e7080e59
adalee2future/learn-python
/empty_and_single_value_tuples.py
233
3.71875
4
# empty tuple empty_tuple = () print empty_tuple # a tuple containing a single value single_value_tuple = (1, ) print single_value_tuple # '+' num_tuple = (1, 2, 3) string_tuple = ('orange', 'apple') print num_tuple + string_tuple
3b970f9decbe998f6029003b2e9e64c7b93bd3cb
stasvorosh/pythonintask
/IVTa/2014/AMETOVA_M_M/task_3_49.py
1,142
4.0625
4
# 3. 49 # , " ", # . , # . # Ametova M. M. # 31.03.2016 name = " " psname = " " print(name, " - , , .") answer = input("\n : ") while answer.find(psname) == -1 and answer.find("0") == -1: print(answer, "- .", name, " .") answer = input("\n ( \"0\" ): ") if answer.find(ps...
48c21a15f9a1f199a9428d26a9a9429bc1f484bf
kinpa200296/python_labs
/lab2/myclasses/lab2_task3/vector.py
1,736
3.9375
4
#!/usr/bin/env python from numbers import Number from math import sqrt __author__ = 'kinpa200296' class Vector(object): def __init__(self, *args): if len(args) == 1 and isinstance(args[0], list): data = args[0] else: data = args if any([not isinstance(value, Numb...
6e0c213a731e32fadccae66651c357af55c4ceda
emmyblessing/alx-higher_level_programming
/0x03-python-data_structures/0-print_list_integer.py
199
4.46875
4
#!/usr/bin/python3 def print_list_integer(my_list=[]): """ A function that prints all integers of a list. """ for i in range(len(my_list)): print("{:d}".format(my_list[i]))
c57fac67edc633b2a80971d1db5da4d5da7a907c
Danielporcela/Meus-exercicios-phyton
/voçe advinha o numero que o comp escolheu de 0 a 5 .py
1,073
4.25
4
#Escreva um programa que faça o computador "pensar" em um número inteiro entre 0 e 5 e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador. O programa deverá escrever na tela se o usuário venceu ou perdeu. from random import randint from time import sleep # tempo pra aparecer resultado com...
38490eb549827af6db7627b62cd27c5d93467f2d
amcosta/python-w3school
/imprimindo-pares.py
169
3.953125
4
limite = int(input('Digite um número: ')) posicao = 1 while posicao <= limite: if posicao % 2 == 0: print('Número: {:d}'.format(posicao)) posicao += 1
02eefa947b4ec2e59c1b04cc68e4aa476d52fdf1
SamanehGhafouri/Data-Structures-and-Algorithms-in-python
/Experiments/comparing_objects.py
1,256
4
4
class Table: def __init__(self, height:int, legs:int, material:str): self.height = height self.legs = legs self.material = material def __eq__(self, other: 'Table'): b_h = self.height == other.height b_l = self.legs == other.legs b_m = self.material == other.mat...
33a4c5395d938a566af03506aa6ebb575cf62757
matkre/Python--w
/python - ćwiczenia/ćw2/zadanie_1.py
138
3.84375
4
od = int(input("Od: ")) do = int(input("Do: ")) co_ile = int(input("Co ile przeskok: ")) while (od <= do): print(od) od = od + co_ile
a87aef00a022e226a160ce1d2b899ac5aa6556d9
byAbaddon/Basics-Course-Python-November-2020
/4.2 Loops Part2 Lab/03-sumNumbers.py
163
3.84375
4
sum_num = int(input()) increase_num = 0 while True: increase_num += int(input()) if sum_num <= increase_num: print(increase_num) break
f114c216a646f128699561b0a8f9e85c1f43ece7
ddaypunk/tw-backup
/Python/small apps/couter_csv.py
161
3.640625
4
import csv row_count = 1 with open('file1.xlsx','rb') as f: reader = csv.reader(f) for row in reader: print "Row " + row_count + " count: " + str(len(row))
81b4b267469ba59fba737f4d332d106c7f196f04
mhinojosa24/Jack-Sparrow-Tweet-Generator
/cleanup.py
786
3.9375
4
def cleanup(source_text): '''This method cleans the text document''' with open(source_text, 'r') as f: # text_body = f.read().decode('utf-8', 'replace') text_body = f.read() removed_new_lines = text_body.replace('\n', '') removed_commas = removed_new_lines.replace(',', ' ') remov...
6e5b1422611136e6526c6e0299b5f57f05fd193c
eisenbar/MTH-325-Project
/Dijkstra.py
1,559
3.65625
4
def infty(graph): total = 0 for node in graph: for relation in graph[node]: total += (relation[1]) total = total/2+1 return (int(total)) def initial(graph): start = {} for node in graph: if node == "A": start[node] = 0 else: start[no...
4fcb292d355c2d26cbaef330339118a3ad873e0b
LRBeaver/WebProgrammingPython35
/function_intro.py
579
4.09375
4
## SQUARE # def square(num): # return num * num # # number = 12 # print(square(number)) ## CONVERT # def convertTemp(temp, scale): # if scale == "c": # return (temp - 32.0) * (5.0/9.0) # elif scale == "f": # return temp * 9.0/5.0 + 32 # # temp = int(input("Enter a temperature: ")) # scale ...
2a0e2b09d15356d311c55be59cb4101f88005a19
pgrobban/Scripts
/sum_100.py
954
3.765625
4
# Write a program that outputs all possibilities to put + or - or nothing between the numbers 1, 2, ..., 9 # (in this order) such that the result is always 100. For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100. # naive approach # author: Robert Sebescen (pgrobban at gmail dot com) import itertools all_combinations = [...
2c2baae35a112a281fd9a9c383b5a42b0718af02
Dave11233/leetcode
/leetcode/leetcode287.py
572
3.859375
4
class Solution: def findDuplicate(self, nums): def helper(nums_list): if len(nums_list) < 2: return nums_list else: pivot = nums_list[0] less_than_pivot = [x for x in nums_list[1:] if x <= pivot] more_than_pivot = [x for...
c90413f384c18d79af969b419a016897c769d94a
burakbayramli/books
/Introduction_to_numerical_programming_using_Python_and_CPP_Beu/Ch06/Python/P06-NewtonSys1.py
894
3.796875
4
# Intersection of circle and parabola from math import * from roots import * def Func(f, x, n): # zeros: (-2.295, 2.267), (2.583, 3.673) f[1] = pow(x[1]-1,2) + x[2]*x[2] - 16e0 f[2] = x[1]*x[1] - x[2] - 3e0 # main n = 2 f = [0]*(n+1) x = [0]*(n+1) dx = [0]*(n+1) x[1] = -5e0; x...
a98b6474a90172140a912dc842ea6a623a9bd8e1
qqmadeinchina/myhomeocde
/homework_zero_class/lesson3/布尔值_times_1.py
329
3.609375
4
# -*- coding: utf-8 -*- # @time :2020/7/10 16:36 # @Author:老萝卜 # @file:布尔值_times_1 # @Software:%{PRODUICT_NAME} print(1 + 2) # print(1 + 'hello') # 报错: TypeError: unsupported operand type(s) for +: 'int' and 'str' print(1 + True) print(1 + False) # 死循环 # while 1: # pass # # while True: # pass
a5cf7b4f99edbe96edd043cc147b1724fcf07df4
andikscript/facedetector
/accesswebcam.py
948
3.65625
4
""" Simply display the contents of the webcam with optional mirroring using OpenCV via the new Pythonic cv2 interface. Press <esc> to quit. """ import cv2 def show_webcam(mirror=False): cam = cv2.VideoCapture(0) gambar = 1 while True: ret_val, img = cam.read() if mirror: img...
3f214427446f34369159a18ff43c2cef20df20bb
AdamZhouSE/pythonHomework
/Code/CodeRecords/2839/60720/237083.py
225
3.640625
4
size=int(input()) list=[0]*size for i in range(size): isY=False list[i]=input() for j in range(i): if list[i]==list[j]: isY=True if(isY): print('YES') else: print('NO')
586e7b60cbd4dfe3f3367f40ac4d9fb5edef05a0
sahayajessemonisha/python-programming
/beginner/swap program.py
128
3.890625
4
x=37 y=73 s=x x=y y=s print('the values of x after swapping:{}'.format(x)) print('the values of y after swapping:{}'.format(y))
acbf28473edac07a1f1cc8904c9ab960867aac4e
navik03/Application_opener_Python
/app.py
1,915
3.96875
4
import tkinter as tk #for gui from tkinter import filedialog,Text #for text and all import os #for runnig apps root = tk.Tk()# it is where all the screen is place #adding all the files into an array apps=[] if os.path.isfile('save.txt'): with open('save.txt','r') as f: tempApps = f.read() ...
007e16dac7a2fb568fb806ac3ad88c7f01318950
MarceloVasselai/pythonDesafios
/Desafio03.py
139
3.828125
4
num1 = int(input('Primeiro número: ')) num2 = int(input('Segundo número: ')) tot = int(num1+num2) print(num1, ' + ', num2, ' = ', tot)
e0110f5b5734529b019afd8c1d69af5f31b0ba61
raffccc/pythonStudy
/learnPythonTheHardWay/ex48/lexicon.py
1,051
3.875
4
from string import lower lexicon = { 'direction': [ 'north', 'south', 'east', 'west', 'down', 'up', 'left', 'right', 'back' ], 'verb': [ 'go', 'stop', 'kill', 'eat' ], 'stop': [ 'the', 'in', 'of', 'from', 'at', 'it' ], 'noun': [ 'door', 'bear', 'princess', 'cabinet' ] } d...
02b6c2b01404655d80cfb02626adc427307c5b16
udayt-7/Python-Assignments
/Assignment_2_Lists_Dictionaries/lists/a2p7.py
496
4.1875
4
# to find union and intersection of the list a = int(input("enter the range of list 1: ")) b = int(input("enter the range of list 2: ")) l1 = [] l2 = [] l3 = [] for ch in range(a): a2 = int(input("enter the list 1: ")) l1.append(a2) for ch2 in range(b): b2 = int(input("enter the list 2: ")) l2.append(b2)...
8695d7bccdf8ac2510f5ada52345f80028744bc1
T3chn3/HFP
/hfp6.py
1,722
3.875
4
#Dictionary and Class usage and examples #cleaning up the input values def sanitize(time_string): if '-' in time_string: splitter = '-' elif ':' in time_string: splitter = ':' else: return time_string (mins, secs) = time_string.split(splitter) return(mins + '.' + secs) ...
b08a3063879c015faea5f7ef3bd3a08e32db29a3
paavonelimarkka/basket
/unit_tests.py
2,087
3.796875
4
# We need to import unittest library and the class we are testing import unittest from ohjelma import Basket import numbers # We need to create a new testcase class by inheriting unittest.TestCase class BasketTests(unittest.TestCase): # Setup method to create a test object def setUp(self): self.keijo...
3680745d78067fab243045c57311477f523b785c
LegendsIta/Python-Tips-Tricks
/number/is_even.py
145
4.1875
4
def is_even(num): return True if num % 2 == 0 else False n = 1 print(is_even(n)) n = 2 print(is_even(n)) # - OUTPUT - # #» False #» True
8e727cc5d0e95b96bc570214dcfa6cb08400e57d
opsahl/programming
/python/euler19.py
312
3.640625
4
import datetime as dt date = dt.date(1901, 1, 1) one_day = dt.timedelta(days = 1) sundays = [] while date.year != 2001: if date.weekday() == 6: sundays.append(date) date += one_day first_of_month_sundays = [sunday for sunday in sundays if sunday.day == 1] print(len(first_of_month_sundays))
874ec48e1f3dc9819c2581566769d9ced254d7c7
darek526/ProgramyPython
/Wyklady/Wykład_2019_11_27/slowniki.py
581
3.609375
4
slownik_1={1:"a", "ala":128, 21:"kot"} print(slownik_1) #klucz pierwsza wartośc musi być wartością nie mutowalną #dodawanie elementów do słownika slownik_1["nowy_klucz"]=1.8 slownik_1["ala"]=12 slownik_1[1]="bc" print(slownik_1) #funkcja zwraca słownik opisujący superpozycję funkcji zadanych #słownikiem f_1 ...
626d68257f9f8b40400f42bb20d89e1e6a335936
carlosjsanch3z/ejercicio_json
/enun2.py
830
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 2.Muestra el número de hoteles que existen por numeros de estrellas que tengan import json with open("hoteles.json") as fichero: datos = json.load(fichero) fivestarts = 0 fourstarts = 0 threestarts = 0 twostarts = 0 onestart = 0 for d in datos["resources"]: if d["...
2e3d3a7109dcd1af3306f2b8a65101146f533af3
Lilhy123/PracticasTeoria
/tercerparcial/correo.py
347
3.765625
4
import re while True: expresion = r'([a-z]+||[0-9]+)(\@)([a-z]+||[0-9]+)(\.)([a-z]+)' resultado = re.compile(expresion) prueba = raw_input("entrada: ") busqueda = re.search(resultado,prueba) if prueba=="": break if busqueda: print "qA" print prueba ...
5f6f00579c46a826953a80713ed55352751aee2f
juanignaciolagos/python
/05-Condicionales/main.py
2,581
4.21875
4
""" Si se cumple esta funcion se ejecuta un conjunto de instrucciones Si NO se cumple se ejecuta otro grupo ejemplo python: If condicion: instrucciones else: instrucciones operadores de comparacion: == igual != diferente < menor que > mayor que <= menor o igual que >= mayor o igual que operadores logicos...
482f53d32cc747b2e053d91bdbb37fa472b8f42b
LucasSchinzari/Code-Industry
/adv set operations Exercise.py
392
4.40625
4
nearby_people = {'Rolf', 'Jen', 'Anna'} user_friends = set() # This is an empty set, like {} # Ask the user for the name of a friend ask_user = input('Write a name of a friend: ') # Add the name to the empty set user_friends.add(ask_user) # Print out the intersection between both sets. This gives us a set with those ...
e253532d5f4613ebb2dbfecea04da393b3088f19
erikliu0801/leetcode
/python3/solved/P653. Two Sum IV - Input is a BST.py
2,230
3.65625
4
# ToDo: """ 653. Two Sum IV - Input is a BST Easy Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. Example 1: Input: [5,3,6,2,4,null,7] 5 / \ 3 6 / \ \ 2 4 7 Target = 9 Output: True Example 2: Inpu...
56709bf73659aec5981fe75378a2e18f9fd14757
RAJKUMAR0003/python_codes
/perfect_square.py
216
4
4
from math import sqrt,floor n=int(input('enter a no upto which you wanna print the perfect square no ')) for i in range(1,n+1): a= sqrt(int(i)) if(a-floor(a)==0): print(int(i),end= ' ')
9d9e06cabcd72bb5eddd04ea88d079f34f9419e2
MaesterPycoder/Python_Programming_Language
/codelist1/Codevita9_p3.py
3,869
3.71875
4
global sm_shirt global sm_shoe global s_shirt global s_shoe global total_cost global shirt_cost global shoe_cost def total_bill(): if __name__ == '__main__': sm_shirt = 0 sm_shoe = 0 s_shirt = 0 s_shoe = 0 total_cost = 0 shirt_cost = 0 shoe_cost = 0 for _ in range(int(input("...
28744cd8b93d2e88906050d363608a172110d460
commonsense/csc-utils
/csc_utils/batch.py
9,675
3.53125
4
import itertools def chunk(seq, chunk_size): ''' Chunk a sequence into batches of a given size. The chunks are iterators (see itertools.groupby). ''' # Based on a strategy on http://code.activestate.com/recipes/303279/ c = itertools.count() for k, g in itertools.groupby(seq, lambda x: c.nex...
bc9e106c5020861bae8c9475235b74a506a17f45
Mewwws/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/1-search_replace.py
213
4.03125
4
#!/usr/bin/python3 def search_replace(my_list, search, replace): rep = [] for i in my_list: if i == search: rep.append(replace) else: rep.append(i) return (rep)
9127a18641f743e6daeb286999a8e7eab3f3600a
jonbrohauge/pySudokuSolver
/board.py
1,589
4.375
4
class Board(object): """This class defines the board""" def __init__(self, board_size): """The initializer for the class""" self.board_size = board_size self.board = [] for index in range(0, self.board_size): self.board.append(['0'] * self.board_size) def is_on...
04aea6814dbea7f774f4be34166923697d6c38d4
pzelnip/datasci
/src/first_assn/frequency.py
1,671
3.984375
4
''' Assignment 1, Problem 4 -- compute term frequency Created on May 6, 2013 @author: aparkin ''' import sys import json from collections import Counter def read_tweets_from_file(tweet_file): ''' Given a file containing raw JSON as returned by the Twitter API, returns a list of extracted tweets ''...
7e82656ef20a444434684c58b1d5760e92107ec8
IMLaoJI/python_flask
/flask原理剖析/s7day141/s4.py
307
3.734375
4
from itertools import chain # def f1(x): # return x + 1 # # func1_list = [f1,lambda x:x-1] # # def f2(x): # return x + 10 # # # new_fun_list = chain([f2],func1_list) # for func in new_fun_list: # print(func) v1 = [11,22,33] v2 = [44,55,66] new = chain(v1,v2) for item in new: print(item)
b28b4d568536e053823bb6740d2d2a7be56aced9
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/bash-commands-walkthrough/steps/4-create-indexhtml/DS-ALGO-OFFICIAL-master/CONTENT/DS-n-Algos/_Extra-Practice/30-days-of-code-master/day8_dictionariesmaps.py
576
3.640625
4
def getphonebook(n): phonebook = {} for x in range(n): line = input().strip().split(" ") name = line[0] number = line[1] phonebook[name] = number return phonebook if __name__ == "__main__": numberofentries = int(input()) phonebook = getphonebook(numberofentries) ...
382ee779e99c8ba84e9431e83d9537bb8cd14bd0
PeterWolf-tw/ESOE-CS101-2015
/B04505044_HW03.py
397
3.90625
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- def charFreqLister(STR): LIST = [] for i in STR: x = STR.count(i) if (float('%.3f'%(x/len(STR))),i) not in LIST: LIST.append((float('%.3f'%(x/len(STR))),i)) LIST.sort(reverse=True) return LIST if __name__== "__main__"...
6334e309d844b61974551b28ae3c68aac36ff59b
stacy-s/Clustering
/K_means.py
1,454
3.84375
4
""" The module of work with the k-means clustering algorithm """ from sklearn.datasets import make_blobs, make_moons, make_circles from sklearn.cluster import KMeans import tkinter import matplotlib.pyplot as plt import mglearn def build_data(kmeans, points, cnt_clusters): """ The function draws the result of...
7341dbca97aa918410d9e18f066371bd28eeda10
BalajiG2000/PhoneBook
/phonebook.py
13,947
3.71875
4
from Tkinter import * import intro_me #importing the file into_me to show the information about myself from tkMessageBox import * import tkFont import sqlite3 root=Tk() #main root window con=sqlite3.Connection('PHONEBOOK_DATABASE1') #connection with database cur=con.cursor() cur.execute("PRAGMA foreign_keys=O...
a8d8a067f39735d3d18acc108bfe0d04aab71605
OLP-FOSS/OLP-FOSS-2018
/bkm3t_DHBKHN/Cau2/Product/service_predict/utils.py
923
3.578125
4
import numpy as np def magnitude(x, y, z): """ Magnitude signal computed from the previous three signals. This magnitude is computed as the square root of the sum of squared components (accelerometer signals). :param ax: :param ay: :param az: :return: """ x2 = np.square(x) ...
b072d9d7efa2954168b3bb4e5fef4004c72c96f7
REDBEANCAKE-LI/ud120-projects
/datasets_questions/explore_enron_data.py
2,237
3.6875
4
#!/usr/bin/python """ Starter code for exploring the Enron dataset (emails + finances); loads up the dataset (pickled dict of dicts). The dataset has the form: enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict } {features_dict} is a dictionary of features associated with that pers...
a5e13c9d98d3cfd8a84538b1754b1a664de5b82b
StefanS97/free-time-fun-python
/human_readable_time.py
391
3.765625
4
def make_readable(seconds): if seconds >= 0 and seconds <= 359999: hrs = seconds // 3600 seconds %= 3600 mins = seconds // 60 seconds %= 60 secs = seconds hour = str('{:02d}'.format(hrs)) minute = str('{:02d}'.format(mins)) second = str('{:02d}'.format...
3eccaa91e943264862f5093c7a49ecff8f95e601
Aman221/HackHighSchool
/Parseltongue Piscine/Parseltongue Piscine Part 3/01_guess.py
1,630
3.859375
4
garray = ["dough", "fight", "light", "world", "anime", "super"] import random word = random.randint(1,6) if word == 1: cat = garray[0] ultimate_first = cat[:1] print "The first letter of the word is " + ultimate_first + " . Start guessing!" if word == 2: cat = garray[1] ultimate_first = cat[:1] print "The firs...
5583e522183803e6c737a66243812edc3c1c5323
vanduong0504/PASSWORD
/main.py
1,030
3.5625
4
import requests import hashlib def read_txt(file): with open(file, mode='r') as file: output = file.read().splitlines() return output def convert_SHA1(string): SHA1 = hashlib.sha1(string.encode()).hexdigest().upper() return SHA1[0:5], SHA1[5:] def get_response(char): url = 'https://api...
ee4cd51cbf1d7f80735a641d6671f56c96c1222a
szhongren/leetcode
/patching_array/main.py
2,478
3.625
4
""" Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required. Example 1: nums = [1, 3], n = 6 Return 1. Combinations of nums a...
0841168696987ae33e26f951bab9407c7768ae5f
UCAS-BigBird/Algorithm
/S11.py
798
3.828125
4
class Solution: def rotate(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ if len(matrix)==0: return 0 h=len(matrix) w=len(matrix[0]) #下面这三行情诗 是交换矩阵 让其沿着对角方向进行变化 for...
8538b8798d9dbb883b88fee734fc9e79136ec763
pakoy3k/MoreCodes-Python
/Easy Problems/problem13.py
146
4.15625
4
#Problem 13: Write a program that outputs the length #of the string. word = "MoreCodes" strLength = len(word) print("String Length: ", strLength)
cbfe47ef8bd0eb8298b0d44d1799cdd69a0c087f
RShveda/pygame-practice
/draw_unicorn.py
5,993
3.65625
4
"""assignment to draw a picture as here: http://cs.mipt.ru/python/images/lab4/10_2.png""" import pygame from pygame.draw import * pygame.init() FPS = 30 WIDTH, HEIGHT = 400, 600 # environment colors blue = (54, 247, 244) green = (57, 250, 27) yellow = (240, 255, 33) # tree colors dark_green = (33, 148, 52) white_g...
db628b9f40a2c1541860125dd964b8059f619237
NinaKumpss/Exercises
/01-basic-python/05-strings/04-word-count/student.py
248
3.765625
4
# Write your code here def word_count(string): #removing spaces from start to end zin = string.strip() count = 1 for i in zin: #als er een spatie is, count +1 doen if i == " ": count += 1 return count
b6ed48a75a4ecb229a73a5b0d3b1b32c7c5c0ec7
tevdevelops/object-oriented
/hw5/hw5problem1_soln.py
4,034
3.75
4
""" Author: Tevin Rivera Solution module for Homework 5, Problem 1 Object Oriented Programming (50:198:113), Spring 2016 No documentation included due to time constraints! """ import math class Point: def __init__(self, init_x = 0, init_y = 0): self.x = init_x self.y = init_y def translate(s...
cb5dfb686cc23ac65b1de6142064d14a12e32d5b
medashiva/pybasics
/encapsulation.py
588
3.765625
4
class speed: def __init__(self): self.speed=10 self.__speed_limit=20 #private variable self.distance=900 def getspeed(self): print(s.distance) return self.speed def setspeedlimit(self,newspeedlimit): self.__speed_limit=newspeedlimit def getspeedlimit(self):...
99d421d796a99df59f14539f7835e1f3f4be10df
ostrowto/python
/Small_examples/file_open_word_counter.py
170
3.59375
4
# file_open_word_counter.py from collections import Counter with open('file.txt') as txt_file: wordcount = Counter(txt_file.read().split()) print(len(wordcount))
05e30bc244d2d231da10ca7ed4d15b5f47108b51
mhichen/problems
/Chapter1/problem1.py
1,367
4.125
4
#!/usr/bin/python3 # ***************************************************** # Takes an integer and returns another integer that is # the floor of the square root of the input # ***************************************************** def floor_of_square_root_of(in_num): # Set the upper bound as input, lower bound ...
ae9ef0332b1e83c5167642c78422c434d3327eb1
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/bcoates/lesson04/trigrams.py
2,343
4.15625
4
#!/usr/bin/env python3 import sys import random def read_in_data(filename): """ Open a file and return the contents """ with open(filename, "r") as input: for line in input: content = input.read() return content def make_words(content): """ Take a string of text and return a list ...
acb52a21a8a621b74a896437da66e46c48de43f0
touhiduzzaman-tuhin/python-code-university-life
/Practice_Anisul/57.py
288
3.984375
4
x = int(input("Enter Your Marks : ")) if 80 <= x <= 100: print("A+") elif 70 <= x <= 79: print("A") elif 60 <= x <= 69: print("A-") elif 50 <= x <= 59: print("B") elif 40 <= x <= 49: print("C") elif 330 <= x <= 39: print("D") else: print("Fail")
95d49803cd8f669a8140a68758952583b398d365
ros-planning/moveit_tutorials
/_scripts/tutorialformatter.py
7,405
3.9375
4
""" tutorialformatter =========================== This extension provides a directive to include a source code file in a document, but with certain comments from the file formatted as regular document text. This allows code for a tutorial to look like: /// BEGIN_TUTORIAL /// This ...
acd6d0558cd7eb5a62d87703e6df17dbdf28498b
green-fox-academy/attilavaczy
/python-practice/22.py
269
3.515625
4
v = [1, 2, 3] out = 0 if len(v) == 1: out = 1 elif len(v) == 2: out = 2 elif len(v) > 2: out = 10 else: out = -1 print(out) #ver if len(v) == 0: out = -1 elif len(v) == 1: out = 1 elif len(v) == 2: out = 2 else: out = 10 print(out)
e6e2a64ce93c9b8ada109d551679f9c80c198e01
ctlnwtkns/itc_110
/abs_hw/ch1/hello.py
482
4.15625
4
#From Automate the Boring Stuff with Python Ch 1 Lesson 3 "Your First Program" #https://automatetheboringstuff.com/chapter1/ #This program says hello and asks for my name. print('Hello World!') print('What is your name?') #ask for their name myName = input() print('It is good to meet you ' + myName) print('The length...
c28fd1ca2d106317a440cf03c2e8e61234c28118
Viserius/Python4Everybody
/chapter2/5-celsiustofahrenheit.py
130
4.0625
4
temp = float(input('Enter the temperature in Celsius: ')) temp = temp * 1.8 + 32 print('The temperature in Fahrenheit is:', temp)
386bc1baaa5a2203e0edd3320838267b0ab27623
GreatBahram/exercism-python
/anagram/anagram.py
433
3.953125
4
from typing import List def detect_anagrams(word: str, possible: List[str]) -> List[str]: return [ candidate for candidate in possible if is_anagram(word, candidate) ] def is_anagram(word1: str, word2: str) -> bool: word1, word2 = word1.lower(), word2.lower() has_same_letters...
4f8a2c3640cf33752b801e9658cc76b0ad763c9d
rafaelperazzo/programacao-web
/moodledata/vpl_data/8/usersdata/97/3858/submittedfiles/imc.py
357
3.875
4
# -*- coding: utf-8 -*- from __future__ import division p=input('Digite o peso em quilos:') h=input('Digite a altura em metros:') imc==(p)/(h**2) if imc<20: print('abaixo do peso') elif 20<=imc<=25: print('peso normal') elif 25<imc<=30: print('sobrepeso') elif 30<imc<=40: print('obesidade') elif imc>...
163ae043b2e0ed63d32f12b0f3ac18a863aebf92
JohanEddeland/advent_of_code
/2017/05/aoc_05.py
1,111
3.953125
4
""" aoc_05.py Solution for Advent of Code 2017 day 05 """ import math import aoc_05_input def execute(instructions, dec_limit=math.inf): ''' execute(instructions) Executes the given list of instructions and print the number of steps it took to get out of the list. dec_limit is the...
d311ce7342b180dbcccac151aa4d3291629d335e
UI-Mario/KF
/KF.py
9,723
3.78125
4
import numbers import numpy as np import matplotlib.pyplot as plt import math # 卡尔曼滤波器需要调用的矩阵类 class Matrix(object): # 构造矩阵 def __init__(self, grid): self.g = np.array(grid) self.h = len(grid) self.w = len(grid[0]) # 单位矩阵 def identity(n): return Matrix(...
1412db653710386fe56d9feedd015169bdaca5ed
daminisatya/MITx-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python
/ProblemSet02/payingDebt.py
433
3.796875
4
monthlyPayment = 10 monthlyInterestRate = annualInterestRate/12 newbalance = balance - 10 while newbalance > 0: monthlyPayment += 10 newbalance = balance month = 0 while month < 12 and newbalance > 0: month += 1 newbalance -= monthlyPayment interest = monthlyInterestRate * newbal...
ed69a35952cdd1b5fe96531e0242163ee3b8956f
scottdao/linux
/python/pandas_test.py
1,241
3.53125
4
from pandas import Series,DataFrame import pandas as pd # obj = Series([4,5,6,-7]) # print(obj) # print(obj.index) # # print(obj.values) # --> index # obj2 = Series([4,7,3,1], index=['a', 'b', 'c', 'd']) # print(obj2) # obj2['a'] = 7 # print(obj2) # print('a' in obj2) #$data = { # 'beijing':1233, #} data...
9e094f75f60bf5e1f926162188effa48fb9b8ccf
Sachin-Wani/algorithms-stanford
/part_1/assignment_6_2_median_maintenance/app/median_maintainer.py
1,598
3.765625
4
from part_1.assignment_6_2_median_maintenance.app.heap import Heap class MedianMaintainer: def __init__(self, input_file=None, input_array=None): self._heap_low = Heap(key=lambda x: -x) self._heap_high = Heap() self._median_sum = 0 self.input_file = input_file self.input_ar...