blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
4c95f5127cb8304fa3d62ec5ef52ea4f943bcc75
JAlsko/pyCompiler
/tests/test35.py
104
3.734375
4
x = 3 if (x + 4 == 7): print x else: print 0 if (x + -3 == 0): y = 4 print y else: y = 1 print y
a54bca0c2d12a8d133fd5684b7091d6515150e7e
jamesroberthershaw/factorial-digits
/factorial-digits.py
602
3.8125
4
import numpy as np import sys if(len(sys.argv)>2):#in case the user has inputted too many arguments print("Too many arguments provided by user, please try again") elif(len(sys.argv)==1):#in case the user has not inputted any arguments print("No number provided by user, please try again") else:#user inputted ...
c35039d477752ba56912ddcb69d27e4c8eb1eaac
nicholasbarnette/ftp-server
/server/utils.py
2,512
3.9375
4
COMMANDS = ["USER", "PASS", "TYPE", "SYST", "NOOP", "QUIT", "PORT", "RETR"] # Test if the command is valid def validateCommand(cmd): """Validates a command Args: cmd (string): any command as a string Returns: string: an error message if the command is invalid """ if not (len(cmd)...
bdeb54567ccc430367439f4c6afe1f1d1bf3348a
ht-evth/computational-mathematics
/lab9/main.py
2,823
3.5
4
import sympy import integral FILENAME_FUNC = 'func1.txt' FILENAME_START_END_STEP = 'ses1.txt' def loadFuncFromFile(filename): """ считать функцию в виде строки из файла """ try: file = open(filename) res = file.readline() file.close return res except FileNotFou...
da451eb9b2ad03a021cebaa935eefb18e94a3ef5
successgilli/python
/multTable.py
433
3.75
4
# print 2 * table def printLine(table, num, error=False): print(f"{table} * {num} = {table*num}") if error == False else print(f"\033[0;30;41m{table} * {num} = {2*num}\033[0m") for num in range(1,13): try: if num == 4: raise Exception('incorrect multiplication') printLine(2, num) except Exc...
2d768ad137a6f97d1e386c733c5ce4304de3d281
lennox-davidlevy/practice
/6 Misc/word_search_ii.py
558
4.0625
4
# Given an m x n board of characters and a list of strings words, return all words on the board. # Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word. # Example 1: ...
864c37ad08e067adf7881e159ee388e68ce1c8bf
nlin24/python_algorithms
/Sorting.py
4,330
4.21875
4
''' Implement sorting algorithms per https://interactivepython.org/runestone/static/pythonds/SortSearch/sorting.html ''' def bubbleSort(aList): for passNum in range(len(aList) -1, 0, -1): for index in range(passNum): if aList[index] > aList[index + 1]: tmp = aList[index] ...
a3d3e5687165d0514db4ea6f98bcebeba620f0fb
eshim/Algorithms
/InsertionSort.py
932
3.875
4
""" Insertion Sort Take the last value of a list and compare it to each element of the sorted sublist and places it accordingly until there are no more elements of the given list. Worst Case Performance: O(n^2) comparisons and swaps Best Case Performance: O(n) comparisons, O(1) swaps Average Case Performance: O(n^2...
16dca826781c4256df098920a0cfd5a64461b0c0
workingpayload/Hash-Cracker
/Hash cracker.py
804
3.890625
4
import hashlib print("***************************PASSWORD CRACKER***************************") pass_found = 0 input_hash = input("Enter the hashed password:- ") pass_doc = input("\nEnter wordlist path:- ") try: pass_file = open(pass_doc,'r') except: print("Error:") print(pass_doc, "is not found. \nPlea...
08d42cfe9358316a3d50c49b6f400c041f92b5ac
br80/zappy_python
/06_game/snake.py
735
3.5625
4
from enemy import Enemy import random class Snake(Enemy): def __init__(self, row, col, game): super().__init__("SNAKE", row, col, 1000, 0.5, game) self.energy = 3 def wait(self): # Snakes store energy whenever they wait super().wait() self.energy += 1 # Some ran...
b5fd561b1bbb06de3d58832535a21415c5fb5233
shamoldas/pythonBasic
/DataScience/pandas/Different2Column.py
440
3.875
4
import pandas as pd # Create a DataFrame df1 = { 'Name':['George','Andrea','micheal', 'maggie','Ravi','Xien','Jalpa'], 'score1':[62,47,55,74,32,77,86], 'score2':[45,78,44,89,66,49,72]} df1 = pd.DataFrame(df1,columns= ['Name','score1','score2']) print("Given Dataframe :\n", df1) # getting...
aa59f848d9b28b496b5159ff17aa17ef4c24ac0d
nn98/Algorithm
/src/BaekJoon/Simple_Implementation/P11772.py
108
3.515625
4
t = int(input()) num = 0 for i in range(t): n = int(input()) num += (n // 10) ** (n % 10) print(num)
8b28ff6c7e303a9c83ac5cfde96022bf0b6cb3e0
sidv/Assignments
/Ramya_R/Ass27Augd24/cluster.py
631
3.5625
4
import json import requests import pandas as pd import matplotlib.pyplot as plt #Got url from data.gov.in url = "https://api.data.gov.in/resource/ee35f072-4d80-4b41-8c17-fd74414907be?api-key=579b464db66ec23bdd000001cdd3946e44ce4aad7209ff7b23ac571b&format=json&offset=0&limit=10" #Requesting the server using GET type re...
808184cb678948142e3f15f48d971ffd4562275b
here0009/LeetCode
/Python/RangeSumQuery2D-Immutable.py
3,479
3.875
4
""" Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2). Range Sum Query 2D The above rectangle (with the red border) is defined by (row1, col1) = (2, 1) and (row2, col2) = (4, 3), which contains sum = 8. Example...
afa126ed970b46c2dc3ad6bb9dd452cc449fbd76
Ramyaveerasekar/python_programming
/sqr.py
93
3.890625
4
num1=int(input("enter the number")) num2=int(input("enter the number")) print(num1**num2)
7d3e150122d2f7dff5d9c40ded061da68c394051
linmounong/leetcode
/2017/530.py
736
3.703125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def getMinimumDifference(self, root): """ :type root: TreeNode :rtype: int """ st...
f7ec7d9135c5c02ad7be923931a9428d34683b1f
reeha-parkar/python
/generators.py
1,029
4.28125
4
''' # In such an example, we store all the values and then access them # If there are so many values, there will be MemoryError x = [i for i in range(10)] for el in x: print(el) ''' ''' # But you can use something like this, which will take each value and then print (one value at a time) for i in range(10): pr...
b0cb66c7963f68f86c54211e46204d07dfcdbdb2
DipendraDLS/Python_OOP
/14.Thread_&_Multithreading/19.Thread_Synchronization_Semaphore.py
2,902
3.796875
4
''' - Semaphore : This is one of the oldest synchronization primitives in the history of computer scicence, invented by the early Dutch computer scientist Edsger W. Dijkstra. A semaphore manages an internal counter which is decremented by each acquire() call and ...
160824fdc53caef4297f6f093625ad3d3dec9b48
Aesthemic/text-rpg
/game.py
16,065
3.5
4
# Work-in-progress text-based game. import os from pathlib import Path import sys # Used for save files and other configuration files. import json # Importing custom modules. import get import put import common # This function displays the main menu for the game. The user is able to start or load a game, view cred...
cd2c71a798c6f82ca08f59c5325db889771da90c
Kanac/Python
/outwitted steven.py
73
3.765625
4
lista = [1,2,3,4,5] for x in range(len(lista)): print (lista[x+1])
177d9f501c1481f70ff26147cdf9bbb5e025679f
jcorn2/Project-Euler
/prob10.py
397
4.09375
4
def isPrime(n): #all even numbers except 2 aren't prime if(n != 2 and n % 2 == 0): return False #checks if an odd number is a factor and thus n is not prime for i in range(3,n // 2 + 1,2): if(n % i == 0): return False return True #list of primes primes = [2] #get primes below 2 million for i in range(3,20...
a800360276b7aa61472726d8c9c9889715699556
ali35351/pythonw
/pythonw/tutoCalendar.py
685
4.09375
4
import calendar print(calendar.weekheader(2)) # returns weekheader with length 2 print(calendar.firstweekday()) # prints 0 for monday print(calendar.month(2020, 1)) # returns calendar of a month in calendar format print(calendar.monthcalendar(2020, 1)) # returns calendar of a month in list format print(calendar.cal...
005551da399cfc45920540c135844077b89148e2
joohee/DailyCoding
/Python/pdf/python_for_secret_agents/bit_byte_calculator.py
1,398
3.765625
4
class Calculator: def __init__(self): pass def to_bits(self, v): #print("to_bits") b = [] for i in range(8): # var i is unused. b.append(v&1) v >>= 1 #print("v", v) return tuple(reversed(b)) def to_byte(self, b): ...
144e33323fc8618c612bc3dd7325669e74f467ee
Tevitt-Sai-Majji/fun-coding-
/navie pattren search algorithm.py
512
3.828125
4
#navie pattren search algorithm def search(txt,ptt): #txt is the text file and ptt is the string pattren n=len(txt) m=len(ptt) for i in range(n-m+1): #lehgth of txt file - pattren len j=0 #to know letter count matched while(j<m): if txt[i+j]!=ptt[j]: ...
2e2d97227377a6a5e482daf634b8fd2a0403ef2c
mawillcockson/leetcode
/monthly_challenges/2020-06/w1-2_delete_node_linked_list.py
1,473
4.21875
4
""" Constraints: - The linked list will have at least two elements. - All of the nodes' values will be unique. - The given node will not be the tail and it will always be a valid node of the linked list. - Do not return anything from your function. """ # Definition for singly-linked list. # class ListNode: # def _...
232c2e34761556ba52c0976fb4ccc07b642a4b39
Divij-berry14/Python-with-Data-Structures
/Hashset.py
1,165
3.515625
4
class Bucket: def __init__(self): self.bucket=[] def update(self,key): found=False for i, k in enumerate(self.bucket): if key==k: self.bucket[i]=key found=True break if not found: self.bucket.append(key) ...
6672b10b52bfb059cbaced6f8b2ec79ad7379c63
shoaibrayeen/Python
/Sorting Algorithm/mergeTwoSortedLists.py
1,383
4.65625
5
def mergeTwoSortedLists(list1,list2,list3=[],index1=0,index2=0) : ''' Objective : To merge two sorted lists into a 3rd list in sorted order Input Parametrs : list1 : First sorted list list2 : Second sorted list list3 : Merge sorted list of list1 and list2 index1 : Using for i...
cc43ee6c762b8c44626312b55b2101ea58a1a4ca
dev-gupta01/C-Programs
/python/classes_and_objects.py
761
3.921875
4
class Robot: def __init__(self,name,color,age): self.name=name self.color=color self.age=age def intro(self): print("My name is: "+self.name) print("My color is: "+self.color) print("My age is: ",end="") print(self.age) print() r1=Robot("Devashish...
74d36e60c227022c23cbd148434b2674811de178
ather1/Pensions
/Python/Flight.py
1,127
3.84375
4
class Flight: def __init__(self, origin,destination,duration): self.origin = origin self.destination = destination self.duration = duration self.Passengers = [] def Print_info(self): print(f"The origin is: {self.origin}" ) print(f"The destination is: {self.dest...
29b73f8ee36f71edba6980a009bbbc5999ef526e
ijf8090/Python_the_hard_way_examples
/.github/workflows/ex18.py
561
3.640625
4
def print_two(*args): arg1,arg2 = args print("arg1: %r, arg2: %r" %(arg1,arg2)) def print_three(*args): arg1,arg2, arg3 = args print("arg1: %r, arg2: %r, arg3: %r" %(arg1,arg2, arg3)) def print_two_again(arg1, arg2): print("arg1: %r, arg2: %r" %(arg1,arg2)) def print_one(arg1): print("arg1: %r " % arg1) def p...
e1689bda43a62123f8d50417fe05401a8134d0ef
chenhh/Uva
/uva_11308_set.py
1,321
3.703125
4
# -*- coding: utf-8 -*- """ Authors: Hung-Hsin Chen <chenhh@par.cse.nsysu.edu.tw> License: GPL v2 status: AC difficulty: 1 https://uva.onlinejudge.org/external/113/11308.pdf """ from collections import defaultdict def main(): n_binder = int(input()) for _ in range(n_binder): binder_name = input()....
c62f9e0154df7f00a5d8f1c8c4fae6e234a097fa
mbuhot/mbuhot-euler-solutions
/python/problem-055.py
1,585
4.125
4
#! /usr/bin/env python3 description = ''' Lychrel numbers Problem 55 If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, 349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337 That is, 349 took three iterations to arrive at a palindrome....
2145718e2b07813b6293893d8d39a88ed7b4993f
vlad-ki/5_lang_frequency
/lang_frequency.py
683
3.78125
4
import re from collections import Counter def load_data(filepath): with open(filepath) as file_handler: return file_handler.read() def text_replace(text): text = text.replace('-\n', '') text = text.replace('\n', ' ') r_ex = re.compile(r'[\w]{3,}') words = r_ex.findall(text) return w...
6b628e9a2f9cfeea262d920a4678abe280df0632
AlexeyTolpinskiy/Python_H
/HW-1.5.py
782
3.953125
4
#6. Спортсмен занимается ежедневными пробежками. В первый день его результат составил a километров. # Каждый день спортсмен увеличивал результат на 10 % относительно предыдущего. # ребуется определить номер дня, на который общий результат спортсмена составить не менее b километров. # Программа должна принимать значения...
541accc2a677b916215f08265c395733d4fd07de
burningskies42/advent_of_code
/day5/puzzle1.py
855
3.734375
4
def assign_seat(half, seat_range): range_len = len(seat_range) if half in ["F", "L"]: return seat_range[:int(range_len/2)] elif half in ["B", "R"]: return seat_range[int(range_len/2):] def deduce_seat(boarding_pass_str): seat_row = list(range(128)) seat_col = list(range(8)) f...
8e351c48251a9e1f721f6986c6e24fa4e06c297e
huskydj1/CSC_630_Machine_Learning
/Python Crash Course/sorting.py
1,777
3.640625
4
import random import numpy as np from numpy.lib.function_base import insert import time def is_sorted(list): for i in range(len(list)-1): if (list[i] > list[i+1]): return False return True def bogosort(list): while True: random.shuffle(list) if is_sorted(list): ...
f652b82d8d45709300ea2101a59e74dcd7ab1a76
mksk1999/guvi-problem
/a7.py
87
3.546875
4
s=input() a=s[::-1] if(a==s): print(s[:-1]) else: print(s)
e74a39eb0fe988f48654485e9d7e579d8c85f701
ilkersenerr/PythonOdevler
/odev3.py
1,109
3.71875
4
class Ogrenci: def __init__(self, ogrenciAdi, ogrenciSoyadi, ogrenciSinifi): self.ogrenciAdi = ogrenciAdi self.ogrenciSoyadi = ogrenciSoyadi self.ogrenciSinifi = ogrenciSinifi ​ ​ class Soru: def NetSayisi(dogru, yanlis): return dogru - yanlis * 0.25 ​ def Hesap...
7c7dd392a9a956568df1fc8ef042a295ca471aa6
jeandy92/Python
/ExerciciosCursoEmVideo/Mundo_3/ex103.py
410
3.703125
4
def ficha(nome='<Desconhecido>', gols=0): print(f"O jogador {nome} fez {gols} gol(s) no Campeonato") # Programa Principal nome_jogador = str(input("Nome do Jogador: ")).title() qtd_gols = str(input("Quantos gols foram marcados:")) if qtd_gols.isnumeric(): qtd_gols = int(qtd_gols) else: qtd_gols = 0 if nom...
7a5d2f83beab8d82d2c9e728a2755d6f7d36b9e6
zzy0119/test
/mytest/test11_map.py
138
3.734375
4
# -*- coding:utf-8 -*- def f(x): return x * x r = map(f, [1,2,3,4,5,6]) print(list(r)) r = map(str, [1,2,3,4,5,6]) print(list(r))
6875cce26577e2298da42931626e8d58a2e052c5
99002500/diabetiespredictonAI
/diabetes.py
493
3.59375
4
# This program detects if someone has diabeties or not # import the libraries import pandas as pd from sklearn.metrics import accuracy_score from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier from PIL import Image import streamlit as st # Create a title and a sub...
2bfb589c995320b7b593fa2c1c7d596d11f08d14
Aasthaengg/IBMdataset
/Python_codes/p03997/s953606614.py
73
3.53125
4
a, b, h = (int(input()) for _ in range(3)) s = (a + b) * h // 2 print(s)
b4df4f4ace6ba16bb78256842e390b9829b48ff9
wendful/hello-world
/my python/xr.py
71
3.515625
4
num= int(input("请输入一个数:")) print(int(str(num)[::-1]))
dc3b64ab33cd89df999179b40a1138b82f2d0681
michaelstresing/python_fundamentals
/07_file_io/07_02_writing.py
426
4
4
''' Write a script that reads in the contents of words.txt and writes the contents in reverse to a new file words_reverse.txt. ''' wordlist = [] with open('words.txt', 'r') as fin: for word in fin: word = word.rstrip() wordlist.append(word) # print(wordlist) wordlist.reverse() with ...
b7eef7493e186d9492e9e306510df287164390da
ryoichi551124/PythonBasic
/q11.py
261
3.890625
4
def reverse_order(num): num_list =[] str_num = str(num) reverse_num = str_num[::-1] for i in reverse_num: num_list.append(i) sepa_num_list = ' '.join(num_list) print(f'"{sepa_num_list}"') reverse_order(7536) reverse_order(123)
31ab431eecdf0ba408e286b1e6b894a0953f3706
enzoprogrammer/mi_primer_programa
/lista_string_contador.py
435
3.953125
4
lista_usuario= [] lista_conteo= [] operar= "SI" while operar != "NO": string_usuario= input("Dime un frase para agregar a mi lista: ") lista_usuario.append(string_usuario) operar= input("Desea seguir agregando frases? Si/No :").upper() if operar != "SI" and operar != "NO": operar=input("Por fav...
34402fdbcde9e9a639f7425ffa60a1a5ed6fc4b2
jhonnjc15/holbertonschool-higher_level_programming
/0x0B-python-input_output/12-pascal_triangle.py
945
3.875
4
#!/usr/bin/python3 """Module that list of lists of integers representing the Pascal’s triangle """ def pascal_triangle(n): """Finds pascal triangle numbers up to n Args: n (int): the depth of pascal's triangle """ pascal_list = [[1]] if n <= 0: return [] else: for ...
fccd439af11a6b5a2e097cc6621c29b432f9043e
Daisy0828/Search
/tarray.py
1,668
3.671875
4
from searchproblem import SearchProblem import numpy as np # The transition array search problem, implemented as a SearchProblem # States are array configurations. # Read the assignment handout for details. class TArray(SearchProblem): def __init__(self, length): self.start_state = TArray.random_start(len...
b55468deaddeebfd91444c37e82f6fa12b91ecbf
jedzej/tietopythontraining-basic
/students/urtnowski_daniel/lesson_06_dicts_tuples_sets_args_kwargs/snakify_lesson_8.py
950
4.21875
4
#!/usr/bin/env python3 """ snakify_lesson_8.py: Solutions for 2 of problems defined in: Lesson 8. Functions and recursion (https://snakify.org/lessons/functions/problems/) """ __author__ = "Daniel Urtnowski" __version__ = "0.1" def capitalize(lower_case_word): first_char_ascii_value = ord(lower_case_word[0]) ...
31e20d805a0e05803091fcbe86dc77219434a640
zhangsanjin3355/zxpython
/36-函数的嵌套调用应用.py
134
3.578125
4
def print_line(): print("-"*50) def print_5_line(): i=1 while i<5: print_line() i+=1 print_5_line()
6f05d194330d0d1604e6aa6259f135ad274211df
sornaami/luminarproject
/Flow Controls/looping stmnts/pgm number is prime.py
243
4.03125
4
#prime number checking number=int(input("enter number")) flg=0 for i in range(2,number): if(number%i==0): flg=1 break else: flg=0 if(flg>0): print("not prime") else: print("prime number")
17142bd444f94370a2e59fb0c8f630f183b7b2ee
gustavocrod/neural_networks
/artificial_neuron_networks/artificial_neuron/artificial_neuron.py
2,197
3.6875
4
import abc import numpy as np import math class ArtificialNeuron(object): __metaclass__ = abc.ABCMeta """ Classe abstrata Adaline: equacao de ajuste obtida para a saida linear Perceptron: equacao de ajuste obtida para a saida do nodo apos a aplicaca...
881e4d96d01adb16225f48502ff230a93a20d3be
kod3r/search-script-scrape
/scripts/100.py
967
3.515625
4
# The California city whose city manager earns the most total wage per population of its city in 2012 import csv import requests from io import BytesIO from zipfile import ZipFile YEAR = 2012 def foosalary(row): return float(row['Total Wages']) / int(row['Entity Population']) url = 'http://publicpay.ca.gov/Reports...
bd24883cc575e9d23ba64fdc1ce551fe5004b8c7
karthikavijayan9696/Training
/pythontask/task10.py
495
4.125
4
count = int(input('How many of you liked the post: ')) names = [] if count == 0: print('Nobody likes this') else: print(f'Enter names of {count} who liked the post ') for i in range(count): names.append(input()) if count == 1: print(f'{names[0]} likes this') elif count == 2: print(f'{names[0]} and {...
c982eaea1105c7e8488b5cb025451260bf3abbde
tanvir-ux/simpleNeuralNetwork
/neuralNetwork.py
734
3.609375
4
weight = 0.1 def neural_network(input,weight): prediction = input*weight; return prediction number_of_toes = [8.5,9.5,10,9] input = number_of_toes[0] pred = neural_network(input,weight) print(pred) # output should be 0.8500000000000001 #because pred = 8.5 * 0.1 #multiple inputs def w_sum(a,b): assert(len...
05b665b56c7967868c3c848293efad8e0b334f99
eamonyates/pp25_guessing_game_two_solutions
/PP25_GuessingGameTwo.py
1,428
3.90625
4
import time, math def start(): print ('\nThink of a number between 1 and 100') time.sleep(1) print ('Don\'t tell me what it is...') time.sleep(1.5) numberList = list(range(1, 101)) number = math.ceil(len(numberList) / 2) counter = 1 return (numberList, number, counter) def computerNumberGuess(): x = s...
40dd00ca6410a7d84011851e7cfb058462cc2ffb
wangpeihu/algorithm017
/Week_03/Construct_Binary_Tree_form_Preorder_and_Inorder_Traversal.py
1,870
3.875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode: ''' #第一种方法:递归 if len(inorder) == 0: ...
5348764de1b27b68a5145456b8e820572145c2af
AlexisPA19/Analisis-de-algoritmos
/MatEnCad.py
3,603
3.578125
4
from tkinter import ttk from tkinter import* class MultMat: def __init__(self,window): self.wind = window self.wind.title('Multiplicación de Matrices en cadena') #Creating a Frame Container frame = Frame(self.wind) frame.grid(row = 0, column = 0, columnspan = 3, pady = 20) ...
a90b6cc432f22d1c6d2ec122cd8daa16b45b09c9
DiegoPorfirio01/PYTHON-BASICO-40H
/NOMECONTAGEM.py
451
3.859375
4
frase = str(input('Qual seu nome completo?')).strip() print('O seu nome completo em maiuscula é {}'.format(frase.upper())) print('O seu nome completo em minusculas é {}'.format(frase.lower())) print('O SEU NOME COMPLETO TEM {} LETRAS '.format(len(frase) - frase.count(' '))) #print(' O SEU PRIMEIRO NOME TEM {}' .format(...
912012775ff30eb425d2683d3d3019f6623b8ac4
DSawtelle/ScammerSpammer
/scammerSpammer.py
6,998
3.75
4
""" Author: Daniel J. Sawtelle *** Purpose: Bombard the given URL with randomized form return data *** *** Source: https://www.youtube.com/watch?v=UtNYzv8gLbs """ import os import random import string import json import time import requests """ Function - Return a string object of a date formatted as specified *** s...
7a8ea8c18c205fc3c8ef0fbafe4f692451458899
cwavesoftware/python-ppf
/ppf-ex04/even.py
100
4.125
4
print("Enter number?") num = int(input()) is_even = (num % 2) == 0 print("Number is even: ",is_even)
bbf07cae1eaa68d596894f1614340627a77055f4
meggangreen/advent-code-2018
/files/day-20.py
6,954
3.78125
4
""" Let's make some trees """ # this is "implement jsonify" import re from collections import deque # class Section: # """ A section of the route in which there are no deviations -- ie each node, # a letter, has only one child -- because I think it will save in counting. # 'children' is a list of ...
54c17bed0fddc3a04215d9b0e5b2143059b0dfdf
alexDx12/gb_python
/lesson_8/exercise_1.py
1,789
3.75
4
""" 1) Реализовать класс «Дата», функция-конструктор которого должна принимать дату в виде строки формата «день-месяц-год». В рамках класса реализовать два метода. Первый, с декоратором @classmethod. Он должен извлекать число, месяц, год и преобразовывать их тип к типу «Число». Второй, с декоратором @staticmethod, долж...
3f98f4c9009e4cb5d8710f7267f9f6cb57fa67dd
tiduswr/Algoritimos_P1_UEPB_CCEA_CAMPUS_VII
/Lista 02/lista02ex13.py
1,482
3.828125
4
#Deixando o programa amigavel: print('=' * 50) print('{:^50}'.format('Banco 24hrs')) print('='*50) valor = int(input('Quanto você deseja sacar? R$ ')) print('') #Nomeando variaveis: total = valor ced = 100 totced = 0 #Tive que aprender esse código novo, pois eu não estava conseguindo fazer de outra forma que ...
da433c9f5c17fd0e7c77d4f95011740e73804d60
Ashwinbicholiya/Python
/Python/assignment/30numpy.py
189
4.0625
4
#add 2 arrays using forloop from numpy import * arr1=array( [1,2,3,4]) arr2=array([1,2,3,4]) arr3= empty(4,int) for i in range(len(arr1)): arr3[i] = (arr1[i] + arr2[i]) print(arr3)
0a653bbbfa79a08a206d4c141d0b5eea0514ff61
Shaaman331/Dev-Aprender-Aulas
/Aula10.recebendo_dadds_usuario.py
602
4.28125
4
'''' Função Input * O input()função permite a entrada do usuário. * Use o parâmetro prompt para escrever uma mensagem antes da entrada: Função Int * O int()função converte o especificado valor em um número inteiro * Converte uma string em valor inteiro ''' print('Função Input') print('Enter your name:') x = inp...
36917421e0461f2c37ab18ad7879c9bddd9c3080
danielcz007/pycharm2021project0416
/practice/5python常见数据结构.py
2,134
3.921875
4
# -*- coding: utf-8 -*- # @Time : 2021/1/24 21:33 # @Author : Daniel ''' 列表 定义: - python中可以通过组合一些值,得到多种复合数据类型 - 列表是其中最常见的数据结构 - 列表通过 元组: () 元素不可修改 字典:键值对 {} 集合:用 set() 关键字创建 {} ''' list_test = ['a', 'b', 'c', 'n', 'd', 1, 2, 3, 4, 5, 7, 8, 1, 'c', 'a', 0] ...
4ba6229ceedd91e9b77aa6e9112ddecf2817040e
stuffyUdaya/Python
/1-9-17/shiftarrayvalues.py
181
3.796875
4
arr = [3,5,7,8] for x in range(len(arr)-1,0): arr[x] = arr[x+1] print arr # def shift(arr): # arr.pop(0) # arr.append(0) # return arr # print shift([1,2,3,4])
d911e033ddcfe181e169173a05c298c5e26f8584
Reid-Norman/100-Days-of-Code
/Day 12/GuessTheNumberGame-v2.py
1,559
4.125
4
from random import randint from art import logo def set_difficulty(): '''A function which returns the number of attempts associated with the chosen difficulty''' if input("Choose a difficulty. Type 'easy' or 'hard': \n").lower() == "hard": return 5 else: return 10 def answer_checker(gues...
61810d5b99c3cfc456f9e24affd85ced270102c4
MIsmailKhan/Project-Euler
/061.py
1,948
3.65625
4
import time import math from itertools import permutations start = time.time() # Fairly verbose solution # Note: Create functions to create more elegant code def triangle_numbers(index,start=1): result = [] for n in xrange(start,index): result.append((n*(n+1))/2) return result def square_numbers(index,start=1)...
511f4ccee9469fffde6e9b69f90c61205c6a53a6
zalanh/learn-python
/ifstate5.py
287
3.9375
4
print("Want to hear a dirty joke?") age = 12 if age == 12: print("A pig fell in the mud !") else: print("Shh. It's a secret.") print("Want to hear a dirty joke?") age = 8 if age == 12: print("A pig fell in the mud !") else: print("Shh. It's a secret.")
3941d5c36a798696d051d618b4eef108791a11c4
wardaddy24/Python_Sorting-Searching
/binarysearch.py
615
3.953125
4
def bsearch(a,key): start=0 end=len(a)-1 while(start<=end): mid=int((start+end)/2) if a[mid]==key: return mid elif a[mid]>key: end=mid-1 elif a[mid]<key: start=mid+1 a=[] x=int(input("Enter the n...
08cd8e545d34d33db2fc4501e7a1231bd3d29332
MarcPartensky/Pygame-Geometry
/pygame_geometry/materialform.py
11,679
3.53125
4
from .materialpoint import MaterialPoint from .abstract import Form,Point,Vector from .material import Material from .motion import Motion from .force import Force from . import materialpoint from . import force from . import colors import math import copy class MaterialForm(Material,Form): """A material form is ...
3503794997dce6518791e3cadd3633111a429f8f
Adewale888/Data_Structures
/Single_Number.py
623
3.84375
4
""" Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. Example 1: Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2] Output: 4 Example 3: I...
9a8f8553651c28b83478c5f5c543030b3a636202
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4127/codes/1800_2567.py
154
3.828125
4
from numpy import* a= int(input("numero de asteriscos: ")) k=a for i in range(a): print("*"*a) a= a-1 a = a +1 for i in range(k): print("*"*a) a=a+1
98c66ee0792bf54e60c292ddc70b33fe29106e9c
qmnguyenw/python_py4e
/geeksforgeeks/python/easy/25_13.py
2,964
4.90625
5
Python | Creating a 3D List A 3-D List means that we need to make a list that has three parameters to it, i.e., (a x b x c), just like a 3 D array in other languages. In this program we will try to form a 3-D List with its content as “#”. Lets look at these following examples: Input : ...
cc204660e3accc9099df3d38b9f3033e2267304d
Okiii-lh/to_offer_note
/python/链表中倒数第k个节点.py
415
3.59375
4
class ListNode: def __init__(self, x): self.val = x self.next = None def findKthNode(pListHead, k): if pListHead is None or k == 0: return tmpNode = pListHead resultNode = pListHead for i in range(k): if tmpNode.next is not None: tmpNode = tmpNode.next else: return while tmpNod...
2a0c3b7cfb8ab58354e5a44dedb6b65f50d33c59
bakker4444/Algorithms
/Python/leetcode_481_magical_string.py
1,688
4.0625
4
## 481. Magical String # # A magical string S consists of only '1' and '2' and obeys the following rules: # # The string S is magical because concatenating the number of contiguous occurrences of characters '1' and '2' generates the string S itself. # # The first few elements of string S is the following: S = "12211212...
229d6a639c3148a85ede91f884cc4004ce71e6a0
Noboomta/ISP-SKE-KU-2020
/labexam1-Noboomta/bank_account.py
5,182
4.09375
4
""" import """ from money import Money from check import Check class BankAccount: """ A BankAccount with a minimum required balance (default is 0) that accepts deposit of Money or Checks. The balance is always the total of deposits minus withdraws, but the value of a check is not available for wi...
6b99f97439b7e623e0197378e7b7c056d295b1e0
jmval111/Programming-Foundations-with-Python
/2 - Uses Classes - Draw Turtles/Making A Circle Out Of Squares/circles squares.py
506
3.8125
4
import turtle def draw_square(some_turtle) : for i in range(0,4) : some_turtle.forward(100) some_turtle.right(90) def draw_art() : window = turtle.Screen() window.bgcolor("red") jp = turtle.Turtle() jp.shape("turtle") jp.color("yellow") jp.speed(6) for i in range(0,36) : draw_...
e252e529272fd288fca0ea9eba48c2ffcc178e29
AlexseyPivovarov/python_scripts
/Lesson13_1527107917/Lesson13/lesson12/yield_.py
236
3.703125
4
def f(a): yield while a: yield a a-=1 else: return 999 a = f(5) print(next(a)) print(next(a)) print(next(a)) print(next(a)) print(next(a)) print(next(a)) print(next(a)) print(next(a)) print(next(a))
07c5c529e740af3fc6d0118d8e630d9750108634
RotcivSnitram/Graphs
/grafico.py
887
3.9375
4
''' Documentação: Gera gráficos de funções escolhidas Ao digitar o comando no terminal deve-se colocar: python (ou python3) nomedoarquivo.py 'equação f(x)' valor_do_intervalo_inicial valor_do_intervalo_final ''' # Biblioteca import numpy as np import math import sys import matplotlib.pyplot as plt # F...
35829561de09a77eb965e593e87afe8e3e03da64
rusini/life10-benchmarks
/life.py
1,170
3.546875
4
# life.py -- Conway's Game of Life in Python (version 2) from sys import stdout n, m = 40, 80 g = 1000 def display(b): for i in xrange(n): for j in xrange(m): stdout.write("*" if b[i][j] else " ") print def main(): b = [[0 for j in xrange(m)] for i in xrange(n)] # initialization b[19][41] = 1...
f79ea66d25d259f45c8fbed68dda5523a7050d37
souravs17031999/100dayscodingchallenge
/cs50/pset1.py
789
3.796875
4
def mario_block_right(n): for i in range(0, n): for j in range(0, n-i-1): # printing spaces print(" ", end = "") for k in range(0, i + 1): # printing stars print("*", end = "") print() def mario_block_left(n): for i in range(0, n): for k in range(0, i + 1): # printing stars print("*", end = "") pr...
1a1d8681f4cf5425888f3e8c57051cdc1d25b22f
Naman5tomar/Hacktoberfest-2021
/Dice Roll Simulator.py
296
4.375
4
#importing module for random number generation import random #range of the values of a dice min_val = 1 max_val = 6 #to loop the rolling through user input roll_again = "yes" #loop while roll_again == "yes" or roll_again == "y": print("Rolling The Dices...") print("The Values are :")
7a34a68ae0051a708c7e4d90b8b7f4a3d75cf662
gabriellaec/desoft-analise-exercicios
/backup/user_107/ch22_2020_09_16_10_50_14_782276.py
193
3.625
4
count = int(input("Quantos cigarros você fuma por dia?")) time = int(input("Há quantos anos você fuma?")) days_per_cigarrette = 10 / 60 / 24 lost_time = count * days_per_cigarrette * time
7fc9b6836b1e0ae6838ddaf4fbdd6ed165afa9b5
katieunger/hmc-homework
/lesson_1/pbj.py
5,820
4.1875
4
# Variables bread = 8 peanutButter = 6 jelly = 0 sandwiches = bread/2 minIngredientQuantity = min(sandwiches, peanutButter, jelly) # Goal 1 # Create a program that can tell you whether or not you can make a peanut butter and jelly sandwich print "Goal 1" print "Can I make any peanut butter and jelly sandwiches?" # If ...
1e782445919645b992cad93a03f6010f4fd8e025
Kronossos/DLS_trees
/test_module/Tree.py
3,981
3.796875
4
# -*- coding: utf-8 -*- import random class Leaf: def __init__(self, value): self.value = value self.color = "white" def __iter__(self): yield self def __str__(self, level=0, blank=False, sign=" "): if not blank: blank = [] line = list(" " * level + s...
775be2c124779c47bf7a5408b9e8f631b6a8d6a9
chenlei65368/algorithm004-05
/Week 1/id_040/LeetCode_283_040.py
1,284
3.703125
4
# 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 # # 示例: # # 输入: [0,1,0,3,12] # 输出: [1,3,12,0,0] # # 说明: # # # 必须在原数组上操作,不能拷贝额外的数组。 # 尽量减少操作次数。 # # Related Topics 数组 双指针 # # leetcode submit region begin(Prohibit modification and deletion) class Solution: def moveZeroes1(self, nums: list) -> None: """ ...
bb49f6363d633439c4856806c202c8e65cc59ad2
s-vedara/Python-Lessons
/Lesson-7-Loops.py
309
4.21875
4
#Конечный цикл. for x in range(0,100, 2): #3 цифра это шаг # print("123") print(x) if x == 50: ##Если x раво 50 то прервать break #Безконечный цикл. x=0 while True: print(x) x=x+1 if x == 100: break
df55eff3c745496dca439685aa8f8b0869b3d7ae
ArnulfoPerez/python
/raspberry/oo/turtle_race.py
623
3.75
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 28 13:06:59 2019 @author: arnulfo """ from turtle import Turtle from random import randint laura = Turtle() rik = Turtle() lauren = Turtle() carrieanne = Turtle() colors = ['red','purple','green','blue'] index = 0 turtles = [laura,rik,lauren,carrieanne] startx, star...
ee80948bf145312860867b875725ab50b6dd2948
Ankush-Anku/Tranning
/38_simple_interest.py
298
3.875
4
#Assignment """ Accept p,n and r si = pnr/100 print si """ def print_interest(n,p,r): si = (p*n*r)/100 print(f"Simple interest is = {si}") def main(): n = float(input("Enter n: ")) p = float(input("Enter p: ")) r = float(input("Enter r: ")) print_interest(n ,p,r) main()
ae6896cc66f403b87d46ea88f23f11284f5c9780
nathan181/entrega2PBD
/exerc04.py
1,546
4.34375
4
"""4. Faça um Programa que leia 2 números e em seguida pergunte ao usuário qual operação ele deseja realizar. O resultado da operação deve ser acompanhado de uma frase que diga se o número é: par ou ímpar; positivo ou negativo; inteiro ou decimal. """ n1, n2 = float(input("Digite o primeiro número: ")), float(input("D...
c23ba21792ac483b47121e4a14a304004abe3576
YusiZhang/leetcode-python
/BinaryTree/MaximumDepthBinaryTree.py
1,194
3.546875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ if not root: ...
c12a39a6bfa880d13d3e62cab36721762d413dfb
grvn/aoc2020
/02/day2-2.py
357
3.59375
4
#!/usr/bin/env python3 from sys import argv def main(): valid=0 with open(argv[1]) as f: for line in f: a,b,passwd = line.strip().split() min,max = a.split('-') letter = b.strip(':') if (passwd[int(min)-1] == letter) ^ (passwd[int(max)-1] == letter): valid+=1 print('1:',valid)...
a64f6cbf7e332f140073895f6c5a35cbe06caba1
sernol9/Python4Beginners
/Python for Everybody/Exercises215.py
299
3.890625
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 11 17:29:40 2019 @author: olivia """ # name = input("Enter your name\n") # print (name) try: hours = float(input ("Enter Hours:")) rate = float(input("Enter Rate:")) print ("Pay"+str(hours*rate)) except: print("Enter float numbers\n")
f7694836e3b09c8212fb19c0ef9a0b6812db61db
jamiejamiebobamie/pythonPlayground
/gold_mine.py
2,162
4.15625
4
# https://www.geeksforgeeks.org/gold-mine-problem/ # Given a gold mine of n*m dimensions. # Each field in this mine contains a positive integer which is the amount of gold in tons. # Initially the miner is at first column but can be at any row. # He can move only (right->,right up /,right down\) that is from a given ce...
c99501502c5ae7e95d117746d09a988f579c8a49
kaushikdivya/realpython
/poetry.py
1,784
3.703125
4
def makePoem(): import random nouns = ["fossil", "horse", "aardvark", "judge", "chef", "mango", "extrovert", "gorilla"] verbs = ["kicks", "jingles", "bounces", "slurps", "meows", "explodes", "curdles"] adj = ["furry", "balding", "incredulous", "fragrant", "exuberant", "glistening"] prep = ["against"...
3f043cdb66ccab201a7610b50151ed0155dce946
Aasthaengg/IBMdataset
/Python_codes/p03544/s750060000.py
132
3.84375
4
memo = {0:2, 1:1} n = int(input()) for number in range(2,n+1): memo[number] = memo[number-1] + memo[number-2] print(memo[n])
5ab6e24f24e404637b835c3e92529b4398e3d7c9
Callum-Diaper/COM404
/1-basics/3-decision/8-nestception/bot.py
851
4.28125
4
user_inp = str(input("Where should I look? ")) if user_inp == "in the bedroom": bedroom_inp = str(input("Where should I look in the bedroom? ")) if bedroom_inp == "under the bed": print("Found some shoes but no battery") else: print("Found some mess but no battery.") elif user_inp == "in t...