blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
d326dc04a721accb9497451c74385dda5b2c50eb
hieutran106/leetcode-ht
/leetcode-python/medium/_241_different_ways_parentheses/test_solution.py
800
3.5625
4
import unittest from .solution import Solution class MyTestCase(unittest.TestCase): def setUp(self) -> None: self.s = Solution() def test_case_0(self): actual = self.s.diffWaysToCompute("2-1") self.assertEqual(actual, [1]) def test_case_1(self): actual = self.s.diffWaysTo...
0afec993fffcf418f677d01778ee754282368145
hieutran106/leetcode-ht
/leetcode-python/easy/_121_best_time_buy_sell_stock/test_solution.py
1,392
3.578125
4
import unittest from typing import List from .solution import Solution class Solution: def maxProfit_optimized(self, prices: List[int]) -> int: n = len(prices) min_val = prices[0] # Min value from 0 index to i-1 max_profit = 0 for i in range(1, n): min_val = min(min_va...
568ac326d28f7f5b1b1b2da5fffc1d541ff0e7dc
hieutran106/leetcode-ht
/leetcode-python/medium/_209_minimum_size_subarray_sum/solution.py
736
3.5625
4
from typing import List class Solution: def minSubArrayLen(self, target: int, nums: List[int]) -> int: n = len(nums) left = 0 right = 0 sum_window = nums[0] min_range = 10e5 + 1 while right < n: if sum_window < target: # print("Enlarge wi...
c32d25e2ef0003f5ba3217d329f8de1867f2706b
hieutran106/leetcode-ht
/leetcode-python/medium/_853_car_fleet/solution.py
1,018
3.984375
4
from typing import List class Solution: def carFleet(self, target: int, position: List[int], speed: List[int]) -> int: """ Because pos and speed are positive, we can sort the vehicles by (pos, speed) pair A stack will store the time a car takes to reach the target - Iterate thr...
5b54e5a4a58d638d6562597aebeb388d597c1be8
hieutran106/leetcode-ht
/leetcode-python/medium/_845_longest_mountain_array/solution.py
1,627
3.921875
4
from typing import List class Solution2: def longestMountain(self, arr: List[int]) -> int: i = mountain = 0 n = len(arr) while i < n: base = i # walk up while i < n - 1 and arr[i+1] > arr[i]: i += 1 if i == base: ...
7847f7d524dc0a087ef644534f97bb6cc72ff0ff
hieutran106/leetcode-ht
/leetcode-python/medium/_130_surrounded_regions/solution.py
1,618
3.6875
4
from typing import List class Solution: def solve(self, board: List[List[str]]) -> None: """ Do not return anything, modify board in-place instead. """ rows = len(board) cols = len(board[0]) for i in range(rows): for j in range(cols): if ...
907c6ddb0a9ecbb4ceba4c651c6e363bd12e849c
hieutran106/leetcode-ht
/leetcode-python/medium/_55_jump_game/test_solution.py
1,724
3.515625
4
import unittest from typing import List import heapq class Solution: def canJump(self, nums: List[int]) -> bool: if len(nums) == 1: return True min_heap = [] for i, v in enumerate(nums): # pop while min_heap and min_heap[0] < i: heapq.hea...
a0b36d63a5d8e45f32323065d77efef96cff0a06
pranjal-mittal0/Python_book_shop_management
/check_stock.py
2,389
3.625
4
from __future__ import print_function import book_detail_input import os #os module imported def check_stock(ISBN,required_stock,file_handler): #check_stock function begins file_handler.seek(0,0) #seek function used which places pointer at specified location. store=file_handler.readlines() fo...
88b20e0e6b55324c0fa2e9b52b34bcc261e4d8f4
addsteel/LeetCode
/p70.py
286
3.640625
4
class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int """ if n <= 2: return n result = [1,1] while len(result) < n result.append(result[-1]+result[-2]) return result[-1]
4fd1d2dd2d62979a97cd4a92edc80f2edf00433f
addsteel/LeetCode
/p101.py
746
3.96875
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 isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ if root is...
9241b8e3407f6d128c1e1c0b7ce39791e3e49dce
addsteel/LeetCode
/p211.py
1,292
3.984375
4
class WordDictionary: # initialize your data structure here. def __init__(self): self.root = {} # @param {string} word # @return {void} # Adds a word into the data structure. def addWord(self, word): node = self.root for c in word: if c not in node: node[c] = {} node = node[c] node['...
804c82f2861f81347430c338747014f6adc7e979
addsteel/LeetCode
/p223.py
988
3.546875
4
class Solution: # @param {integer} A # @param {integer} B # @param {integer} C # @param {integer} D # @param {integer} E # @param {integer} F # @param {integer} G # @param {integer} H # @return {integer} def computeArea(self, A, B, C, D, E, F, G, H): #If there exists overlap if ...
9f9c65b24e0262f4bee1e41a15b4686055a3c60c
addsteel/LeetCode
/p141.py
778
3.6875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def hasCycle(self, head): """ :type head: ListNode :rtype: bool """ node1 = head count = 1 wh...
210143818c2b007da842b7993bb76a85a62e85ad
addsteel/LeetCode
/p166.py
2,104
3.671875
4
class Solution: def div(self, dividend, divider): result = "" dic = {} #dic[dividend/10] = 0 #print dividend,divider #dic[dividend] = 0 while dividend is not 0: length = len(result) num = 0 if div...
ad9b1c1f321768042e88d2078f8f930f25e8096a
addsteel/LeetCode
/P35.py
783
3.671875
4
class Solution: # @param {integer[]} nums # @param {integer} target # @return {integer} def searchInsert(self, nums, target): left = 0 right = len(nums) while left < right: mid = (left + right)/2 if nums[mid] > target: right = mid - 1 ...
e6b0cc3a5b827db4154038fceb1734e69328811a
Shashwatsingh22/Using_Python_To_Access_Web_Data
/Extracting_data_in_the_list_and_finding_max_value.py
373
4.0625
4
#Extracting Data In the list and then finding the max in it... import re fname = input("Enter the File Name: ") lines = open(fname) numlist = list() for line in lines: line = line.rstrip() stuf=re.findall("[0-9. ]+",line) print(stuf) if len(stuf)!=1 :continue num=int(stuf[0]) numlis...
24be1fa0525162f68cc612c2c6c89daed198ba8e
bibizzz/quorridor
/breadth_first.py
3,088
3.515625
4
#!/usr/bin/env python3 """ Group 05 Authors : Aref Shabana - Christophe Limbree """ import random from quoridor_LM import * import minimax import time class MyAgent(Agent, minimax.Game): """My Quoridor agent.""" def initialize(self, percepts, players, time_left): self.step = 1 def successors...
01a30c0611fe77004c3a25e4f748ed744e91b910
vxlk/stoinks
/src/scraper/app_trainer.py
1,796
3.578125
4
from autoscraper import AutoScraper import csv # this is where the app will learn the rules for its scrapes scraper = AutoScraper() main_page = False history = True # ---------------------------------- Main Page --------------------------------------------------------------- if main_page: url = 'htt...
374182efba1c7e07c9bf826dded00091d774f657
Dturati/estudos_python
/estudos/oo/params.py
801
3.796875
4
class Peoples: def __init__(self, people): self.people = people def __getitem__(self, item): return self.people[item] class HauntedBus: def __init__(self, passengers: Peoples = None): if passengers is None: self._passengers = [] else: self._pass...
4f60fcdfbe0533f4cdf04f20a94acdf321028831
Dturati/estudos_python
/basico/array.py
262
3.546875
4
from array import array from random import random floats = array('d', (random() for i in range(1,10))) # print(floats) # print(floats[-1]) DIAL_CODES = [(86,'China'),(91, 'India'),(1, 'USA')] res = {s: r for r, s in DIAL_CODES} print(res.get('China', 0))
3f481eb12ec84b606dc6a7308c1350449ebe3cd4
Dturati/estudos_python
/testes/sequencia.py
156
3.71875
4
number = [1,2,3,4,5] res = [ (x) for x in number if x % 2 == 0] tupla = 'david', 'turati' pessoa = {'nome':'David', 'idade':34} print(pessoa['nome'])
705d7f1a475a7397f87d707b6424a9260d117a2d
Dturati/estudos_python
/estudos/oo/conta.py
1,288
3.6875
4
class Conta: def __init__(self, numero=0, titular="" ,saldo=0, limite=0): self._numero = numero self._titular = titular self._saldo = saldo self._limite = limite self._codigo_banco = "001" def deposita(self, valor): self._saldo += valor def saca(self, valor...
3e4cc0222d35b8842d578f7934c176ed08e0fa0b
Oben/ms
/ProjectEuler/projecteuler_10.py
420
3.640625
4
#!/usr/bin/env python # encoding: utf-8 """ import sys import os from scipy import * from numpy import * def main(): j=1 i=3 Prime=[2] S=2 while i<2000000: if isprime(i,Prime): j=j+1 Prime.append(i) S=S+i i=i+2 print S def isprime(num,Prime): count = int(sqrt(num)) i=0 while count >= Prime...
bcdc3d96b83fcf126d8ec49f76535e8e2d70c56f
pabloem/hanja-graph
/bin/get_pairs_meanings.py
884
3.625
4
#!/usr/bin/python3 import csv import sys from crawlers.utils import get_hanja_meaning usage = """Usage: ./get_pairs_meanings.py input_csv output [amount] Obtains the meanings of the pairs of words or characters that come from a CSV file. The amount can be limited.""" if len(sys.argv) < 3: print() sys.exit() i...
bb1e7b42406bc34b4e23cf5ec9c4c4bef8dbc0cd
christran206/EducationPrograms
/CSS490-Bioinformatics/Rosalind Solutions/rosalind_revc_123_1_code.py
369
3.90625
4
import csv import sys def complement(s): basecomplement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'} letters = list(s) letters = [basecomplement[base] for base in letters] return ''.join(letters) def revcom(s): return complement(s[::-1]) print("Takes a DNA string and returns reverse compliment") dn...
a79b7b939d60da9053b19d3aad5a634a1e7ef1d8
christran206/EducationPrograms
/CSS490-Bioinformatics/Rosalind Solutions/rosalind_long_123_1_code.py
1,188
3.5
4
__author__ = 'Christopher' infile = open(raw_input("Name of text file: "), 'r') lines = (line.rstrip('\n') for line in infile) string = [] count = -1 for line in lines: if line[0] == '>': count += 1 string.append("") else: string[count] += line while len(string) != 0: max_lengh = ...
70759ab49883a75e9fca38c92e7bfa6163b1ae4c
hericlysdlarii/Respostas-lista-de-Exercicio
/Questao17.py
299
3.953125
4
# Faça um Programa que peça um número correspondente a um # determinado ano e em seguida informe se este ano é ou não bissexto. ano = int(input("Ano: ")) if ((ano % 4 == 0) and (ano % 100 != 0) or (ano % 400 == 0)): print("Ano Bissexto") else: print("Não é ano bissexto")
50ac0dc6dfbe3a6dff8fb85eb0788936e75e9845
hericlysdlarii/Respostas-lista-de-Exercicio
/Questao4.py
266
4.15625
4
# Faça um Programa que verifique se uma letra digitada é vogal ou consoante. letra = str(input("Digite uma letra: ")) if ((letra == 'a') or (letra == 'e') or (letra == 'i') or (letra == 'o') or (letra == 'u')): print("Vogal") else: print("Consoante")
995df9ae25209de13ffb34dab1edd86ad5f99ce4
hericlysdlarii/Respostas-lista-de-Exercicio
/Questao7.py
266
4.03125
4
# Faça um Programa que leia três números e mostre o maior e o menor deles. a = input("digite um numero: ") b = input("digite um numero: ") c = input("digite um numero: ") lista = [a, b, c] print("maior: " + str(max(lista))) print("menor: " + str(min(lista)))
f7fb074ec569208dd8cae69fcbf48e8143f3cc51
elnoob893/Genes
/codon.py
2,057
3.765625
4
seq_a='ATGCAATGCCCTGATTTGGGG' seq_b='ATGCAATGCCTTGATTAGAAA' length_a = len(seq_a) length_b = len(seq_b) if (length_a == length_b): print('will run ') else: ('***See a programmer because program is broken***') print(list(seq_a)) print(list(seq_b)) print('____________________') #breaks st...
092e4a81e5b2fd7ae19165e575c4cb0d7c2c20d6
JordiSalaJuarez/AdventOfCode2020
/day_4/passport_processing.py
1,420
3.65625
4
def passports(): try: while True: line = input() d = dict() while len(line.strip()) != 0: # empty line fields = line.split() d.update(dict(field.split(':') for field in fields)) line = input() # will fail for last pasport ...
e350941fce725c61a0953e29e36754867edb7f6b
Discordia23/Udacity-Near-Earth-Objects
/write.py
2,187
3.53125
4
"""Write a stream of close approaches to CSV or to JSON. This module exports two functions: `write_to_csv` and `write_to_json`, each of which accept an `results` stream of close approaches and a path to which to write the data. These functions are invoked by the main module with the output of the `limit` function and...
5fddff1509c6cdd53ecf20c4230f1db35f769544
tawrahim/Taaye_Kahinde
/Kahinde/chp6/tryitout (2).py
1,912
4.125
4
print "First Question:" firstname="Kahinde" lastname="Giwa" print "Hello,my name is,",firstname,lastname print "\n\n\n" print "**************************\n" firstname=raw_input("Enter your first name please:") lastname=raw_input("Now enter your lastname:") print "You entered",firstname,"for your firstname," pr...
77ef1a85e93549c28e6eeef9fdeeeab5a1365350
tawrahim/Taaye_Kahinde
/Taaye/chp4/dec-int.py
1,346
4.625
5
print "Question #1, Try it out" print"\n" print'This is a way to change a string to a float' string1=12.34 string="'12.34'" print 'The string is,',string point= '12.34' formula= float(string1) print "And the float is,",point print 'We use this formala to change a string into a float, the formula is,', formul...
d74df1cca1b65e385a10f1ea77272818f8ec75d1
tawrahim/Taaye_Kahinde
/Taaye/chp7/tryitout.py
1,477
3.6875
4
# Taaye Giwa #This code helps take the per centage off the price. # No mistakes import easygui user_money= float(raw_input("How much are your items in total? ")) percent1= user_money - (user_money * 0.1) percent2= user_money-(user_money * 0.2) if user_money < 10: print percent1, " is how much you pay" if...
07566268fa1ca3f0e66a41f8fc4d6f758fdaa9d0
tawrahim/Taaye_Kahinde
/Kahinde/chp8/looper_tio.py
1,077
4.125
4
#Kainde's work,Chapter 8,tryitout,question1 number=int(raw_input("Hello, what table should I display? Type in a number:")) print "Here is your table:" for looper in range(number): print looper, "*",number,"=",looper*number print "\n*************************************" #Chapter 8,tryitout,question2 ...
533bd4222f04d9480067d7152a660c75f70e9361
tawrahim/Taaye_Kahinde
/Tawheed/chp11/demo2.py
865
3.8125
4
numBlocks = int(raw_input("How many block of stars do you want: ")) for numBlocks in range(1,numBlocks+1): print 'the variable numBlocks is: ', numBlocks for lines in range(1, numBlocks *2): print 'the variable line is: ', lines for stars in range(1, (lines + numBlocks)*2): print "*"...
64a16c8edaa72de44c368ebb49343918a2681a1d
tawrahim/Taaye_Kahinde
/Taaye/chp6/easygui_changingfahr-cel_machine.py
1,244
3.859375
4
#1 (with extra stuff) :) import easygui easygui.msgbox ("This program converts Fahrenheit to Celcius.") user=easygui.integerbox("Type in the temperature in fahrenheit:") girl=float(user) celcius= (girl-32)*5.0/9 easygui.msgbox("The temperture in celcius is " + str(celcius)) girl=easygui.buttonbox ("Isn't this p...
b3d8cdd8264c60f76b1ab7f6917b31d8dd5cfe94
abhisheksurpur2/1BM17CS007
/board.py
173
3.90625
4
dashes=6 rows=int(input("Enter no of rows")) for i in range(rows//2): print("- "*rows) print("| | | |") if rows%2!=0: print("- "*rows)
7501613b9559c64ea0745abf3006d35bf072efdb
laurencoding/Billing-Program-Project
/Program5a.py
1,683
3.5625
4
# ------------------------------------------------------------------- # Author: Lauren Canning # Name: Program 5a # # Description: # Reads record from Billing.txt file and produces a control report # ------------------------------------------------------------------- from Module4 import * def main(): ...
89db3213b07c9738b14a4d3fd9f6c30aed6cbe38
astra3301-mitnick/pyPacMan
/tests/12 - Point System (in Level)/Pacman.py
4,344
3.6875
4
import pygame from pygame.locals import * class Pacman(pygame.sprite.Sprite): def __init__(self, x, y, speed, collisions): # Call the parent class constructor pygame.sprite.Sprite.__init__(self) # Get the main window's display self.surface = pygame.display.get_surface...
065867818425fd5feec779259036eddb1987f679
astra3301-mitnick/pyPacMan
/tests/14 - Movement System/Pacman.py
2,972
3.640625
4
import pygame from pygame.locals import * class Pacman(pygame.sprite.Sprite): def __init__(self, x, y, speed, collisions): # Call the parent class constructor pygame.sprite.Sprite.__init__(self) # Get the main window's display self.surface = pygame.display.get_surface...
89ba7658b45e09a370813e75845e4009e9d4fa28
TrinityChristiana/py-classes
/main.py
882
4.15625
4
# **************************** Challenge: Urban Planner II **************************** """ Author: Trinity Terry pyrun: python main.py """ from building import Building from city import City from random_names import random_name # Create a new city instance and add your building instances to it. Once all buildings ar...
e003dfa18152e59f44feb4cfda4875130f99f97a
Dessnick/python-project-lvl1
/brain_games/engine.py
615
3.578125
4
import brain_games.cli as cli def run(game, rounds=3): name = cli.welcome_user(game.GAME_RULES) counter = 0 while counter < rounds: question, correct_answer = game.start() print(question) answer = cli.user_answer() if correct_answer == answer: print('Correct!') ...
149e84d728e254ef5aea6226aced161a8c65a764
VishnuvarmaSubramani/varma2
/sum of square number digits.py
116
3.671875
4
value=int(input()) Sum=0 digit=0 while(value>0): digit=value%10 Sum=Sum+(digit*digit) value=value//10 print(Sum)
c85f33d9c64b3be032f22fd92a2de34e229321f5
VishnuvarmaSubramani/varma2
/print the reverse string .py
121
3.515625
4
x=input() s=str(input()) lis=('a','e','i','o','u') for x in s: if x in lis: s=s.replace(x,"") print(s[::-1])
840bd80c33c82a49f83170a2956d402d2f33d67e
SethC94/Python
/coursera/python_basics_01/week_4/append_vs_concatinate.py
609
3.984375
4
origlist = [45,32,88] origlist.append("cat") print(origlist) origlist = [45,32,88] print("origlist:", origlist) print("the identifier:", id(origlist)) #id of the list before changes newlist = origlist + ['cat'] print("newlist:", newlist) print("the identifier:", id(newlist)) #id of the list ...
a080bfd6c014a8637f6ee9423005e6c8db51315d
SethC94/Python
/coursera/python_basics_01/week_3/accumulator_conditionals.py
1,773
4.0625
4
phrase = "What a wonderful day to program" tot = 0 for char in phrase: if char != " ": tot = tot + 1 print(tot) s = "what if we went to the zoo" x = 0 for i in s: if i in ['a', 'e', 'i', 'o', 'u']: x += 1 print(x) nums = [9, 3, 8, 11, 5, 29, 2] best_num = 0 for n in nums: if n > best_nu...
d1deb247bbda8f7c3b16cc4b0e79ab8372d198fa
npardue/Predicting-Sales-List-Prices
/data/cleaning_script.py
4,108
3.546875
4
def return_clean_dataframe(): #load pandas, numpy import pandas as pd import numpy as np # Import the Data df = pd.read_csv('./data/kc_house_data.csv') # Convert Date to Datetime: df['date'] = pd.to_datetime(df['date']) # Create yr_sold column: df['yr_sold'] = df.date.dt.year ...
a518587f9057de22d1c64e66395ff722632c7eac
tudor-alexa99/fp
/X0_exam_practice/ui.py
1,983
3.875
4
from game import Game class Ui(): def __init__(self): self.game = Game() def start_menu(self): print("Choose an option:\n") print("\t1.Start new game") print("\t2.Load saved game") print("\t0.Exit") i = input(":") if i == "1": ...
b67bc041036a3d0b8f20529f3c5c117794edae0a
ShannonTully/data-structures-and-algorithms
/sorting-algos/quicksort/quicksort.py
701
4.0625
4
"""The quick sort algorithm.""" def quicksort(unsorted, low=0, high=False): """Quick sort a list.""" if len(unsorted) < 2: return unsorted if high is False: high = len(unsorted) - 1 if low < high: swapper = swap(unsorted, low, high) quicksort(unsorted, low, swapper - ...
a332ce980f21b0ab7ee0c9fb2a746e2b3c58da9b
ShannonTully/data-structures-and-algorithms
/data_structures/hash_table/test_hash_table.py
2,237
3.53125
4
"""Hash Table tests.""" from .hash_table import HashTable def test_hash_table_creation(): """Test that a Hash Table can be created.""" table = HashTable(100) assert len(table.buckets) == 100 def test_hash_key(empty_hash_table): """Test hash works.""" assert empty_hash_table._hash_key('abc') == ...
cdb4d3650e82bbef368656ecce8cb0e9feef4474
ShannonTully/data-structures-and-algorithms
/data_structures/hash_table/test_repeated_words.py
491
3.9375
4
"""Test for repeated words function.""" from .repeated_words import repeated_words def test_basic_repeat(): """Test with basic string.""" assert repeated_words('word word') == 'word' def test_empty_string(): """Test empty string.""" assert repeated_words('') is None def test_complex_string(): ...
aaa71b3819d083dc057c8631a8d8474698b6610d
ShannonTully/data-structures-and-algorithms
/challenges/multi-bracket-validation/multi_bracket_validation.py
548
3.75
4
def multi_bracket_validation(bracket_string): counter1 = 0 counter2 = 0 counter3 = 0 for item in bracket_string: if item is '(': counter1 += 1 elif item is ')': counter1 -= 1 elif item is '{': counter2 += 1 elif item is '}': ...
4d8652129074d9e0fbb1724328b6d50ef1e4b8b2
FyahhDragon/Euler_Project
/Euler_Problem_002.py
975
3.734375
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 10 19:25:49 2021 @author: Roger Even Fibonacci numbers Problem 2 Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the term...
ebbf0ec5834ca67456706bb4311b702a3ca922c5
teotiwg/studyPython
/200/pt2/050.py
438
4.09375
4
class MyClass: var = 'Hello!' def sayHello(self): param1 = "hello" self.param2 = "hi" print(param1) print(self.var) obj = MyClass() print(obj.var) obj.sayHello() # 클래스에서 선언되는 변수에는 클래스 멤버와 인스턴스멤버가 있음 # 클래스 멤버는 클래스 메소드 밖에서 선언됌 # 인스턴스 멤버는 메소드 안에서 self와 함께 선언되는 변수
adf4ad5cd2454ac88b978cb6b3c6fc739761820a
teotiwg/studyPython
/200/pt3/133.py
240
3.5
4
val = input('문자 코드값을 입력하세요') val = int(val) try: ch = chr(val) print('코드값: %d[%s], 문자: %s' %(val, hex(val), ch)) except ValueError: print('입력한 %d라는 문자는 존재 않습니다.' %val)
6dd2d52883486bd8957f34ee7675a87ac7d26915
teotiwg/studyPython
/200/pt2/037.py
182
3.734375
4
tuple1 = (1,2,3,4,5) tuple2 = ('a', 'b', 'c') tuple3 = (1, 'a', 'abc', [1,2,3,4,5], ['a','b','c']) tuple1[0] = 6 def myfunc(): print("Hello") tuple4 = (1,2, myfunc) tuple4[2]()
634f762876859aa8f5f2303a0682917ff468972b
teotiwg/studyPython
/200/pt2/039.py
195
3.5
4
def add_number(n1,n2): ret = n1 + n2 return ret def add_txt(t1,t2): print(t1 + t2) ans = add_number(10,15) print(ans) text1 = '대한민국~' text2 = '만세!' add_txt(text1, text2)
8f62c456465154e9bfeda5d34e7b1ef1080e2541
teotiwg/studyPython
/200/pt3/061.py
216
3.515625
4
numdata = 57 strdata = 'python' listdata = [1, 2, 3] dictdata = {'a':1, 'b':2 } def func(): print("Hello") print(type(numdata)) print(type(strdata)) print(type(listdata)) print(type(dictdata)) print(type(func))
d95781d781df07074445562991f1a787c6721623
thomazthz/desafios
/idwall_tools/strings/wrap.py
4,421
3.84375
4
import re import random RE_NON_WHITESPACE = re.compile(r'\S+') def wrap(text, columns=40, justified=False, force=False): """Make a generator that takes a text and yields wrapped line. All lines fits the width defined by :columns:. The text is splitted in chunks. Each chunk is a simple word or a wo...
7eac17a3c6ee5311bbad9fcc22fa59e483f9ea80
Yasmin-Alhajjaj/python.exercises
/exe11.py
2,094
3.984375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Dec 4 09:42:25 2019 @author: owner #Q1 from tkinter import * def action(): if enter1.get()=="Orange" and enter2.get()=="CodingAcademy": answer = messagebox.showinfo("Login", "Successful login") if answer == "ok": blog...
1a0a76a3d6e503dcd39ffc358f1c74a210207a0f
rashmitallam/PythonBasics
/patterns2.py
1,066
3.703125
4
#WAP to print various patterns def Pattern1(n): print 'Pattern1:' for i in range(1,n+1): if i <= 4: for j in range(1,i+1): print j, else: for j in range(1,n-i+2): print j, print('') def Pattern2(n): print 'Patter...
a2ca245925c0c9fd9408ba5d5ca109c655d9af56
rashmitallam/PythonBasics
/tables_2_to_n.py
271
4.25
4
#WAP to accept an integer 'n' from user and print tables from 2 to n n=input('Enter an integer:') for x in range(2,n+1): print("Table of "+str(x)+":\n") for y in range(1,11): z = x*y print(str(x)+"*"+str(y)+"="+str(z)) print('\n')
b5b39b0c2a79d3bddedb127d6c9abe02d01dde4b
atsuhisa-i/Python_study1
/class_attr1.py
276
3.703125
4
class Food: count = 0 def __init__(self, name, price): self.name = name self.price = price Food.count += 1 def show(self): print(Food.count, self.name, self.price) x = Food('milk', 150) x.show() y = Food('egg', 200) y.show()
e15fe8940a626fbd3b0e32fbe268a86ab21f29af
atsuhisa-i/Python_study1
/enumerate3.py
87
3.734375
4
drink = ['coffee', 'tea', 'juice'] for i in range(len(drink)): print(i+1, drink[i])
49a86e0516ed6dbe5f35eaac6d9ab90b57431f1a
atsuhisa-i/Python_study1
/cond3.py
199
3.671875
4
number = input('Number:') print('1st Prize:Money' if number == '123456' else '2nd Prize:Gift Box' if number[-4:] == '7890' else '3rd Prize:Stamp Sheet' if number[-2:] == '05' else 'Lose')
1067d95745c6c4d0cefe0e910cfeeda7c20432b2
lokeshom1/python
/parampassing.py
252
4.03125
4
def increment(x): print("Beginning execution of increment,x =",x) x +=1 print("Ending execution of increment, x=",x) def main(): x=5 print("Before increment ,x=", x) increment(x) print("After increment,x=",x) main()
a2e72fc8db97045e7b33c13ec8d40eb9dcb37ca6
lokeshom1/python
/datetransformer.py
682
4.21875
4
month = eval(input('Please enter the month as a number(1-12): ')) day = eval(input('Please enter the day of the month : ')) if month == 1: print('January', end='') elif month == 2: print('February', end='') elif month == 3: print('March', end='') elif month == 4: print('April', end='') elif month ==...
136ed5346192721c64f48680b61cc485c7779020
zemi347/python
/Assingment6/Q4.py
1,435
3.578125
4
Question 4: Define the following terms: 1. Class 2. Object 3. Attribute 4. Behavior Answer: 1: Class: A class is a code template for creating objects. Objects have member variables and have behaviour associated with them. In python a class is created by the keyword class . An object is created using the constructor ...
9467f6602583d064eb6fafd81e51e00d793d1d8a
zemi347/python
/Assingment6/Q2.py
3,755
3.90625
4
Question 2: List down the Benefits of OOP? Answer: The Benefits of OOP: 1. Re-usability It means reusing some facilities rather than building it again and again. This is done with the use of a class. We can use it n number of times as per our need. 2. Data Redundancy This is a condition created at the place of d...
c090f93c4e505e633ebef2446a973224293651ca
TimilsinaBimal/Sudoku-Solver
/test_sudoku.py
1,892
3.859375
4
from sudoku_solver import SudokuSolver import unittest class TestSudoku(unittest.TestCase): def setUp(self): self.board = [[0, 0, 0, 2, 6, 0, 7, 0, 1], [6, 8, 0, 0, 7, 0, 0, 9, 0], [1, 9, 0, 0, 0, 4, 5, 0, 0], [8, 2, 0, 1, 0, 0, 0, 4, 0], ...
34c2473289796f762ec655fdbf349394028fc779
lorodin/py-lesson2
/task5/main.py
2,715
3.59375
4
# 5. Реализовать структуру «Рейтинг», представляющую собой не возрастающий набор натуральных чисел. # У пользователя необходимо запрашивать новый элемент рейтинга. # Если в рейтинге существуют элементы с одинаковыми значениями, то новый элемент с тем же значением должен разместиться после них. # Float validator def is...
9ade136f8327785c9b650e31f4b70c3b307b61f7
devendra-gh/ineuron_assignments
/python-assignment-4.py
3,503
4.25
4
""" 1.1 Write a Python Program(with class concepts) to find the area of the triangle using the below formula. area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 Function to take the length of the sides of triangle from user should be defined in the parent class and function to calculate the area should be defined in subc...
5e379a7dd6724b7298056996104159abd0d82240
roomyt/dancoff_util
/expandFIDO.py
829
3.9375
4
import sys import re def expandFIDO(list_): """ Given a list of strings, this function will check each element for FIDO style input and expand it if found. """ read_shorthand = re.compile(r'^(\d+)([rp])([a-zA-Z0-9.\-+]*)') # ie for 4p5.43e-5 the returned list will contain ['4', 'p', '5.43e-5'] for i ...
dc9afc957f1864116c6a6ecde8a2fca1a96e7e15
mananarora200/python
/single_linked_list.py
2,112
4.03125
4
class Node: def __init__(self,data): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None self.length = 0 def append(self,data): new_node = Node(data) if self.head is None: self.head = new_node retu...
a27d1e78300a46746ad26378d8bb8ab0fc41ec3e
HackerSchool/HS_Recrutamento_Python
/Henrique_Caraca/app_chatbot.py
2,681
3.625
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 31 23:05:08 2021 @author: User """ from random import randrange def chatbot1(): # dá return de uma pessoa e uma ação pseudo aleatoriamente tendo em conta o input pessoas=["O João", "O Homem-Aranha", "O Michael Jordan", "O Presidente", "A Maria"] verbo=["é f...
c5d1137a36aa9c3616ac19f15d57502da3e1a6fb
HackerSchool/HS_Recrutamento_Python
/Henrique_Caraca/app_calculadora.py
5,089
4.03125
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 30 11:57:09 2021 @author: User """ def operacao1(): # recebe dois numeros (n1 e n2) e uma operacao (op) # dá print do resultado de n1 op n2 n1 = float(input('Primeiro número: ')) op = input('Escolha a operaçao (+, -, x, /, **, %): ') n2 = float(input...
b396f09185f6c21543bcf514bd4f1a837956d8c2
HackerSchool/HS_Recrutamento_Python
/Diogo_V_Ferreira/loginFunc.py
2,061
3.90625
4
import auxiliares as aux import apps def login(): i=1 while True: if i>3: print('''Número máximo de tentativas alcançado! |----------------------------------| | A regressar ao menu inicial... | |-----------------...
8bf84eb24bf3d03df3da59b7b9c6befad1ea616c
HackerSchool/HS_Recrutamento_Python
/Diogo_Santos/user.py
1,399
3.703125
4
class User: '''The user entity Attributes: name The username by which the user is referenced to loggenIn The state that tracks if user is loggen in inApp The state that tracks if user is in an app currentApp The name of the app the user is currently in Noti...
76e37dae57693f3b2e79f5ecaeaf9ca5a38ad0ac
HackerSchool/HS_Recrutamento_Python
/Luís_Barbosa/calculadora.py
4,890
3.796875
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 2 19:13:34 2021 @author: luis_ """ import time #import matplotlib.pyplot as plt #import numpy as np def calcular(): # Calcula expressões com dois números expressao = str(input("Introduza a expressão ( 1 + 1 ...
2a0dd73beedc5984f1ef6460ecbecd5db1b6d591
HackerSchool/HS_Recrutamento_Python
/Armando_Gonçalves/main.py
3,013
3.75
4
from calculadora import * def mudarpass(user): contador =-1 stop = 0 password = input("\nInsira a nova password:") f2 = open("base_de_dados.txt", 'r+') f2.seek(0) for line in f2: if(stop == 0): contador += 1 if(user == line.split()[0]): stop = 1 ...
c933b22cf3fadee137acbf400d16f89c0b544bc2
HackerSchool/HS_Recrutamento_Python
/Diogo_Santos/Calculator/calculator.py
7,972
4.125
4
import matplotlib.pyplot as plt import numpy as np from user import User class Calculator: ''' The core of the app tictactoe Attributes: user The user in app This app allows the user to calculate algebraic expressions with one operation, to calculate the sum/sub/mult of two mat...
603f63fc7a9ff7c81e9130ffaa826a523731448c
HackerSchool/HS_Recrutamento_Python
/André_Santos/modules/tictactoeai.py
3,915
3.515625
4
from os import system import sys import random def clear(): if sys.platform.startswith("linux"): system("clear") else: system("cls") grid = [" " for _ in range(10)] def draw(): print(f"""\n {grid[1]} │ {grid[2]} │ {grid[3]} 1 │ 2 │ 3 ───┼───┼─── ───┼───┼─── {grid[4...
83c6632ac9d09b6a0acf345bcd3e8a6a04b5dd66
HackerSchool/HS_Recrutamento_Python
/Daniela_Cardoso/projeto.py
702
3.609375
4
from app import menu as menu from login import login as login from login import register as register def main(): print("Bem vind@:\n") k=1 f= open('registos.txt', '+w') while k==1: print('''\nO que desejas fazer?: a - Login b - Registar c - Quit ...
14ae5bcd73be3b0e094db254b163b5c484989605
vaibhavwade/python-programming-lab
/armsstrong.py
148
3.71875
4
x=input('enter the number ') L=len(x) sum=0 for j in range (0,L): sum+=int(x[j])**L if int(x)==sum: print('angstrong number') else: print('not')
d0f9610404f5b037cdec3d6f3d093ec7e2d988cc
vadimsh73/algorithms
/Linear search in the array.py
1,160
4.03125
4
# -*-coding:UTF-8-*- def array_search(a:list, n:int, x:int): """ Осуществляет поиск числа x в масстве A от 0 до N-1 включительно. :param a: type list :param n: type int :param x: type int :return: Возвращает индекс элемента x в массиве A или -1 если такого элемента нет ...
594179b2ff92cc1b4b9c12d465f0604b971eef23
madsngh/python
/exe18.py
445
3.875
4
#_*_coding: utf=8_*_ '''NMAE VARIABLE CODE FUNCTION IN THIS WE WILL LEARN TO DEFINE FUNCION FIRST THEN WE WILL USE FUNCTION''' def siddhu(*a):#the value or r and s is laatter stored in *a c,d=a print("the values you entered are %r %r"%(c,d)) def siddhu2(r,s):#with two argument print("the values you entered are %r %...
636534263f94b550f67e1aad2b61e9885ee3efca
madsngh/python
/exe10.py
279
3.859375
4
#_*_coding: utf=8_*_ siddhu="i\'m 5\'10 in height" del siddhu print(siddhu) papa="\bhe is 5\"6 in height" # \b is being used for backspace print(papa) a=""" \a*a quick brown fox \t*jumps over the \t*lazy dog """ print(a) '''if we put \\ then it will print backslash'''
311ab08d466143062b58036743236330b0c92f57
khamosh-nigahen/linked_list_interview_practice
/Insertion_SLL.py
1,692
4.5625
5
# Three types of insertion in Single Linked List # ->insert node at front # ->insert Node after a given node # ->insert Node at the tail class Node(object): def __init__(self, data): self.data = data self.nextNode = None class singleLinkedList(object): def __init__(self): ...
ade90410ef47e5d0c7f86278e142d87ac82891a5
Edb83/postgres-tutorial
/sql-psycopg2.py
1,253
3.734375
4
import psycopg2 # connect to "chinook" database connection = psycopg2.connect(database="chinook") # build a cursor object of the database cursor = connection.cursor() # Query 1: select all records from the "Artist" table # cursor.execute('SELECT * FROM "Artist"') # Query 2: select only the "Name" column from the "...
d49705746dd3cee9dfb6b3691dd68731a9d6457a
nmm1108/selenium
/testcase/method.py
1,715
3.5
4
from selenium import webdriver from time import sleep class seleniumMethod(object): def __init__(self): self.webdriver = webdriver.Chrome() self.webdriver.get("https://www.baidu.com") self.webdriver.maximize_window() def method(self): self.webdriver.find_element_by_id("kw").se...
24671963b16c19c9bdc7977d321f8427946df020
inholland-compolab/FanucAutomatedManufacturing
/RoboDK/2021-8 Ruben/MoveRobotWithKeys.py
2,927
4.0625
4
# This macro allows moving a robot using the keyboard # Note: This works on console mode only, you must run the PY file separately # # More information about the RoboDK API here: # https://robodk.com/doc/en/RoboDK-API.html # Type help("robolink") or help("robodk") for more information from robolink import * # API t...
52ceb771eca1d259cbceccf5311388cdf8303ea1
djharten/Coding-Challenges
/Kattis-Problems/Python-Solutions/Trik.py
432
3.796875
4
a = input() loc = 1 for i in range(len(a)): move = a[i:i+1] if(move == 'A' and loc == 1): loc = 2 elif(move =='A' and loc == 2): loc = 1 elif(move == 'B' and loc == 2): loc = 3 elif(move == 'B' and loc == 3): loc = 2 elif(move == 'C' and loc == 1): ...
6c10bf8c8de9747acf05feab92b90da5d3305ba2
djharten/Coding-Challenges
/Kattis-Problems/Python-Solutions/AboveAverage.py
363
3.609375
4
a = int(input()) for i in range(a): arr = list(map(int, input().split())) numArr = arr[0] arr.remove(arr[0]) sum = 0 for k in range(numArr): sum += arr[k] avg = sum/numArr count = 0 for j in range(numArr): if arr[j] > avg: count+=1 p...
b9fc8891232f83c596747008484ab0bf25c5c1d8
capss22/python
/python_程式碼/ch2/ex4-賣場買飲料.py
128
3.5
4
罐數 = int(input('請輸入購買飲料的罐數?')) 金額 = (罐數//12)*200 + (罐數%12)*20 print('需花費', 金額)
3e3e1829ccebbdb8fae6f63e29e9aded89a11d98
capss22/python
/python_程式碼/ch4/4-2-3-三角形判斷.py
280
3.71875
4
a = int(input('請輸入三角形邊長a長度為?')) b = int(input('請輸入三角形邊長b長度為?')) c = int(input('請輸入三角形邊長c長度為?')) if (a<b+c)and(b<a+c)and(c<a+b): print('可構成三角形') else: print('無法構成三角形')
7f323bd157220374c8f776becd281af79156afd9
capss22/python
/python_程式碼/ch2/2-5-2-計算圓面積與圓周長.py
183
3.71875
4
半徑 = float(input('請輸入半徑?')) PI = 3.14159 圓周長 = 2 * PI * 半徑 圓面積 = 半徑 * 半徑 * PI print('圓周長為', 圓周長, '圓面積為', 圓面積)
70fb6c828476565ee20e401672f35d397eef8c5d
capss22/python
/python_程式碼/ch3/ex1-存取串列中元素.py
100
3.515625
4
s = input('請輸入一行英文句子?') s.strip(' .') words = s.split(' ') print(words[::-1])
da602e1d87b340fd673a9c040e658c2826be2684
capss22/python
/python_程式碼/ch4/4-4-條件判斷與運算子「in」.py
500
3.65625
4
a = (1,2,3,4) if 1 in a: print('數字1在tuple a中') else: print('數字1不在tuple a中') a = list('abcdefghijklmnopqrstuvwxyz') if 'q' in a: print('q在串列a中') else: print('q不在串列a中') lang1={'早安':'Good Morning','謝謝':'Thank You'} if '謝謝' in lang1: print('謝謝的英文為', lang1['謝謝']) else: print('查不到謝謝的英文')...