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
2c01174a18eddce5acb9c6af4dbe8d3eada0753a
aly50n/Python-Algoritmos-2019.2
/lista01ex06.py
297
3.8125
4
print("Reajuste de salário do funcionário:") s=float(input("Digite o valor do salário atual do funcionário-> ")) p=float(input("Digite de quantos porcento será o reajuste-> ")) ns=print("O novo salário do funcinoário será de:", (s*p)/100+s) ns print("Obrigado por usar este aplicativo :D")
1f48de20b12bbe2fe102b827524497c2b4b95ecd
Abinesh1991/Numpy-tutorial
/NumpyTutorial3.py
1,795
4.4375
4
""" Indexing and Slicing Assigning to and accessing the elements of an array is similar to other sequential data types of Python, i.e. lists and tuples. We have also many options to indexing, which makes indexing in Numpy very powerful and similar to core Python. Arrays of Ones and of Zeros - Intializing Arrays with 0'...
aada49073f0425411e870a18cbde25178ad23d62
kamalsingh-engg/udemy_courses_python
/3. Basic Operation With Data type/string_slice.py
255
4.34375
4
#string slicing is same as the list slicing #e.g. a = "kamal" a1 = a[0] a2 = a[:3] a3 = a[-1] a4 = a[-2:] print(a1) print(a2) print(a3) print(a4) #example of string slicing with list l = ['kamal',2,4,5,6] l1 = l[0] l2 = l[0][3] print(l1) print(l2)
b2b66debb5b4b1150b7bf205b2de2ed978843b70
Josue23/matplotlib
/aula4.py
1,328
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' https://www.udemy.com/making-graphs-in-python-using-matplotlib-for-beginners/learn/v4/t/lecture/6304432 4. Rotating Axis Ticks, Adding Text and Annotations ''' import matplotlib.pyplot as plt with open("Goals.txt", "r") as f: HomeTeamGoals = [ int(x) for x in ...
6a17114d29abd640bd672696e665d35cbde28b92
NivaLado/Numerical-Methods
/Laboratory work 3/bisection.py
429
3.765625
4
def f(x): return (1/2)*(25/x+x) iteration = 0 a = 1 b = 4 epsilon = 0.01 while abs(b - a) > epsilon: iteration += 1 c = (a + b) / 2 if (f(a) * f(c) > 0): a = c else: b = c print(str(iteration) + ' ' + str(abs(b-a)) + ' ' + str(c)) print('X: ' + str(c)) print('Число Итераций: ...
bfeb140b2abf25fc5d96b65ab18fd915a031702d
Suresh8353/ATM-Work
/ATM.py
5,528
3.6875
4
amount=500 def ATM(): print("========================================================================") print("\t\t A T M O P E R A T I O N") print("========================================================================") print() print("\t\t\t 1. Deposite ") ...
5b1c9d1ad36af18dbce6a3055a08e37b4864067d
zzwerling/DailyCodingProblemSolutions
/challenge1.py
294
3.78125
4
# Problem 1 # Given a list of numbers and a number k, return whether any two numbers from the list add up to k. def adds_up(list, k): for i in range(len(list)): for j in range(i+1, len(list)): if list[i] + list[j] == k: return True return False
3c318c562d10bf6108e7b17c94e5b5cf8f7a31d5
duniganc1945/CTI110
/P5T2_FeetToInches_DuniganHogan.py
552
4.25
4
#P5T2 - Feet to Inches #CTI-110 #Ciera DuniganHogan #19 April 2019 # choice = 'yes' while choice.lower() == 'yes' : def main(): #Get input feet = int(input('Enter measurement in feet: ')) #Display conversion conversion (feet) def conversion (feet) : #Calculate feet to inches ...
42e7b0f1caced2a97f9b258f5865a83b4db1e630
jjeong723/Algorithm_Practices_Test
/Codeit_Code/Algorithm/4-1. Test_Level1_pro1.py
572
3.546875
4
def sublist_max(profits): # 코드를 작성하세요. size_num = len(profits) list_range = [] max_num = 0 for num in range(size_num): sum_num = 0 for num2 in range(num, size_num): sum_num += profits[num2] if sum_num > max_num: max_num = sum_num ...
039dd77719356fd2c12665d2e68de239e9b96140
riddhisahu9/hackerrank
/Python/Strings/Find a string/solution.py
705
4.125
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- # @Script: solution.py # @Author: Pradip Patil # @Contact: @pradip__patil # @Created: 2018-02-17 14:56:02 # @Last Modified By: Pradip Patil # @Last Modified: 2018-02-18 13:51:34 # @Description: https://www.hackerrank.com/challenges/find-a-string/problem def count_substrin...
561966c5f877f78fe6ab28e4e8207f668aaf9eec
anamariagds/primeiroscodigos
/repetições/forteste2.py
523
3.671875
4
def eh_par(n): return n%2 ==0 def pares(inicio, quantidade): if eh_par(inicio): inicio += 2 else: inicio += 1 numeros_pares ='' for n in range(inicio, inicio+(quantidade*2), 2): numeros_pares += str (n) + ' ' return numeros_pares.strip() def main(): in...
269d4b1df449320656cfe6ea653537896729b198
yuchien302/LeetCode
/leetcode146.py
804
3.5
4
from collections import OrderedDict class LRUCache(object): def __init__(self, capacity): """ :type capacity: int """ self.dict = OrderedDict() self.cap = capacity def get(self, key): """ :rtype: int """ if key in self.dict: ...
c0aff8e5e706b784f7ad3411323331bacb6c6114
shreyrai99/CP-DSA-Questions
/LeetCode/LinkedList Palindrome/ll palindrome.py
462
3.515625
4
class Solution(object): def isPalindrome(self, head): """ :type head: ListNode :rtype: bool """ curr = head # This is the key to O(1) space. stringified_list = "" while (curr): stringified_list += str(curr.val) curr = curr.nex...
2827c8423400bfe3d5c7992fd80d1a8d321dbd9f
pmmorris3/Code-Wars-Solutions
/5-kyu/valid-parentheses/python/solution.py
471
4.25
4
def valid_parentheses(string): bool = False open = 0 if len(string) == 0: return True for x in string: if x == "(": if bool == False and open == 0: bool = True open += 1 if x == ")" and bool == True: if open - 1 == 0: ...
8ee8e96d7bdbbf7d3f182c73eddc93877fc4323e
WckdAwe/SortViz
/SortViz/pysort.py
15,659
3.75
4
from random import shuffle from time import sleep from .display import * import threading x = 0 def bubble_sort(a_list, fig): ''' Performance: Best O(?) || Average O(n^2) || Worse O(n^2) :param a_list: :param fig: :return: ''' for i in range(1, len(a_list)): for j in range(1, len(...
71d495e8529cc05b26af0dc346e120271071780f
galkampel/Link_prediction
/link_prediction/cracking_the_code.py
738
3.71875
4
def get_all_paren(n_open,n_close,tmp_s,all_paren = []): if n_open == n_close and n_open == 0: all_paren.append(tmp_s) return all_paren elif n_open == n_close: return get_all_paren(n_open-1,n_close,tmp_s+'(',all_paren ) elif n_open == 0: tmp_s += n_close * ')' ...
4af24bbfdd17facea513e2d2058613c50c281baf
ellisp97/pythonHR
/bubblesort.py
1,174
3.765625
4
#!/bin/python3 import math import os import random import re import sys """attempt 1 not actually bubble sort """ # def countSwaps(a): # count = 0 # for i in range(len(a)): # if not (a[i] == i+1): # for j in range(i+1,len(a)+1): # if a[j] == i+1: # # prin...
073c1d22430e65a9780a876318bb1dcc600c5b0e
NikaEgorova/goiteens-python3-egorova
/homeworks/hw3/num1.2.py
455
3.578125
4
George_Washington = 2 Thomas_Jefferson = 2 Herbert_Hoover = 1 Barack_Obama = 2 coef = 4 for a in range(1, 3): if a % 2 == 1: print("Herbert Hoover був президентом", a * coef, "роки") if a % 2 == 0: print("George Washington був президентом", a * coef, "років", "\n" "Thomas Jefferso...
fc0e1b7c9aa823f3dba6f8d99b8086d93f31b986
Hasib104/Learning-Python
/Day012/Guess the number.py
1,622
4.0625
4
import random print("Welcome to Guess the number.") print("I am thinking of a number between 1 and 100.") numbers=[] for counter in range(0,101): numbers.append(counter) #print(numbers) def select_number(): chosen_number = random.choice(numbers) return chosen_number lives_easy = 10 lives_...
5645a88eaaec98ce289fe3f6c5d05a1161f2e7b9
prakash-simhandri/Jessie_artificial_intelligence-
/Jessie/Jessie_AI.py
9,115
3.59375
4
import datetime,time import speech_recognition as sr # sudo pip3 install SpeechRecognition % sudo pip3 install SpeechRecognition OR sudo apt-get install python-pyaudio python3-pyaudio import wikipedia,random # sudo pip3 install wikipedia import webbrowser,os,wolframalpha # sudo pip3 install wolframalpha from ...
d2606f0d965b8353a6cf5046c313f0806e347142
CodecoolGlobal/lol_erp
/sales/sales.py
5,343
3.8125
4
""" Sales module Data table structure: * id (string): Unique and random generated identifier at least 2 special characters (except: ';'), 2 number, 2 lower and 2 upper case letters) * title (string): Title of the game sold * price (number): The actual sale price in USD * month (number): Month o...
e68c4609833c0e11e448a1b338dd38eb3f5a1e37
luojxxx/Coding-Practice
/hackerrank/interview_prep/comparator_sorting.py
581
3.640625
4
# https://www.hackerrank.com/challenges/ctci-comparator-sorting from functools import cmp_to_key class Player: def __init__(self, name, score): self.name = name self.score = score def __repr__(self): return self.name + ' ' + self.score def comparator(a, b): ...
33f070247da3e66d9830e062bdf2488e45137400
GreatGodApollo/bashbot
/cogs/random.py
1,018
3.546875
4
import discord from discord.ext import commands import random class Random: """Random Cog""" def __init__(self, bot): self.bot = bot @commands.command(pass_context=True) async def roll(self, ctx, sides: int = 6): """Roll a die""" if sides >= 2: await self.bot.say(...
48886ec0a33211daa61803553b77b66a50640354
djmar33/python_work
/ex/ex4/ex4.3.3.py
222
3.765625
4
#4.3.3列表统计 digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] #列表中最小的数 print(min(digits)) #列表中最大的数 print(max(digits)) #列表中所有数之和 print(sum(digits)) #列表长度 print(len(digits))
e8bb4ae0457880e7025a93fbccc241b2c23179c2
Jamibaraki/adventOfCode2017
/day13b.py
3,450
3.75
4
#Advent of Code '17 #Day 13a: Packet Scanners #This runs slowly with proper data! #Quicker to optimise than run again #Check 13b2.py for optimized version import platform print ( platform.python_implementation() ) import re #read input file = open('input13.txt','r') input = file.read().split('\n') file.close() #ge...
53fa6c2a34d0dce377597de737455c86dfd0c39e
JulietaCaro/python
/Condicional/ejercicio 6 condicional.py
504
3.828125
4
paginas = int(input("Ingrese la cantidad de paginas: ")) if paginas<300: costo1 = 125 + (paginas*2.20) print("El costo es de ", costo1) else: if paginas>300 and paginas<600: #costo2 = 125 + (paginas * 80) costo2 =int( 125 + 80 + (paginas * 2.20)) print("El costo es de ", cost...
4664cf1295e072383d367bedd29c468708deaa8f
maxfeldman14/tools
/permuter.py
819
4
4
#!/usr/bin/env python import sys import enchant import itertools def permute(string, numchars): words = {} count = 0 d = enchant.Dict("en_US") #l = list(string) perms = itertools.permutations(string, int(numchars)) #now have a spellchecker and all permutations #keep only words which are valid and <= numc...
86fe6020084d15e3141f292ee06f8ff66119b937
whysuman/Hacktoberfest_2020
/Problems/sumanthra problem3.py
334
4.03125
4
a = int(input("Please enter your number a: ")) b = int(input("Please enter your number b: ")) c = int(input("Please enter your number c: ")) if (a**2) == (b**2) + (c**2) : print(f'{a},{b},{c}') elif (b**2) == (a**2) + (c**2): print(f'{b},{a},{c}') elif (c**2) == (a**2) + (b**2) : print(f'{c},{...
f3a37f9049674f0c94205583ba34a09af8859511
romebell/python_classes
/inheritance.py
2,648
3.984375
4
# Inheritance class Phone: def __init__(self, phone_number): self.number = phone_number def __str__(self): return f'Phone: {self.number}' def call(self, other_number): print("Calling {} from {}.".format(other_number, self.number)) def text(self, other_number, msg): pr...
4b68a3139ba368cd6f80caed3349044a40eb9dfe
Mr-StraightFs/Simple_Calculator_with_Tkinter
/Calculator.py
3,434
4.125
4
import tkinter from tkinter import * root = Tk() root.title="Simple Calculator" e=Entry(root , width=35,borderwidth=5) e.grid(row=0,column=0,columnspan=3,padx=10,pady=10) def button_click(number): if number == "clear" : e.delete(0, END) return current= e.get() e.delete(0,END) e.insert(...
7fe54b433df2a57dc813822950f22a741d7beb97
abid-mehmood/SP_Labs
/Labs/Python_homework/task4.py
260
3.890625
4
def remove_adjacent(name): i=1 while i < (len(name)-1): if name[i-1] == name[i] or name[i+1]== name[i]: del name[i] i-=1 i+=1 return name if __name__=="__main__": TempList=[1,2,2,2,2,3,4,5,5] print TempList print remove_adjacent(TempList)
322aa3bedd4ce2c7bdf80cd7bca5c5bc1b24b743
dhruvag02/Pyhton
/distinctPairs.py
1,030
3.5
4
def isNotEmpty(a): if len(a) == 0: return True else: return False def binarySearch(a, value): low = 0 high = len(a) - 1 while low <= high: mid = (low + high)//2 if a[mid] < value: low = mid+1 elif a[mid] > value: high ...
0fc380fd98ecad25e2dc6ee2fa0628d733431714
Pechi77/generate-charts
/nass_weather.py
631
3.5625
4
def weather_by_city(city): weather = Weather(unit=Unit.CELSIUS) location = weather.lookup_by_location(city) condition = location.condition current_condition=condition.text current_temp=location.print_obj["item"]["condition"]["temp"] forecasts = location.forecast weather_df=pd.DataFram...
c777c808594dee47a5500234cecf6628ce096ee6
jjkim110523/flask_tutorial
/flask_Sessions/flask_session.py
1,317
4.0625
4
""" 쿠키랑은 다르게 세션은 서버에 저장되어있는 데이터입니다. 세션은 서버의 임시 디렉토리에 저장되어 작동합니다. 각각의 클라이언트는 세션 ID를 부여받습니다. 암호화가 된 데이터이기 때문에 Flask에서는 SECRET_KEY가 필요합니다. """ from flask import Flask, session, redirect, url_for, escape, request app=Flask(__name__) app.secret_key="asdfsdfg" @app.route("/") def index(): if "username" in session: ...
a60959075c931679a424838f807b1b8141d8138d
pedroesc123/codigo_python
/complejidad_algoritmica.py
652
3.65625
4
import time import sys sys.setrecursionlimit(2500) print (sys.getrecursionlimit()) #Iterativo def factorial(n): respuesta = 1 while n > 1: respuesta *= n n -= 1 return respuesta #Recursivo def factorial_r(n): if n == 1: return 1 return n * factorial_r(n-1) if ...
65240998e3eee7f8897536256a1be9da535a6944
aaroncsolomon/244proj
/linear_regression2.py
2,331
4.0625
4
import tensorflow as tf import numpy as np # Generate samples of a function we are trying to predict: samples = 100 xs = np.linspace(-5, 5, samples) # We will attempt to fit this function ys = np.sin(xs) + np.random.uniform(-0.5, 0.5, samples) # First, create TensorFlow placeholders for input data (xs) and # output (...
5632767ce48d3c89e02549b6799ff2c19ab2a34a
MADMAXITY/cipherschools-june-2021
/Day-1/AlternativeSorting.py
337
3.9375
4
def print_alternative(arr): low, high = 0, len(arr) - 1 while high > low: print(arr[high], arr[low], end=" ") high -= 1 low += 1 if high == low: print(arr[high]) if __name__ == "__main__": arr = [int(x) for x in input("Enter array : ").split()] arr.sort() print_...
1f95dd4e2b26038b1b96b9d1cc70c840d7b104d7
SteveGaleComputingStudies/2020Python2
/classes/shark3.py
264
3.828125
4
class Shark: def __init__(self, name, age): self.name = name self.age = age new_shark = Shark("Sammy", 5) print(new_shark.name) print(new_shark.age) stephan = Shark("Stephan", 8) print("stephan name= ",stephan.name) print("Age = ",stephan.age)
440f5a6d277e4dfc80786e95529aaae5513f8602
jvlazar/mutation
/substitute.py
2,662
3.890625
4
from pathlib import Path import sys try: fName = open(sys.argv[1], "r") oName = open(sys.argv[2], "w+") if len(sys.argv) !=3: print("An input and output file name must be provided") quit() fasta = False target = input("What amino acid do you want to delete?: ") ...
f1b5956c67d6c94bfec28209faeb3fdeb526208b
Kohdz/Algorithms
/LeetCode/easy/07_mergeTwoList.py
1,346
4.1875
4
# https://leetcode.com/problems/merge-two-sorted-lists/ # Merge two sorted linked lists and return it as a new list. # The new list should be made by splicing together the nodes of the first two lists. # Example: # Input: 1->2->4, 1->3->4 # Output: 1->1->2->3->4->4 # Definition for singly-linked list. class ListN...
b3366364e4722a046917840396e1c4781ee9aaf3
aleexiisz57/Lessons
/Lesson-1/ex6.py
1,016
4.5625
5
# x is a variable and we giving it a value with strings, we also set the values for "binary" #and "do_not" so that they can be used inside the strings. x = "there are %d types of people." % 10 binary = "binary" do_not = "don't" y = "Those who know %s and those who %s." % (binary, do_not) #these lines print my variable...
1063dd4961d52b1a7700c7dab58d5545cd8c6162
FerCremonez/College-1st-semester-
/a8e1.py
178
3.875
4
soma=0 #conta quantas entradas foram adicionadas for i in range (0,4): #limite do intervalo num=int(input("insira o número:")) soma+=num print('soma =',soma)
a955c24262b1fbab963100780392ac0c4b875f86
bing1zhi2/algorithmPractice
/pyPractice/algoproblem/kth_largest.py
1,923
4.125
4
''' Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example 2: Input: [3,2,3,1,2,4,5,5,6] and k = 4 Output: 4 ''' class Solution(object): def findKthLargest(self, nu...
0e9676cf7d639c4ab59bb8ef0e00c8ffd59e53ad
ctc316/algorithm-python
/Lintcode/Ladder_48_Backpack/3_Complete backpack/440. Backpack III.py
1,409
3.5625
4
# Version 1: TLE class Solution: """ @param A: an integer array @param V: an integer array @param m: An integer @return: an array """ def backPackIII(self, A, V, m): dp = [0 for _ in range(m + 1)] for i in range(len(A)): for j in range(1, int(m / A[i]) + 1): ...
b8eb0130f6e381a6362e0312e6276bac2a86149f
Weenz/software-QA-hw2
/main.py
2,228
4.21875
4
import math from bmiCalc import * from retirementCalc import * option = 1 while (option != 3): print ("--------------------------------") print ("| |") print ("| Software QA Assignment 2 |") print ("| |") print ("------------...
f1948a316d199be4c8ee13e55d307a1333957d07
Jackthedowner/My_python_school_programs
/Even_series_program.py
443
3.875
4
def ev(n): listofEven=[] listofall=[] print('ALL NUMBERS:→') for i in range(0,n+1): print(i,end=' ') listofall.append(i) print('List of All Numbers:',listofall) print('EVEN NUMBERS→') for i in range(0,n+1,2): print(i,end=' ') listofEven.append(i) print('...
7b44b16d18e00ceb79851b1c848e75d3f33cba0a
joeyscl/Programming_Challenges
/Sorting & Searching/linearSortSequence.py
533
4.125
4
''' given an array of integers from 0 ~ n-1 where (n is the length of the input array) sort the array in-place in linear time ''' ''' We 'sort' by swapping elements directly into where they belong since element value correspond to indices directly ''' def linSort(arr): count = 0 idx = 0 while count < len(arr): ...
adafc259fcea61f98c3e88aa66081b02a31c3957
chuajunyu/scvu-git-tutorial
/HW5/HW05_Ian.py
3,892
3.90625
4
#QN5 '''def make_counter(): """Return a counter function. >>> c = make_counter() >>> c('a') 1 >>> c('a') 2 >>> c('b') 1 >>> c('a') 3 >>> c2 = make_counter() >>> c2('b') 1 >>> c2('b') 2 >>> c('b') + c2('b') 5 """ "*** YOUR CODE HERE ***" di...
9c6eb34fb1be659e26ff04684d88bc939b62ee89
QPaddock/Rubik
/moves.py
7,222
3.5
4
from print_cube import print_cube temp_cube = [["" for i in range(12)] for j in range(9)] def make_moves(mix, cube): if valid_mix(mix) == False: print("Invalid Mix...") exit(0) for twist in mix.split(): if twist == "R": right_turn(cube) if twist == "L": ...
a684f5bdadaaa7b79376438cc0293b9bfe2c5f22
ugobachi/AtCoder
/ABC162/A.py
330
3.75
4
"""[solution] 入力をリスト化して、フラグを用意 リスト内でfor文を回し、7が含まれていたらフラグをTrueにする フラグによって出力を変える """ N = list(input()) flag = False for i in N: if i == '7': flag = True if flag == True: print('Yes') else: print('No')
bd02d8201908f150a0a7147f4c39f2ea6757c1f6
jmg5219/First-Excercises-in-Python-
/print_a_box.py
609
4.09375
4
width = int(input("Width?"))#prompting user for input on the width of the box height = int(input("Height?"))#prompting user for input on the height of the box i = height#initializing incrementors j = width for i in range(1, i+1) : #cycling through row for j in range(1, j+1) : #cycling through column if ...
be9fc28dd4637c7f132979f6beaee0104208808c
AO-StreetArt/AOWorkflowDeveloper
/Application/src/export/Tree_Iterators.py
6,209
4.03125
4
# -*- coding: utf-8 -*- """ Created on Sun Feb 21 18:38:26 2016 Tree Iterators @author: alex """ #Base class which other iterators will inherit from class Tree_Iterator(object): """ :param Tree tree: Internal tree :param String name: Iterator name """ def __init__(self, tree, name): ...
c889c48fc3a4cd71ab3aaa3707c8e3d1a53e6684
xqhu2008/Larva
/src/algorithm/data_structures/heap.py
2,440
4.125
4
#!/usr/bin/env python # -*- encoding:utf-8 -*- ''' Function Name: heap.py heap data structure implementation by python language. Author: Alex Hu Create date: 2020 - 01 - 20 ''' class Heap: def __init__(self, datas = None): self._initialize(datas) def _initialize(self, datas): self._...
1a70d708e7635ae15c5f67f47408c257a4b9d07c
eMUQI/Python-study
/mooc/week3_BasicDataType/exercises/5.py
3,224
3.71875
4
# -*- coding:utf-8 -*- ''' 1585122477573 恺撒密码 描述 恺撒密码是古罗马恺撒大帝用来对军事情报进行加解密的算法,它采用了替换方法对信息中的每一个英文字符循环替换为字母表序列中该字符后面的第三个字符,即,字母表的对应关系如下:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬ 原文: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‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪...
85af3486a59f0e5275e53c2f413232c1fc5c4a81
ShallowAlex/leetcode-py
/1-100/43.py
928
3.53125
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 21 16:40:23 2020 @author: Alex code for windows """ class Solution: def multiply(self, num1, num2): list1 = [int(i) for i in num1[::-1]] list2 = [int(i) for i in num2[::-1]] l1 = len(num1) l2 = len(num2) tmp = [0 for i in rang...
8f8e72d410c46acfc1255b705a1e4731850ffb2c
timur-qa/leetcode
/26_remove_duplicatest_from_array.py
280
3.609375
4
#https://leetcode.com/problems/remove-duplicates-from-sorted-array/ def removeDuplicates(nums: [int]) -> int: index = 1 while index < len(nums): if nums[index] == nums[index - 1]: nums.pop(index) else: index += 1 return index
d857780687a6d7fa9bbb323fe03d0374e4ae98c5
kmboese/interview-practice
/parsing/extended-csv/parser.py
2,298
4.125
4
''' Given a line of csv input, parse the following inputs: 1. String: a. Always opened with a double quote and closed with a double quote b. Escaped double quotes are allowed as a sequence of two double quotes, i.e. '""' c. Strings may contain commas that should not be treated as a delimiter 2. Intege...
0775a1aedd5d3b53642ddcacc33b778a852211eb
amyfranz/Problem-1-sum-of-multiples
/main.py
222
3.734375
4
def multipleSum(num, multiples): sum = 0 for x in range(1, num): for i in range(0, len(multiples)): if x % multiples[i] == 0 : sum += x break return sum print(multipleSum(1000, [3, 5]))
67f36024a50051775c6fcce30945af9c20e19730
raveltan/itp-git
/01-Introduction/Nathaniel_ALvin - 2440042430/calculator.py
493
4.21875
4
while True: first_Number = int(input('first number: ')) second_Number = int(input('second number: ')) operator = input('operation: ') if operator == '+': print(first_Number + second_Number) elif operator == '-': print(first_Number - second_Number) elif operator == '*': p...
7debbb395eea3094a9d8004aea2b74e3cff2b110
nitzanadut/Exercises
/Python/8 Pirates of the Biss/pirates.py
342
4.09375
4
def dejumble(jumbled_word, words): "Recieves a jumbled_word and a list of fixed words. The function returns the dejumbled word" words_new = [sorted(word) for word in words] return [words[i] for i, word in enumerate(words_new) if word == sorted(jumbled_word)] print(dejumble('ortsp', ['sport', 'parrot...
0fa349f2b8e092d00a452ee7daaa919e385104b7
ar90n/lab
/sandbox/tdd_by_example/the_money_example/python/mytest.py
2,324
3.734375
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- from .money import Money from .bank import Bank from .sum import Sum def test_multiplication(): five = Money.dollar(5) assert five * 2 == Money.dollar(10) assert 2 * five == Money.dollar(10) assert 3 * five == Money.dollar(15) def test_equality(): ...
9dcb310f50228b38f54e988bfa49f9c2699010d5
thiagolrpinho/solving-problems
/2019_12_31-merge_sorted_lists.py
5,969
4.125
4
''' The question we'll work through is the following: return a new sorted merged list from K sorted lists, each with size N. Before we move on any further, you should take some time to think about the solution! First, go through an example. This buys time, makes sure you understand the problem, and lets you gain some ...
bcc3e360323d6e27bdf2046c7d719db9cc8cf403
rakesh2827/Rakesh_python_lab
/week3_c.py
235
4.28125
4
def factorial(num): fact = 1 for i in range(1, num + 1): fact = fact * i return fact number=int(input(" enter any Number to find factorial :")) factof= factorial(number) print("factorial is:" ,factof)
7611dae3167e7e36288d4aee2e4d56342b1f2d2d
why1679158278/python-stu
/python资料/day8.15/day12/exercise03.py
845
3.984375
4
""" day10/exercise01 day10/exercise03 直接打印商品对象: xx的编号是xx,单价是xx 直接打印敌人对象: xx的攻击力是xx,血量是xx 拷贝两个对象,修改拷贝前数据,打印拷贝后数据. 体会拷贝的价值. """ class Commodity: def __init__(self, cid=0, name="", price=0): self.cid = cid self.name = name self.price = price def __str__(self): ...
464574dd981dc1b91f191c6f4aa87e47d32e3d15
ImtiazMalek/PythonTasks
/GuessGame.py
349
3.9375
4
counter=0 limit = int(input('How many time you wanna guess? :')) correct_word = 'panda' check =False #taking the guesses while counter<limit: guess=input('Guess a word: ') if guess == correct_word: check=True break counter+=1 #checking the boolean if check: print('You win') ...
cd9a279c36fb98d4691eae227e88b7dcd4c4662c
UvinduW/Smart-Dots
/smart_dots.py
19,164
4.0625
4
# smart_dots.py # Created: 27/07/2018 # Author: Uvindu Wijesinghe # # Description: # This code is a Python implementation of the "Smart Dots" example/tutorial done by Code Bullet. He used the # Processing language to build his version. You can view his detailed tutorial and project at: # YouTube: https://www.you...
ffa2064a19e8bc0c5344176cdcb4415e064cc5b9
dayalnigam/-Python-Development-Intern
/q.6.py
203
4.0625
4
#q.6: Write a Python program to convert an array to an array of machine values and return the bytes representation. from array import * x = array('b', [1, 2, 3, 4, 5, 6]) s = x.tobytes() print(s)
7b00e3881325330c435b44fede2d39d3d25f2980
southwall93/pycharm_project1
/05If/06while.py
462
3.765625
4
#숫자를 계속 더해서 더한 숫자가 100보다 커지면 빠져나가서 출력 i=1 sum=0 while True: sum+=i i+=1 if sum>100: print("i: ",i-1) print("sum: ", sum) break #1~10 출력 홀수만 출력 #1부터 시작하면서 2씩 증가 i=1 while True: print(i) i+=2 if i>10: break i=1 while True: if i%2==0: i += 1 ...
e8b1a40ce25339f694dab3fc00dad0dc48988345
mohdjahid/Python
/Data types/String.py
166
3.890625
4
str="Hello,World!"; print(str); #Hello,World! print(str[0]); #H print(str[2:5]); #llo print(str[2:]); #llo,World! print(str*2); #Hello,World!Hello,World!
f13f45c0e9ac00a422fea0082ec765ccb137e58f
adriancarriger/experiments
/udacity/self-driving-intro/3-working-with-matrices/3/36.py
1,433
4.6875
5
# TODO: Write a function called inverse_matrix() that # receives a matrix and outputs the inverse ### # You are provided with start code that checks # if the matrix is square and if not, throws an error ### # You will also need to check the size of the matrix. # The formula for a 1x1 matrix and 2x2 matrix are different...
e979009432f7830312be1ba93b8cc0b229167957
reyeskevin9767/modern-python-bootcamp-2018
/12-lists/06-accessing-values-exercise/app.py
561
4.09375
4
# * Accessing List Data Exercise people = ['Hanna', 'Louisa', 'Claudia', 'Angela', 'Geoffrey', 'aparna'] # Change 'Hanna' to 'Hanna' people[0] = 'Hannah' # Change 'Geoffrey' to 'Jeffrey' people[4] = 'Jeffrey' # Change 'aparna' to 'Aparna' (capitalize it) people[-1] = 'Aparna' print(people) # ['Hannah', 'Louisa', '...
1d0adab6dfcd38391b6b05800fcd4d6ee7350601
npkhang99/Competitive-Programming
/Codeforces/101473A.py
175
3.71875
4
a, b, c = [int(i) for i in input().split()] if a == b == c: print("*") elif a == b and b != c: print("C") elif a == c and c != b: print("B") else: print("A")
0af09bb616b0adadb3e7baf150626414216a8fa7
rexelit58/python
/2.Advanced/10.Nested_Classes_Nested_Methods.py
494
3.875
4
class Person: def __init__(self,name,dd,mm,yyyy): self.name=name self.dob = self.DOB(dd,mm,yyyy) def display(self): print("Name:",self.name) self.dob.display() class DOB: def __init__(self,dd,mm,yyyy): self.dd = dd self.mm=mm self...
17071c25dc46e353dc4005a096688e211c765c14
MareikeJaniak/PFB_ProblemSets
/ProblemSets/Python5/sets_practice.py
309
3.796875
4
#!/usr/bin/env python3 mySet = {'3','14','15','9','26','5','35','9'} mySet2 = {'60','22','14','0','9'} print('intersection: ',mySet.intersection(mySet2)) print('difference: ',mySet.difference(mySet2)) print('union: ',mySet.union(mySet2)) print('symmetrical difference: ',mySet.symmetric_difference(mySet2))
b12d08cd128542602f885f541b89f64c1482abe1
jonte450/Hackerrank
/Python/Electronic_shop.py
899
3.828125
4
#!/bin/python from __future__ import print_function import os import sys # # Complete the getMoneySpent function below. # def getMoneySpent(keyboards, drives, b): answer = -1; for key in keyboards: for driv in drives: tot_sum = key + driv; if tot_sum <= b: answ...
d546b1b4faa7cabe233755a66b781709067db259
sasha-n17/python_homeworks
/homework_3/task_2.py
639
3.765625
4
def personal_info(name, surname, year_of_birth, town, email, phone_number): info = [name, surname, year_of_birth, town, email, phone_number] return ' '.join(info) print(personal_info(surname=input('Введите фамилию: '), name=input('Введите имя: '), town=input('Введите го...
389f9ec59a9ae91c3fdad6556e28a050dfd70d94
HITESH-235/PYTHON-2
/2.17.Indexing_lists.py
383
3.875
4
# 0th 1st 2nd 3rd 4th 5th THIS I HOW INDEXING WORKS WHEN "[x:y]"(colon) is used(line 10) # +0th +1st +2nd +3rd +4th POSITIVE INDEXING(line 8) x = ["apple", 1 ,"banana", 2 ,"mango"] # -1th -2st -3nd -4rd -5th NEGATIVE INDEXING(line 12) print(x[4]) #POSITI...
1dad52df74b27ce57abf6cb539efcd9c74d5e65c
TCReaper/Computing
/Computing Revision/Computing Quizzes/The Folder/TD01 - Jit/JIT/T1.py
2,257
4.09375
4
# 2017 - Term 1 - SH2 Computing Practical Lecture Test # Code for Task 1 from random import random #ASKING FOR PLAYER NAME ============================================ name_p = str(input("Please enter your name:")) name_p = name_p.strip() while True: try: name_p = int(name_p) print("Illegal name; P...
30fc31ac54d5e838e57cbbe3be4681d9af010e7f
willnien10005914/VPA
/tf.py
14,630
4.0625
4
import math import statistics import pandas as pd import numpy as np """ 台北第一期 """ def Deviation(X): N = 0 sum = 0 avg = 0 result = 0 for i in X: N += 1 sum += i avg = sum / N for i in X: result += (i - avg) * (i - avg) result = result / (N - 1) return ma...
bf030cc3d4e550e26681ba21f7dd945fb4582fc2
SyedTajamulHussain/Python
/PythonTutorial/IFELSEdemo.py
686
4.09375
4
x = int(input("Please enter the value of X")) if x < 0: print("X is a negarive number") elif x > 0: print("X is a positive nubmber") elif x == 0: print("x is equal to zero") else: print("undefined") # write a program to find the highest number a = 100 b = 20 c = 30 if a > b and a > c: print("a is ...
d004fdcd07acd68e21ccfb58ad69fbd3c1cc642e
Goopard/Study-2
/Currency.py
8,794
4.59375
5
#!/usr/bin/env python3 import abc import functools class Course: """This is a descriptor class for the subclasses of class Currency. It is used to store and operate a course of some currency.""" def __init__(self, value): """Constructor of class Course. :param value: Value of the course...
c88cb1dfc03d33eae0a8ed42039316ef75ddcf1d
codewarriors12/jobeasy-python-course
/lesson_1/homework_1_2_passed.py
566
4.21875
4
# Find the second power of a variable. Save the expression to result_1 variable #Find the second power of a variable. a = 10 result_1 = a ** 2 # Convert integer variable b to a float. Save the expression to result_2 variable b = 10 result_2 = float(b) # Convert a float variable c to integer. Save the expression to...
9099dede0f7d1b83ee33ed4a217c78fa725f56b5
eeshaun/python_exercises
/centenary.py
522
4.03125
4
from datetime import datetime now = datetime.now() print now year = now.year print year name = raw_input("name: ") age = raw_input("age: ") def check_name(name): x = 1 while x >= 0: if name.isalpha(): x -= 1 return name else: name = int(raw_input("You need to enter your name: ")) name...
d39347f5c827e08547015c1b40f8a6bfe11211ad
yashwanth-chamarthi/Logics
/PalindromeCheck.py
245
4.15625
4
def palindrome_check(string): x = '' for a in string.lower(): if a.isalpha(): x += a if x==x[::-1]: return True else: return False string = input() print(palindrome_check(string))
e5a5af1b7889d2b3e0b7238042fd62aba7ab0878
FrontendFigoperiFistemi/code-jams
/975485/975485.py
3,398
3.578125
4
import logging logging.basicConfig(filename='975485.log', level=logging.DEBUG) log = logging.getLogger(__name__) hallway = range(1, 101) class bot(object): def __init__(self, name, hallway): self.__name__ = name self.name = name if name == "orange": self.short_name = "O" ...
015006694facae6bcc17f007e47c929ddf242cec
itachiRedhair/ds-algo-prep
/trees/check-balanced-bt.py
2,576
3.96875
4
import sys # Better algorithm here, for poor one scroll down more # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right # This code runs in O(N) time and O(H) space, where H is the h...
0e709f1b933447d013b954ca3e28cda2b40da513
Darya1501/Python-course
/lesson-14/Password-generator.py
2,848
3.765625
4
import random def ask_question(question, sets): global enabled_chars print('Если в пароле нужны', question, 'введите Да: ') answer = input().lower() if answer.strip() == 'да': enabled_chars += sets def generate_password(length, chars): password = ' ' if length > 0: ...
29216478e08bb673816f0998d73f83c63be81a26
avni510/data_structures_and_algo
/src/sorting/sorting_algorithms.py
4,632
4.28125
4
## Bubble Sort - bubbles up the largest item to the end # of the array # Runtime: O(N^2) # Space Complexity: O(1) def bubble_sort(array): for size in range(len(array) - 1, 0, -1): for i in range(size): if array[i] > array[i + 1]: temp = array[i] array[i] = array[...
2bc80e66a5f6137243421a68686234a44ab2e882
MarkJParry/MyGMITwork
/Week03/absolute.py
257
4.125
4
#Filename: absolute.py #Author: Mark Parry #Created: 03/02/2021 #Purpose: Program to take in a number and give its absolute value inNum = float(input("Please enter a negative number: ")) print("the absolute value of {} is: {}".format(inNum,abs(inNum)))
93befa506193332d1a8f14a64ae1e630f4d880d0
dmaring/holbertonschool-higher_level_programming
/0x11-python-network_1/8-json_api.py
727
3.78125
4
#!/usr/bin/python3 """ A Python script that takes in a letter and sends a POST request to http://0.0.0.0:5000/search_userA script sends an email """ import requests import sys def searchAPI(): """ A function that sends POST and prints the response """ if len(sys.argv) < 2: _data = {'q': ""} ...
2bd8e8f3bb7c1f72e2f790fe61faa8ef1267fe9a
vishnoiprem/pvdata
/lc-all-solutions-master/028.implement-strstr/test.py
329
3.546875
4
class Solution(object): def strStr(self, haystack, needle): if len(haystack)<1 and len(needle): return 1 n=len(needle) for i in range(len(haystack)): #print(haystack[i:i+n],i) if haystack[i:i+n]==needle: return i return -1 if __name__ == "__main__": print (Solution().strStr("hello...
a7e1fca5e40361977737653c3f94b67b23fbd26d
Minh-Trung-SE/Python_Core
/Lesson_8/8.03.py
267
4.0625
4
# Counting elements in list until it's tuple. def count(data_source): result = 0 for element in data_source: if isinstance(element, tuple): return result else: result += 1 data = [1,2,5,6,(9,9)] print(f"{count(data)}")
c7a8640520f04478ea3aef8cfc4f824401a0a8e0
Gi1ia/TechNoteBook
/Algorithm/855_Exam_Room.py
3,335
3.5
4
import heapq import bisect class ExamRoom(object): def __init__(self, N): self.N = N self.students = [] self.heap = [] self.avail_first = {} # used later in leave() self.avail_last = {} # used later in leave() self.put_seg(0, self.N - 1) # Initialize with empty room ...
233ee00d9e19344e982499a6d241b2286505b6cb
hrrs/wikiscraper
/plot_network.py
814
3.53125
4
from turtle import * from types import * myTree = ["A",["B",["C",["D","E"],"F"],"G","H"]]; s = 50; startpos = (0,120) def cntstrs(list): return len([item for item in list if type(item) is type('')]) def drawtree(tree, pos, head=0): c = cntstrs(tree) while len(tree): goto(pos) item = tree.p...
ec20e8e84c830679dece10d80b273dfab2f07609
letai2001/python
/python/Baitap8.xulichuoi.py
674
3.75
4
"""Xây dựng hàm nhận đầu vào là chuỗi s và hai số nguyên k, n sau đó xóa chuỗi con độ dài n bắt đầu từ vị trí k ra khỏi chuỗi s . Viết chương trình minh họa""" def xoaKiTu(string,k,n): list = [] for i in range (k): list.append(string[i]) newstring = ''.join(list) return newstring print(...
09377a7b25dde34dc0fb7c03d2e5f83bf26dadee
Clever/kayvee-python
/kayvee/kayvee.py
1,054
3.6875
4
import json def format(data): """ Converts a dict to a string of space-delimited key=val pairs """ return json.dumps(data, separators=(',', ':')) def formatLog(source="", level="", title="", data={}): """ Similar to format, but takes additional reserved params to promote logging best-practices :param level -...
cca5ba722e79b2a238d8143a9d74093b468f5172
610yilingliu/leetcode
/Python3/693.binary-number-with-alternating-bits.py
539
3.5625
4
# # @lc app=leetcode id=693 lang=python3 # # [693] Binary Number with Alternating Bits # # @lc code=start class Solution: def hasAlternatingBits(self, n: int): if n == 0 or n == 1: return True pre = n & 1 n = n >> 1 while n > 0: cur = n & 1 if cur...
1b7a53144aede78bf8c269edfc5553c65db351d5
JunyaZ/LeetCode-
/Algorithm/Contains Duplicate.py
722
4.0625
4
""" Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. Example 1: Input: [1,2,3,1] Output: true Example 2: Input: [1,2,3,4] Output: false Example 3: Input:...
ce1b6eed4f85c14e76f6db5119852459b0feabbf
savourylie/interview_questions
/bst/heap.py
2,212
3.859375
4
class MinHeap(object): def __init__(self, value_list=[]): self.heap = [] if len(value_list) > 0: for x in value_list: self.add(x) def add(self, value): self.heap.append(value) self.heapify_up() def pull(self): min_element = self.heap.pop(0) last_element = self.heap.pop() self.heap.insert(...
c02bedb9024eb21d645655c15ae63896c600cc6c
BenjiDa/sga
/sgapy/ZeroTwoPi.py
717
4
4
import numpy as np def zerotwopi(a): ''' zerotwopi constrains azimuth to lie between 0 and 2*pi radians b = zerotwopi(a) returns azimuth b (from 0 to 2*pi) for input azimuth a (which may not be between 0 to 2*pi) NOTE: Azimuths a and b are input/output in radians MATL...