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 |
|---|---|---|---|---|---|---|
9551e2adfa93226aafea33e89b5fc04ba788fd28 | rojicha07/LLBean_data_science | /CLASE 2 - 05-07-2019/ejemplo_tuplas.py | 566 | 3.953125 | 4 | #crear una tupla de 5 elementos de tipos diferentes
mi_tupla = (1,'Roger', 5.34, 'Python', False)
print(mi_tupla)
# agregar mas elementos en una tupla??
mi_tupla = mi_tupla + (11, 'Nuevo elemento')
print (mi_tupla)
# acumular elementos
mi_tupla += (0,'x')
print(mi_tupla)
#subtupla
#el segundo hasta el penultim... |
62e0b61997e50d5eb4ff4c95f551b0b4ca90127f | Starsclaw/Magnetic-reconnexion-events | /PDF merger.py | 1,022 | 3.625 | 4 | import os, PyPDF2
#Ask user where the PDFs are
userpdflocation=input('Where are your files')
userpdflocation=userpdflocation.replace('\\','/')
#Sets the scripts working directory to the location of the PDFs
os.chdir(userpdflocation)
#Ask user for the name to save the file as
file_name=input('What should I ... |
dfe8ca78e57b0ba105b402678655f6a680888e2f | YewonS/KEA_DAT18_Python | /Module/os_exercise.py | 1,181 | 3.734375 | 4 | # os_exercise.py
# Do the following task using the os module
"""
1. create a folder and name the folder 'os_exercises.'
2. In that folder create a file. Name the file 'exercise.py'
3. get input... |
64c426b1edc231d08726d8bef8a5766cb33738c8 | SUJEONG999/Python_Practice | /day5/listLab3.py | 592 | 3.6875 | 4 | listnum = [10, 5, 7, 21, 4, 8, 18]
min_listnum = listnum[0] # 리스트 중 첫 번째 값을 일단 최솟값으로 기억
min_listnum = listnum[0]
for i in range(1, len(listnum)): # 1부터 n - 1까지 반복
if listnum[i] < min_listnum: # 이번 값이 현재까지 기억된 최솟값보다 작으면
min_listnum = listnum[i] # 최솟값을 변경
elif listnum[i] > max_listnum: # 이번 값이 현재까지 ... |
39013a1664feba4777ee98f7ea55218b874f739b | dmytro73/QA-Google | /test0809.py | 723 | 4.09375 | 4 | print('ЗАДАЧА 1: Создать лист из 6 любых чисел. Отсортировать его по возрастанию\n')
numbers = [1, 22, 23, 0.19, 1802, -2]
print('Исходный список ', numbers)
numbers.sort()
print('Сортировка "по возрастанию" ', numbers)
print('\n\nЗАДАЧА 3: Создать tuple из 10 любых дробных чисел, найти максимальное и минимальное знач... |
11edcd2a65c85489709391190f4b30dd545f4d66 | Yllcaka/Random.python | /python-universum-ks.org-master/Binarysearch.py | 437 | 3.859375 | 4 | def binary(list,number):
low = 0
high = len(list)-1
while low <= high:
mid = (low + high) // 2
print(mid)
if list[mid] == number:
return f"{number} is on index [{mid}] of the list"
elif list[mid] < number:
low = mid+1
elif list[mid] > number:
... |
d4108d1af50f12ff6fefb050590fe05b0133dd5a | prashanthar2000/ctf-junk | /five86-2/five86-1/worklist.gen.py | 409 | 3.5625 | 4 |
for i in range(10):
for j in range(i):
print("\t",end="")
print("for" ,chr(i+107) , "in 'aefhrt':")
if i == 9:
for j in range(i+1):
print("\t" , end="")
temp = ""
print('print(', end="")
for a in range(107, 107+i):
print(chr(a), end="+" )
... |
d185b3a8bec87fe8413b44603c623b722f9773e8 | mohanrajanr/CodePrep | /we_230/5690.py | 1,007 | 3.671875 | 4 | from typing import List
def closestCost(baseCosts: List[int], toppingCosts: List[int], target: int) -> int:
closest = [float('-inf'), float('inf')]
def add_to(value):
if value <= target:
closest[0] = max(closest[0], value)
else:
closest[1] = min(closest[1], value)
... |
9620f76ca5e437b2df2f9019f14cb33b568db5d4 | raffi01/Python-Finite-State-Machines | /transition.py | 3,353 | 4.3125 | 4 | class Transition:
"""A change from one state to a next"""
def __init__(self, current_state, state_input, next_state):
self.current_state = current_state
self.state_input = state_input
self.next_state = next_state
def match(self, current_state, state_input):
"""Determines if... |
0a4d83d9476f4780e0868aa022e32b329163f5c6 | aasmirn/prgrm | /bonus/bonus3.py | 1,070 | 4.09375 | 4 | def change_word(word):
vowels = 'aeiouy'
index = 0
for letter in word:
if letter not in vowels:
index +=1
if letter in vowels:
break
return word[index:] + word[:index] + 'ay'
def remove(phrase):
symbols_to_remove = '.,!"()/?'
for s in symbols_to_remove:
... |
b0f244bc99ccfd6546978811443d9173c692de56 | srikanthpragada/PYTHON_16_MAR_2020 | /demo/libdemo/thread_demo.py | 290 | 3.59375 | 4 | import threading
def print_numbers():
for n in range(10):
print(threading.current_thread().name, n)
print("Current Thread : ", threading.current_thread().name)
t = threading.Thread(target=print_numbers)
t.start()
t.join() # Wait until t is terminated
print("End of Main") |
3bd2f9bba9236c4bebc6071259459eaaa6be441a | Evaldo-comp/Python_Teoria-e-Pratica | /Livros_Cursos/Pense_em_Python/cap03/Exercicio_3-1.py | 419 | 4.0625 | 4 | """
Escreva uma função chamada right_justify, que receba uma string chamada s como parãmentro e exiba
a string com espaços sufucuentes à frente para que a última letra da string esteja na coluna 70 da tela.
"""
def right_justify(s):
numero_espacos = 70 - len(s)
#print("{0:>numero_espacos}".format(s))
... |
3841cfc408e29d31a208679c73d100c42103298a | RaghunathSai/Algorithms_Data_Structures_Placement | /stack.py | 890 | 4.09375 | 4 | class Stack:
def __init__(self,stack):
self.stack = stack
def push(self,data):
stack.append(data)
def pop(self):
value = stack[len(stack)-1]
print(value)
stack.remove(value)
print("Pop value = ",value)
def peep(self):
value = stack[len(stack)-1]... |
45a032253033278aa5e3c594eac6ddea74392db9 | kanghyunwoo20/MSE_Python | /ex120.py | 256 | 3.5625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[2]:
fruit = {"봄" : "딸기", "여름" : "토마토", "가을" : "사과"}
user = input("좋아하는 과일은?")
if user in fruit.values():
print("정답입니다.")
else:
print("오답입니다.")
|
097b8a144ad8e97e2e063648cdea6c31dd2706a1 | ikamino/hackathon_eyetest | /Hackathon/untitled8.py | 315 | 3.953125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 23 13:25:28 2019
@author: jasonliang
"""
import datetime
import time
start = time.time()
start2 = start + 12
while time.time() <= start2:
print("1")
#t1 = datetime.datetime.now()
#print (t1)
#t2 = datetime.datetime.now()
#print (t2) |
63031724da954f1550663e8e55fe088e19e2c91c | erikachen19/leet_code_ex | /Valid Parentheses.py | 1,418 | 4.03125 | 4 | #EASY
#Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
#An input string is valid if:
#Open brackets must be closed by the same type of brackets.
#Open brackets must be closed in the correct order.
#
#Example 1:
#Input: s = "()"
#Output: true
#
#E... |
e263df01619fa814aae414f73e03e96816c7504d | Kcpf/DesignSoftware | /Aluno_com_dúvidas_.py | 519 | 4.15625 | 4 | """
Faça um programa que pergunta ao aluno se ele tem dúvidas na disciplina. Se o aluno responder qualquer coisa diferente de "não", escreva "Pratique mais" e pergunte novamente se ele tem dúvidas. Continue perguntando até que o aluno responda que não tem dúvidas. Finalmente, escreva "Até a próxima".
Seu programa deve... |
9fe6caea169b99f59e6ce70d868cbe8c581b08d4 | Obj-V/Project-Euler | /Project_Euler_023/Project_Euler_23.py | 1,613 | 3.890625 | 4 | #Project_Euler_23.py
#Virata Yindeeyoungyeon
"""
A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.
A number n is called deficient if the sum o... |
6642f46ad80523da8087ac19a0b7701917ee9536 | wasifMohammed/test | /pangram.py | 539 | 3.59375 | 4 | Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> def main():
str0=raw_input("Enter string.. ")
i=0
fl=[]
for i in range(26):
fl.append(False)
for c in str0.lower():
if not c == " ":
... |
448c81dabcdde4799237f229655c15b851e22306 | RagaSenitent/ragachandars | /a.py | 80 | 3.984375 | 4 | a=int(input("Enter a number:"))
sum=0
while(a>0):
sum=sum+a
a=a-1
print (sum)
|
7cac511606c1ee285c09abade3bccb0c6b8b7e57 | vishnuvardhan2005/PythonSamples | /Samples/HardWayExes/ex5.py | 517 | 3.609375 | 4 | name = "Vishnu Vardhan Reddy"
age = 32
height = 74
weight = 180
eyes = 'Blue'
teeth = 'white'
hair = 'brown'
print "Let's talk about %s" % name
print "He is %d inches tall" % height
print "He is %d heavy" % weight
print "Actually that's not too heavy"
print "He has got %s eyes and %s hair" % (eyes, hair)
print "His te... |
79fa45f6cfbc4ee01acc8fee6ee3c241e485cff6 | andelgado53/interviewProblems | /rotate_matrix.py | 1,216 | 3.78125 | 4 | # Problem from Cracking the Coding Interview.
# Chapter 1 Strings and Arrays.
# Given an image represented by an NxN matrix, Write a method to rotate the image by 90 degress.
# Do it in place
import pprint
data = [
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15,... |
537f298da91e383462bfdef4a62b46350af35431 | StBogdan/PythonWork | /Leetcode/987.py | 1,538 | 4.0625 | 4 | from collections import defaultdict, deque
from typing import List
# Name: Vertical Order Traversal of a Binary Tree
# Link: https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/
# Method: Traverse graph, store seen in a per-column dict, build output from dict
# Time: O(n * log(n))
# Space: O(n)
# D... |
957333cfdb9e24e97bc134d329a4214143324eab | dannymulligan/Project_Euler.net | /Prob_132/prob_132a.py | 3,819 | 3.796875 | 4 | #!/usr/bin/python
# coding=utf-8
#
# Project Euler.net Problem 132
#
# Determining the first forty prime factors of a very large repunit.
#
# A number consisting entirely of ones is called a repunit. We shall
# define R(k) to be a repunit of length k.
#
# For example, R(10) = 1111111111 = 11 x 41 x 271 x 9091, and the ... |
412550a5985b669219a9b01aa5e23fa743823392 | mithrandil444/Make1.2.3 | /wachtwoord.py | 4,088 | 4.375 | 4 | #!/usr/bin/env python
"""
This is a python script that generates a random password or a password of your choice
bron : https://pynative.com/python-generate-random-string/
"""
# IMPORTS
import random, string
__author__ = "Sven De Visscher"
__email__ = "sven.devisscher@student.kdg.be"
__status__ = "Finished"
# Variab... |
78f15b41936f23feda24840fe514fc405a018f0d | Panda3D-public-projects-archive/pandacamp | /Demos and Tests/Tests/18-vars.py | 514 | 3.875 | 4 | from Panda import *
# This is how you make a button on the screen
b = button("Hit me", P2(-0.8, .6))
# This is a value that you can access from reaction code
v = var(0) # 0 is the initial value
# This is a reaction that will add 1 to v
def bump(w, x):
v.add(1)
# When the button clicks, bump up v
react(b, bump)
# S... |
4c3938543f625425f0d6ac81885c3276a34a011b | Dhanya1234/python-assignment-3 | /assignment 3_quadratic equation.py | 405 | 4.0625 | 4 | from math import sqare
print("quadratic function :(a*x^2)+b*x+c")
a=float(input("a:"))
a=float(input("a:"))
b=float(input("b:"))
c=float(input("c:"))
r=b^2-4*a*c
if(r>0):
num_roots=2
x1=(((-b)+sqrt(r))/(2*a))
x2=(((-b)-sqrt(r))/(2*a))
print("there are 2 roots:"%fand%f %(x1,x2)
elif(r==0):
num_roots=1
x=(-b)/2*a... |
74ca40157c352e04ee0e90de2859112091e49ef9 | morita657/Algorithms | /Leetcode_solutions/Increasing Triplet Subsequence.py | 743 | 3.5 | 4 | class Solution(object):
def increasingTriplet(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
small = float('inf')
big = float('inf')
for n in nums:
if n <= small:
small = n
elif n <= big:
big = n... |
72104950bcc21244dc7fa23884845fb6bdc9fbca | FatbardhKadriu/Permutations-of-a-given-letters-list-with-Python | /permutations.py | 735 | 3.53125 | 4 | from itertools import permutations
from nltk.corpus import wordnet
from nltk.corpus import words
list_of_letters = []
number_of_letters = int(input('How many letters are in total: '))
for i in range(0, number_of_letters):
list_of_letters.append(input('Write char' + str(i+1) + str(": ")))
no_of_perm = int(input('... |
01cb6ebb97347d44a4f57db379c23e53529c11b8 | anbansal/Python-for-Everybody | /Ch4-Functions/exerciseEndOfChp1.py | 453 | 3.890625 | 4 | def computepay(hours,rate):
multiplier = 1.0
if hours > 40:
multiplier = 1.5
pay = multiplier * hours * rate
print("Pay: ", round(pay, 2), "$")
promt = "Please enter hours: "
try:
hours = float(input(promt))
except:
print("Please enter hours in numeric!")
quit(0)
promt = "Please ent... |
216ce81ab9282b393cb370d0166d6501bb8214ea | rizkyprilian/purwadhika-datascience-0804 | /Module1-PythonProgramming/map.py | 2,046 | 3.828125 | 4 | # def times2(num) :
# return num * 2
# listNum = [ 1, 2, 3, 4, 5]
# listNum = list(map(times2, listNum)) #diconvert jadi list dari map object
# print(listNum)
# listNum = [ 1, 2, 3, 4, 5]
# listNum = list(map(lambda z: z * 2 if z <3 else z/2, listNum)) #lambda comprehension baby yeaaah!
# print(listNum)
# de... |
a575302082d07055b0eaa0acf39fe8820eb05637 | DeepAQ/Python-Statistics | /Exercise3/10.py | 920 | 3.84375 | 4 | # -*- coding:utf-8 -*-
'''
log api example: log('output is: ' + str(output))
'''
import math
from scipy.stats import t
from log_api import log
class Solution():
def solve(self):
d = t.ppf(0.05, 24)
sv = (7.73 - 8) / 0.77 * math.sqrt(25)
con = sv > d
return [24, round(sv, 2), con]
... |
a45c88aa1fcec8a382b9844424f0048886d7fd3f | EmanuelYano/python3 | /Aula 7/aula_7_ex4.py | 121 | 3.53125 | 4 | #!/usr/bin/env python3
#-*- coding:utf-8 -*-
n = int(input())
i = 0
while i < n:
r = 2 ** i
print(r)
i += 1
exit(0) |
a7d0bcba7013147a3866fe02bb95c7808d1e2203 | RadovanTomik/Sudoku_solver | /solver.py | 2,352 | 4.03125 | 4 | example_board = [
[7, 8, 0, 4, 0, 0, 1, 2, 0],
[6, 0, 0, 0, 7, 5, 0, 0, 9],
[0, 0, 0, 6, 0, 1, 0, 7, 8],
[0, 0, 7, 0, 4, 0, 2, 6, 0],
[0, 0, 1, 0, 5, 0, 9, 3, 0],
[9, 0, 4, 0, 6, 0, 0, 0, 5],
[0, 7, 0, 3, 0, 0, 0, 1, 2],
[1, 2, 0, 0, 0, 7, 4, 0, 0],
[0, 4, 9, 2, 0, 6, 0, 0, 7]
]
def... |
bf9488fa06ffe73102f26d68576940b8a205bbff | Damdesb/python_fundamental | /02_basic_datatypes/2_strings/02_09_vowel.py | 543 | 4.25 | 4 | '''
Write a script that prints the total number of vowels that are used in a user-inputted string.
CHALLENGE: Can you change the script so that it counts the occurrence of each individual vowel
in the string and print a count for each of them?
'''
#get a sentence from user (sentence)
sentence = set(input(... |
c150e4835e485fc8f0e1d319902927d51c700d38 | emilycheera/coding-challenges | /selection_sort.py | 324 | 3.75 | 4 | def selection_sort(nums):
for i in range(len(nums)):
min_index = i
for j in range(i + 1, len(nums)):
if nums[j] < nums[min_index]:
min_index = j
nums[i], nums[min_index] = nums[min_index], nums[i]
return nums
print(selection_sort([44, 5, 3, 7, 5, 6, 3, 4... |
3cb80c92ca041466cf54a1f755b5dcf1e6afc746 | tomerguttman/leet-sol | /py-sol/ValidParentheses.py | 549 | 4.03125 | 4 | class Solution:
def isValid(self, input_string):
parentheses_stack = []
my_dict = {'(':')','[':']','{':'}'}
for parentheses in input_string:
if parentheses in my_dict:
parentheses_stack.append(my_dict[parentheses])
else:
#closing bracke... |
0148f74e50eba683faa64af6133ad38c7011ed28 | WISDEM/LandBOSSE | /landbosse/tests/model/test_DevelopmentCost.py | 3,189 | 3.796875 | 4 | from unittest import TestCase
import pandas as pd
from landbosse.model import DevelopmentCost
class TestDevelopmentCost(TestCase):
def setUp(self):
"""
This setUp() method executes before each test. It creates an
instance attribute, self.instance, that refers to a DevelopmentCost
... |
774fffafe7a086b816012007a0a80d2fd6de4e9e | codingcerebrum/codewars-codes | /Kata/countConnectivityComponent.py | 2,464 | 4.09375 | 4 | # The following figure shows a cell grid with 6 cells (2 rows by 3 columns), each cell separated from the others by walls:
# +--+--+--+
# | | | |
# +--+--+--+
# | | | |
# +--+--+--+
# This grid has 6 connectivity components of size 1. We can describe the size and number of connectivity components by the
# list ... |
b096f33302afc860050b17b776b86a97d2992709 | aanantt/Python-DataStructure | /Queue.py | 506 | 3.859375 | 4 | class Queue:
def __init__(self):
self.llist = []
def push(self, key):
self.llist.insert(0, key)
def pop(self):
return self.llist.pop()
def isEmpty(self):
return self.llist[0]
def reverse(self):
self.llist = self.llist[::-1]
return self.llist
d... |
0eb81c2c14773de15d8310f313e522f399d4f38d | ankit98040/TKINTER-JIS | /tut6new.py | 831 | 3.609375 | 4 | from tkinter import *
def getvals():
print(f"The value of username is {uservalue.get()}")
print(f"The value of password is {passvalue.get()}")
root = Tk()
root.geometry("655x333")
f1 = Frame(root, borderwidth = 6, bg = "grey", relief = SUNKEN, padx = 90)
f1.pack(side = TOP, anchor = "nw", fill = ... |
dba45441dbfd6d7cd34211dc5f5d4eebbed87926 | tysonpond/lending-club-risk | /data_dictionary.py | 865 | 3.515625 | 4 | # Constructing a lookup for meaning of columns
import pandas as pd
df_desc = pd.read_excel("LCDataDictionary.xlsx", nrows = 151)
df_desc["LoanStatNew"] = df_desc["LoanStatNew"].apply(lambda x: x.rstrip()) # some cells have trailing whitespace
df_desc["LoanStatNew"] = df_desc["LoanStatNew"].replace({'verified_status_jo... |
e6388896b49da860a134eb4f2774c360b1ced322 | mivicms/c2py | /19.py | 1,843 | 3.875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*
# 题目:对10个数进行排序
# ___________________________________________________________________
# 程序分析:可以利用选择法,即从后9个比较过程中,选择一个最小的与第一个
# 元素交换,下次类推,即用第二个元素与后8个进行比较,并进行交换。
# 程序源代码:
# #define N 10
# main()
# {int i,j,min,tem,a[N];
# /*input data*/
# printf(“p... |
f0ef3429a55f926d811d53599d245bf1ffe1e6cb | N3UN3R/data_preparation | /ENetGetterNew.py | 1,888 | 3.6875 | 4 | import json
import csv
def get_meter_id_to_zipcode_dict(file):
""" function that reads in 'AssetListe.json and
returns a python dictionary with all meterIds matched
to zipcodes"""
with open(file, 'r') as json_data:
payload = json.load(json_data)
meter_ids_to_zipcode... |
91faf0114d1338e8c11479fb3e4e06c1db444ad4 | ubiswal/DataStructures | /tst/algos/test_graph_problems.py | 2,231 | 3.515625 | 4 | import unittest
from lib.algos.graph_problems import *
from lib.ds.bst import Bst
class TestSiblingTree(unittest.TestCase):
def setUp(self):
self.tree = BinaryTree(5)
self.tree.left = BinaryTree(10)
self.tree.right = BinaryTree(20)
self.tree.left.left = BinaryTree(30)
self... |
fc8ac5a4bd70babb89c80573e18a539f489737ff | valentinavera/python-course | /introduction/programa8.py | 168 | 3.875 | 4 | # ciclos
rango = range(5)
# for i in rango:
# print(i)
# fibonacci = [0, 1, 1, 2, 3, 5]
# for j in fibonacci:
# print(j)
a = 5
while a < 10:
print(a)
a += 1
|
5ed4ebf0f9b095222117525acf12b4226123a028 | jashidsany/Learning-Python | /Codecademy Lesson 5 Loops/LA5.10_Review.py | 220 | 3.75 | 4 | single_digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
squares = []
for digit in single_digits:
print(digit)
squares.append(digit**2)
print(squares)
cubes = [digit**3 for digit in single_digits]
print(cubes)
|
4a7cca8d21d44261e88f0e5d20a834203566e129 | ckloppers/PythonTraining | /exercises/day1/wordslast.py | 108 | 3.78125 | 4 | sentence = raw_input("Sentence: ")
sentenceList = sentence.split(' ')
print 'Last word: ', sentenceList[-1] |
8c41ee1352854c33b77cbd1045f013ad4616a6c2 | aj28293/dsp | /python/q5_datetime.py | 958 | 3.84375 | 4 | # Hint: use Google to find python function
####a)
from datetime import datetime
date_start = '01-02-2013'
date_stop = '07-28-2015'
def difference_in_days(date_start, date_stop):
date_format = "%m%d%Y"
date1 = datetime.strptime(date_start, date_format)
date2 = datetime.strptime(date_st... |
f770744f4b78addf3c1dc2a300d8b76712bf296f | paulkirow/Study | /shortest-disance.py | 3,610 | 3.53125 | 4 | import heapq
import sys
class Solution:
def shortestDistance(self, grid: [[int]]):
buildings = []
num_rows = len(grid)
num_cols = len(grid[0])
for row in range(len(grid)):
for col in range(len(grid[row])):
value = grid[row][col]
if value ... |
e700c5cda28b61ca20a3302efb203ad97f863521 | bangalcat/Algorithms | /algorithm-python/boj/boj-11758.py | 2,039 | 4.09375 | 4 | from math import hypot
# ccw 판단
class Vector:
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y
def __eq__(self, other):
return isinstance(other, Vector) and other.x == self.x and other.y == self.y
def __add__(self, other):
if isinstance(other, Vector):
... |
dbd782f5b7f5ac4d9e84036c89fd11c5a4cb2ebd | wpram45/PyProblems | /sirali_ekle.py | 1,241 | 3.609375 | 4 | class Node:
def __init__(self,veri=None,sonraki=None):
self.veri=veri
self.sonraki=sonraki
def __str__(self):
return str(self.veri)
def yazdir(root):
while(root!=None):
print(root)
root=root.sonraki
def sirali_ekle(r... |
c26c3af6c50710362c95ed0372e093713ab53b4e | thirdparty-core/pythonstest | /test01/list.py | 2,107 | 4.03125 | 4 | # -*- coding:utf-8 -*-
# 列表的定义
# 有序集合
# 可以存放不同的类型的数据
# 放在中括号中,有逗号分隔
cars = ['c++', 'java', 'android', 'ios']
print(type(cars))
print(cars)
numbers = list(range(10))
numbers1 = list(range(0, 10, 2))
print(numbers)
print(numbers1)
# 对数字列表的统计计算
print(min(numbers))
print(max(numbers))
print(sum(numbers))
# 列表推导
vec = [... |
14cf463c571d7e6470a8d863eb59064ce54eefa1 | NicolaiFinstadLarsen/thenewboston_Python_Programming_Tutorial | /e14_Gender.py | 221 | 4.0625 | 4 | def get_gender(sex="Unknown"):
if sex is "M":
sex = "Male"
elif sex is "F":
sex = "Female"
return sex
print(get_gender(input("What gender are you? Please type M, F or leave it blank: ")))
|
92ce41b7e48f2304d2a3c387401fec4ac44ca737 | Shridhar2025/Calculator_tkinter | /Calculator_tkinter.py | 2,245 | 3.984375 | 4 | # import tkinter as tk
# from tkinter import messagebox
# mainWindow = tk.Tk()
# mainWindow.title("Calculator")
#
# heading_label = tk.Label(mainWindow,text = "First Number")
# heading_label.pack()
#
# name_field = tk.Entry(mainWindow)
# name_field.pack()
#
# Subtitle_label = tk.Label(mainWindow,text = "Sec... |
2ecb4e8d2f30a4c6a99c512676ef59eba2ee3148 | CoachEd/advent-of-code | /2021/day19/rotations.py | 1,350 | 3.5625 | 4 | from numpy import rot90, array
from copy import copy, deepcopy
def rotations24(polycube):
"""List all 24 rotations of the given 3d array"""
def rotations4(polycube, axes):
"""List the four rotations of the given 3d array in the plane spanned by the given axes."""
for i in range(4):
... |
7e1b41618a107343ca5be075b9576bf41c86f66d | MattGeske/ThunderstoneGameBuilder | /util/card_inserter.py | 4,986 | 3.5 | 4 | import csv
import sqlite3
def main():
#for my own convenience/sanity - imports card data from a csv and adds it to the database
#to prevent typos, it does not insert any new values in CardAttribute, CardClass, Requirement, or ThunderstoneSet
csv_path = 'card_data.csv'
db_path = '../assets/databases/ca... |
2762a3e6bef8eb5cf3b97761a8ba3d66f2950206 | Elena-May/MIT-Problem-Sets | /ps1/ProblemSet1c.py | 1,357 | 3.984375 | 4 | #not currently working
# runs infinitely
semi_annual_raise = 0.07
invest_return = 0.04
down_payment = 0.25
house_cost = 1000000
currentsalary = int(input('Enter the starting salary: '))
monthlysalary = currentsalary/12
#Find the amount you need to save
total_to_save = dream_house * down_payment
print ('Total to save... |
a61e4545cc7c1f707fd6fee373883a875ff6a728 | komaly/DailyProgrammer | /BankersAlgorithm/BankersAlgorithm.py | 2,453 | 4.375 | 4 | '''
Implementation of Banker's Algorithm.
Answer to Reddits Daily Programmer Challenge #349
'''
# Uses Bankers Algorithm to determine the order that the
# processes should be selected based on the need dictionary
# (indicating the remaining resources needed for each process),
# allocation dictionary (containing the... |
c711256e2ac783100f6b8be5d4563054a7e605f2 | Jane11111/Leetcode2021 | /234.py | 666 | 3.625 | 4 | # -*- coding: utf-8 -*-
# @Time : 2021-03-05 10:56
# @Author : zxl
# @FileName: 234.py
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution(object):
def isPalindrome(self, head):
"""
... |
a59a5c2d66b3f45b8f162f80b9c42017d96bdbff | hyewonm/py_lab2 | /my_pkg/module1.py | 198 | 3.765625 | 4 | #!/usr/bin/python3
def result1():
binN = input('input binary number : ')
num = int(binN, 2)
print('OCT> ', format(num,'o'))
print('DEX> ', num)
print('HEX> ', format(num, 'X'))
|
49a37017e9435a3eb0db7a386be77f895ca619fa | YoussefAlTabei/GUI-python-simple-code- | /GUI.py | 2,630 | 3.828125 | 4 | from tkinter import *
Y=Tk()
Y.geometry('500x500+650-100')
Y.title("3atf")
Y.minsize(500,500)
Y.maxsize(500,500)
X=Tk()
X.title("first window")
X.geometry('500x500+150-100')
Y.resizable(False,False)
X.lift()
#X.lower()
X.state("normal") #X.iconify() zy X.state("iconic"))
if X.state()=="normal":
X.st... |
ca7cf47111090039f05ae855cc4a20a1c087a477 | rdguerrerom/pysurf | /pysurf/utils/design.py | 544 | 3.625 | 4 | from itertools import cycle
from collections import namedtuple
RGBColor = namedtuple("RGBColor", ["red", "green", "blue"])
#
BLACK = RGBColor(0,0,0)
BLUE = RGBColor(63/255, 81/255, 181/255)
RED = RGBColor(253/255, 86/255, 33/255) ... |
c6e02957de761bc2c505c2b5c5a04b70bdc032a5 | riyooraj/atchuthan | /at7.py | 44 | 3.5625 | 4 | x="Hello \n"
y=int(input())
i=x*y
print (i)
|
1422d7649ef0b22c1b2786769a5ece33cba11f6b | StefanTsvetanov/python_basics | /Hollyday.py | 706 | 3.875 | 4 | money_needed = float(input())
start_money = float(input())
total_days_counter = 0
spend_days_counter = 0
while True:
action = input()
money = float(input())
total_days_counter +=1
if action == "spend":
start_money -= money
if start_money <= 0:
start_money = 0... |
5300f794b61a4000ae20b49d5a9145513493929f | Sandy4321/twitter-sentiment-analysis-19 | /experiments/classifiers/classifiers.py | 4,449 | 3.59375 | 4 | def tweet_formatting(directory):
##formats tweet for classification
##directory to the txt file containing a list of tweet texts (just a raw list with RT's removed)
import nltk
directory="D:\SEECS\Research & Projects\FYP\Codes\classifiers/jordansample_raw.txt"
fp=open(directory,"r")
twee... |
dbdeec349e678aeef13f00698e8eecdf422e1a0f | FelipeGabrielAmado/Uri-Problems | /Iniciantes/1132.py | 210 | 3.5625 | 4 | soma=0
a=int(input())
b=int(input())
if (b>a):
for n in range(a,(b+1)):
if (n%13!=0):
soma+=n
if (a>b):
for n in range(b,(a+1)):
if (n%13!=0):
soma+=n
print(soma) |
d9a6619165b5ab6e74b58a25c3fb33f2161ea202 | willy900529/E94086181_lab1 | /RemoveOutliers.py | 1,088 | 4.40625 | 4 | remove_number=int(input("Enter the number of smallest and largest values to remove:"))
list1=[] #construct a list
number_input_check=1 #if number_input_check=1,code keep run. if number_input_check=0,code stop
while(number_input_check):
number_input=input("Enter a value (q or Q to quit):")
if(number_input==... |
d1588f2f8e4d17aa3656412383eb181800033b73 | NasimNozarnejad/Data-Science-Machine-Learning | /Set2/Q3.py | 860 | 3.546875 | 4 | import sys
import re
n0=sys.argv[1]
n1=sys.argv[2]
n2=sys.argv[3]
A=open(n0, 'r')
data=A.read().upper()
data1=re.findall(r"[\w]+",data)
print(data1)
WORD1=[]
WORD2=[]
LWORD1=len(n1)
LWORD2=len(n2)
def main(n0,n1,n2):
num=0
for word in data1:
num+=1
L=len(word)
if word.sta... |
e693245b9fe91cad22791e590229fe907b007586 | archananfs/Python_projects | /dictionary_gui.py | 1,277 | 3.8125 | 4 | from tkinter import *
from PyDictionary import PyDictionary
dictionary = PyDictionary()
def dict_translate():
word = e1_value.get()
list1.delete(0, END)
meaning = dictionary.meaning(word)
for key, value in meaning.items():
if type(value) == list:
for line in value:
... |
469634bf66c6fb700ecf733d2379264c3bdb5c9e | BrianSipple/Python-Algorithms | /Data_Structures/binary_heap.py | 3,298 | 4.15625 | 4 | class BinaryHeap(object):
def __init__(self):
self.items = [0] # Initialize with unused zero to enable integer division in later methods
self.size = 0
def insert(self, item):
self.items.append(item)
self.size += 1
self.percolateUp(self.size) # Begin percolating at t... |
8e9194dca33dd0bec33728d0142b62a48eb95968 | JeckyOH/LeetCode | /88_Merge_Sorted_Array/Solution.py | 763 | 3.890625 | 4 | class Solution(object):
def merge(self, nums1, m, nums2, n):
"""
:type nums1: List[int]
:type m: int
:type nums2: List[int]
:type n: int
:rtype: void Do not return anything, modify nums1 in-place instead.
"""
k = m + n -1 # k is next filled position in... |
2928f3010e6518d472191c2887ea2e9efab1257e | abaldeg/EjerciciosPython | /Ejemplo de conversion de entero a lista.py | 386 | 4.53125 | 5 | # Python3 code to demonstrate
# conversion of number to list of integers
# using list comprehension
# initializing number
num = 2019
# printing number
print ("The original number is " + str(num))
# using list comprehension
# to convert number to list of integers
res = [int(x) for x in str(num)]
... |
7d9950725c4920723109378002da9fe13cbfe9cc | Haydz/Practice | /automate_boring_python/regexs/Character_classes.py | 462 | 3.59375 | 4 | import re
"""
Regex can use other classes than \d
\w any letter, numeric digit, or underscore chaacter
\s any space tab or new line character "space characters"
"""
xmasRegex = re.compile(r'\d+\s\w+')
mo1 = xmasRegex.findall('12 dummers, 11 pipers, 10 lords, 9 ladies')
print mo1
for x in mo1:
print x
"""
Make... |
eb5bef529bc897cfa6a8ec490a9044ccb2efc6fa | cuimin07/cm_offer | /16.数值的整数次方.py | 734 | 4 | 4 | '''
实现函数double Power(double base, int exponent),求base的exponent次方。不得使用库函数,同时不需要考虑大数问题。
示例 1:
输入: 2.00000, 10
输出: 1024.00000
示例 2:
输入: 2.10000, 3
输出: 9.26100
示例 3:
输入: 2.00000, -2
输出: 0.25000
解释: 2-2 = 1/22 = 1/4 = 0.25
说明:
-100.0 < x < 100.0
n 是 32 位有符号整数,其数值范围是 [−231, 231 − 1] 。
'''
#答:
class Solution:
def myP... |
36f379f4a30c014a9020422889bf30d2fab024a3 | AmineNeifer/holbertonschool-higher_level_programming | /0x03-python-data_structures/9-max_integer.py | 214 | 3.703125 | 4 | #!/usr/bin/python3
def max_integer(my_list=[]):
if len(my_list) == 0:
return None
maxi = my_list[0]
for element in my_list:
if maxi < element:
maxi = element
return maxi
|
4db35f1aff595b9c676ae91f20047f8f88ecd5cc | Mnrsrc/Python | /14-71_DeleteOperation.py | 397 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 9 15:42:33 2019
@author: Munire
"""
import sqlite3
connection=sqlite3.connect("chinook.db")
cursor= connection.execute("""Delete from genres where Name like '%&%' """)
connection.commit()
cursor2=connection.execute("""select Name from genres """)
print("***G... |
077f639687ae2a13eb238f30a3d007acd519c64f | KishorP6/PySample | /The Cargo arrangement.py | 1,216 | 3.515625 | 4 | ##The Gocargo carriers have a pattern of arranging the cargos in the container. Given the length of edge of the container, print the cargo arrangement pattern in the container as shown in the sample IO. The base of the container is always a square.
##
##Note: The Cargo are of unit length.
##
##Input format :
## ... |
22b50722a6e726a6dc88d61bd5010c898d1f0801 | JulianNymark/stone-of-the-hearth | /soth/player.py | 2,410 | 3.546875 | 4 | from .card import *
from .utility import *
from .textstrings import *
class Player:
"""A player in the game"""
mana = 1
mana_used = 0
overload_now = 0
overload_next = 0
health = 30
armour = 0
damage = 0
attack = 0
def __init__(self, ct, npc=False):
self.classtype = ct
... |
430f8494f4dceed4ef028b15f232cae5342ed623 | karolkuba/python | /ćwiecznia/cw53.py | 926 | 3.796875 | 4 | # kwadraty liczb od 3 do 9
for i in range(3,10):
print("%i ^ 2 = %i" % (i, i**2))
# wygeneruj tablice z przedzialami losowymi od 0 do 10
import random
randomList = []
for i in range(10):
randomList.append(random.randint(1,10))
print(randomList)
#wyszukaj elementu z listy i zwróć jego indeks
#jeżeli ele... |
ecb3c2aa29cc645e011d5e599a0ed24eb1f983b2 | PraneshASP/LeetCode-Solutions-2 | /69 - Sqrt(x).py | 817 | 3.9375 | 4 | # Solution 1: Brute force
# Runtime: O(sqrt(n))
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
sqrt = 1
while sqrt*sqrt <= x:
sqrt += 1
return sqrt-1
# Solution 2: Use Newton's iterative method to repeatively "guess"... |
85266e788d44082e223cd9c335a5f0f2f1d79de4 | dabrygo/bmc | /src/Sample.py | 1,517 | 3.9375 | 4 | '''A collection of words for a user to guess'''
import abc
import re
import Tokens
import Word
class Sample(abc.ABC):
@abc.abstractmethod
def text(self):
pass
@abc.abstractmethod
def guess(self, guess):
pass
@abc.abstractmethod
def hint(self):
pass
@abc.abstractmethod
def shift(self):... |
99699995249aa20d64042a3e86407da6fd6883ec | JuDa-hku/ACM | /leetCode/95UniqueBinarySearchTreeII.py | 1,530 | 3.609375 | 4 | # Definition for a binary tree node.
import copy
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# @param {integer} n
# @return {TreeNode[]}
def generateTrees(self, n):
nums = range(1,n+1,1)
res = self.ge... |
4aef6c53756ff26927c98a486de3818608bc4fe0 | yash-k9/Heart-Disease-Prediction | /model.py | 5,089 | 3.703125 | 4 | #!/usr/bin/env python
# coding: utf-8
# //These are the following attributes present in the dataset
# //dataset contains the information of the previous patient's health records.
#
# age: The person's age in years
#
# sex: The person's sex (1 = male, 0 = female)
#
# cp: The chest pain experienced (Value 0: typical ... |
be7637d7ef6783ab1533e0dab430a94043dd6f67 | kses1010/algorithm | /programmers/level2/carpet.py | 350 | 3.59375 | 4 | # 카펫
def solution(brown, yellow):
x = 3
while x <= brown:
y = (yellow / (x - 2)) + 2
if y == int(y):
y = int(y)
if (x + y - 2) * 2 == brown:
return [max(x, y), min(x, y)]
x += 1
print(solution(10, 2))
print(solution(14, 4))
print(solution(8, 1)... |
6111c8382c179fd7eb060372b6a0e8624cdb16e1 | Marou-Hub/myfirstproject | /learnPython/text3.py | 307 | 3.75 | 4 |
# code
wallet = 5000
computer_price = 50000
# le prix de l'ordinateur est inferieur a 1000€
if computer_price <= wallet or computer_price > 1000:
print("L'achat est possible")
wallet -= computer_price
else:
print("L'achat est impossible, vous n'avez que {}€".format(wallet))
print(wallet) |
74eed9092b6f78115430fe3b0c777f19ec9bd7e0 | shinobe179/atcoder | /kakomon_seisen/ruiji/abc082_b/ans.py | 168 | 3.5 | 4 | #!/home/shino/.pyenv/shims/python
s = sorted(input().encode("utf-8"))
t = sorted(input().encode("utf-8"))
print(s, t)
if s < t:
print('Yes')
exit()
print('No')
|
987233e66925b03f18460e8155d7c7a6443f75bb | heroca/heroca | /ejercicio89.py | 529 | 3.765625 | 4 | sueldos=[]
for x in range(5):
valor=int(input("Ingrese sueldo:"))
sueldos.append(valor)
print("Lista sin ordenar")
print(sueldos)
for k in range(4):
for x in range(4-k):
if sueldos[x]>sueldos[x+1]:
aux=sueldos[x]
sueldos[x]=sueldos[x+1]
sueldos[x+1]=aux
"""
for ... |
2a6b4d1de001ed24cb3e4e7d9866aec321c3f2e1 | jingriver/testPython | /Projects/mandelbrot_project/solution_5/mandelbrot/mandelbrot/model/core_numpy.py | 1,497 | 3.8125 | 4 | """ Core math functions to compute escape times for the Mandelbrot set. """
import numpy
def mandelbrot_escape(x, y, n=100):
"""Mandelbrot set escape time algorithm for a given c = x + i*y coordinate.
Return the number of iterations necessary to escape abouve a fixed threshold
(4.0) by repeatedly applyin... |
05ad72db301f3c50cddf5b3c0a8e2dcef49f68a8 | jlhuerlimann/Assignment_05 | /CDInventory_for_review.py | 3,398 | 3.6875 | 4 | #-----------------------------------------------------------------------------#
# Title: CDInventory.py
# Desc: Script for Assignment 05, managing a CD inventory.
# Change Log: (Who, When, What)
# Jurg Huerlimann 2020-Aug-07, Created File from CDInventory_Starter.py script.
# Jurg Huerlimann 2020-Aug-08 Changed fu... |
9c519feaa0d3347310bef113c633f21b5ace8e4e | mmskm/ForFuckSake | /employe.py | 1,546 | 4 | 4 | name = []
jobtile = []
age = []
salli = []
while 1 :
print('--------------------------------------------------------')
print('| 1 - Add a new employe \n| 2 - delete employe \n| 3 - searh employe \n| 4 - exit ')
print('--------------------------------------------------------')
something = int(... |
e19eff1acba1c9b61383b49099dffe0b0e16a42a | meliassilva/pythonprograms | /Lab05_Mario.py | 4,563 | 3.71875 | 4 | # class Node:
# def __init__(self, value, left=None, right=None):
# self.left = left
# self.right = right
# self.value = value
# self.count = 1
# def add(self, value):
# if self.value == value:
# self.count += 1
# elif value < self.value:
# if self.left is None:
# se... |
de750071a423486605fefbe569ee2c429e9ef6c8 | Shahrein/Python-Training-Projects | /larger_number2.py | 227 | 4.15625 | 4 |
number1 = int(input("Enter the 1st number: "))
number2 = int(input("Enter the 2nd number: "))
if number1 >= number2: larger_number = number1
else: larger_number = number2
print("The larger number is: ", larger_number) |
9fc1274e4c53ade205ccd889533374952413b0f2 | ps9610/python-web-scrapper | /02-01/function.py | 805 | 3.609375 | 4 | #함수 만드는 방법 (파이썬은 함수를 define(정의)한다고 한다.)
#1. function의 이름을 쓴다. | say_hello
#2. function옆에 소괄호 | say_hello()
#3. ()를 채우거나 비워두면 끝
#4. 함수를 정의할 땐 함수이름 앞에 def(함수를 정의한다는 뜻)
#5. 함수 옆에 ⭐콜론⭐을 쓰고 body에 내용 입력
def say_hello():
print("hello")
# 파이썬은 자바스크립트 함수 function blabla(){}처럼 괄호로 묶지 않고
#... |
4db430dfc85cfd78dcfa3530d2090e919ee7d475 | me6edi/Python_Practice | /F.Anisul Islam/5.program_User_input.py | 309 | 4.125 | 4 | #Getting User Input
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
result = num1 + num2
print("The sum is ", result)
result = num1 - num2
print("The sum is ", result)
result = num1 * num2
print("The sum is ", result)
result = num1 ** num2
print("The sum is ", result) |
1b62bf9ecb032caad9aa4b3f21477ede52ef0788 | LaminarIR/framework | /helper/factors.py | 616 | 3.859375 | 4 | from fractions import gcd
def lcm(a,b):
"""Compute least common multiplier of two numbers"""
return a * b / gcd(a,b)
def listgcd(l):
"""Compute the gcd of a list of numbers"""
if len(l) == 0:
return 0
elif len(l) == 1:
return l[0]
elif len(l) == 2:
return gcd(l[0],l[1])... |
2520f77f618ec7a78bf38533c6d2c281d5e86170 | HelloYeew/helloyeew-lab-computer-programming-i | /Inclass Program/6310545566_wk4ic_ex7.py | 602 | 4.0625 | 4 | def print_list(list):
for x in list:
print(x)
def read_list(n):
i = 1
listoutput = []
while i < n + 1:
value = float(input(f"Enter value{i}: "))
listoutput.append(value)
i += 1
return listoutput
def compute_area_list(list1, list2):
area_list = []
n = len(l... |
be3b06e22d12ef6267c1f41d720a0a5d5ce09917 | ken1286/Sorting | /src/iterative_sorting/iterative_sorting.py | 2,307 | 4.09375 | 4 | # TO-DO: Complete the selection_sort() function below
def selection_sort(arr):
# loop through n-1 elements
for i in range(0, len(arr) - 1):
cur_index = i
smallest_index = cur_index
# TO-DO: find next smallest element
# (hint, can do in 3 loc)
for n in range(cur_index+1, l... |
8a2f06e6edfa5a9a9f6b00cfbe0fd5d48e6eafdd | VIKULBHA/Devopsbc | /Python/First project/Exercises/Functions.py | 347 | 4 | 4 | def my_function():
print('Hello from my function')
# What is the syntax for function
# def printme( str ):
# "This prints a passed string into this function"
# print(str)
# return
#Homework
# Do your own search on how "while" works;
# Create a simple app to convert temperatures;
# Create a simple app that... |
4ad775d2883c0cee32a697c167abf440ab91ebb1 | YJL33/LeetCode | /current_session/python/809.py | 2,324 | 4.03125 | 4 | """
809. Expressive Words
Sometimes people repeat letters to represent extra feeling,
such as "hello" -> "heeellooo", "hi" -> "hiiii".
In these strings like "heeellooo",
we have groups of adjacent letters that are all the same: "h", "eee", "ll", "ooo".
For some given string S, a query word is stretchy -
if it can ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.