blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
dea8c9fe6c5e3c13907accbc7eaf9184fa85e831
ahmetTuzen/codewars
/4 Kyu/sudokuSolutionValidator.py
573
3.671875
4
def valid_solution(board): # get rows columns and squares total = [] for i in range(9): total.append(board[i]) for i in range(3): for j in range(3): square = [] for part in board[i*3:(i+1)*3]: square += part[j*3:(j+1)*3] total.append(s...
a2f0f14b95e161c42a4b82e6f07384c51eb2363f
Yriiko/GloAcademy_Python
/Урок 4/lesson_4-6.py
275
3.515625
4
# Задание 6 from math import * print('Введите одно целое четырехзначное число') n = int(input()) print('У числа', n, 'максимальная цифра равна', max(n // 1000, n // 100 % 10, n % 100 // 10, n % 10))
d53a54997d2dbff8ff462e530a6f653cdcd2473e
jayantabh/project_euler_solutions
/p4_LargestPalindromeProduct.py
516
3.65625
4
import time #Direct Loop print("Reverse Loop:") m1_start_time = time.time() max = 0 def check_palindrome(num): reverse = 0 org = num while num > 0: reverse = reverse * 10 + num % 10 num = num // 10 return reverse == org for i in range(999,1,-1): for j in range(999, i, -1): prod = i * j if prod > ...
38b774f4e96649c579e64a9b690dcca1b268756a
Cashfire/leetcodePython
/longest-substring-without-repeating-characters.py
1,413
3.875
4
# Time: O(n) # Space: O(1) # # Given a string, find_root the length of the longest substring without repeating characters. # For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. # For "bbbbb" the longest substring is "b", with the length of 1. # class Solution:...
b0769e3c8ee478d9eb486294fc4b63ed84773771
EdiTV2021/Python_2021
/funcion_tres_parametros.py
534
3.765625
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 2 20:24:27 2021 @author: Edison """ def direccion(provincia,ciudad,barrio): print("Su dirección es: ") print("Su provincia es: ", provincia) print("La ciudad de domicilio es:", ciudad) print("La dirección de referencia es: ", barrio) ...
5ace7314f4646e18cfde5593ff73262dbd4904aa
gabriellaec/desoft-analise-exercicios
/backup/user_313/ch47_2020_04_13_14_07_28_514996.py
361
3.5625
4
def estritamente_crescente(l1): new = list() if len(l1) == 0: return l1 else: new.append(l1[0]) for i in range(1,len(l1)): if l1[i] not in new: if l1[i] > max(new): new.append(l1[i]) else: ...
b69eda00394cc74dcda626abefd97c034b97b446
carlandreolsen/INFO132
/col020_oblig7/col020_oblig7_oppgave1.py
588
3.859375
4
alphabet = "abcdefghijklmnopqrstuvwxyzæøå" def legal_filename(text): for i in text: if i not in alphabet: return False return True def write_message(filename): myfile = open(filename,'w') print('type the input of your file. ** to end session.') while 1: texttofile = input() if texttofile == '**': bre...
78b366bef0d56fd73afad53fc0273577e7287418
callapatel/github
/string.py
7,241
4.15625
4
print("--------------------- (1)Test Capitalize --------------------------") #Return a copy of the string with its first character capitalized. print("peace".capitalize()) print("LEARN".capitalize()) print("330Crescent".capitalize()) print("##$##$$@".capitalize()) print("b'eyonce".capitalize()) print("---------------...
893efbf8278f451124198ad95babcd4a42eb2ea8
BatuhanAktan/SchoolWork
/CS101/Assignment9/q1.py
3,583
4.09375
4
""" This program generates the input to a word-cloud generator program Author: Batuhan Aktan Student Number: 20229360 Date: Nov 2020 """ def readFile(): """ This function reads the input file and gets rid of all the punctuation and \n. Parameters: None Return: List - datalist contains all words in ...
b01633e85cc2c4f1214ee719b9901cecb8a3c7c7
Aditya-live/PythonProgram
/SqlDB.py
877
4.0625
4
""" SQLite 3 """ import sqlite3 as db #print(type(db)) conn=db.connect(":memory:") qry="create table student(roll no int primary key, name Text,branch Text)" cur=conn.cursor() cur.execute(qry) """rollno=input("Enter rollno") name=input("Enter name") branch=input("Enter branch") qry="insert i...
82daa78c3284fb7819d74518cad022de0f55e6ea
qq1295334725/zheng
/第一周/7-26/datetime模块.py
1,101
3.90625
4
""" 座右铭:将来的你一定会感激现在拼命的自己 @project:7-26 @author:Mr.Chen @file:datetime.PY @ide:PyCharm @time:2018-07-26 14:34:55 """ import datetime # 1.获取当前时间和日期 datetime_dt = datetime.datetime.today() print('当前时间和日期是:{}'.format(datetime_dt)) # 格式化日期和时间 datetime_str = datetime_dt.strftime('%Y-%m-%d %H:%M:%S') print('当前时间和日期格式化之后为:{}'...
8bf1596c954107cffbf11c355d723555eb33811c
Bambina-zz/learning-py
/9_7.py
506
3.765625
4
#!/usr/bin/python #encoding: utf-8 input = {'にんじん':1,'じゃがいも':1,'たまねぎ':0.5,'牛肉':150,'オリーブオイル':0.5,'ルー':4} def count_diplicates(input): '''引数として辞書を取り、複数回現れる値の数を返す''' dip_counter = 0 freq = [] vals = set() for key in input: if input[key] in freq: vals.add(input[key]) else...
7f60227828c6d58f596dcf546dfcea6c914943c6
samuelzaleta/PythonBasico-Intermedio
/Modulo 2.py
5,017
3.8125
4
print("hola, mundo") print("La Witsi Witsi Araña subió a su telaraña.") print() print("Vino la lluvia y se la llevó.") print("La Witsi Witsi Araña\nsubió a su telaraña.") print() print("Vino la lluvia\ny se la llevó.") print("La Witsi Witsi Arañar" , "subió" , "a su telaraña.") print("Mi nombre es", "Python.") print("M...
2e048a134df25ddca2ebacdc72ba92784fc5dca8
amansharma2910/HackerRankSolutions
/venv/DrawingBook.py
594
3.8125
4
#!/bin/python3 import os import sys # # Complete the pageCount function below. # def pageCount(n, p): if n % 2 == 0: n += 1 pages = list(range(n+1)) pagesCountFront = pages.index(p) turnFront = pagesCountFront//2 pages.reverse() pagesCountBack = pages.index(p) turnBack = pagesCount...
0689b5afc38fca9face47e52b7b41f737aab67a1
isaszy/python_exercises
/Strings/L4E10Palindrome.py
242
3.921875
4
def palindrome (palavra: str) -> bool: listaLetra = [] for letra in palavra: listaLetra.append(letra) if listaLetra[0:] == listaLetra[::-1]: return True return False print(palindrome('casa'))
bd921ecc9b3204162a2ec122f1f166ecb23131a0
aduV24/python_tasks
/Task 13/example programs/while_not.py
344
4.28125
4
import random num = random.randint(1,50) num_guess = int(input("Guess a number from 1 to 50: ")) while num_guess != num: if num_guess < num: num_guess = int(input("To small! Guess another number from 1 to 50: ")) else: num_guess = int(input("To big! Guess another number from 1 to 50: ")) print("Y...
39257c4091c98d066571aeaa307a61a0372c4e96
kojo-gene/data-structures-and-algorithms
/challenges/shift-array/test_shift_array.py
573
3.609375
4
from shift-array from * def test_shift_array_if_len_odd(): prior_array = [0, 0, 0] value = 1 prior_array = shift_array.insert_shift_array(prior_array, value) assert prior_array[2] == 1 def test_shift_array_if_len_even(): prior_array = [0, 0, 0, 0] value = 1 prior_array = shift...
3b5a0e71c3fcd685cf58476be0f541bffbf57fa6
lydiaelliott/BaxterEPCSWeek1
/studentInfo.py
1,344
3.703125
4
import random def main(): students = [ Student("Larsson,Halsted", 37), Student("BonJovi,Jon", 55), Student("Danvers,Lilly", 28) ] printHeader() selection = getUserSelection() class Student: def __init__(self, lastName, firstname, age): self.lastName = lastName self.age = age self.first...
2ed46d78686ddf29b6ddbbd5d6fc2c02652138f8
olivia-ea/PythonPrep
/SumOfDigits.py
486
3.9375
4
#Chapter 2: Sum the Digits number = eval(input("Enter a 5 digit number: ")) digit1 = number // 10000 #gives you first digit random1 = number % 10000 digit2 = random1 // 1000 #gives you second digit random2 = random1 % 1000 digit3 = random2 // 100 #gives you third digit random3 = random2 % 100 digit4 = random3 /...
e90688650c4b96aab5c822aa211e354dafb85332
developertqw2017/scraping
/sorted1.py
225
3.5
4
L = sorted([34,23,2,-7,45,4],key = abs) print(L) L1 = sorted(['bob', 'about', 'Zoo', 'Credit']) print(L1) L2 = sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower, reverse=True) print(L2,'key = str.lower,reverse = Ture')
5e1ef1a77562c872988690b4be292f55c121029e
Taoge123/OptimizedLeetcode
/LeetcodeNew/LinkedIn/LC_366.py
1,095
3.515625
4
class Solution(object): def findLeaves(self, root): def order(root, dic): if not root: return 0 left = order(root.left, dic) right = order(root.right, dic) lev = max(left, right) + 1 dic[lev] += root.val, return lev ...
2350e7ba20c4a150c06a3b26bd657f75c6a633ce
elvin-kang/interview-prep-uci
/utils/Stack.py
675
3.703125
4
class Stack: def __init__(self): # disallow construction from a list to prevent data reservation self._stack = list() def isEmpty(self): return len(self._stack) == 0 def peek(self): try: return self._stack[-1] except: raise IndexError("pe...
dad1cba040b1ef5f511934fceb10970ddee7929f
henriquekirchheck/Curso-em-Video-Python
/desafio/desafio023.py
339
3.90625
4
# Faça um programa que leia um numero de 0 a 9999 e mostre na tela cada um dos digitos separados num = int(input('Digite um numero inteiro de 0 a 9999: ')) numstr = str(num) uni = numstr [3] dez = numstr [2] cen = numstr [1] mil = numstr [0] print('\n Unidade: {}\n Dezena: {}\n Centena: {}\n Milhar: {}\n' .format(un...
1d0ea58dcd2bd77487b85029cd01494a3b902939
eghobrial/python-resources
/python-tutorial/Tutorial2-LoopsFunctions/factorial_recursive.py
325
4.21875
4
# define factorial function (Recursive method) def factorial (n): if n == 1: return 1 else: return n * factorial(n-1) user_input = int (raw_input("Enter number to calculate factorial of ")) factorial_of_input = factorial(user_input) print "Factorial of %d is equal to %d" % (user_input, factorial_of_input)...
d99c92899d8a614456df9004ad8ef6064aaae3e1
dh256/adventofcode
/2019/Day10/Point2D.py
460
3.75
4
class Point2D: def __init__(self,x,y): self.x = x self.y = y def distance(self, value): ''' Returns Manhattan distance between 2 points ''' return abs(self.x - value.x) + abs(self.y - value.y) def __eq__(self, value): return self.x == value.x and sel...
e2046f8b4e1700d9269f1b9740c42961cfeb095a
sierradean/function_composition
/classes.py
8,453
4.1875
4
import random import math import os import textwrap class function_composition(object): """ Summary: function composition object that organizes our logic Parameters: simple_func function_list: a list of simple_func objects to pick from """ def __init__(self, function_list): assert function_list and len(func...
d1b546c7fb75101cbaf2f4b2efbca99630249595
FlorianTSUALA/data-structures-and-algorithms
/lists/problems/add_one.py
3,446
4.3125
4
""" ------------Problem Statement--------- You are given a non-negative number in the form of list elements. For example, the number 123 would be provided as arr = [1, 2, 3]. Add one to the number and return the output in the form of a new list. Example 1: input = [1, 2, 3] output = [1, 2, 4] Example 2: input = [9, ...
d7a8f648d1b8eaee52b76cc0c2e6393f2818b902
TMNwamaghinna/Hamoye-Quiz
/Code_for_Introduction_to_Python_for_ML_Quiz.py
2,147
3.71875
4
#!/usr/bin/env python # coding: utf-8 # In[26]: import pandas as pd #Importin the pandas package import numpy as np #Importing the numpy package import matplotlib.pyplot as plt #Importing the matplotlib package data = pd.read_csv('Hamoye.csv') #Importing the dataset. Note that data from link has been previously sto...
3cd8a9e14f671c80fab67af48ff3523dae1e19ce
brianchiang-tw/leetcode
/2020_September_Leetcode_30_days_challenge/Week_2_House Robber/by_dp.py
2,643
3.765625
4
''' Description: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses ...
6cac127f7e8430ee371f2e5bc4ed34e0e417cc82
camano/Aprendiendo_Python
/Master/15-errores/main.py
691
4.3125
4
""" try : nombre =input("Cual es tu nombre ? ") if len(nombre)>1: nombre_usuario="El nombre es "+nombre print(nombre_usuario) except: print("ooh a ocurrido un error ingresa bien tu nombre") else: print("Todo a ocurrido bien") finally: print("Fin de la iteracion !!") """ #multiple excepc...
c14b1a7ba79c65a2c7b6c742facb856ba96afcee
nadia1038/Assignment-3
/task3-8.py
580
4.34375
4
arr1 = [ 1, 2, 3, [ "A", "B", [ "string1", "string2", "string3" ] ] ] #assignment: 03 print string3 from the arr1 print(arr1[3][2][2]) #assignment: 04 change string3 to "string4" arr1[3][2][2]= "string4" print(arr1) # assignment: 05 remove "string4" arr1[3][2].po...
fb8ef3612d00e3e1c41508c73df41d205d595bef
szmuschi/Python
/Lab1/src/3.py
521
4.21875
4
# Write a script that receives two strings and prints the number of occurrences of the first string in the second. def strstr(): print('Function that receives two strings and counts the number of occurrences of the first string in the second') str1 = input("Enter first string: ") str2 = input("Enter secon...
2185ae449c30538bb453cd5a775df04eab84e5cf
tgrip/socialAlgorithm
/orderStatistics.py
528
3.640625
4
__author__ = 'Theo' import csv maxVal = 0 secondVal = 0 mostName = '' secondName = '' csvFile = open('file.txt') fileReader = csv.reader(csvFile) for row in fileReader: if row[1] == 'F': # print row[2] if int(row[2]) > maxVal: print 'changed to', row[2] secondVal = maxVal ...
9d04e381c8198a51a4600b693d18f8e5c3f7caa4
ks228/Kim_CycloneAnalysis
/COMP7230_Assignment_1_Animation.py
2,412
3.921875
4
""" COMP7230 2018 Assignment 1 Once you have completed questions 1, 2, 3 and 6, running this file will produce the animation of the cyclone tracks. You do not need to modify the contents of this file. """ import collections import matplotlib.animation as animation import scipy.ndimage as ndimage from COM...
6598e730ee6696ccb8a4f429ff87b31756a7a3ac
raghusayana/AoC2018
/1.py
831
3.5
4
#! /usr/bin/python freq_list = list() with open('input/1.input') as fp: line = fp.readline() while line: freq_list.append(line) line = fp.readline() fp.close() initial = 0 for freq in freq_list: if '+' in freq: initial = initial + int(freq[1:]) else: initial = initial ...
6c2106099e38aae8debed28e8152a9a23383a136
mnvijay1998/GUVI-Programs
/Beginner/set5/poweroftwo.py
146
3.71875
4
n=int(input()) c="yes" if n==0: c="no" else: while(n!=1): if n%2!=0: c="no" break n=n/2 print(c)
3b9833deb4f3c88afd1c2e39fdde670cface4e14
jwross24/DS-Unit-3-Sprint-2-SQL-and-Databases
/module1-introduction-to-sql/buddymove_holidayiq.py
964
3.71875
4
import sqlite3 queries = [] # Count how many rows you have - it should be 249! query1 = '''SELECT COUNT("User Id") FROM review;''' queries.append(query1) # How many users who reviewed at least 100 Nature in the category also # reviewed at least 100 in the Shopping category? query2 = '''SELECT COUNT("User Id") FROM r...
876b0a61b7340a7c8d097a141684f691c8b5211b
QuentinDuval/PythonExperiments
/linked/PairwiseSwapElements.py
1,385
4.34375
4
""" https://practice.geeksforgeeks.org/problems/pairwise-swap-elements-of-a-linked-list-by-swapping-data/1 Given a singly linked list of size N. The task is to swap elements pairwise. """ class Node: def __init__(self, data): self.data = data self.next = None def pairWiseSwap(head: Node): "...
0a7d96ca21c4a8cde1851dd55692ffd86102b354
alinefutamata/May-2020
/06-05-2020_Code_Command_1.py
159
3.546875
4
# Watching the 15 min of Python youtube video from Code Command welcome = "Hello, " print("Please enter your name: ") name = input() print(f"{welcome}{name}")
c25969659a73139a1ef9a75a09ca54f91d88b4e5
aewens/Algorithms-HacktoberFest
/Python/dijkstra.py
3,534
3.640625
4
from collections import deque, namedtuple infinity = float("inf") Edge = namedtuple("Edge", ["start", "end", "cost"]) class Graph: def __init__(self, edges): invalid_edges = list() self.edges = list() for edge in edges: if len(edge) in [1, 2]: invalid_edges.app...
4c47042310c108a06f5574a382ece5f29bb34959
cookies5127/algorithm-learning
/leetcode/default/404_sum_of_left_leaves.py
971
3.9375
4
from utils import build_binary_tree from utils.types import TreeNode ''' 404. Sum of Left Leaves Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24. ''' EXAMPLES = ...
ff032f6b97993c9b1b1792dd0dbcf1233302335a
laramaktub/HiggsChallenge-MasterPartCosm
/HiggsChallenge-MasterPartCosm/history_tools.py
2,431
3.734375
4
""" Module with tools to plot and study the training history of the neural network """ import keras.callbacks as cb import matplotlib.pyplot as plt class LossHistory(cb.Callback): """ Class to store the training information: loss and accuracy """ def on_train_begin(self, logs={}): # Initi...
f1fa95830d2814d5bf4b60d5035666ec8e3bdd5e
sohaibullah4d/LAB-02
/PE 3.py
497
3.75
4
print("MUHAMMAD SOHAIB - 18B-054-CS - SEC-A") print("LAB NO: 02") import math print("\n(a)\n") lst = [1,3,5,7,9,11,13,15,17] mid_index = math.floor(len(lst)/2) print("The index of the middle number in lst is:",mid_index) print("\n(b)\n") print("The middle element of the lst is:",lst[mid_index]) print("\n...
e76b1bfcf6ebe29a065be0ecacdb8ee6da30b1c4
Mostofa-Najmus-Sakib/Applied-Algorithm
/Leetcode/Python Solutions/Matrix/ValidSudoku.py
2,238
3.671875
4
""" LeetCode Problem: 36. Valid Sudoku Link: https://leetcode.com/problems/valid-sudoku/ Language: Python Written by: Mostofa Adib Shakib """ # Brute Force # Time Complexity: O(1) # Space Complexity: O(n) class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: row = len(board[0]) ...
d8c4597b4f0812239eca5264f548c5d7f06e32d9
zvikinoza/mars-rover-kata
/src/marsrover/direction.py
767
3.734375
4
class Direction: def __init__(self, direction: str) -> None: self._direction = direction def rotate_left(self): self._direction = self.get_left_side(self._direction) def rotate_right(self): self._direction = self.get_right_side(self._direction) @staticmethod def get_left_s...
0fd4af3407fedb3a6d5c99ceaf2cfb4ece7aa632
Akazfu/Python-Rewind
/fishc/flower.py
170
3.765625
4
def findflower(x): c = x % 10 b = (x // 10) % 10 a = x // 100 if x == a**3 + b**3 + c**3: print(x) for i in range(100, 1000): findflower(i)
64a472f7c2f94f1b4b0ba223170e3b68d6301d25
MartaSzuran/Python-for-the-Absolute-Beginner-M.Dawson
/Chapter 7/handle_it.py
1,681
4.5
4
# program for handling excepts # program runs till ends and inform us about mistakes # using try instruction with except # try takes particular slice of your code which probably can make a mistake # to broad exception clause it need to be specify try: num = float(input("Input number: ")) except: print("Some e...
4ca0bb106789f2412baca95740207c9a391782b4
syurskyi/Python_Topics
/110_concurrency_parallelism/_exercises/templates/Learning Concurrency in Python/Chapter 03/threadLifecycle.py
1,102
3.90625
4
# ______ th.. # ______ ti.. # # # A very simple method ___ our thread to execute # ___ threadWorker # # it is only at the point where the thread starts executing # # that it's state goes from 'Runnable' to a 'Running' # # state # print("My ? has entered the 'Running' State") # # # If we call the t__.s..() met...
00972a4450debb7e4f0b48dfd59a603ae8ec4465
MartinHan01/MyPractices
/sicp/c1/c_2_6.py
2,428
3.703125
4
def make_instance(cls): def get_value(name): if name in attributes: return attributes[name] else: value = cls['get'](name) return bind_method(value, instance) def set_value(name, value): attributes[name] = value attributes = {} instance = {'g...
d756e9c3a1cb72a4e9ef6d27d2a7bdb56edab993
xiang-daode/Python3_codes
/T30-turtle-带轴th(x)之积分.py
1,040
3.6875
4
import math from turtle import * N = 50 def f(x): return x def jumpto(x, y): penup() goto(x,y) def line(x1, y1, x2, y2): jumpto(x1, y1) pendown() goto(x2, y2) def coosys(): width(4) pencolor('red') line(-0.8*N, 0, 0.8*N+1, 0) write("X", font=("Times", ...
f8b2be94ae85d1b8fc553b338212cc3c1f06eb09
JuDa-hku/ACM
/leetCode/28ImplementstrStr().py
380
3.53125
4
class Solution: # @param {string} haystack # @param {string} needle # @return {integer} def strStr(self, haystack, needle): m, n = len(haystack), len(needle) if n>m: return -1 for i in range(0, m-n+1): if haystack[i:n+i:1] == needle: return...
40e8123bd21e7c6257d20e6fc79c94fee1fb7af2
andbra16/CSF
/F13/labs/lab3.py
583
4.34375
4
n= 6 series= "sum" #if the string(series) is fibonnaci if series == "fibonnaci": a=1 b=0 #calculates fibonnaci to the nth number for i in range(n): c = a + b print c a=b b=c #if the string(series) is sum elif series == "sum": number=0 sums=0 ...
b5cd280715ef549b713b51ae49468239f70fded9
chapman-phys220-2018f/cw06-lol
/elementary.py
2,677
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ### # Name:Gabriella Nutt and Gwenyth #Student ID: 2307512 #Email: nutt@chapman.edu #Course: PHYS220/MATH220/CPSC220 Fall 2018 #Assignment: CW 5 ### import numpy as np from scipy import constants import pandas as pd import sympy as sp import matplotlib.pyplot as plt i...
ed336089c77f381bf6d6578a5a5279d3ee865835
oliveiralecca/cursoemvideo-python3
/arquivos-py/CursoEmVideo_Python3_DESAFIOS/desafio35.py
384
3.921875
4
print('======= DESAFIO 35 =======') print() print('{:=^30}'.format(' TRIÂNGULOS ')) r1 = float(input('Comprimento da Reta 1: ')) r2 = float(input('Comprimento da Reta 2: ')) r3 = float(input('Comprimento da Reta 3: ')) if (r1 < r2 + r3) and (r2 < r3 + r1) and (r3 < r1 + r2): print('Podem formar um TRIÂNGULO!') else...
445fdc9004245816f5ac0fb000c96925e85a73af
davidlamyc/python-for-data-101
/matplotlib_demo.py
804
4.15625
4
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0,5,11) y = x ** 2 # plt.plot(x,y,'r-') # 'r-' defines the line style # plt.xlabel('X Label') # plt.ylabel('Y Label') # plt.title('Title') # plt.subplot(1,2,1) # arguments: no of rows, no of cols, plot no referenced # plt.plot(x,y,'r') # plt.subplot...
ee2c11bf6e1dab1e9c382a9ca8a2e12e66c6d496
AnupreetMishra/-creating-a-class-in-oops-python-
/main.py
388
3.5625
4
class Teacher: def __init__(self,ID,NAME): self.te_id=id self.te_name=NAME def introduction (self): print(self.te_id) print(self.te_name) te1=Teacher(1,"Shivam") te1.introduction() te2=Teacher(2,"Vikas") te2.introduction() te3=Teacher(3,"Gyan") te3.introduction() te4=Teacher(4,"Dile...
2a0109ba8e32ad58fc5a64c2b6537371f3c62ad2
darshanjani/dj-practice
/python-practice/ForStatement.py
189
3.640625
4
__author__ = 'Darshan' words = ['cat', 'window', 'theorem'] for w in words: print(w, len(w)) for w in words[:]: if len(w) > 6: words.insert(0, w) print(words)
5a3a635f9a98f1b68bf734bf7c8bab686b3c4ca4
bogggggh/SpotifyAPI
/navigator.py
5,992
3.578125
4
import time # used to stop program from selenium import webdriver # used for automating & working through a browser # special thanks to: # https://towardsdatascience.com/controlling-the-web-with-python-6fceb22c5f08 def spotify_login(driver, password, username, walkthrough_mode=True): """ Automatically log...
7fbc4437ce518131a3c5a4b6da5ce0dc818bad24
majsylw/Introduction-to-programming-in-python
/Laboratory 10/P3. Liczby pierwsze.py
672
3.859375
4
''' Liczba pierwsza to taka liczba naturalna, która jest większa od 1 i dzieli się tylko przez 1 i sama siebie, czyli posiada jedynie dwa dzielniki. Napisz program, który sprawdzi czy podana przez użytkownika liczba całkowita jest liczbą pierwszą. W obu przypadkach wypisz na ekran stosowny komunikat. Pamiętaj aby sp...
e32142de38be47e8bd1786a63ce148edd07d45d7
laiqjafri/LeetCode
/problems/00740_delete_and_earn.py
1,425
3.875
4
# 740. Delete and Earn # Medium # # 1569 # # 118 # # Add to List # # Share # Given an array nums of integers, you can perform operations on the array. # # In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal to nums[i] - 1 or nums[i] + 1. # # You start...
bafd38a5f43541edfb7b498fb6b4b4d627494716
daniel-reich/ubiquitous-fiesta
/Ff84aGq6e7gjKYh8H_4.py
139
3.703125
4
def minutes_to_seconds(time): return int(time.split(':')[0])*60 + int(time.split(':')[1]) if int(time.split(':')[1]) < 60 else False
a01d985a38ff5b47c66744102720cbf76c5d594d
tapioca2000/ASCIIria-Chronicles
/Unit.py
1,022
3.828125
4
# contains the class representing a unit from random import randint unitweaknesses = {"T":"L","S":"HN","H":"LN","L":"TN","E":"TSHLN","N":"TSHL"} # unit weaknesses class Unit: def __init__(self,name,type,hp,att,pos,friendly): self.name = name self.type = type self.hp = int(hp) ...
3491cf0146eec7445226bb28f6824732b5e69623
1325052669/leetcode
/src/data_structure/tree/convert.py
6,396
3.625
4
from typing import * from src.data_structure.tree.model import TreeNode, Node # https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ class Solution108: def sortedArrayToBST(self, nums: List[int]) -> TreeNode: def dfs(l, r): # r not include if l >= r: return None ...
abadef7b029695a37096f8f2a333b94b52615fb1
LucSouza/rumo1vaga
/excpythonbr/latas.py
747
4.1875
4
print("""Faça um programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 3 metros quadrados e que a tinta é vendida em latas de 18 litros, que custam R$ 80,00. Informe ao usuário a quantidades de latas de ti...
23b7c46047cca4672301f3a43c8cad573a2dcb94
mottaquikarim/pydev-psets
/pset_loops/loop_basics/p6.py
318
4.34375
4
""" GCD """ # Find the greatest common denominator (GCD) of two number input by a user. Then print out 'The GCD of <first number> and <second number> is <your result>.' print('Enter two numbers to find their greatest common denominator.') user_input1 = input('First number: ') user_input2 = input('Second number: ')
bee409c983e2f26a3cdb475266c66e3ea3d9279b
ckidckidckid/leetcode
/LeetCodeSolutions/142.linked-list-cycle-ii.py
1,085
3.65625
4
# # [142] Linked List Cycle II # # https://leetcode.com/problems/linked-list-cycle-ii/description/ # # algorithms # Medium (30.52%) # Total Accepted: 148.6K # Total Submissions: 487.1K # Testcase Example: '[]\nno cycle' # # # Given a linked list, return the node where the cycle begins. If there is no # cycle, retur...
6ff1848d46ef3fc134be575355985904502097f9
testerkurio/python_learning
/python_with_kids/list_5-3_tran-temperature.py
203
4.21875
4
print("This program converts Fahreherit to Celsius"); print("Type in temperature in Fahrenheit:"), Fahreherit = float(input()); Celsius = (Fahreherit - 32)*5/9; print("This is",Celsius,"degrees celsius")
61ae96b08cd09cdf42531c7c445463539d8acb50
balupabbi/Practice
/DS_and_ALG/trees/BinaryTreeLevelOrderTraversal.py
1,690
3.609375
4
from collections import defaultdict from collections import deque class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def levelOrder(root: TreeNode): q = [] level = 0 q.append((root, level)) ans = defaultdict(list) while q: c...
b28e2b1f0b671fbba2f38fe4302c9cb90b80a64e
sapna2394/list-python
/list_1.py
134
3.609375
4
s=["robin","animika","sanju","amisha","neha"] length=(len(s)) i=0 while i<length: print(s[i]) print("index",i,"=",s) i=i+1
2d87fb65002cd2c1f7df32f6871e86fa4c2f9f99
Jorick/pytask
/date_conversions.py
1,367
4.21875
4
"""Module to handle conversions of date format to several string formats.""" import datetime def text_to_date(text_due_date): """Convert text like "tomorrow" into a date format.""" text_due_date = text_due_date.lower() if text_due_date == "today": return datetime.date.today() elif text_due_da...
e93d92c4911cb5cd7fcb474f70d300c26876cadf
nabil16497/Artificial-Intelligence-Course-Algorithms-nQueen-Problem-Genetic-Algorithm-Map-Coloring-CSP-
/nQueen Problem(Solution Board).py
998
3.75
4
def solve(): if colcheck(matrix, 0) == False: print ("Solution does not exist") return False output(matrix) return True def colcheck(matrix, col): if col >= n: return True for i in range(n): if attackcheck(matrix, i, col): matrix[i][col] = 1 if colcheck(matrix, col + 1) == True: ...
ccd2bd41b07df800a7c85ddbd6c71c842c2bc677
ktmriki/programok
/szamtipp.py
589
3.625
4
import random x = int(random.randint(-50, 100)) i = 0 #Hány tipp volt eddig print("Egy véletlen számot kell kitalálnod 0 és 100 között.") y = int(input("Tipped: ")) while x != y: if x > y: print() print("A tipped kisebb a számnál. Tippelj nagyobbat.") print() y = in...
ae1040a8b86ffda6771caabadb16e4fe388c76db
CodeTest-StudyGroup/Code-Test-Study
/qrlagusdn/[3]Programmers/#네트워크.py
704
3.53125
4
#네트워크 def bfs(start,idx,n,computers,visited): queue = list() queue.append(start) while queue: pos = queue.pop(0) visited[pos] = idx for i in range(0,n): if visited[i] == 0 and computers[pos][i] == 1: queue.append(i) visited[i]...
399a338072aaf06c933b49bfc3bb1a903d6e2f6d
Rakk4403/effective-python
/generator/generator.py
576
3.734375
4
# basic code def index_words(text): result = [] if text: result.append(0) for idx, letter in enumerate(text): if letter == ' ': result.append(idx + 1) return result address = 'Four score and seven years ago, There was a light...' result = index_words(address) print(result) ...
38c2545180c939bc7f4b830b5cb56e8887b5ec5b
bklanuradha/PythonBasic
/variables.py
145
3.859375
4
# getting inputs from user a = int(input("Enter Name: ")) b = int(input("Enter Number: ")) # adding inputs c = (a + b) # print answer print(c)
00783f21ef4acb56cdebd3c42fce6c0ec8894a5d
Siddiqui2442/Python_GUI
/scale.py
627
3.6875
4
from tkinter import * def submit(): print("現在の温度は"+ str(scale.get())+"度") window = Tk() scale = Scale(window, from=100,to=0, lengthen=600, orient=VERTICAL, font =('Consolas',20), tickinterval=10, #showvalue=0 ...
2a2c911bc36b75673b8293cf96c987edae0ce15a
GEEK1050/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/1-search_replace.py
235
4.0625
4
#!/usr/bin/python3 def search_replace(my_list, search, replace): replaced_list = my_list[:] for i, element in enumerate(my_list): if element == search: replaced_list[i] = replace return replaced_list
521d7683f95f29786b075ab3ea2338185ac0e942
priyeshverma234/python
/assignment9.py
1,746
4.15625
4
#Q.1- Name and handle the exception occured in the following program: ''' a=3 if a<4: a=a/(a-3) print(a) ''' a=3 try: if a<4: a=a/(a-3) except ZeroDivisionError: print("Zero Division Error") print(a) #Q.2- Name and handle the exception occurred in the fo...
215ec6fb2e492cd8696b0c24e33b2906ee6a6686
isakib/python
/ex31.py
2,233
4.0625
4
print "2 room booking options you have, choose good one?" room = raw_input("> ") if room == "1": print "there is a big large room for couple, what inside the room?" print "1. A large bed room" print "2. A large garden infront of the room" room = raw_input("> ") if room == "1": pr...
39527daf9f647fdf4f27d6479c54e1e405acaa8d
rhkrm/coding
/acmicpc/2751.py
293
3.640625
4
import sys def solution() : N = int(sys.stdin.readline()) list_num = [] for _ in range(N): list_num.append(int(sys.stdin.readline())) list_num.sort() # result = [-1]*N # merge_sort(result, list_num, 0, N-1) for i in list_num : print(i) solution()
89b2df3228db45529355544d29dfa9ac5addbc57
KayleighPerera/COM411
/Basics/Week2/repetitions/for_loop/membership_operators.py
234
4.25
4
# Ask what phrase they see print("What phrase do you see?") phrase = input() # identifying markings print("\nRversing... \nThe phrase is: ", end="") reversed ="" for letter in phrase: reversed = letter + reversed print(reversed)
43238375b1423eac11ec5015cc85da355f7dc135
salhernandez/twitterweb
/twitterweb/__init__.py
1,501
3.65625
4
import os import requests from BeautifulSoup import BeautifulSoup from urllib2 import urlopen from urllib2 import urlparse import urllib from datetime import datetime twitter = "https://www.twitter.com/" # this will scrape the twitter handle for users # and returns a list with the names def getUsersFromUser(tHandle):...
a5e16b3535c9b6e01f47c1ac3ce0703fb574a9ad
true-false-try/Python
/A_Byte_of_Python/OOP/class_/turtle/Figures.py
3,984
3.921875
4
import turtle import random class Point: """Точка екрану """ _count = 0 def __init__(self, x, y): self._x = x # _x - координата x точки self._y = y # _y - координата y точки self._visible = False # _visible - чи є точка видимою на екрані Point._count +=...
fee5ef964a353a2abb287e1e01bbf0070674338a
mitrisyriani/python
/email_parsing.py
436
4.15625
4
# reads a file and parse all the 'From ' emails and prints them out while True: try: fname = input("Enter file name: ") fh = open(fname) break except: print("Oops! That was not a valid file name. Try again") counter = 0 for line in fh: line = line.rstrip() if line.startswith('From '): words = line.spl...
d7ad2a248aaa98090212082305cbed226a5df739
kluchnik/cheat-sheets-on-python
/matrix/go_clockwise
1,119
3.578125
4
#!/usr/bin/python3 A = [] Ax = [] Nx = 5 Ny = 6 print('create matrix {}x{}:'.format(Nx, Ny)) for item in range(Nx): Ax.append(None) for item in range(Ny): A.append(Ax.copy()) for item in A: print(item) print('------------------') print('set start position:') x = 0 y = 0 dx = 1 dy = 0 print('x = {} (step: {})\ny = {}...
b7e01ff0b593211dd58f2b11d17b378882e41413
ESIPFed/esip-hackfest-summer2020
/other/parse_csv.py
553
3.828125
4
import csv with open('input.csv', 'r') as csv_file: csv_reader = csv.DictReader(csv_file) # add , delimiter=',' to specify delimiter # next(csv_reader) # skips over both header rows for line in csv_reader: # print(line) # prints "['GFMS', 'http://flood.umd.edu/', '2014'...etc]" print(li...
a94dada2f3e421377fd28bb908f01dfac5cca3e1
YskSt030/LeetCode_Problems
/500.KeyboardRow.py
1,486
4.03125
4
""" Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. (image) Example: Input: ["Hello", "Alaska", "Dad", "Peace"] Output: ["Alaska", "Dad"] Note: You may use one character in the keyboard more than once. You may assume th...
644ea04f35d7bdb544e8bb1acc0a46ea1b58afd6
antoniosarosi/algoritmia
/src/algoritmia/problems/sorting/countingsort.py
481
3.5
4
from algoritmia.problems.sorting.interfaces import ISorter class CountingSorter(ISorter): #[Counting def sorted(self, a: "IList<int>") -> "sorted IList<int>": if len(a) == 0: return [] b = [0] * len(a) k = max(a) + 1 c = [0] * k for v in a: c[v] += 1 for i ...
eb439de6d41e719cfc2b6880f1723f9840905f95
lees19/Foundations
/Foundations/homeworks/randomwalk1.py
521
4.3125
4
""" random walk example """ import random import matplotlib.pyplot as plt def animate(x,y): plt.plot(x,y,'r.') return() def randomwalk(n): x=0 y=0 #animate(x,y) for i in range(n): step=random.choice(['N','S','E','W']) if step == 'N': y+=1 elif step=='S': ...
f99e2c9db28a8cc5afbca110b18268dfb082ac61
biglala89/algorithms
/Hashtable/longest_contained_range.py
587
3.859375
4
def Largest_Contained_Range(arr): hashset = set(arr) range_ = 0 while hashset: random = hashset.pop() print 'number popped: ', random upper = random + 1 while upper in hashset: print 'current upper: ', upper hashset.remove(upper) print 'upper removed: ', upper upper += 1 lower = random - ...
b09cad6540ae16ad8bc9454f4948aaa22ee59500
KoushikShaik/Python
/Kaprekar's Constant Number.py
1,030
3.71875
4
kaprekar_Numbers_Found = [] loop = 'loop' def asc(n): # To get Ascending Order return int(''.join(sorted(str(n)))) def desc(n): # To get Descending order return int(''.join(sorted(str(n))[::-1])) n = input("Specify a number: ") n = int(n) while True: # iterates, assigns the new di...
9223254d686ec9991f8e446ebb9fda93f3b2037f
jlucasldm/coursera
/pythonForEverybody/usingPythonWebData/assignment3/urllinks.py
1,371
3.90625
4
# Following Links in Python # The program will use urllib to read the HTML from # the data files below, extract the href= vaues from # the anchor tags, scan for a tag that is in a particular # position relative to the first name in the list, follow # that link and repeat the process a number of times and # report ...
f8b3151a06ea1db565600c17ec776b8a8ed9c2c0
rafaelperazzo/programacao-web
/moodledata/vpl_data/415/usersdata/292/85477/submittedfiles/exe11.py
169
3.53125
4
# -*- coding: utf-8 -*- n1=int(input()) n1=str(n1) summ=0 if len(n1)==8: for n in n1: n=int(n) summ=summ+n print(summ) else: print("NAO SEI")
a0251a620ba0dfb77f7dbeae15ec85189ffcf81b
its-sachink/data-structure
/3_Basic Data Structures/3.8. Converting Decimal to Binary.py
870
3.78125
4
from stack import Stack def divideby2(decNum): remstack = Stack() while decNum > 0: rem = decNum % 2 remstack.push(rem) decNum = decNum // 2 binstring = "" while not remstack.isEmpty(): binstring = binstring + str(remstack.pop()) return binstring print(divideby2(...
8d3e06b8ff4a477de0bb6edb27ab76dcd3fbbea3
jeremyjchung/BMGT404FinalProject
/CustomerOrder.py
4,041
3.65625
4
# Carry Out Tracker Customer Side # Takes customers order and adds it to a dictionary # The dictionary hold the user's name, telephone number, the items ordered, and the # the quantity of each item ordered # From there the this dictionary entry is written to an excel file which is the database # for all carry out ...
3638675ee3f0a13ca3c4d9907bb54fb9ec493952
vijay8484/Assignmnet3-4
/Assignment3_5.py
433
4.03125
4
from MarvellousNum import * def main(): print("In Main") ListPrime() def ListPrime(): print("In ListPrime") arr = list() count = 0 num = input("Enter the No of Element :") for i in range(0, int(num), 1): no = input("Num :") arr.append(int(no)) primelist = ChkPrime(a...
2cbcfbb7cb6d88b094de0e52dc7ff15bb572bc2a
Amo10/Computer-Science-2014-2015
/Pico CTF/Pico CTF 2014/python_alg/fib_r.py
648
4.28125
4
# fib_r.py - calculates the Fibonacci series, recursively, # using command line arguments import sys def main(): if (len(sys.argv) != 2): usage() else: try: num = int(sys.argv[1]) print("Fibonacci of", num, "is", fib(num)) except ValueError: usage() ...
c285c43f556777d6e9ce81cf4fad6a010f9ec4a7
wangweiwg/python
/09-错误、调试和测试/02-调试.py
3,451
3.890625
4
# 程序能一次写完并正常运行的概率很小,基本不超过1%,总会有各种各样的bug需要修正,有的bug很简单,看卡错 # 误信息就知道,有的bug很复杂,我们需要知道出错时,哪些变量的值是正确的,哪些变量的值是错误的,因此,需要 # 一套调试程序的手段来修复bug # 第一种方法简单粗暴,就是用print()把可能有问题的变量打印出来看看 # 用print()最大的坏处是将来还得删掉它,想想程序里到处都是print(),运行结果也会包含很多垃圾信息 # # 断言 # 凡是用print()来辅助 查看的地方,都可以用断言(assert)来替代 def foo(s): n = int(s) assert n != 0, 'n is...
d21a5e4b7a1dc856578b3cdaa237c5f2739e782f
ahmadreza-smdi/ms-shop
/.venv/lib/python3.7/site-packages/pylint/test/functional/invalid_sequence_index.py
7,190
3.546875
4
"""Errors for invalid sequence indices""" # pylint: disable=too-few-public-methods, no-self-use, import-error, missing-docstring, useless-object-inheritance, unnecessary-pass import six from unknown import Unknown TESTLIST = [1, 2, 3] TESTTUPLE = (1, 2, 3) TESTSTR = '123' # getitem tests with bad indices def function...
52a0ded5d7d80e43823d21f8c655c00a9815b049
COMPTCA/COMPTCA.github.io
/Tutorials/Python In Easy Steps Book/Methods.py
507
3.828125
4
class Person: '''A base class to define Person properties.''' def __init__(self, name): self.name = name def speak(self, msg = '(Calling The Base Class)'): print(self.name, msg) class Man(Person): '''A derived class to define Man properties.''' def speak(self, msg): print(s...