blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
12b846aec3683597dbac24f4e0fbead63b7db42d
Asko24/pp1-pythonprojects
/06-ClassesAndObjects/13.py
1,178
3.5
4
class TV(): def __init__(self): self.is_on=0 self.channels=[] def on(self): self.is_on=1 def off(self): self.is_on=0 def show_status(self): if self.is_on==1: print('Telewizor jest włączony',end=', ') e...
07143726be6cde7bc29618e196fa2fe13abb2778
WChurchill/search_workshop
/src/bidirectional.py
2,711
3.9375
4
from Maze import Maze class SearchNode(): def __init__(self, state, parent): self.state = state self.parent = parent MAZE_SIZE = 20 maze = Maze(MAZE_SIZE, MAZE_SIZE) goal_test = maze.getTerminalFunc() successors = maze.getSuccessorFunc() goal_node_start = SearchNode((0, 0), None) # we are given...
003eae00dc8a80bc2c3fac349b356c28f55dd4c2
AdrianoW/BlackJack
/blackJack.py
19,491
3.84375
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 3 22:05:13 2014 @author: adrianwoalmeida """ # imports from random import shuffle import os from time import sleep from math import floor # global variables - defines SUITE_NAMES = ['Spades', 'Hearts', 'Clubs', 'Diamonds'] FACE_NAMES = ['2', '3', '4', '5', '6', '7', '8...
d96001245deb585c36e790e600c20aefdc5daaf2
saiyesaswym/Algorithms-DataStructures-using-Python
/Leetcode/DynamicProgramming/MinCostClimbingStairs.py
432
3.875
4
""" BottomUp - Iterative approach - Tabulation No. of ways he can reach nth step: f(n-1)+f(n-2) -> Fibonacci sequence Time complexity: O(n) Space complexity: O(n) """ def minCostClimbingStairs(self, cost: List[int]) -> int: n = len(cost) table = [-1]*(n+2) table[0]=0 table[1]=cost[0] cost.append(0...
0c448510054bfb67043767c06582ae8bb53c52b0
SagarKulk539/APS_Lib_2020
/Codeforces/quasiPalindrome_Edu_29_A.py
510
3.796875
4
''' APS-2020 Problem Description, Input, Output : https://codeforces.com/contest/863/problem/A Code by : Sagar Kulkarni ''' str1=input() list1=list(str1) list2=list1[:] list2.reverse() if list1==list2: print("YES") else: count=0 for i in range(len(list2)): if list2[i]!='0': break ...
8254f60a7aab147374d8805e69bbf6e7709a0b82
Marstaable/Repo_warsztaty
/zadanie_domowe_week2/Gra_Fizz_Buzz.py
474
3.96875
4
# Popularna gra słowna FizzBuzz # - wypisz liczby od 1 do 100 (wlacznie) # - jesli podzielna przez 3 to napisz Fizz # - jesli podzilena przez 5 to napisz Buzz # - jesli podzielna przez 3 i przez 5 to napisz FizzBuzz for number in range(100): if number % 5 == 0 and number % 3 == 0: print(f"FizzBuzz {numb...
76e3aeacb111e14ba0d2716a7eedfb3ce9c0090e
martadrozsa/curso-coursera-python
/exercises/fahrenheitTemperature.py
220
3.9375
4
# conversor de temperatura fahrenheit_temperature = input("Enter a Fahrenheit temperature: ") celsius_temperature = (float(fahrenheit_temperature) - 32) * 5 / 9 print("The Celsius temperature is", celsius_temperature)
0000e504240b90092d7951cc5d0cffc7e97f0d30
egolov/stepic-python
/Inheritance.py
1,005
3.6875
4
def readInheritance(input, parents): if ':' in input: clazz, parentsStr = input.split(' : ') parentsClasses = parentsStr.split() parents[clazz] = parentsClasses for p in parentsClasses: if p not in parents: parents[p] = None else: parents[input...
8ae197b499597d1f4f1f254f06c412649faa3271
boristotle/cifar
/mnist_without_phd.py
2,500
3.625
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) X = tf.placeholder(tf.float32, [None, 784]) W = tf.Variable(tf.zeros([784, 10])) b = tf.Variable(tf.zeros([10])) init = tf.initialize_all_variables() #model Y = tf.nn.soft...
75945f717b1d12297142b466ee7c5be315010e3f
thomaswhyyou/python_examples
/lists.py
1,126
3.703125
4
game_of_thrones_characters = [ "Tyrion Lannister", "Cersei Lannister", "Daenerys Targaryen", "Arya Stark", "Jon Snow", "Sansa Stark", "Jorah Mormont", "Jaime Lannister", "Sandor Clegane", "Theon Greyjoy", "Samwell Tarly", "Tywin Lannister", "Joffrey Baratheon", "C...
2fff0ca5417b2c52037dac5abee7849a65d9469c
boodscode237/turtle-module-python
/spirograph.py
556
3.515625
4
import turtle as t import random tort = t.Turtle() t.colormode(255) tort.shape("turtle") def random_color(): red = random.randint(0, 255) green = random.randint(0, 255) blue = random.randint(0, 255) random_colour = (red, green, blue) return random_colour tort.speed('fastest') def draw_spirog...
74ffe9f44fe173d58bba89f6c3d89748a1a8abb9
gerasim-tg/generali-test-04112021
/src/test_assignment.py
8,096
3.515625
4
import csv import xml.etree.ElementTree as ET import json import os from datetime import datetime, timedelta from datetime import date from collections import namedtuple from datetime import datetime, timezone from pytz import timezone class ModifyInputData(): """The class that performs data input modification ...
feec58918ef45f11bb184476d6966b818b1e8ca7
ileng/ElementOfProgrammingInterviews
/chapter7/Yao/p7-3.py
288
3.890625
4
#!/usr/bin/env python # encoding: utf-8 def isPalindrome(s): n = len(s) ix = 0;rix = n-1; while ix < rix: if s[ix]!=s[rix]: return False ix +=1 rix -= 1 return True s = 'abcba' s2='abda' print(isPalindrome(s)) print(isPalindrome(s2))
fb3bf520b225b256c1659395e392248ecc202529
sergio-kzn/advent_of_code_2020
/day5.py
4,553
3.796875
4
""" --- Day 5: Binary Boarding --- You board your plane only to discover a new problem: you dropped your boarding pass! You aren't sure which seat is yours, and all of the flight attendants are busy with the flood of people that suddenly made it through passport control. You write a quick program to use your phone's c...
9ede594c752d1cb7fbb6f8ad908330b0a44206d7
wangwenjun/python
/chapter07/tuple-index.py
61
3.53125
4
pets = 'dog', 'cat', 'parrot' print(pets[1]) print(pets[-1])
514d89f88e29b41eb157b4ff138db6c0c5a0f0d4
ebaker15/HappyNumbers_
/happynumbers.py
1,105
3.65625
4
def happynumber(): number = (input("Please Enter a Number. : ")) s=number print(s) slice=s[0:1] print(s) newnumber = (int(s[0]) * int(s[0])) + (int(s[1]) * int(s[1])) print(newnumber) if(newnumber==1): print("Happy Number!") slice=s[0:1] print(s) newnumber1 = (int(s[0]) * int(s[0])) + (int(s[1])...
557b359c35f5427d9a9045a4a1ecdffe08044e6c
anuraganands/parallel-GSGD
/Python code by students - inprogress/parallelSGD/ASGD_read_csv.py
332
3.578125
4
import csv import numpy as np def loadCSV(filename): ''' function to load dataset ''' with open(filename, "r") as csvfile: lines = csv.reader(csvfile) dataset = list(lines) for i in range(len(dataset)): dataset[i] = [float(x) for x in dataset[i]] return np.arr...
0dab5ef1e0c39fd1a96f3e5031321f2626d4ecbe
Renzhihan/machine_learning
/Part 1 - Data Preprocessing/Section 2 -------------------- Part 1 - Data Preprocessing --------------------/Data_Preprocessing/data_preprocessing.py
1,290
3.53125
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt #importing the dataset dataset=pd.read_csv('Data.csv') X=dataset.iloc[:,:-1].values #取所有行数 除去最后一列 y=dataset.iloc[:,3].values #taking care of missing data from sklearn.impute import SimpleImputer imputer = SimpleImputer(add_indicator=...
b62e2b91cb1c70a8e0c538ee05127d7584220b79
kadirturan0/PythonKampi
/Gun_5/ornek_zar_atma.py
606
3.6875
4
import random def zar(): while True: puan=0 tahmin = int(input("Birinci zar tahmini:")) tahmin2 = int(input("İkinci zar tahmini:")) print("Çıkmak için x yazarak enter tuşuna basınız") x = random.randint(0,6) y = random.randint(0, 6) print(x,y) if ta...
2787ae16bc0b41da4c27de3657d351f139a1f292
diegojramirezs7/finalproject
/rpi_client/helper.py
14,574
3.640625
4
import record import speech_recognition as sr from request_handler import general_request, file_request import os r = sr.Recognizer() m = sr.Microphone() countdown_cmd = 'mpg321 ttsfiles/countdown.mp3' def file_to_text(filename): # takes audio file and returns the corresponding string from transcription wit...
38c22d545aac5c7f04a5b16927319190ee624c5b
JoshCrusader/Octomind
/logs/date_parser_2_13.py
829
3.546875
4
from datetime import datetime from datetime import timedelta #Add 1 day #print datetime.now() + timedelta(days=1) #Subtract 60 seconds #print datetime.now() - timedelta(seconds=60) #Add 2 years #print datetime.now() + timedelta(days=730) #Other Parameters you can pass in to timedelta: # da...
6fb6bd6c2aff0dde652b51f708b3f5f4fde46c8c
imaaduddin/Everything-Python
/MathFunctions.py
225
3.578125
4
import math pi = 3.14 x = 7 y = 5.67 z = 1.23 # print(round(pi)) # print(math.ceil(pi)) # print(math.floor(pi)) # print(abs(pi)) # print(pow(pi, 2)) # print(math.sqrt(pi)) # print(max(x, y, z, pi)) print(min(x, pi, y , z))
2de034fec8068d3790e1e4a5a60fcb7266fa8844
pfarrell85/py-client-server
/TcpClient.py
1,329
3.734375
4
#!/usr/bin/env python # Written by: Patrick Farrell # # Basic TCP Client program that will connect to our TCP Server application import sys import socket import struct import string import ctypes import random import time import math import signal class TcpClient(): def __init__(self): self.HOST = '' # T...
272c293ceb09ff017abc451161a326003302aa0d
LebedevOleg/pylaba1
/venv/Task1/linklist.py
2,077
3.625
4
import random class Node: def __init__(self,value = None, next = None): self.value= value self.next = next class LinkList: def __init__(self): self.first = None self.last = None self.lenght = 0 def __str__(self): if self.first != None: current = ...
83878eac4aec5fbbda909232da8aeafd7ea20369
Sravyapi/project-euler
/Multiples_of_3_and_5.py
454
3.78125
4
def Multiples_of_3_and_5(max_limit, num1, num2): multiplier = 1 total = 0 while num1*multiplier < max_limit: total+=num1*multiplier multiplier+=1 multiplier = 1 while num2*multiplier < max_limit: total+=num2*multiplier multiplier+=1 multiplier = 1 while num1*n...
67d61b139ddc6248f8f0a80eea945ab9a784a081
caioforteribeiro/gmit_programming
/week03/floor.py
215
4.21875
4
#Asks for a float and outputs a rounded down integer #Author: Caio Forte Ribeiro import math x = float(input("Enter a float number:\n")) flooredNumber = math.floor(x) print("Your floored number is: {}".format(flooredNumber))
ae90dacee57f76ec02686152e3a3b2547a4424aa
yunnikum/BIOT670_EEG
/Extracting_Features_Draft.py
997
3.609375
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: #BIOT670 Spring2021 # In[ ]: # Author: Yekaterina Unnikumaran # In[ ]: # Extracting Features Using Pixels in txt files from conversion # First step is put eeg1.txt file in our path so we can read it and work with it, in Notebooks I can simply use read code # as...
b26376014bb985e79188120202834b3d99bf8ea9
vijaynitrr/python-code
/code/class2.py
652
3.765625
4
import sys import os class Boss(object) : def __init__(self): self.name = "" self.salary = "" print "Boss construtor" def setName(self,name): self.name = name def getName(self): return self.name def setSalary(self,salary): self.salary=salary def getSalary(self): return self.salary def printD...
940113eb4be7e370855e74b57e5460588a60b621
mwinn53/Euler
/Problem 5 - Smallest multiple/prime_sieves.py
9,007
3.9375
4
""" Sieve of Eratosthenes --------------------- Is a simple, ancient algorithm for finding all prime numbers up to any given limit. It does so by iteratively marking as composite (i.e. not prime) the multiples of each prime, starting with the multiples of 2. The sieve of Eratosthenes is one...
eafc5dc46cbd0bbc7bad02d3045d0743d18b06f2
ii6uu99/ipynb
/python/hard_python/oo/Dog版本的吃鸡游戏/123.py
124
3.515625
4
while(True): cmd=input() if(cmd=='88'): print('88') break; """下面的语句不执行"""
d03000beffd314d4f63e6242a06c39bb35b67ec5
VanessaLimana/Python-3
/test_json.py
327
3.75
4
import json data = { 'nome' : 'vanessa', 'idade' : 30, 'peso' : 70 } json_str = json.dumps(data) print(json_str) # transormação da estrutura de dados em json print(type(json_str)) data = json.loads(json_str) # # transormação da estrutura de json de volta para estutura de dados py print(data) print(type(dat...
d9784f18e7dc1f068e7a5a546a4f104f00d03e51
rohit1205/python-programming
/checkpallindromeinstring.py
191
3.96875
4
st = input('Enter the string : ') l=len(st) ts='' for i in range(0,l): ts=st[i]+ts if st==ts: print('The string is palindrome') else: print('The string is not palindrome')
caec51b1c02c7b78797c09d6a440999f4507e083
JonRivera/cs-guided-project-problem-solving
/src/demonstration_1.py
1,177
4.03125
4
""" Given a list of integers and a target value, return the indices of the two numbers in the list that add up to a specific target. *Note: You can assume that each input has exactly one solution, and the same element cannot be used more than once.* Example: Given nums = [3, 8, 12, 17], target = 15, Because nums[0]...
69996e586ca80eb2db3362ee4d0d5c213e583dc6
dicao425/algorithmExercise
/LeetCode/majorityElement.py
604
3.640625
4
#!/usr/bin/python import sys class Solution(object): def majorityElement(self, nums): """ :type nums: List[int] :rtype: int """ #return sorted(nums)[len(nums)/2] result = nums[0] count = 0 for n in nums: if count == 0: resu...
75a3307cf2b994c63bc5f6480f997534d3526d27
chris234567/tinyPy
/main.py
6,465
4.25
4
#https://www.codementor.io/@ilyaas97/6-python-projects-for-beginners-yn3va03fs # some inspiration from here #1 Guess The Number def guessTheNumber(): import random print('Guess a random number between 0 and 20:') while (True): i = random.randint(0, 20) x = int(input()) if (i == x...
e3bb53e452bae42f18d3ac721432c2d3f44fe5ec
walterdd/Boremeter
/boremeter/bounding_boxes.py
2,534
3.609375
4
class BoundingBox: """ Bb - class for bounding boxes x (left) right | | | | y (top)___|__________| | | | BOUNDING | | BOX | h bottom____|__________| w """ def ...
7ba6798c9f2f6609dd6ba566ff39384f67761e7d
steven-mathew/contest-problems
/python-solutions/J1Speed.py
365
4.15625
4
speed_limit = int(input()) speed = int(input()) delta = speed - speed_limit if delta < 1: print("Congratulations, you are within the speed limit!") elif 1 < delta < 20: print("You are speeding and your fine is $100.") elif 21 < delta < 31: print("You are speeding and your fine is $270.") else: print("...
5a357eaf0617af6ad4546258a907ac04395e37d3
x4nth055/pythoncode-tutorials
/python-for-multimedia/combine-audio/concatenate_audio_moviepy.py
926
3.6875
4
from moviepy.editor import concatenate_audioclips, AudioFileClip def concatenate_audio_moviepy(audio_clip_paths, output_path): """Concatenates several audio files into one audio file using MoviePy and save it to `output_path`. Note that extension (mp3, etc.) must be added to `output_path`""" clips = [Audi...
1a026717ea0d592d9c97d66dc984c2602ba1fe94
maoyalu/leetcode
/Python/1200-1299/1221_Split_a_String_in_Balanced_Strings.py
786
3.65625
4
import unittest def solution(s): # ********** Attempt 1 - 2019/10/31 ********** count = 0 current = 0 for c in s: if c == "R": current += 1 else: current -= 1 if current == 0: count += 1 return count class TestSolution(unittest.Test...
31e347099ce76d0b6650d98077c57eee2fa0bd76
jacchkiki/kiki-python
/before/0824.py
593
3.546875
4
import time import random class car: loc=0 name="" def carname(self,fc): self.name=fc def gogo(self): self.loc=self.loc+1 def backback(self): self.loc=self.loc-1 def whereiscar(self): print self.name print self.loc def gogo2(self,skop): ...
53ede1790cd22692ec08207b447c31cb298003b7
Alkantou/PythonClass
/BlackJack_Project.py
4,768
3.734375
4
# Milestone Project 2 - Blackjack Game # In this milestone project you will be creating a Complete BlackJack Card Game in # Python. import random from typing import List class Card: def __init__(self, suit, rank): self.suit = suit self.rank = rank def __str__(self): if self.rank == 1...
25d1314015e3b471758737e8779fcdcbe2fb86b8
jusevesi/pyENL
/utils.py
6,871
3.546875
4
#/usr/bin/env python3 ''' Utilidades para reconocimiento de parámetros de ecuaciones ''' from numpy import * from pyENL_fcns import * import re ln = log prop = log # Solo importa el nombre de la función para comprobación... haprop = log def ajustes(texto): ''' Ajusta el contenido del texto de cada ecuación ...
440048d3900e4f9e82c02f5ee264b24ab0781842
suatztrk/Python
/Kodlama Egzersizleri/Temel Veri Yapıları ve Objeler/oyuncu_kaydetme.py
362
3.703125
4
print("Oyuncu Kaydetme Programı") ad = input("Oyuncunun Adı : ") soyad = input("Oyuncunun Soyadı : ") takim = input("Oyuncunun Takımı : ") bilgiler=[ad, soyad, takim] print("Bilgiler Kaydediliyor...") print("Oyuncu Adı : {}\nOyuncu Soyadı : {}\nOyuncunun Takımı : {}\n".format(bilgiler[0], bilgiler[1], bilgiler[2])...
034db313e2717522eba7fc1e16207b08dc4605af
OldDon/UdemyPythonCourse
/UdemyPythonCourse/2.27 Exercise. Calculate Length Second Attempt.py
238
3.625
4
def string_length(mystring): return len(mystring) print(string_length("Hello")) print(string_length("SecondString")) def convert_string_to_int(con_string): return (cint(con_string)) print(convert_string_to_int("Hello"))
c414b8bcf57238b667d3af344eeb66cf6603b8fb
sahand-karimi/Python-Numerics
/MultinomialMarkovAndEncoding/multinomialMM.py
5,289
3.890625
4
import numpy as np import encoding class MultinomialMM(object): """ Create and learn a multinomial Markov model Input: encoding: a EncodingScheme class that will process the data prior to fitting. If no scheme is given, and the data is inputed without encoding, a default ...
217997f9073dc781f60d8109d721facef8b7239f
DavidDDavidson/HackerRank
/Domains/Python/Strings/Find a String/Find_String.py
201
3.671875
4
string = raw_input() find = raw_input() times_found = 0 for i in range(0, len(string) - len(find) + 1): if(string[i:i + len(find)] == find): times_found = times_found + 1 print times_found
cad0ab9170353bd352f477ae39e4f3ec9e5ea157
gwiily/Python-Crash-Course-Practice
/chapter10/10-10.py
243
3.734375
4
filename = 'alice.txt' try: with open(filename) as f: contents = f.read() except FileNotFoundError: print("Can't find " + filename) else: times = contents.lower().count('the') print("Word 'the' has been found " + str(times) + " times.")
b4d5c299cf7296a20d5e25870964ce9e2691b3aa
juanmanuelbaldonado/AED3-TP2
/experimentos/ejercicio1/ejercicio1_experimento3.py
901
3.65625
4
from random import randint # Este script genera casos random con costo random y con una cantidad fija de trabajos, # pero disminuyendo el costo máximo de los trabajos cuanto más adelante(mayor indice) estos se encuentren # Ej: El costo máximo de los 10 primeros trabajos es 100, pero el de los # últimos 10 es 10 traba...
7e723a7b2adcca5c436e28ea27e7f8c0e2dbd219
gofr1/python-learning
/other/regex_basics.py
12,803
4.25
4
import re # Matching Regex Objects phoneNumRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d') mo = phoneNumRegex.search('My number is 555-123-4567.') print('Phone number found: ' + mo.group()) # Adding parentheses will create groups in the regex phoneNumRegex = re.compile(r'(\d\d\d)-(\d\d\d-\d\d\d\d)') mo = phoneNumRegex....
b1319ac2f190287f05f4039e71d17bd583acf5a6
bdorea/logicadeprogramacao
/logica2/Aula 2/Exercircio1.py
351
3.828125
4
#Exercircio 1 preco = float(input('Digite o preço do produto:')) p = float(input('Digite o percentual de desconto (0-100)%:')) desconto = preco * (p / 100) final = preco - desconto print('O preço do produto é {}. Desconto de {}%.'.format(preco, p)) print('Valor calculado de desconto: {}. Valor final do produto: {}'....
e0c5c6bdf289a558c0b67716c2504e3a4963aec7
rsprenkels/kattis
/python/1_7/moscowdream.py
380
3.59375
4
def possible(a: int, b: int, c: int, n: int) -> str: if any(p == 0 for p in [a,b,c]): return 'NO' if a + b + c >= n and n >= 3: return 'YES' return 'NO' assert possible(0, 3, 3, 5) == 'NO' assert possible(4, 10, 6, 13) == 'YES' if __name__ == '__main__': print(possible(*list(map(int, i...
f7b8f9ace9a9a270a4d868912e9b92b96900eea9
ritobanrc/project-euler
/challenge18.py
1,370
3.5625
4
#!/usr/bin/env python3 triangle = ( '''75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 40 80 70 33 41 48 72 33 47 32 37 16 94 29 53 71 44 65 25 43 91 52 97 51 14 70 11 33 28 77 73 17 78 39 68 17 57 91 71 52 38 17 14 91 43 58 50 27 29 48 63 66 0...
49f165a1560e47afb328dc9c8cc302f78492456a
RekaVoelfinger/I_learn_python
/coffee_machine/src/coffee_machine/CoffeeIngredients.py
908
3.765625
4
# Make the class privat class CoffeeIngredients: def __init__(self, water_in_ml, milk_in_ml, coffee_beans_in_gramm): self._water_in_ml = water_in_ml self._milk_in_ml = milk_in_ml self._coffee_beans_in_gramm = coffee_beans_in_gramm def has_enough(self, other): has_enough = True ...
ee2eed2d7af28c9c05d1b446bd3e611560857423
gokhangungor/Object-Detection-ImageAI
/ObjectDetectionPythonCode.py
3,241
3.515625
4
#Image AI library is imported here from imageai.Detection import ObjectDetection #os and cv2 libraries are imported here for image editing with text import os import cv2 #PIL library is imported here for image editing from PIL import Image from PIL import ImageFont from PIL import ImageDraw #Execution is defi...
6f54afdc5a6b29798128c98d9fb6dd6d2bdd65c0
Rufito-ruf/training
/python/conditions_loops/check_armstrong.py
273
4.15625
4
from math import floor num = int(input("Enter the number to check it: ")) sum = 0 check_num = num while num > 0: digit = num % 10 num //= 10 sum += digit**3 if (sum == check_num): print("It is an Armstrong number") else: print("It is not an Armstrong number")
3514912a39085e4f85c7e49806942d08e7b0cbc3
hoodielive/pythonnerd
/dbcb/capture_anon_func.py
355
3.765625
4
x = 10 print(x) a = lambda y: x + y print(a(10)) x = 20 print(x) b = lambda y: x + y print(b(10)) print(a(10)) funcs = [lambda x: x+n for n in range(5)] for f in funcs: print(f(0)) funcs = [lambda x, n=n: x+n for n in range(5)] for f in funcs: print(f(0)) funcs = [lambda x, n=n: x+n for n in range(5)] ...
2bb1963b1a9a3aaa4962e23e0605096cdcf096d8
luizffdemoraes/Python_1Semestre
/Exercicios/Escalas de temperatura.py
1,398
4.46875
4
""" Descrição Faça um programa em Python3 que receba uma temperatura em Fahrenheit, calcule e imprima o valor convertido para a escala Celsius e para a escala Kelvin, de acordo com as equações de conversão abaixo: t_celsius = (t_fahrenheit - 32) * 5/9 t_kelvin = t_celsius + 273.15 Formato de entrada A entra...
4ab0a9d491b7a50e2f8d10c0e4d699b5ae04e969
hackettccp/CSCI111
/Modules/Module6/SampleCode/Dictionaries/5_dictionary_copies_and_merging.py
1,324
4.375
4
""" Demonstrates copying and merging dictionaries """ #Declares a dictionary employees = {1001:"Joe", 1005:"Kathy", 1003:"Lou"} #Creates a shallow copy of the employees dictionary employees_copy = employees #Both variables point to same dictionary employees_copy[1009] = "Bill" #Adds a value to the "copy" print("emplo...
16553deebf6f06a72049563287f42effd6a1c213
deepak1214/CompetitiveCode
/LeetCode_problems/kth-smallest-element-in-a-bst/Solution.py
922
3.875
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 5 2020 @author: Shrey1608 """ # Approach :1) Recursive inorder traversal i.e first do a inorder traversal which is a method of Dfs and then just follow the recursion(Time complexity= O(N)(h is height of the tree) # It's a very straightforward approach with O(N)\mathcal{O...
91eea998613dc95ff089ad8421351ee997ec9bb9
mukund1985/Python-Tutotrial
/Core_Python/52. Dictionary/17. AccessDictForLoop.py
222
4.28125
4
# Accessing Dictionary using for loop stu = {101:'Rahul', 102:'Raj', 103:'Sonam'} # Accessing Single Value print(stu[101]) # Display Keys for k in stu: print(k) #Display Values for k in stu: print(stu[k])
0b47e551ea0af6efb680e0bd66d764d75ba36811
anze3db/adventofcode2019
/src/d11.py
4,523
3.5625
4
import itertools from collections import defaultdict def multiply(a, b): return a * b def add(a, b): return a + b def store(program, loc, input): program[loc] = input def load(program, loc): ... def jump_if_true(): pass def jump_if_false(): pass def less_than(a, b): return 1 if...
06ea761dbdf5b6ee5a32ec64c15c07de5cb2aa62
jcwmke/random
/euler2.py
530
3.765625
4
##Each new term in the Fibonacci sequence is ##generated by adding the previous two terms. ##By starting with 1 and 2, the first 10 terms will be: ##1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... ## ##By considering the terms in the Fibonacci ##sequence whose values do not exceed four million, ##find the sum of the even-valued...
7a6f447b3ae09f095e7a8909f9d01a6ac00bf8f2
obaidullah-faruk/Education-Gap-Analyzer
/thesis_implementation/education_gap_analyzer/BM.py
1,905
3.53125
4
import time # charComparison, shift, preProcessTime, searchTime , isMatch NO_OF_CHARS = 256 def badCharHeuristic(string, size): start=time.time() badChar = [-1]*NO_OF_CHARS count = 0 #astric = size + 1 for i in range(size): if i == size: for j in size-1: if badC...
021bb52fafd9eff7deeff98cae425d6d09bc1b52
rhedshi/project-euler
/python/utils/number.py
6,759
4.21875
4
#!/usr/bin/env python3 from math import factorial from typing import Any, Dict, Generator, List, Union def choose(n: int, k: int) -> int: """ Returns the binomial coefficient for n choose k. """ if 0 <= k <= n: N = 1 K = 1 for i in range(1, min(k, n - k) + 1): N *=...
4057a2237943ef01df1af2be3e1ed1ee28f7b79f
sakawejsza/sakawejsza.github.io
/python/main.py
237
4
4
##### SWAP #Shelby Kawejsza ##### Main Program a = (input('Give me an interger number ->A:'))#ask for a z = (input('Give me an interger number ->Z:'))#ask for z #swap them temp = a a = z z = temp print('A is now:', a) print('Z is now:', z)
483d963ea1569b73b7f0cdb97303b9e378749aab
vrbarros/udacity-data-structures-algorithms-nanodegree
/p_0/Task2.py
1,081
4.0625
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ 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) """ TASK 2: Which telephone number spent the...
0ad24c529bfe82f9a46869a990ff4f60420f1bb9
maverick1234567/password-genrator
/password.py
912
3.875
4
import random letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] numbers = ['0', '1', '2', '3', '4',...
af50aeff53d10b2e74c20d71a4c28812c3c9593c
laureenf/two-player-pong
/pong_2P.py
5,530
3.71875
4
import pygame import random pygame.init() clock = pygame.time.Clock() #variable declarations speed = 30 display_width = 800 display_height = 500 x = 100 y = 100 radius = 10 dx = 3 dy = 3 paddle_width = 4 paddle_height = 40 paddle1_x = 10 paddle1_y = 10 paddle2_x = display_width - 10 - paddl...
592ea9d85f9942ab83964ed97df38fd718922d56
paulorv/udacity
/CS101/exp-5.3.py
975
4.21875
4
# Write a procedure, rotate which takes as its input a string of lower case # letters, a-z, and spaces, and an integer n, and returns the string constructed # by shifting each of the letters n steps, and leaving the spaces unchanged. # Note that 'a' follows 'z'. You can use an additional procedure if you # choose to as...
b2d73507df761e87fc50404c2c3288c034753aa7
HuangeChen/Python_Assignments
/Assignment3/Q1-part+two.py
973
3.5625
4
# coding: utf-8 # Q1_Part Two # Use ‘vehicle_collisions’ data set. # For each borough, find out distribution of each collision scale. (One car involved? Two? Three? or more?) (From 2015 to present) # Display a few rows of the output use df.head(). # Generate a csv output with five columns ('borough', 'one-vehicle', '...
6c2bc992d591fd52965b4b3147d817fa4a55ed97
pragyadaga/SMART-QUIZZER
/generator/nouns.py
1,141
3.65625
4
''' input file: se_para.txt nouns file: nouns_list.txt output questions : question.txt ''' import sys nouns=[] #read from file and do pos tagging c=open("se_para.txt","r") str=c.read() import nltk t=nltk.word_tokenize(str) #print(t) #words of the text tagged=nltk.pos_tag(t) #print(tagged) #tagged list of all words ...
8b66d436d74d4f1fc651279f710b3c56e0622e2c
vcooley/Code_Abbey_Problems
/prob104.py
2,251
4.4375
4
""" Triangle Area. Solve area of a triangle given three points in a plane. """ __author__ = 'Vince' from math import sqrt def distance(p1, p2): """ Finds the distance between two points :param p1: :param p2: :return dist: """ dist = sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) r...
3257fe04cf9c0a17ccb366a58538dba9b6ddc652
haloapping/python-basic
/4-number-string-char-transformation/prefix-and-suffix.py
1,905
4.5
4
# rstrip (prefix) print("Rahel cantik ") print("Rahel cantik ".rstrip()) print() # lstrip (suffix) print(" Rahel cantik") print(" Rahel cantik\n".lstrip()) # strip (prefix and suffix) print(" Rahel cantik ") print(" Rahel cantik ".strip()) # Select character you want to d...
099031f70a262fd90857182f1b2c757845f7fefe
AndyWalker81/PANDS
/Week_2/false.py
455
4.125
4
# false.py # A program to output whether a statement is true or false # Author: Andy Walker # these lines get the input firstNumber = int(input("Please enter the first number: ")) print ("The first number is {}".format(firstNumber)) secondNumber = int(input("Please enter the second number: ")) print ("The second numbe...
eb14c6f63d265a02e4a73c4750167f0bac32d4f1
biosharp-dotnet-labs/ParOpt
/paropt/command.py
626
3.859375
4
"""Command functions for use with external optimization functions""" def format_fn(frmat): """Create a commandline function that builds a command line from a format string Upon binding on parameters, String.format will be called to create a command line call. Example: >>> fn = format_fn("echo {1} {0...
132e0ef737c9a12012d564a084c2e477285d98f7
sgeller98/project_euler
/Solved/Problem_030.py
206
3.59375
4
# Project Euler Problem 30 limit = 5 * pow(9, 5) def is_digitPowSum(num, p): return sum([pow(int(n), p) for n in str(num)]) == num print(sum([n for n in range(10, limit) if is_digitPowSum(n, 5)]))
94cbcce0bce020fb38933137dc9490ff2bc00ae8
kayanpang/champlain181030
/190225_revision/slide-5_class.py
471
3.75
4
# class is a blueprint or a set of instructions to build a specific type of objects # an object or an instance is a specific object built from a specific class # to define a method or function in a class class Student: name = "" def myfunction(self): print(self.name) # __init__ (initialize sets of each...
2c27643264babc9b08b16c9ae0294abd753f15ce
Nxiansen/untitled
/day03/my2.py
991
3.625
4
if __name__ == '__main__': klist = [ "good ", "good ", "study", " good ", "good", "study ", "good ", " good", " study", " good ", "good", " study ", "good ", "good ", "study", " day ", "day", " up", " day ", "day", " up", " day ", "day", " up", ...
a4ce1d883d0f3331c1e1c764b7e60ee9d0361d43
jhgaylor/magicquery
/tools.py
1,921
3.625
4
# tools.py class Null(object): def __repr__(self): return "<Null>" def __le__(self, other): return False def __lt__(self, other): return False def __gt__(self, other): return False def __ge__(self, other): return False def __eq__(self, other): return False def __neq__(self, other): return F...
d89f25f0ca1bc3390a3e2a1f36fc04780fc49a20
lmdpadm/Python
/desafio73.py
814
3.75
4
tabela = ('FLAMENGO', 'INTERNACIONAL', 'ATLÉTICO MG', 'SÃO PAULO', 'FLUMINENSE', 'GRÊMIO', 'PALMEIRAS', 'SANTOS', 'ATHLÉTICO PR', 'BRAGANTINO', 'CEARÁ', 'CORINTHIANS', 'ATLÉTICO GO', 'BAHIA', 'SPORT', 'FORTALEZA', 'VASCO', 'GOIÁS', 'CORITIBA', 'BOTAFOGO') print('\033[1;32m⚽⚽⚽\033[m CEN...
9dee1d68c389efb75dc70f6c77eb14f68702cd5c
nilesh23cs1/Face-Detection-Using-ML
/1.py
396
3.75
4
#simple program to read and show image using opencv and matsploit import cv2 from matplotlib import pyplot as plt img = cv2.imread('OpenCV Basics/dog.png')#read an image #by default opencv uses bgr color spaces. se we convert back into rgb colorspaces newImg = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) plt.imshow(im...
2caac5f8999b941b751e6649f98e57c61614bb45
soroosh-rz/Spark-Python
/basics/word-count.py
569
3.703125
4
from pyspark import SparkConf, SparkContext conf = SparkConf().setMaster("local").setAppName("WordCount") sc = SparkContext(conf = conf) input = sc.textFile("file:///Spark-Python/basics/book.txt") # one paragraph per line words = input.flatMap(lambda x: x.split()) # take every individual line of text and split it up ...
96a89b443a41e3fc376d5ad1ded664296fa07bfb
TehnoBronik/Programming
/Stepik 1/malevia.py
408
3.8125
4
from math import sqrt sh = (input()) if sh == "треугольник": a = (int(input())) b = (int(input())) c = (int(input())) p = ( a + b + c ) / 2 s = sqrt(p*(p-a)*(p-b)*(p-c)) print(s) elif sh == "прямоугольник": a = (int(input())) b = (int(input())) s = a * b print(s) elif sh == "круг...
394d4d145bd2a96ab0521adffe9938abc11b7ae6
FabriceCh/advent-of-code
/2022/3.py
979
3.5625
4
from utils import read_file ar = read_file("/home/fabrice/advent-of-code/2022/input") a = [ 'vJrwpWtwJgWrhcsFMMfFFhFp', 'jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL', 'PmmdzqPrVvPwwTWBwg', 'wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn', 'ttgJtRGJQctTZtZT', 'CrZsJsPPZsGzwwsLwLmpwMDw', ] def letter_to_priority(letter): ...
d5da5352e742ea6cd4656c3939b5713bb0da06b3
elaverdiere1/100_days_code
/day4_rock_paper_scissors.py
1,362
4.34375
4
rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____) ---.__(___) '''...
c9d8e0508665956d3f9f814d7950be474d4995fd
va1337/Ozon-newskills-Python
/Ozon/lesson_3/string1.py
246
4.3125
4
string1 = 'Съешь ещё этих мягких французских булок ДА выпей же чаю' string1 = string1.split(' ') print(string1[3].upper()) print(string1[6].lower()) print(string1[7][2]) for i in string1: print(i)
65cf98869dc0dd3256f9deeb83017f646ebe8648
flaviasalisboa/coursera-python-usp-parte1
/Semana-3/ordenacao.py
348
4.09375
4
# Semana 3 - Exercício 5 - Verifica a ordenação # dos números - crescente ou não a = int(input("Digite o primeiro número inteiro: ")) b = int(input("Digite o segundo número inteiro: ")) c = int(input("Digite o terceiro número inteiro: ")) if ( (a<b) and (a<c) and (b<c) ): print("crescente") else: print("não está em...
0b3101b110e58d0154ad77e10e267ad24dced1a6
cifpfbmoll/practica-5-python-Marat-Rafael
/practica5/practica5/p5e11.py
652
3.921875
4
#autor:Marat-Rafael """ Escribe un programa que pida un número e imprima todos sus divisores. Dame un número: 200 Los divisores de 200 son: 1 2 4 5 8 10 20 25 40 50 100 200 """ """ num=int(input("introduce un numero, por favor\n")) print "Los divisores de ",num," son: ", div=num for i in range (num): div-=1 ...
57fbe0bd002975ac6aded39b63bf8b0ab30112eb
vzkrish/Python
/opr1_1.py
329
3.734375
4
#! /usr/bin/python import os os.system ('clear') class vector(object): def __init__(self,a,b): self.first=a self.last=b def __str__(self): return "vector(%d,%d)" % (self.first,self.last) def __add__(self,other): return vector(self.first+other.first, self.last+other.last) v1=vector(2,-5) v2=vector(-7,6) pri...
a27dbcc4ca666d9da826912d34ac10c32e8139f1
nathanlct/cp
/project_euler/58.py
452
3.796875
4
def is_prime(n): if n < 2: return False if n % 2 == 0: return (n == 2) for k in range(3, int(n ** 0.5) + 1, 2): if n % k == 0: return False return True counter = 1 incr = 2 n_primes = 0 while True: for _ in range(4): counter += incr if is_prime(counter): n_pri...
8010eddabf749eaf0373ea60915eb9217ab2cdb9
daniel-reich/turbo-robot
/wyr9gCiBtFM7YLauK_12.py
1,079
4
4
""" Create a function that takes a list of strings representing times (`'hours:minutes:seconds'`) and returns their sum as a list of integers (`[hours, minutes, seconds]`). ### Examples time_sum(["1:23:45"]) ➞ [1, 23, 45] time_sum(["1:03:45", "1:23:05"]) ➞ [2, 26, 50] time_sum(["5:39:42", "10...
87e8dfd724a3abb3feda18f28b30a4509889b309
7kamison7/work
/kadai2-5.py
197
3.984375
4
#5 # 配列の最後に新しい数字(11)を追加する.サンプル配列:[1,3,5,7,9]出力配列:[1,3,5,7,9,11] list_num = [1,3,5,7,9] print(list_num) list_num.append(11) print(list_num)
1ad78145df4004ad2b83fd42f5c8a0bcbda0df82
yordan-marinov/fundamentals_python
/mid_exams/next_level.py
787
3.8125
4
needed_experience = float(input()) count_battles = int(input()) experience = 0 flag = False for battle_number in range(1, count_battles + 1): current_experience = float(input()) if battle_number % 3 == 0: current_experience *= 1.15 if battle_number % 5 == 0: current_experience *= 0.9 ...
6d28d5e36f729b1d5d487d33d241c6cf23b2000e
priyankakumbha/python
/laraPython/day15-1/test13.py
291
3.546875
4
class A: def test(self): print("from A.test") class B(A): def test(self): print("from B.test") class C(B): def test(self): print("from C.test") class D(A): def test(self): print("from D.test") list = [A(), B(), C(), D()]; for obj in list: obj.test();
7e1c7487f39587e00cf14058830df0e604da41a1
xuke829/pycode
/pycode/Day3/narcissistic.py
360
3.53125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- """code_info @Time : 2020 2020/6/29 14:58 @Author : Xuke @File : narcissistic.py """ count = 0 for i in range(100, 1000): t = i a = int(t / 100) b = int((t / 10) % 10) c = int(t % 10) if t == a ** 3 + b ** 3 + c ** 3: count = count + 1 ...
d8ebef4492bc895762a39f2544a5d01f345917ee
PaladhiDinesh/Web-Science
/Using Python Extracting 1000 unique URI's from twitter and downloading TimeMaps for each target URI using Memento Aggregator/1/get_1000urls.py
1,822
3.5625
4
# I have queried subway,walmart,trump,McDonalds,Old Dominion import urllib import json import tweepy import sys import time ACCESS_TOKEN = '118623489-QsSuqItzx8cnReRHI67ylffqpOPNs7z4Qp8hcOiI' # Variables that contains the user credentials to access Twitter API ACCESS_SECRET = 'PAPovgDO6QPy9QV8BbllM8p2MGWrcLLD8pesMHj...
9a093783bbb244b612fececaeac19baea4bfd31b
william-xiangzi/NetworkTest
/AndroidTestExecute.py
3,051
3.59375
4
#!/usr/bin/python3 # -*- coding: UTF-8 -*- # 性能测试思路:可以不用 while True: 让用例一直运行的方法;可以采用轮训 即每个1秒采集一次数据 写一次 # 这样的话可也以使用多线程 即让用例一直执行 知道接收到一个外部命令即停止;此方法 可以不使用 while True 实现;可以使用线程退出实现 import threading import time from Excle_Operation import ExcleDataSave from FpsData import Activitymonitor from CpuData import Cpu from Batter...
01b92c66fef4ab019657af809d86498301073701
zoog15/python_practice
/시간순삭 파이썬/0712 8장 실습 클릭하는 곳에 사각형 그리기.py
599
3.953125
4
import turtle t = turtle.Turtle() def square(length) : #사각형을 그리는 함수 for i in range(4) : t.forward(length) t.left(90) def drawit(x,y): #x,y좌표를 중심점으로 초록색으로 꽉찬 사각형 그리기 t.penup() t.goto(x,y) t.pendown() t.begin_fill() #색채우기 시작 t.color("green") #색지정 square(50) t.end_fill() ...
d16d245c1d8f9edc5846000bcdbc634017bb13d8
games/py-onecore
/onecore/helpers.py
408
3.5
4
# coding=utf-8 # funnylab.org # Date: 11-10-9 # Time: 上午2:18 __author__ = 'valorzhong' def arr_to_str(arr): if isinstance(arr, list): s = '' for a in arr: if len(s) > 0: s += ', ' if isinstance(a, list): s += '[' + arr_to_str(a) + ']' ...
367f3da3018f2df49034ce55097e8a489a08c4cb
sanjeevseera/Hackerrank-challenges
/Greedy_Algorithms/MaxMin.py
1,205
4.125
4
""" You will be given a list of integers, arr, and a single integer k. You must create an array of length k from elements of arr such that its unfairness is minimized. Call that array subarr. Unfairness of an array is calculated as max(subarr) - min(subarr) Where: - max denotes the largest integer in subarr -...