blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
4ec4ad97a2c4c64ab4dc104c89a4fbaf6b1f9988
scottwedge/python-programs
/web scrapping projects/flipkart web scrapping items.py
539
3.5
4
import bs4 import requests def flp(name): page_url="https://www.flipkart.com/search?q="+name page= requests.get(page_url) print(page) soup = bs4.BeautifulSoup(page.content,'lxml') # you need to pip install "xml" # print(soup) ### method two once scor = soup.select("._1HmYoV .bhgxx2 ....
4b4fcb862b710a65bc922c91a10d939cfcb463b9
innovia/training-exercise
/02_working_with_strings/translate.py
525
3.84375
4
# Copyright (c) 2016 Ami. All rights reserved. def user_input(): return input("Enter some text: ") def translate(text): new_text = text dictionary = { "a": "4", "b": "8", "e": "3", "i": "1", "o": "0", "s": "5", "t": "7" } for char in diction...
07f9952b25edc004c3ff9c312e435d246b2403e6
innovia/training-exercise
/03-functions-and-loops/invest.py
741
4.03125
4
# Copyright (c) 2016 Ami . All rights reserved def print_invest_prediction(initial_amount, interest_rate, duration): amount = initial_amount print("Principal amount: ", initial_amount) print("Annual return rate: ", interest_rate) for year in range(1, duration + 1): compound_rate = amount * int...
f76c2cf36a6cd48762044a9d8a31680e2b8dc118
ndouard/Neuromorphic_Learning
/video-classification/processor.py
494
3.578125
4
""" Process an image that we can pass to our networks. """ from keras.preprocessing.image import img_to_array, load_img import numpy as np def process_image(image, target_shape): """Given an image, process it and return the array.""" # Load the image. h, w, _ = target_shape image = load_img(i...
2b0755fc4a25cc3bbce7fef1f2b33fd84a87d163
kalaibenjamin/kalai
/positive.py
154
4.21875
4
number = float(input("Enter the number:")) if number> 0: print("Positive number") elif number == 0: print("Zero") else: print("Negative number")
b39babf840177c48052bc566d35d6e7a6d78cfe7
joseppi/AugmentedReality
/ClassExercices/Numpy Exercices.py
6,183
3.640625
4
import numpy as np import cv2 # 1. Create a vector of 10 floats (zeros) arr = np.arange(0, 10) for i in range(0, 10): arr[i] = 0 # print(arr) # 2. Create a vector of 10 float (zeros) whose 5th element is one arr2 = np.arange(0, 10) for i in range(0, 10): if i == 4: arr2[i] = 1 else: arr2[...
0c8d5f321eab5db635f2c108166e72bdb1d7dbd8
asuttles/euler
/problem15.py
845
3.828125
4
# Starting in the top left corner of a 2×2 grid, # and only being able to move to the right and down, # there are exactly 6 routes to the bottom right corner. # # How many such routes are there through a 20×20 grid? # Note: This problem grows exponentially as gridSize grows # See 'alternate' solution fo...
6f3c813327d27e0252cc2774b2da8b7291a97a0f
asuttles/euler
/problem7.py
346
3.921875
4
import math def isPrime(x): for i in range(2, int(math.sqrt(x))+1): if x % i == 0: return False return True if __name__ == "__main__": i, counter = 1, 0 while counter < 10001: i += 1 if isPrime(i): counter += 1 print("The 10,001st p...
41c83cd16e77c8168644e1154899754bd8b4b912
ryanhake/python_fundamentals
/04_conditionals_loops/04_07_search.py
311
4.09375
4
''' Receive a number between 0 and 1,000,000,000 from the user. Use while loop to find the number - when the number is found exit the loop and print the number to the console. ''' x = int(input("Please print number 0 - 1,000,000,000: ")) y = 0 while x < 1000000000: if y <= x: print(y) y += 1
c388cc4fb91fd3b4e4d568f9b8dcfebdffc9319e
ryanhake/python_fundamentals
/02_basic_datatypes/2_strings/02_09_vowel.py
533
4.3125
4
''' Write a script that prints the total number of vowels that are used in a user-inputted string. CHALLENGE: Can you change the script so that it counts the occurrence of each individual vowel in the string and print a count for each of them? ''' def isvowel(c): return (c == "a") or (c == "e") or (c...
16d8884b52f368d613c1c75b7965f116678001ae
ryanhake/python_fundamentals
/10_testing/10_02_tdd.py
1,171
4.375
4
''' Write a script that demonstrates TDD. Using pseudocode, plan out a couple simple functions. They could be as simple as add and subtract or more complex such as functions that read and write to files. Instead of writing out the functions, only provide the tests. Think about how the functions might fail and write te...
242f3d077365c84e60e7c735528d3904f12b5b74
ryanhake/python_fundamentals
/17_decorators/17_01_wraps.py
258
3.625
4
""" Write a decorator function that wraps text passed to it in a html <p> tag. """ def para(func): def wrapper(): return "<p> " + func() + " <p>" return wrapper @para def formatted_text(): return "Hello World" print(formatted_text())
2fa2e54cc2598df4abe3d485e54bc41a612a6603
UT1/Project-Euler
/Python 3/31-40/p40.py
237
3.546875
4
counter=1 number="." while len(str(number))<1000001: number=number+str(counter) counter+=1 number=list(number) ind=[1,10,100,1000,10000,100000,1000000] product=1 for i in ind: product*=int(number[i]) print("Answer:",product)
d5a39ab255b87c3517294e82890468f9f64f56a6
UT1/Project-Euler
/Python 3/31-40/p37.py
845
3.609375
4
import math def isPrime(n): x=2 if n!=1: while x<= int(math.sqrt(n)): if n%x==0: return 0 x+=1 else: return 0 return 1 def gen_truncates(n): trunc=[] copy=n n=str(n) trunc.append(n) while len(n)>0: trunc.append(n[1:]) ...
3a59f9fe9db63e4d28feff8158c5cb7c6dace08e
UT1/Project-Euler
/Python 3/41-50/p43.py
1,089
3.734375
4
def isPandigital(a): word=str(a) word_list=sorted(word) # print(''.join(word_list)) if ''.join(word_list)=='0123456789': # print('Pandigital') return True # else: # print('Not Pandigital') return False st="0123456789" import itertools def guessables(nu...
4a459c075142a1de156f74b565550bc2dd943056
willluer/pickle_challenge
/src/all_wordifications.py
7,674
3.5625
4
from number_to_words import NumberToWords import argparse import utils class AllWordifications(NumberToWords): def __init__(self,language="american_english",min_word_size=3,config="config.json",print_search_progress=False): super().__init__(language,min_word_size,config,print_search_progress) self....
4c0960015e4ebfe69e5e06a30c0c0c0223f7979d
DesireeMcElroy/hacker_rank_challenges
/python_exercises.py
2,383
4.21875
4
# Python exercises # If-Else # Task # Given an integer, , perform the following conditional actions: # If is odd, print Weird # If is even and in the inclusive range of to , print Not Weird # If is even and in the inclusive range of to , print Weird # If is even and greater than , print Not Weird # Input Fo...
1ba9c46f898868cc19a08d0d856edbcc8c69596f
mikh/spirit-island-playground
/models/test_object_reference.py
527
3.59375
4
class A(): def __init__(self, a, b, c): self.a = a self.b = b self.c = c def match(self, X): if self.a == X.a and self.b == X.b and self.c == X.c: return True return False A1 = A(1,2,3) A2 = A(2,3,4) A3 = A(3,4,5) L = [A1, A2, A3] A4 = A(1,2,3) print("...
afe670ecc996422b99c36dd1d6f5986205874feb
serveba/project_euler_py
/problem_3.py
722
3.6875
4
#!/usr/bin/python ''' project_euler.net problem 3: Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? @see https://en.wikipedia.org/wiki/Integer_factorization ''' def solve_upwards(number): max = 1 for i in xrange(2, number): ...
a281298efde2288ccd659387e61fc112b8a61241
sahullander/RandomProjects
/PMScheduler.py
3,502
3.8125
4
while True: certChoice = input("Type 1 for Network+ or 2 for Security+ and press enter: ") if certChoice not in ('1', '2'): print("Sorry, I only accept 1 or 2. \n") else: break totalSeconds = 0 inFile = "" outFile = "" if certChoice == "1": inFile = "PMNetVids.txt" outFile = "PMNetS...
c04cd5b9a73669a0d50e4515b07b63033a272491
shelltian820/Dumbledore
/authentication.py
1,920
3.71875
4
# logs user in. import hashlib import re import getpass import sqlite3 from create_user import * # This function prompts the user for a login and password. It assumes that # the username can only contain letters a-z, numbers 0-9 and underscores. # If hashed password matches stored hash, and username, then return the n...
6ad6836a606c3f22dcc6d1d786040e0550835f7f
mahalakshmima/python1
/g1.py
106
3.90625
4
find=int(input()) if(find>0): print("Positive") elif(find<0): print("Negative") else: print("Zero")
09eeef78dadd7fd4d8eac66245b4ebde96a64538
mahalakshmima/python1
/g15.py
100
3.609375
4
p1,p2=[int(x) for x in input().split()] for p3 in range(p1+1,p2): if(p3%2==0): print(p3,end=" ")
7c4cfd51a15616ddcb84a9ae6709d97bbffb67c7
kwentine/exercism
/python/hangman/hangman.py
990
3.515625
4
# Game status categories # Change the values as you see fit STATUS_WIN = "win" STATUS_LOSE = "lose" STATUS_ONGOING = "ongoing" class Hangman: def __init__(self, word: str): self.remaining_guesses = 9 self.status = STATUS_ONGOING assert word.isalpha(), "ASCII characters only" self.w...
c26685754503397d2e7af5b59d27b9a52ce7c1c2
YouseefNoaman/WideBot-WebParser
/WideBot-WebParser.py
1,997
3.625
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 19 19:33:00 2019 @author: SefoNoaman """ import re import requests from bs4 import BeautifulSoup import sys import time URLS = [] # a list to hold the URLs to check if there is a duplicate def waitForThirty(): # this function will be used to make a 30 seconds interv...
7dada2ebf691809f39ee1f6a7806d15042b12f03
YYx00xZZ/olxer
/mutils.py
635
3.625
4
import re def normalizePrice(dataframe): itemPrice_new = '' for index, row in dataframe.iterrows(): itemPrice_new = str(row['Price']).strip(' лв.') dataframe.at[index, 'Price'] = float(itemPrice_new) return dataframe def normalizeLocation(dataframe): """ personal product location(ci...
c3d8fe4474989bbac72f289c0a0022b73e830275
Boris-Rusinov/BASICS_MODULE
/Conditional Statements Advanced/Lab08-Cinema_Ticket.py
367
3.765625
4
day = input() ticket_price = 0 if day == "Monday": ticket_price = 12 elif day == "Tuesday": ticket_price = 12 elif day == "Wednesday": ticket_price = 14 elif day == "Thursday": ticket_price = 14 elif day == "Friday": ticket_price = 12 elif day == "Saturday": ticket_price = 16 elif day == "Sund...
efff5f29d8d582791442ca80e632372b2f00b816
Boris-Rusinov/BASICS_MODULE
/Conditional Statements/Ex08-Scholarship.py
1,253
3.640625
4
from math import floor income = float(input()) avg_grade = float(input()) min_work_salary = float(input()) social_scholarship = 0.00 excellent_results_scholarship = 0.00 if income < min_work_salary and avg_grade > 4.5: social_scholarship = min_work_salary * 0.35 if avg_grade >= 5.5: excellent_results_schola...
c535f20a9f7bc234840dc7d97db6a8e00b5b7ff3
Boris-Rusinov/BASICS_MODULE
/Nested Loops/Ex03-Sum_Prime_Non_Prime.py
858
4.1875
4
prime_nums_sum = 0 non_prime_nums_sum = 0 curr_num = 0 no_remainder_divisions = 0 while True: command = input() no_remainder_divisions = 0 if command == "stop": break else: curr_num = int(command) if curr_num == 0: continue elif curr_num == 1: n...
f238d30e5d0566af413b317edd5392e6afd9c1c1
Boris-Rusinov/BASICS_MODULE
/While Loop/Lab08-Graduation_pt._2.py
635
4.03125
4
student_name = input() curr_year_avg_grade = float(input()) curr_year = 1 chances_to_do_year_again = 1 total_avg_grade = 0.00 while True: if curr_year_avg_grade < 4.00: chances_to_do_year_again -= 1 if chances_to_do_year_again < 0: print(f"{student_name} has been excluded at {curr_year}...
0bf27c9deb3f0977ed51adf7724835560c582476
Boris-Rusinov/BASICS_MODULE
/First_Steps_in_Python_Coding/Ex04-Vacation_Book_list.py
224
3.78125
4
book_pages = int(input()) pages_read_per_hour = int(input()) deadline = int(input()) hours_to_read_book = book_pages / pages_read_per_hour pages_to_read_per_day = hours_to_read_book / deadline print(pages_to_read_per_day)
f7ba79d6b86b1b6752d9964b1a4c335f5bf37c1d
Boris-Rusinov/BASICS_MODULE
/Conditional Statements/Ex01-Sum_Seconds.py
847
3.84375
4
from math import floor first_runner_secs = int(input()) second_runner_secs = int(input()) third_runner_secs = int(input()) #Faster and easier way to do this total_secs = first_runner_secs + second_runner_secs + third_runner_secs mins = floor(total_secs / 60) secs = total_secs % 60 if(secs >= 0 and secs <= 9): p...
70de02489ba2bd7bf9da97c10564374612dc43ff
Boris-Rusinov/BASICS_MODULE
/Nested Loops/Lab04-Sum_Of_Two_Numbers.py
729
3.578125
4
interval_start = int(input()) interval_end = int(input()) magic_num = int(input()) curr_outer_num = interval_start curr_inner_num = interval_start curr_combo_num = 0 curr_sum = 0 while curr_outer_num <= interval_end: while curr_inner_num <= interval_end: curr_sum = (curr_outer_num + curr_inner_num) ...
14198f5e8783efe177cd61b4736c7086979227cd
Boris-Rusinov/BASICS_MODULE
/For Loop/Lab10-Odd_Even_Sum.py
391
3.828125
4
num_amount = int(input()) even_sum = 0 odd_sum = 0 diff = 0 for curr_index in range(0, num_amount): curr_num = int(input()) if curr_index % 2 == 0: even_sum += curr_num elif curr_index % 2 == 1: odd_sum += curr_num diff = even_sum - odd_sum if diff == 0: print(f"Yes") print(f"Sum...
b7162972e935467c8b36aae42039c27043c5c15c
Boris-Rusinov/BASICS_MODULE
/EXAMS/Practice/6 and 7 July 2019/Ex02-Shopping.py
737
3.609375
4
budget = float(input()) video_card_count = int(input()) # 250 lv. per piece processor_count = int(input()) # 35% video card price per piece RAM_memory_count = int(input()) # 10% video card price per piece video_card_total_cost = video_card_count * 250 processor_total_cost = video_card_total_cost * 0.35 * processor...
74e06239d76c625fc27e56f82364a03ce247cd4d
Boris-Rusinov/BASICS_MODULE
/EXAMS/Practice/2 and 3 May 2019 - Retake/Ex03-Mobile_Operator.py
1,283
4.03125
4
duration_of_contract = input() type_of_contract = input() added_mobile_internet = input() amount_of_months_to_pay = int(input()) total_cost_of_contract = 0.00 if duration_of_contract == "one": if type_of_contract == "Small": total_cost_of_contract = 9.98 elif type_of_contract == "Middle": tota...
3eae6bab7e30fa17e2d31f5e4957c049b718f18a
Boris-Rusinov/BASICS_MODULE
/Conditional Statements/Ex06-Godzilla_vs_._Kong.py
482
3.65625
4
film_budget = float(input()) extras = int(input()) costume_price_per_extra = float(input()) film_decor = film_budget * 0.1 if(extras > 150): costume_price_per_extra -= costume_price_per_extra * 0.1 film_budget -= (extras * costume_price_per_extra + film_decor) if(film_budget >= 0): print("Action!") prin...
dd62b46ba1cf1a47b75c7383694ec475db65ab68
AustinHellerRepo/DesignPatternDemo
/design_pattern/facade/framework.py
1,347
3.921875
4
from __future__ import annotations from typing import List from abc import ABC, abstractmethod class FacadeInterface(ABC): """ This class will facilitate the task of wrapping more complex actions into a simple function. """ def __init__(self, *, first_complex_class: FirstComplexClass, second_complex_class: Secon...
cf182d1a117d54d094bc6873c73e7bcb3799350d
sylverjoy/Electric-billing-app
/DBAdapter.py
1,985
3.6875
4
import sqlite3 as sq from sqlite3 import Error from tkinter import messagebox def connect(): conn = None try: conn = sq.connect("db.sqlite3") conn.commit() except Error as e : messagebox.showinfo("Error",str(e)+" during connect") return conn def create_table(conn,t_name) : ...
f069c3a13efd9d60c94023a1331701083f9f7b35
jjeong723/Study_note
/12000026/04/Link.py
1,276
4.1875
4
class Node : # Ʈ ϴ data+ def __init__(self, data, next=None) : self.data = data self.next=next def init() : # Ʈ Ѵ. node 1~node 4 ׸ global node1 node1 = Node(1) node2 = Node(2) node3 = Node(3) node4 = Node(4) node1.next = node2 node2.next = node3 node3.next = node4 def delete(del_data) ...
eabb7a1da9d68ec7fd6fd3eff5eb168fbbc268bd
Chen-Chun/MTApython
/D2_dict1.py
266
3.9375
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 26 16:29:03 2021 @author: 陳淳 """ dict1 = {"a":"apple","b":"banana","c":"cat",} dict1['d'] = 'dog' for key in dict1.values(): print(key) for k,v in dict1.items(): print(k,"->",v)
38746973f7693144d5bea95cd215ac9da4117631
Chen-Chun/MTApython
/D1-1grade.py
376
3.78125
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 1 14:35:56 2021 @author: 陳淳 """ score = int(input("分數:")) if score<100 and score>0: if score>=90: print("A") elif score>=80: print("B") elif score>=70: print("C") elif score>=60: print("D") else: ...
5b28f9a66b17bc456f463e87b0477437ba8ffa16
Chen-Chun/MTApython
/D1-num1+10.py
182
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 1 15:12:33 2021 @author: 陳淳 """ #數字1~10加法 n=1 total=0 while n<=10: total+=n n+=1 print(total)
35c7c5abc2a95ba5bea9a6e27357a15ecb8ac1bb
Abhijnan-Bajpai/Budget-Estimation
/data.py
968
3.53125
4
import pandas as pd import random as ran def generate_expense(year, lst): if year >= 2001: generate_expense(year - 1, lst) base_num = ran.randint(10000,15000) lst.append(base_num * (year % 2000)) return lst else: return n = int(input("Data from 2001 upto w...
861e68d2f4c891101261ddae3ad988f87ef6c000
Maninaa/SimulatedAnnealing-VRPTW-implementation
/model/package.py
1,197
3.859375
4
class Package: def __init__(self, id_, address, city, state, zip_, deadline, mass, notes, status='at the hub'): """ Initializes a package object. """ self.id_ = id_ self.address = address self.city = city self.state = state self.zip_ = zip_ sel...
3436a50f0156a936a7b25664d8c7e2232c2fd0f6
JoshuaPrice/evolution-fingerprints
/eval/count.py
664
3.609375
4
''' Counts number of SNPs in each chromosome Prints the list of chromosomes sorted by SNP count ''' import sys import csv import numpy assert len(sys.argv) > 1, 'Usage: count.py list of csv files to count' files = sys.argv[1:] chrom_count = {} for filename in files: with open(filename, newline='') as rsfile: ...
b2628c3c0225103c19a8898aa6835a972446edff
denze11/gb_osnovi_python_vebinar
/lesson_6/5.py
582
3.515625
4
class Stationery: title: '' def draw(self): print('Запуск отрисовки.') class Pen(Stationery): title = "ручка" def draw(self): print(f'Это - {self.title}') class Pencil(Stationery): title = 'карандаш' def draw(self): print(f'Это - {self.title}') class Handle(Stati...
ad6d04547dd5c97b1cc93cdafb1356e0ba34adc8
denze11/gb_osnovi_python_vebinar
/lesson_1/4.py
232
3.90625
4
number = int(input('Введите число: ')) item = number % 10 number //= 10 while number > 0: if number % 10 > item: item = number % 10 number //= 10 print(f'Самое большое число - {item}')
68af4952aa45dc8f46ee37d8197b355919023e21
denze11/gb_osnovi_python_vebinar
/lesson_4/2.py
441
3.6875
4
from random import randint random_numbers = [randint(1, 300) for i in range(13)] numbers = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55] new_numbers = [numbers[i] for i in range(1, len(numbers)) if numbers[i] > numbers[i - 1]] new_random_numbers = [random_numbers[i] for i in r...
a23c1085ea24234eb019868ebc65852e9b5968ef
2wnstjq2/java_joon
/byebye/inClass/pythonJoon/rootStudy/mb-func2.py
692
3.71875
4
def repeat(n, *val): for i in range(n): # 가변매개변수의 데이터를 출력 for a in val: print(a, 'arg', end=' / ',sep=' % ') print() repeat(2, 'hi', '메롱', 'wow') # def ma(*val): # for i in val: # # 가변매개변수의 데이터를 출력 # res = '' # for v in val: # re...
d000f27036ee116980b1292f84608d2ebb560424
sreeharikmarar/python
/program5.py
403
3.75
4
# flatten a list def flatten(a): flaplist=a list1=[] for sublist in flaplist: if isinstance(sublist,list): list2=flatten(sublist) list1.extend(list2) else: list1.append(sublist) return list1 # pass assert(flatten([[1,[2,3]]]) == [1,2,3]) assert(flatten([[[1,2]]]) == [1, 2])...
45cea939f22333f705f5495d0ae39d2b0a2b6866
VitaliiHlapshun/Coaxsoft
/reverse_string.py
73
3.71875
4
S = "string" R1 = S[::-1] R2 = ''.join(reversed(S)) print(R1) print(R2)
ce32fe301ed92d8516ca5842787088fd81174044
rachd/Ai-A-Modern-Approach
/chap3/missionaries-and-cannibals.py
4,954
3.796875
4
# in state: [missionaries, cannibals] and boat position is left = 0, right = 1 # initial state: left: [3, 3], right: [0, 0], boat: 0 # possible actions: # - move 1 missionary right # - move 2 missionaries right # - move 1 cannibal right # - move 2 cannibals right # - move 1 missionary and 1 cannibal right #...
13a9085da0b6231a2510b65f27a3828a9550031c
izotomas/CVUT---Cybernetics-and-AI
/labs/npuzzle/solvability_check.py
1,584
3.640625
4
import npuzzle def is_solvable(env): ''' True or False? ''' # your code comes here size = env._NPuzzle__size tiles = env._NPuzzle__tiles inv = __inversion_count(tiles, size) blank = __blank_row_number_from_bottom(tiles, size) if __is_even(size): ''''the blank is on an even...
ba75776a8f3d6fc71704b1e7ff209f7a02404a1c
tttmmiao/python
/output_pascal_triangle.py
380
3.671875
4
import sys def next(row): L = [1,] n = len(row) if n < 2: L.append(1) else: i,j = 0,1 while j < n: a,b = row[i],row[j] L.append(a+b) i = i+1 j = j+1 L.append(1) return L def triangles(max): row = [1] n = 1 while n <= max: yield row row = next(row) n = n+1 def main(): g = triangles(10...
dfa5fe28b7652201a0dbe4ca2dfab7444af12e74
alis70929/02_FundRaisingCalculator
/02_YesNoChecker.py
469
3.9375
4
def yes_no(question): to_check = ["yes", "no"] valid = False while not valid: response = input(question).lower() for item in to_check: if response == item: return item elif response == item[0]: return item print("Please ente...
6a44f2643d932719830c12f95e5b8b1260247e4e
Vicente29/Python
/EjerciciosPython/src/Ejercicio3.py
1,052
3.65625
4
#!/usr/bin/env python2 #encoding: windows-1252 # To change this license header, choose License Headers in Project Properties. # To change this template file, choose Tools | Templates # and open the template in the editor. if __name__ == "__main__": #Lo primero que hacemos es pedir los datos. salir1=False ...
503df27342116a6c1046e65198fd5fdfe33306ac
orion1900/ADSA
/Spark/Pyspark/demos/code/python/m3-demo2-AirlineData.py
3,676
3.75
4
# coding: utf-8 # ### Analyzing airline data with Spark SQL # In[1]: from pyspark.sql import SparkSession spark = SparkSession .builder .appName("Analyzing airline data") .getOrCreate() # In[74]: from pyspark.sql.types import Row from datetime import datetime # #### Loading in airline data # In...
f6d641b0d77eaba5fd94bfd30ae10260499af202
kun0769/studypy
/28.py
280
3.90625
4
#!/usr/bin/env python #coding:utf8 def h(): print 'one' yield 1 print 'two' yield 2 print 'three' yield 3 #h()函数返回的是生成器对象,需要通过next方法来获得值 #先赋值给a变量,再执行next方法 a=h() for i in a: print i
9ef774feb6bea3d6bce504ec1bdbad7e802fbb2f
kun0769/studypy
/14.py
147
3.734375
4
#!/usr/bin/env python # #函数的递归 计算阶层 def fun(n): if n==0: return 1 else: return n*fun(n-1) print fun(5)
4b78bcdc367bfab95ce04db8787af364dddbe557
danny-hunt/Advent-of-Code-2020
/Day03/puzzle_two.py
684
3.828125
4
def find_trees(x_increment, y_increment): with open("day_three.txt", 'r') as puzzle_input: input_list = puzzle_input.readlines() tree_count = 0 horizontal_position = 0 for vert, line in enumerate(input_list): if vert % y_increment == 0: if line[horizonta...
bf0566c2db8c2ef839d57eaf7477ee49707f0a9b
geertvd/adventofcode
/2015/day_12/2.py
446
3.703125
4
import json import re input = json.load(file('input.txt')) findnumbers = re.compile('(-?\d+)') def countjson(o): count = 0 for oo in o: oo = o.get(oo) if type(o) is dict else oo if type(o) is dict and oo == 'red': return 0 elif isinstance(oo, int): count += oo ...
376b0240e4412d35c6f9461683a5c66ca46b917e
geertvd/adventofcode
/2015/day_8/2.py
236
3.875
4
txt = open('input.txt') chars = 0 for line in txt: line = line.strip() chars -= len(line) line = line.replace('"', '||') line = line.replace('\\', '||') line = '"' + line + '"' chars += len(line) print chars
5e7fe36fca03edc3afe4583550b38616c826437a
gnool/np_sudoku
/demo.py
9,321
3.625
4
import json import numpy as np class SudokuNP: def __init__(self, string=None): self.board = None if string: self.create(string) self._init_units() self._init_box2unit() def _init_units(self): """Initialize the fundamental units - row, column, and block. ...
34215553c7c2e29cb965360e86eb92dc396c546f
AhmetFurkanDEMIR/Data-Structures
/AllExams/2017_But/hasing.py
1,699
3.5
4
data = [] # struct, data sakladığım listeler. def init(data,x): for i in range(0,x): data.append([]) return data # python 3.9 def hasing(data,x): # karekterlerin ascii toplamini tatacagim degisken y = 0 #gelen stringin tüm karekterleri for i in x: y+= ord(i) #ascii hale cevirdim key = y%10 #topla...
ae66bae89eef93469146b1ac63d060d4a405d31f
mihajloJelenic/QA_Domaci
/CetvrtaGrupa/mihajloJelenic.py
477
3.609375
4
# osobe=[] # nastavi="d" # while nastavi =="d": # ime=input("Unesite ime: ") # prez=input("Unesite prezime: ")a # nastavi=input("Nastavi: d/n? ") # osobe.append((ime,prez)) # filter=input("Unesite slova za filtriranje imena: ") # print(osobe) # filtriranaLista=[x for x in osobe if filter in x[0]] # print(filt...
d773408ca641ebb9d5670a41c8c5d22fe760dec0
subhamkrverma/pythonprog
/hierarchal.py
881
3.65625
4
class Student: college="Aditya" def __init__(self,name,rollno,fee): self.name=name self.rollno=rollno self.fee=fee class HostelStudent(Student): def __init__(self,room,hfee,name,rollno,fee): super().__init__(name,rollno,fee) self.room=room ...
a473160d3ca45415aa3958bd42234c2cf1259bbf
kjkombat/SimplyQuizSystem
/LOGININPUT.py
2,239
3.5625
4
from tkinter import * import tkinter.messagebox import pymysql.connections def finish(): root.destroy() def checkEntry(): # Connect to the database connection = pymysql.connect(host='localhost', user='root', password='mysql', ...
b0ac99115ff7bf4eaed0e03282475e8b107a4595
ironpiggies/delta_robot
/toppings.py
831
3.609375
4
import numpy as np class item: def __init__(self,pos_list,name): self.name=name self.pos=pos_list def convert(self): rotate = np.array([[1, 0, 0], [0, -1, 0], [0, 0, -1]]) # 180 degree rotation about x translate = np.array(...
8e42222f1b79b8dceb926ab6d64aaf4b52b93228
Dang-Hai-Tran/The-boredless-tourist-project
/script.py
3,153
3.5
4
destinations = ["Paris, France", "Shanghai, China", "Los Angeles, USA", "São Paulo, Brazil", "Cairo, Egypt"] test_traveler = ['Erin Wilkes', 'Shanghai, China', ['historical site', 'art']] def get_destinations_index(destination): for item in destinations: if item == destination: index = destinati...
a36bc76d9119572cab203e42f8825756dd609830
Gusmantas/webservice
/logistic_regression.py
1,726
3.71875
4
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.linear_model import LogisticRegression import sqlite3 # We need two functions: One for training model and another for predicting results. classifier = LogisticRegression(random_state=...
1157b0ecd4e42523bd3b5a30ecb2cd3251147554
ajsaule/Python
/v1.0/grading.py
428
3.703125
4
print ('Welcome to your friendly grading system') grad = input('Please input your recent test result: ') try: if grad >= 0.9 : print ('A') elif grad >= 0.8 : print ('B') elif grad >= 0.7 : print ('C') elif grad >= 0.6 : print ('D') else grad < 0.6 : print ('F....
be94ac20a75dfd505e5cbcbd868474aad242da19
ajsaule/Python
/v2.0/search4easter.py
559
3.671875
4
#Use filename mbox-short.txt try: file = input('Enter a filename: ') if file = 'gimp': print = ('You wanna go m8?!?') except: print = ('Enter a valid filename please?') file1 = open(file)s for line in file1: if line.startswith('X-DSPAM-Confidence:'): line1 = float(line[20:26]) add = add ...
6926089dba99457116a5a6c73be36eb3e13dc77b
ajsaule/Python
/v1.0/magic8ball.py
697
3.890625
4
#!/user/bin/env python3 ### """ magic_8_ball.py @author Andrej Saule @version 05-04-2019 """ import random def main(): print('Magive 8 Ball predicts the future and helps you make decisions. Probably bad ones ;)') #Get user to enter a question question = input('Enter a Yes/ No Question: ') #rep...
d82b1ff40d0c767f576d5c0eae21acfb4543c055
sallytomohno/chibi
/calc.py
178
3.640625
4
def calc(s): print('s=',s) nums=map(int,s.split('+')) print('nums=',nums) return sum(nums) print(calc("1")) print(calc("1+2")) print(calc("1+2+3"))
cea32c5d0f4bdba921e5da8b4d15f3f12b3483bf
MGalati/MyFaithIsMySword
/aubergiste.py
1,217
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import game_functions as gf def aubergiste(active_player, current_dice, players_score, list_players, current_role): """When someone take something, he can apply +1 ou +1""" if int(current_dice[0]) == 5 and int(current_dice[1]) == ...
a5decb7ce0709b75e163c6886358f9cef17600a4
mrinaldhar/mycode
/hackerrank/codesprint/r1/a3.py
312
3.640625
4
def doaction(): broken = raw_input() word = raw_input() count = 0 done = [] for each in word: if each in broken and each not in done: count = count + 1 done.append(each) print count def init(): loops=raw_input() loops = int(loops) while loops>0: doaction() loops = loops - 1 exit() init()
e5ebf5739c7e55842b4db0fcef06c18719da92dc
christiandt/ECC-operations
/ecc_operations.py
1,392
3.53125
4
from copy import copy def egcd(a, b): if a == 0: return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a) * y, y) def modinv(a, m): g, x, y = egcd(a, m) if g != 1: raise Exception('modular inverse does not exist') else: return x % m def dou...
32c48119c17b7d334467f7ce4e58eac0e7fbeaec
sreelekha-7/DSC-task
/time.py
134
3.921875
4
name = "time" time = int(input("time")) if (time%2==0): print("its an even number") else : print ("its an odd number")
e3fa39e357a3b95189d5df2f2c8c978ffa91c1b4
adagiox/project_euler
/02.py
457
3.984375
4
def naive_fib(i: int) -> int: if i == 1 or i == 2: return i return naive_fib(i-1) + naive_fib(i-2) def fib(i: int) -> list[int]: # uses dynamic programming (aka a table to hold already calculated fib values) table = [1, 2] for i in range(2, i): table.append(table[-1] + table[-2]) ...
6a62fe9bdf596d29e8d923b78e92789fae5e95cd
nathanielng/python-snippets
/cloud/webscrape_tables.py
1,466
3.84375
4
#!/usr/bin/env python import argparse import requests def get_data_from_url(url): """ With a specified user agent, download data from a specified URL """ user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)' headers = {'User-Agent': user_agent} req = urllib.request.Request(url, data=Non...
367ca0f55ab68a42d590e7b01997547fe5df6a67
nathanielng/python-snippets
/other/lib_datetime.py
509
3.546875
4
#!/usr/bin/env python import datetime def get_datestamp(dt=datetime.datetime.now(), fmt='%Y%m%d'): """ Returns a date stamp. Default format: YYYYMMDD """ return dt.strftime(fmt) def get_datetimestamp(dt=datetime.datetime.now(), fmt='%Y%m%d-%H%Mh'): """ Returns a date-time stamp. Defa...
1c62a48b7d94ff0ce8efa12262268cabf9adede3
nekitvand/qa-python
/lection1/code/with.py
331
3.734375
4
import random class Random(object): def __enter__(self): print('entering random') return random.randint(0, 100) def __exit__(self, exc_type, exc_val, exc_tb): print('exiting random') with Random() as r: print(r) print('inside') with Random() as r: print(r) print('...
e3313134497fd201510be16f10c58862dc6d903e
fireinrain/python_programing
/chapter7/gui3.pyw
553
3.5
4
#! /usr/bin/python3 # _encoding:utf-8_ # Written by liuzhaoyang from tkinter import * import sys name=input('sssssss') def hello(name): print('你好,刘朝阳'+name) sys.exit() root=Tk() widget=Label(root) widget.config(text='hello ,gui python') widget.pack(side=TOP,expand=YES,fill=BOTH) btt=Button(root,command=(lamb...
1ba1adb12f3cdb1693556018be2b8eed85cc21f1
fireinrain/python_programing
/chapter5/thread-alt.py
550
3.65625
4
#!/usr/bin/env python3 # encoding:utf-8 # written by:liuzhaoyang import threading,time def action(i): print(i ** 8) class Power: def __init__(self, i): self.i = i def action(self): print(self.i ** 8) def parent(): # 开启一个线程 threading._start_new_thread(action, (3,)) #j开启另一个线...
f32c49ac62c7f046c3503da2d3f707ec6daee7ae
fireinrain/python_programing
/chapter11_deepinpy/sample2.py
860
3.828125
4
#! /usr/bin/python3 # _encoding:utf-8_ # Written by liuzhaoyang # wcontact:liu575563079@gmail.com # 本代码片段主要描述python的上下文管理器 ###################关闭文件 # f = open('new.txt',"w") # print(f.closed) # f.write("hello,world") # f.close() # print(f.closed) # with open("new.txt","w") as f: # print(f.closed) # f.write("h...
94bebf10fb0e68ff130c32c1e356b07cdc712b3d
Arda-Bati/DSC-20-Homework-Questions
/hw06/starter/hw06.py
7,815
4.25
4
""" DSC 20 HW 06 NAME: PID: """ ## Question 1.1 ## def conversion_binary(n): """ Converts the given base-10 number to binary representation. Restrictions: You should use recursion in this question. You should do input validation. Parameters: n (int): Number to convert Returns: (str):...
2bcb41fe39f06baf9045fde06b4b3d725b8f3ee3
wilsonify/design-patterns-python
/dpatterns_python/gang_of_four/interpreter.py
916
3.796875
4
""" interpreter pattern in python """ from abc import abstractmethod class AbstractExpression: """ AbstractExpression """ @abstractmethod def interpret(self): """ interpret :return: """ print("interpret") class NonTerminalExpression(AbstractExpression): ...
7949affb91d37efcff4672de6d73fc2d6c922f51
mshekhar/random-algs
/epi_solutions/arrays/majority-element-ii.py
928
3.5
4
class Solution(object): def majorityElement(self, nums): """ :type nums: List[int] :rtype: List[int] """ ele_1 = ele_2 = None ele_1_count = ele_2_count = 0 for n in nums: if ele_1 == n: ele_1_count += 1 elif ele_2 == n:...
31dc4273dc5e6036161e329303ca5d1433a29afe
mshekhar/random-algs
/bits/reverse_digits.py
802
3.65625
4
import random import sys def reverse_number(number): r_number = 0 abs_number = abs(number) while abs_number > 0: r_number = r_number * 10 + abs_number % 10 abs_number /= 10 return -r_number if number < 0 else r_number def check_ans(x): s = str(x) s = '-' + s[:0:-1] if s[0] ==...
acd697af5a41959882d3024d5639405a89d253a5
mshekhar/random-algs
/epi_solutions/arrays/subsets-ii.py
728
3.609375
4
class Solution(object): def backtrack(self, nums, res, ele_list, start): res.append(ele_list[:]) i = start while i < len(nums): if i > start and nums[i] == nums[i - 1]: # print 'skipping ', nums[i], i, start, ele_list i += 1 continu...
6205185cb3944e73f2e9624eabe49b3c1ddffb31
mshekhar/random-algs
/epi_solutions/linked_list/reorder-list.py
2,293
4
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None @classmethod def construct_ll(cls, arr): head = None curr = None for i in arr: n = ListNode(i) if head is None: h...
980c8e025ab28ab7f76cc9e4ae2730f978aa4a9a
mshekhar/random-algs
/epi_solutions/binary_tree/my-calendar-ii.py
1,063
3.53125
4
# Definition for a binary tree node. class MyCalendarTwo: def __init__(self): self.overlaps = [] self.calendar = [] def book(self, start, end): for i, j in self.overlaps: if start < j and end > i: return False for i, j in self.calendar: if...
c87b3d7185bd72e7d9d040dc0f6b7425848dd839
mshekhar/random-algs
/geeks_for_geeks/largest-number-formed-from-an-array.py
448
3.75
4
import functools def compare(num1, num2): return int(num1 + num2) - int(num2 + num1) def largest_number(arr): return "".join(sorted(arr, key=functools.cmp_to_key(compare), reverse=True)) def abc(): t = int(raw_input()) for _ in range(t): n = int(raw_input()) print(largest_number(li...
f6362fa3c091eb753d401a02c099d85994928721
mshekhar/random-algs
/epi_solutions/linked_list/linked-list-cycle-ii.py
1,381
3.90625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def detect_loop(self, head): try: slow_ptr = head fast_ptr = head.next while slow_ptr != fast_ptr: ...
8459877878dcd1757c546c3cc30e7c95d4a56440
mshekhar/random-algs
/epi_solutions/linked_list/add-two-numbers.py
2,439
3.65625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None @classmethod def construct_ll(cls, arr): head = None curr = None for i in arr: n = ListNode(i) if head is None: h...
63f4f514536c473716a315624b7c41fed73da6b0
mshekhar/random-algs
/epi_solutions/arrays/remove-duplicates-from-sorted-array.py
922
3.6875
4
class Solution(object): def removeElement(self, nums, val): """ :type nums: List[int] :type val: int :rtype: int """ i = 0 non_val_i = 0 while i < len(nums): if nums[i] != val: nums[non_val_i] = nums[i] non_v...
1ba5ef6fc44cc811a5d5ab6cbec208aa9024c922
mshekhar/random-algs
/epi_solutions/arrays/remove-element.py
638
3.6875
4
class Solution(object): def removeElement(self, nums, val): """ :type nums: List[int] :type val: int :rtype: int """ i = 0 non_val_i = 0 while i < len(nums): if nums[i] != val: nums[non_val_i] = nums[i] non_v...
7b8b05c095e42bdafa2287e8272524f2f0002b90
mshekhar/random-algs
/general/fraction-to-recurring-decimal.py
1,115
3.59375
4
class Solution(object): def fractionToDecimal(self, numerator, denominator): """ :type numerator: int :type denominator: int :rtype: str """ if numerator == 0: return "0" res = ["-" if (numerator > 0) ^ (denominator > 0) else ""] denominat...
6d235a8765703aa186c521f71e0f3b95f77a0ef0
mshekhar/random-algs
/epi_solutions/binary_tree/populating-next-right-pointers-in-each-node-ii.py
2,329
3.984375
4
# Definition for binary tree with next pointer. class TreeLinkNode: def __init__(self, x): self.val = x self.left = None self.right = None self.next = None class Solution: def helper(self, root, parent): if not root: return if parent: nex...