blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
230b1f483b617e08823bdba20dbbf0272be5e8a7 | esturniolo/iades2do | /paisan/2doCuatrimestre/Ej08-determinarGrupoEtareoEdad.py | 328 | 4.0625 | 4 | edad = int(input("Ingrese la edad del jugador: "))
if (edad <= 12):
print("El jugador es categoria Menor")
elif (edad > 13 and edad <= 18):
print("El jugador es categoria Cadete")
elif (edad > 18 and edad <= 26):
print("El jugador es categoria Juvenil")
elif (edad > 26):
print("El jugador es categoria ... |
0f9e02966fd49346f3fcb8fe4ba68f6c3296b272 | weekmo/master_python | /src/matrix2.py | 1,298 | 3.796875 | 4 |
def matrix_get_submatrix(m,i,j):
'''
>>> matrix_get_submatrix([[1,2,3,4],[5,6,7,8],[2,6,4,8],[3,1,1,2]],0,3)
[[5, 6, 7], [2, 6, 4], [3, 1, 1]]
'''
d=len(m)
assert d>2
ks=[]
for x in range(d):
sub_matrix=[]
for y in range(d):
if x !=i and y!=j:
... |
6d074668d3bfe4e71240b545ccd18e658200484b | MedAmine-SUDO/30daysofcode | /day25.py | 515 | 4.03125 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
#!/bin/python3
import math
def is_prime(n):
if n <= 1:
return "Not prime"
max_div = math.floor(math.sqrt(n))
for i in range(2, 1 + max_div):
if n % i == 0:
return "Not prime"
return "Prime"
if __name__ ... |
f0183d69b60938418e9dded92f44fda3e822d1c8 | Kuehar/LeetCode | /Search Insert Position.py | 602 | 3.890625 | 4 | class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
left,right = 0,len(nums)-1
mid = 0
while right >= left:
mid = (left+right)//2
if nums[mid] == target:
return mid
if nums[mid] > target:
right = mid... |
5b2bf6685ec246bc8ed40068aa4b69ddc0a7044f | simonaDemo/python | /python_palindrome.py | 269 | 4.375 | 4 | word = input ("Please, enter a word: ")
word = str(word)
rvs = word[::-1] #from the beginning to the end of a word go backwards
if word == rvs:
print ("This word is a palindrome")
else:
print ("This word is not a palindrome")
|
b9681d0d1df29d15f3786e04846e426dc23287a1 | testautomation8/Learn_Python | /Python Exercises/Exercise_9.py | 888 | 4.40625 | 4 | """Generate a random number between 1 and 9 (including 1 and 9).
Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right
Extras:
Keep the game going until the user types “exit”
Keep track of how many guesses the user has taken, and when the game ends, print this out"""... |
23a1fcabced8677153cfe7b957d3abfbf542a1b0 | andres823/Ejercicios-spydr-20211 | /Ejercicio_129_18_03_2021_1_F_P.py | 358 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Mar 19 01:26:51 2021
@author: Andres Giron
"""
def multiplicar(lista,va):
for x in range(len(lista)):
multi=lista[x]*va
print(multi)
# bloque principal
lista=[3, 7, 8, 10, 2]
print("Lista original:",lista)
print("Lista multiplicando cad... |
fd0804916d888393f863820b637e69c63503657a | lipikumari/python_learning | /math.py | 604 | 3.859375 | 4 | #Python math
#Built-in math function
a=min(5,7,9)
b=max(5,7,9)
print(a)
print(b)
#abs() function return absolute value
a=abs(-49.66)
print(a)
#pow(a,b) function returns x to the power of y
a=pow(7,8)
print(a)
#math.sqrt() method returns the square root of a number
import math
a=int(math.sqrt(225))
print(... |
b2cca85663c814e36962a52613953b1bcc7646bd | arivolispark/datastructuresandalgorithms | /leetcode/leetcode_question_bank/problems/20_valid_parentheses/valid_parentheses.py | 2,315 | 3.9375 | 4 | """
Problem #: 20
Title: Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']',
determine if the input string is valid.
An input string is valid if:
1) Open brackets must be closed by the same type of brackets.
2) Open brackets must be closed in the correct order.
Note that... |
88b848a42fa96cfd9db61375963aaede558df4df | golfnut1400/kalacademy | /Hwk1_1.3 Dispaly a pattern FUN.py | 1,360 | 4.0625 | 4 | # Introduction to Programming
# Homework 1
# Created by: Stan Corpuz
# Jan 16, 2018
#1.13 Display a Pattern - FUN
'''
I needed help on this. After an exhaustive search how I would join each characters, I reached out to the Community
in StackOverflow
See https://stackoverflow.com/questions/48276660/print-pattern-fun... |
01fe4e0679f132781193f522614a069ebcacf21b | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_116/433.py | 1,572 | 3.546875 | 4 | # -*- coding: utf-8 -*-
def who_win(board):
for player in ['X', 'O']:
for i in xrange(0, 4):
line = board[i]
line_processed = [c for c in line if c == player or c == 'T']
if len(line_processed) == 4:
return player
for i in xrange(0, 4):
... |
337a204762cf53674e10225b86750a0fc17ce62b | anieshchawla/algorithms | /checksum.py | 2,832 | 3.6875 | 4 | '''This is the file to calculating the ip header checksum it assumes that 2 bytes checksum value
is (0,0) before it calculates the checksum and then outputs the resultant ip header'''
class csum_ip():
def __init__(self,header_list):
self.header_list = header_list
def calc_checksum(self,header_hex):
... |
c9c696e55a500b38ab082f7ec1d339e01eb4370c | asmagulzar/Python | /Assignment/SubstringInString.py | 132 | 4.15625 | 4 | str = input("Enter String:")
substr = input("Enter SubString:")
if (str.find(substr) == -1):
print("NO")
else:
print("YES") |
97064c6a556e315f7e747a54df9318ddd40d5469 | icerovski/Python_Fundamentals | /Unit_04/Exercise_Dicts_05.py | 438 | 3.8125 | 4 | # 05. Mixed Phones
phone_book = {}
while True:
line = input()
if line == "Over":
break
else:
new_line = line.split(' : ')
if new_line[0].isdigit():
name = new_line[1]
phone = new_line[0]
else:
name = new_line[0]
phone = new_li... |
7b3a459b85b3fccc72d2b3f231dada2e3219ab6a | jsimkoff/DataStructures | /Module6/set_range_sum/set_range_sum.py | 9,687 | 3.59375 | 4 | # python3
from sys import stdin
import sys, threading
sys.setrecursionlimit(10**7) # max depth of recursion
threading.stack_size(2**27) # new thread will get stack of such size
# Splay tree implementation
# Vertex of a splay tree
class Vertex:
def __init__(self, key, sum, left, right, parent):
(... |
bc6a1f6d2f89418119d719f1a16240d66c5ccf09 | PranavM98/Poker-Simulation | /evaluate.py | 9,981 | 3.65625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 28 15:08:03 2020
@author: pranavmanjunath
"""
from card import Card, card_from_num
from deck import Deck
# finds flush suit
def find_flush(hand):
d_suit={}
for card in hand.cards:
if card.suit in d_suit:
d_suit[card.sui... |
7325fab2c63ab51785b543a9da9f0943daf7897f | MadJangE00/Algoritom_py | /chap06/binary_insort.py | 650 | 3.921875 | 4 | # 이진 삽입 정렬 알고리즘 구현하기
from typing import MutableSequence
import bisect
def binary_insertion_sort(a: MutableSequence) -> None:
""" 이진 삽입 정렬(bisect.insort 사용) """
for i in range(1, len(a)):
bisect.insort(a, a.pop(i), 0, i)
if __name__ == "__main__":
print("이진 삽입 정렬을 수행합니다.")
num = int(input("원소 ... |
ffa4c7acc3e2c8ba324859e2c6d23bc24b28d985 | kju2/euler | /problem004.py | 702 | 4.1875 | 4 | """
A palindromic number reads the same both ways. The largest palindrome made from
the product of two 2-digit numbers is 9009 = 91 * 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
from euler import is_palindromic
def main():
"""
>>> main()
906609
"""
max_palin... |
575da21a38ff2e09c6ed5cf34348c92a1dfaa5e7 | HBinhCT/Q-project | /hackerrank/Algorithms/Matrix Layer Rotation/solution.py | 1,763 | 3.546875 | 4 | #!/bin/python3
# Complete the matrixRotation function below.
def matrixRotation(matrix, r):
height = len(matrix)
width = len(matrix[0])
for i in range(min(height // 2, width // 2)):
state = []
# top-left to top-right
for j in range(i, width - i):
state.append(matrix[i][... |
2b9b46e43510c0f42db08e01dd70d1d87af6e1bd | mccornet/leetcode_challenges | /Python/0448.py | 1,322 | 3.5625 | 4 | """
# 448. Find All Numbers Disappeared in an Array
- https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/
- Classification: Array
## Challenge
Given an array nums of n integers where nums[i] is in the range [1, n],
return an array of all the integers in the range [1, n] that do not appear in num... |
31ec846065806b104d2c4802ea1cc1960fccee09 | yangjiahao106/LeetCode | /Python3/513_找树左下角的值.py | 1,186 | 3.875 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def __init__(self):
self.max_depth = 0
self.res = 0
def findBottomLeftValue(self, root: TreeNod... |
7bd38c348bbce4902dfd68272ae8aac992b28e6c | yannyappi/python_projects | /EchoBot.py | 255 | 3.734375 | 4 | print("Hi and welcome to EchoBot.")
username = input("What is your name?")
print("Hi "+username+". This chatbot will repeat what you will say.")
stuff_to_echo = input("Please enter something to repeat")
print("You said: "+stuff_to_echo)
print("Bye bye.")
|
6295c9940fd60326123783b68e8dc7ef2f2e211a | muyurainy/interview | /bishi_code/tenxun_0405/tx_2.py | 710 | 3.65625 | 4 | def solution():
'''消除相邻不同的字符
输入:
4
1100
Notes
-----
直接从左到右循环去判断
'''
_, string = int(input()), input()
old_length = 0
new_str = ""
while old_length != len(string) and len(string) >= 2:
index = 0
while index < len(string):
if index == len(string... |
3096b4b5b19c4d80d73c49b2350c41a1f5edf72e | jos-h/Python_Exercises | /CSV_Excel_File_openpyxl.py | 1,536 | 3.9375 | 4 | from openpyxl import Workbook
from openpyxl.utils import get_column_letter
import csv
def csv_Excel_conversion(csv_input_file):
workbook = Workbook()
# new workbook created with atleast one Worksheet
worksheet = workbook.worksheets[0]
worksheet.title = "a demo "
# a variable to separate csv based on ','
cs... |
0589d11a523e8e118e953d8078136e0648932295 | bazhenov4job/Algorithms_and_structures | /Lesson_09/homework/Task_02.py | 1,515 | 3.828125 | 4 | """
2. Закодируйте любую строку по алгоритму Хаффмана.
"""
from collections import Counter, OrderedDict
from binarytree import Node
from copy import deepcopy
def tree_search(tree, symbol, path=''):
print(symbol, path, tree.value)
if tree.value == symbol:
print('нашёл', path)
return path
... |
953d8db68446a752f138d7277015e63efe1b0f6b | BoomerLives/RabitHole | /Trivial_Python_Practice/Trivial/celsius_to_fahrenheit_Calderon.py | 669 | 4.5 | 4 | # Author: Nathan Calderon
# File Name: celsius_to_fahrenheit_Calderon.py
# This program converts a temperature entered in Celsius
# to Fahrenheit.
# User enters a temperature in Celsius.
celsius_temp = float(input("Enter the temperature in \
Celsius and press enter: "))
# Celsius temperature converted to Fahrenheit... |
26e3014ab03ebc0e1dd369d5e31f76e07bd8413e | cittie/Leetcode---Python | /048. Rotate Image.py | 709 | 3.609375 | 4 | class Solution(object):
def rotate(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
n = len(matrix)
for row in range(n >> 1):
for column in range(row, n - row - 1):
... |
db7b4f62d86f8370b124cc29d50a965c03c3a98d | SURAJTHEGREAT/vector_udacity_khan_python | /Linear_Algebra/vector_product.py | 3,014 | 4.09375 | 4 | """http://interactivepython.org/courselib/static/pythonds/Introduction/ObjectOrientedProgramminginPythonDefiningClasses.html - to know more about str and eq ... str is used to know what needs to be done when print method is called and _eq_ is to find equal to
and http://stackoverflow.com/questions/16548584/adding-two-t... |
1b7412e75bd42b0c7fa4004b605b82f2b482a48b | PriyathamRaj/MITx-6.00.2x-Introduction-to-Computational-Thinking-and-Data-Science | /Midterm/max_contig_sum.py | 572 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 17 16:28:00 2017
@author: Priyatham
"""
def max_contig_sum(L):
""" L, a list of integers, at least one positive
Returns the maximum sum of a contiguous subsequence in L """
max_so_far = 0
sub_sum = 0
for i in range(len(L)):
... |
2260580e977d51549f7081574acc29cf56253f6a | kamiruizdiaz/Projeto-Pedra-papel-e-tesoura | /jokenpo.py | 1,163 | 3.71875 | 4 | import random
print("JOGO PEDRA PAPEL E TESOURA \nOpções:\n0-Pedra \n1-Papel\n2-Tesoura")
opcoes = ['pedra', 'papel', 'tesoura']
jogada_computador = random.choice(opcoes)
jogadaUsuario=int(input("Digite a sua jogada: "))
if jogada_computador == "pedra":
print("O computador escolheu: Pedra")
if jogadaUsuari... |
b319b3b87021bc4cf08a8c45151177273f9ac2c3 | wellqin/USTC | /PythonBasic/base_pkg/python-06-stdlib-review/chapter-05-Mathematics/5.3-random/py_02_randomGenerate.py | 624 | 3.5 | 4 | import sys, random
sys.path.append('.')
from pkg.breaker import addBreaker
@addBreaker
def random_randomm():
for _ in range(5):
print('%04.3f' % random.random(), end=' ')
return
@addBreaker
def random_uniform():
for _ in range(5):
print('%04.3f' % random.uniform(1, 100), end=' ')
retur... |
a334d55ff91c7b12d218ccc8bc7d6cc4f47d7f7b | gutpdn/2D | /Data-Structure/Graph/Traversals.py | 1,916 | 3.515625 | 4 | class Graph:
def __init__(self, graphList):
self.weight = dict()
for node in graphList:
self.weight[node] = []
def edge(self, prede, suc, weight = 1):
if suc not in self.weight[prede]:
self.weight[prede].append(suc)
self.weight[suc].append(prede)
def graphInArray(s... |
62774e4d3b2617638c114b267a2af0773b246c47 | CaesarWattsHall/TurtleGraphics4 | /Turtle Design.py | 310 | 3.890625 | 4 | # Python program to draw
# Rainbow Benzene
# using Turtle Programming
import turtle
colors = ['#05668d', '#028090', '#00a896', '#02c39a', '#f0f3bd', '#FFFFFF']
t = turtle.Pen()
turtle.bgcolor('#000000')
for x in range(360):
t.pencolor(colors[x%6])
t.width(x/100 + 1)
t.forward(x)
t.left(59)
|
a15c60d402cbbaed63e20e48365fc8b32fb9bcf6 | MDGSF/JustCoding | /python-leetcode/69.01.py | 172 | 3.5625 | 4 | class Solution:
# 牛顿迭代法
def mySqrt(self, x: int) -> int:
if x <= 1: return x
r = x
while r * r > x:
r = (r + x // r) // 2
return int(r)
|
3aceefcd3b461521b4b0f5f28c07808be05a72e3 | wulfebw/algorithms | /scripts/recursion/power_set.py | 481 | 3.890625 | 4 |
def power_set(s):
'''
the idea is that you either include each item in the set or you do not
and for both options you have to collect all future sets
O(2^n)
'''
if len(s) == 0:
return ['']
else:
suffixes = power_set(s[1:])
sets = suffixes
sets += [s[0] + ... |
6572067870582b31d37413649cd5632d07906768 | Boy0211/dataprocessing | /week6/data/convertCSV2JSON.py | 1,130 | 3.515625 | 4 | import pandas as pd
import copy
filename_IN = "RPOP_15122018150449599.csv"
filename_OUT = "data_final.csv"
def open_data(filename):
df = pd.read_csv(filename, sep=',')
return df
def process_data(df):
countrys = []
years = []
genders = []
population = []
print(df)
for i in range(len(... |
06ccf17e2d704e35ae7824739cbfeeb2cdb486ad | sahiljajodia01/Competitive-Programming | /leet_code/container_with_most_water.py | 612 | 3.53125 | 4 | # https://leetcode.com/explore/interview/card/top-interview-questions-hard/116/array-and-strings/830/
###### Two pointer approach #######
class Solution:
def maxArea(self, height: List[int]) -> int:
count1 = 0
count2 = len(height)-1
max_ = 0
while count1 < count2:
area =... |
4d060835ff653a6a2262ed47b5a4146325583935 | brjatoba92/exercicios | /salarios.py | 1,436 | 4.03125 | 4 | #Desconto
salario_bruto = float(input('Digite o salario:'))
sindicato = 0.03
fgts = 0.11
inss = 0.1
valor_sindicato = salario_bruto
valor_fgts = salario_bruto * fgts
valor_inss = salario_bruto * inss
#descontos_primarios = valor_fgts + valor_inss + valor_sindicato
"""
IR = 900 ==> ISENTO
1500 ==> -5%
2500 ... |
1febad598012f7d273a8c0112937e3083a334882 | qwrrty/adventofcode2019 | /adv14.py | 3,198 | 3.984375 | 4 | #! /usr/bin/env python3
import math
# A reaction is expressed as:
# - Reaction.chemical (the output chemical)
# - Reaction.quantity (the output quantity)
# - Reaction.ingredients (a hash of chemicals and quantities
# that go into this reaction)
class Reaction(object):
def __init__(self, chemical, quant... |
813b557d9c022089db2a8a8bb9402ad2dfa62539 | khaledmohamed00/Deeplearning.ai_specialization_coursera | /deeplearning.ai_specialization_coursera/ANN/untitled0.py | 4,281 | 3.671875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 3 10:19:15 2019
@author: khaled
"""
import numpy as np
import matplotlib.pyplot as plt
from gradient_checking import gradient_checking
def sigmoid_prime(z):
"""Derivative of the sigmoid function."""
return sigmoid(z)*(1-sigmoid(z))
... |
414c90484032eb0395f0f16fc6d2e5ce381ae550 | justcallmelarry/advent-of-code-2019 | /03/a.py | 1,677 | 3.71875 | 4 | import os
from collections import *
from utils import get_actual
from utils import *
def calc(x, y, grid):
grid[f"{x}:{y}"] = i if grid.get(f"{x}:{y}") in (None, i) else True
if __name__ == "__main__":
day = os.path.dirname(os.path.abspath(__file__)).rsplit("/", 1)[-1]
_input = get_actual(day=int(day),... |
f8548e3bd4c1c0cbde60e03c84bbe4a0bc17b69e | uvsq22004753/l1-python_2020_2021 | /exercises/TD3_fonctions/TD3.py | 6,145 | 3.53125 | 4 |
import sys
import time
def tempsEnSeconde(temps):
""" Renvoie la valeur en seconde du temps donné comme \
(jours, heures, minutes, secondes)."""
return 86400 * temps[0] + 3600 * temps[1] + 60 * temps[2] + temps[3]
def secondeEnTemps(seconde):
"""on donne un temps en seconde et la fonction renvoie u... |
53c826707335e8eb20e99f915de7cc5aaf202dfb | logriffith/CS0 | /notes/notes.py | 3,499 | 3.890625 | 4 | ### Notes From CSCI 110 class ####
"""
a=10
print(float(a))
b='10'
print(a*float(b))
3 in binary is 11.
1(2)^1+2^0=3
round(area, 4) rounds area to 4 decimal points
def getData():
s1=input("What is the first number")
s2=input("What is the second number")
s3=input("What is the thrid number")
# does it ... |
70cf595883fe72b65200c246a37dc881c29556c8 | Djerys/logy | /interpreter.py | 4,935 | 3.578125 | 4 | import sys
import cmd
import boolean_lexer as blex
from boolean_parser import parse
from calculation import BooleanCalculator, ConstantError
class CalculatorInterpreter(cmd.Cmd):
def __init__(self):
cmd.Cmd.__init__(self)
self.calculator = None
self.prompt = '> '
self.intro = ('-... |
76a1c118aca42e1f388fc34fa86f73947a09f119 | zuikaru/2110101_Com_Prog_2018_2 | /12/12_P2.py | 752 | 3.546875 | 4 | class ComplexNum:
def __init__(self,re,im):
self.re = re
self.im = im
def __str__(self):
if self.im >= 0:
return str(self.re) + '+' + str(self.im) + 'i'
return str(self.re) + str(self.im) + 'i'
def absolute(self):
ab = (self.re**2+self.im**2)**0.5
... |
10cd8e81e95d122853e62d0a60118b3ff0366f1c | JaySutcliffe/Group-Project | /Control/s.py | 1,340 | 3.515625 | 4 | import socket
# run on pi
# HOST = '10.42.0.1' #USB interface to EV3
HOST = '192.168.137.1'
# HOST = 'localhost'
PORT = 65432
class Server:
# Sets up server socket and accepts connection
def __init__(self, host, port):
print("Attempting to connect to Robot arm")
self.s = socket.socket(socke... |
7329e011796290b118a9dc81424a0b1db5c0d79b | Empythy/Algorithms-and-data-structures | /排序/选择排序.py | 1,073 | 3.734375 | 4 | def selection_sort(arr):
for i in range(len(arr) - 1):
min_index = i
for j in range(i + 1, len(arr)):
if arr[j] < arr[min_index]:
min_index = j
arr[min_index], arr[i] = arr[i], arr[min_index]
return arr
"""
选择排序和冒泡排序很类似,但是选择排序每轮比较只会有一次交换,
而冒泡排序会有多次交换,交换次数比冒泡... |
e740658f81b2fa3a0a2253bc1fe31fe2c9e21ed2 | waltman/advent-of-code-2020 | /day23/crab_cups2.py | 1,672 | 3.6875 | 4 | #!/usr/bin/env python3
from sys import argv
N = 1_000_000
MOVES = 10_000_000
class LinkedList:
def __init__(self, val):
self.val = val
self.next_node = None
def create_circle_list(cups):
d = {}
arr = [int(c) for c in cups]
for i in arr:
d[i] = LinkedList(i)
for i in range... |
97e049c04f90a90c0857bddafee417171533a547 | guillermoojeda/CodingChallenges | /python/queens_in_board.py | 543 | 3.703125 | 4 | # You have an N by N board. Write a function that, given N, returns the number of possible arrangements of the board
# where N queens can be placed on the board without threatening each other, i.e. no two queens share the same row,
# column, or diagonal.
N = 5
myBoard = []
#Creating board
for i in range(N):
my... |
70f484cc8fd9504bb6e6e8788de69baa8b60927b | Vedvyas-Kalupnath/Python-projects | /ASCII.py | 217 | 4.28125 | 4 | print("Find Value of a specific character in ASCII")
print("")
a = str(input("Enter a single character: "))
# print the ASCII value of assigned character in c
print("The ASCII value of '" + a + "' is", ord(a)) |
816f6df2b305daf2d682a2fcd52a1befc0b7ab41 | carlotamburin/Metode-optimizacije-Python | /Vjezba2/Zad2.py | 1,485 | 3.625 | 4 | import random
def kamenSkarePapir():
bodoviIgrac = 0
bodoviRacunalo = 0
rezultat = [(1, 2), (3, 1), (2, 3)]
while bodoviIgrac <= 5 or bodoviRacunalo <= 5:
print("1. Kamen")
print("2. Skare")
print("3. Papir")
odabirIgrac = int(
input("odaberite broj pokra... |
eab6f1e56129e768a3a2afe00be4e206992944ef | greatabel/puzzle_I_cracked | /3ProjectEuler/i26_50/i32Pandigital products.py | 1,986 | 3.734375 | 4 | # Pandigital products
# Problem 32
# We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.
# The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and prod... |
643f8d654bc07c7fd01c67edbc088124f0139db2 | ahmetselimakbalik/pythonProjectlast | /edabit/01-very-easy/return-the-sum-of-two-numbers.py | 589 | 4.4375 | 4 | """
Return the Sum of Two Numbers
Create a function that takes two numbers as arguments and return their sum.
Examples
addition(3, 2) ➞ 5
addition(-3, -6) ➞ -9
addition(7, 3) ➞ 10
Notes
Don't forget to return the result.
If you get stuck on a challenge, find help in the Resources tab.
If you're really stuck, unlock ... |
c42eef898cf2b9aa7c3d51d5ca2b7439046808de | mradulpandya/contact_management_system-PYTHON | /main.py | 1,369 | 3.65625 | 4 | from dbhelper import db
def main():
DB = db()
while True:
print("**********WELCOME**********")
print()
print("Press 1 to Insert new user")
print("Press 2 to Display all user")
print("Press 3 to Delete user")
print("Press 4 to update User")
prin... |
7ab98282a5ca91d6777653f75899b86cb56eb292 | python101ldn/exercises | /Session_4/4b_input_solution.py | 365 | 4.25 | 4 | # Get the below code to run in a while loop until the user enters 'EXIT'
# users_name = input('What is your name? ')
# print('Hello, ' + users_name + '!')
loop = True
while loop:
users_name = input('What is your name? ')
if users_name.upper() != 'EXIT':
print('Hello, ' + users_name + '!')
else:
... |
700ab9b75023f007f7c9b0925aa7b3539284ee16 | zadacka/python_morsels | /11_point/point.py | 772 | 3.90625 | 4 | class Point(object):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __eq__(self, other):
return (self.x, self.y, self.z) == (other.x, other.y, other.z)
def __repr__(self):
return f"Point({self.x}, {self.y}, {self.z})"
def __mul__(self, multi... |
c883365709f2d45080849dc039f22ee1a187128c | miguel-uribe/BRT-Simulation | /stationC.py | 4,191 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 16 06:50:22 2017
@author: miguelurla
"""
from __future__ import division
import parameters
# Importiung the anim parameter
anim=parameters.anim
# If anim, import the vpython module
if anim:
from vpython import *
class stationC:
"This class contai... |
7be298dfda59c2f8eb567387e15de04b32a20129 | consmith/Password_Generator | /Password_Generator.py | 1,417 | 4.0625 | 4 | #Password Generator
import random
def HowManyPasswords():
PasswordAmount = raw_input('how many passwords do you want to generate? ')
Amount = ErrorChecking(PasswordAmount,'Amount')
return Amount
def ErrorChecking(String_Input,Which_One):
bad_word = False
for i in range(0,len(String_Input)):
... |
539cd0d77d07c5413e25ce7426ff7f240b55210b | Cassie07/Leetcode_2020 | /Arrays/35. SearchInsertPosition.py | 238 | 3.515625 | 4 | class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
if target in nums: return nums.index(target)
c = 0
for i in nums:
if i < target:
c += 1
return c
|
d84402bff68f1fc055a32f1e0f8bb9a239a60ef8 | jyameo/machine-learning | /svm/svm_author_id.py | 1,281 | 3.53125 | 4 | #!/usr/bin/python
"""
This is the code to accompany the Lesson 2 (SVM) mini-project.
Use a SVM to identify emails from the Enron corpus by their authors:
Sara has label 0
Chris has label 1
"""
import sys
from time import time
sys.path.append("/root/projects/machine_learning/ud120-projects/to... |
03e460bcd4eb343494ea29933b3ed00fe66030ca | bb2qqq/tech_notes | /THEORIES/algorithm/leetcode/HN_4_Irregular_Probability_Variation.py | 2,120 | 4.125 | 4 | """
Design a function, which returns True or False in a random way.
Which requires:
1. The total distribution of True&False is irregular and unpredicatable(Won't fixed on a ratio even after a huge number of tests.
2. Run this function two times with same parameters will get totally different results.
"""
# The average... |
2bdac3723b23d38e051fab241d703e95261fb91d | mobishift2011/My-100-Days-Of-ML | /1/code.py | 1,695 | 3.859375 | 4 | """数据预处理"""
# Step 1: Importing libraries
from sklearn.impute import SimpleImputer
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder, OneHotEncoder, StandardScaler
import numpy as np
import pandas as pd
import os
# Step 2: Importing dataset
file_path = os.path.join(os.... |
f17665afaae3c576dfc47cc09d86bacffcd90e05 | liwaya29/python | /1_variable_types.py | 229 | 3.5 | 4 | # variable declaration
# variable_name assignment_operator value
x = 1
print(x)
y = 2
print(y)
# variable types
print(type(x))
print(type(y))
name = "liwaya"
print(name)
print(type(name))
z = 3.9
print(z)
print(type(z))
|
5e4ca3db42ad683fc71bfdbe0080dc1232b0284b | abhishekzambre/Python_Programs | /EPI/set.py | 147 | 3.625 | 4 | x = set("A Python Tutorial")
print(x)
y = set(["A", "B", "C"])
print(y)
z = set("ABCcC")
print(z)
l = ["a","b","b","c"]
s = set(l)
print(s) |
e14ef6b662d4a9225c3eda49d596e6c87cfacaa6 | iboros1/PTP | /pr2.py | 2,113 | 3.625 | 4 | # P2. Merge 2 objects with any depth (including contained dictionaries, lists, sets, strings, integers, floats).
# Type mismatches should yield a tuple with the two elements. Examples:
# a = {'x': [1,2,3], 'y': 1, 'z': set([1,2,3]), 'w': 'qweqwe', 't': {'a': [1, 2]}, 'm': [1]}
# b = {'x': [4,5,6], 'y': 4, 'z': set([4,2... |
25e2af3b9061bc47bc76f845cc3998d8e8d92c44 | rrdesai/dsp | /python/q8_parsing.py | 840 | 4.1875 | 4 | # -*- coding: utf-8 -*-
# The football.csv file contains the results from the English Premier League.
# The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of
# goals scored for and against each team in that season (so Arsenal scored 79 goals
# against opponents, and had 36 goals scored against ... |
483136ce7c7aa923b1dd3f0cd4731a17a18c9ad6 | Pawls/Coding-Challenges | /CtCI/python/Ch 2 Linked Lists (missing intersection)/LinkedList.py | 7,270 | 3.78125 | 4 | class Node:
total = 0
def __init__(self, data):
self.data = data
self.next = None
Node.total += 1
#print('Nodes:', Node.total)
def __del__(self):
Node.total -= 1
#print('Nodes:', Node.total)
class LinkedList:
def __init__(self):
# Define aliases
... |
c517d3b144014b9477b744191468f495184a3ce7 | ai2-education-fiep-turma-2/05-python | /solucoes/TiagoPedrosa/listabash/exerciciocidades.py | 364 | 3.53125 | 4 | def analisaCidades():
arquivo = open("cidades.txt")
linhas = [i.strip().lower() for i in arquivo.readlines()]
unique = set(linhas)
for i in unique:
frequencia = linhas.count(i)
print("A frequência de", i.upper(), "é", frequencia)
print("Cidades total:", len(linhas), ", Cidades... |
3ebc3d0ed8429b9b867c2168d57164d7258e8b3c | ibogdanova/homework | /array.py | 241 | 3.671875 | 4 | array = [0, 1, 2, 3, 4, 5]
sum = 0
number = 1
if len(array) <= 0:
print(0)
else:
for number in range(len(array)):
if number % 2 != 0:
sum = sum + array[number]
result = sum * array[-1]
print(result)
|
d1da9a2a27c82118e3793b59ecd5641e13492a28 | Fatimaliras/Analytics | /arvore b/arvore_oficial.py | 5,699 | 4.1875 | 4 | # Programação Dinâmica - Estruturas de Dados
# Implementação de Árvores e seus algoritmos - by hallpaz
# https://youtube.com/programacaodinamica
from queue import Queue
ROOT = "root"
# Implementando uma Árvore Binária: https://youtu.be/6E169kShoNU
class Node:
def __init__(self, data):
self.data = data
... |
5db852dde5395ad4153e5f73e008ac062d0ea5de | gistable/gistable | /dockerized-gists/1935894/snippet.py | 711 | 4.5625 | 5 | """Simple example showing why using super(self.__class__, self) is a BAD IDEA (tm)"""
class A(object):
def x(self):
print "A.x"
class B(A):
def x(self):
print "B.x"
super(B, self).x()
class C(B):
def x(self):
print "C.x"
super(C, self).x()
class X(object):
de... |
5f7d093a66e28a9a0d84502b91dc0178b9381d7e | mehdizit/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/12-roman_to_int.py | 604 | 3.53125 | 4 | #!/usr/bin/python3
def roman_to_int(roman_string):
if isinstance(roman_string, str):
total = 0
nums = {'M': 1000, 'D': 500, 'C': 100, 'L': 50,
'X': 10, 'V': 5, 'I': 1}
list_n = [nums.get(char) for char in roman_string]
len_l = len(list_n)
if len_l == 1:
... |
a838b15d296e5774b1b97c259398b15aa62c0632 | kookou/study | /Algorithm/카카오2020코테2번.py | 1,035 | 3.734375 | 4 | orders = ["XYZ", "XWY", "WXA"]
course = [2,3,4]
from itertools import combinations as cb
def solution(orders, course):
answer = []
for count in course: # 각 코스 마다
sum_combo = [] # 코스 별 전체 콤보 리스트
for i, order in enumerate(orders): # 각 오더 마다
order = ''.join(sorted(order)) # 오더를 알... |
7e10bccaa6ec4759eb2ec7155a6cd1cb2af4d492 | PiotrStankiewicz/codebrainers2019 | /dni/04_dzien/funkcjefinbonacci.py | 222 | 3.84375 | 4 | def fibonacci(m):
lista = [0,1]
for i in range(2, m+1):
# lista[i] = lista[i-1] + lista[i-2]
lista.append(lista[i-1] + lista[i-2])
return lista[-1]
wartosc = fibonacci(10)
print(wartosc)
|
4b61af7a5144cb8ceb4a28782efc3f7bf380dc47 | Hemie143/realpython2 | /chp04_database_programming/04_072_sql-search.py | 596 | 4.125 | 4 | import sqlite3
prompt = '''
Select the operation you want to perform (1-5):
1. Average
2. Max
3. Min
4. Sum
5. Exit
'''
operation = {'1': 'AVG', '2': 'MAX', '3': 'MIN', '4': 'SUM'}
with sqlite3.connect("newnum.db") as connection:
c = connection.cursor()
while True:
choice = input(prompt)
if c... |
7b017f3ebb0176c42a0ac1e44bf669cb5e2dd694 | tianwei1992/Python_oop_leaning | /advanced/staticmethod_and_classmethod/classmethod_demo.py | 700 | 3.71875 | 4 | class Spam:
numInstances = 0
def __init__(self):
Spam.numInstances += 1
def printNumInstances(cls):
print("Number of instances:", cls.numInstances)
printNumInstances = classmethod(printNumInstances)
if __name__ == "__main__":
a,b = Spam(), Spam()
a.printNumInstances()
Spam.printNumInstances()
print()
cl... |
0cc99e80b71f68b0803caaf0e7b86ba346da3513 | hayatbayramolsa/pandas | /main.py | 2,841 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 26 11:00:20 2020
@author: Hp 840
"""
import pandas as pd
sozluk = {"NAME": ["Ali", "Ahmet", "Ayşe", "Mustafa", "Sinan", "Zeynep", "Büşra", "Esra"],
"AGE": [15, 17, 22, 27, 18, 20, 32, 21],
"MAAS": [100, 150, 130, 220, 350, 120, 250, 180]}
... |
e10ea3d2f156f15eeb2e2f3926c72739fb235556 | Yurun-LI/CodeEx | /MaximumSubArray.py | 342 | 3.671875 | 4 | from typing import List
class Solution:
def maximumSubArray(self,nums:List[int])-> int:
pre = 0
max_ans = nums[0]
for i in range(0,len(nums)):
pre = max(pre+nums[i],nums[i])
max_ans = max(max_ans, pre)
return max_ans
nums = [-1,-2,1]
print(Solution().... |
7542a0c434c1d91d7b4966055e6db050affd0e38 | vamsi12619/IntroToPyOrg | /lists/lists.py | 542 | 4.25 | 4 | birds = ['aquatic warbler', 'arctic skua', 'avocet', 'goose', 'owl'] # list of birds, lists are defined by square brakets.
bird = birds[0] #This defines 'bird' as the first entry in the list known as 'birds'. The variable 'bird' could be anything (i.e. 'i' or 'n')
print(bird.title()) #We know this, it prints the vari... |
2870963be304c38afbaaa64c65cb6c73901329bc | ityrpak/Minijuegos-con-Python | /paroimpar.py | 600 | 3.703125 | 4 | # Minijuego Par o Impar
class ParOImpar:
@staticmethod
def jugar_juego():
print(f"\nPar o Impar")
try:
x = float(input("Ingresa un Numero: "))
except:
ParOImpar.jugar_juego()
if x % 2 == 0: print("Es un numero par.")
else: print("Es un numero imp... |
630aa17a945a8b526c0cdc0f5cd64b5c37a13719 | petertia/kaggle | /genderclassmodelpy.py | 4,371 | 3.515625 | 4 |
import csv as csv
import numpy as np
csv_file_object = csv.reader(open('C:/Users/Peter/Documents/Kaggle/Titanic/train.csv','rt'))
header = next(csv_file_object)
data = []
for row in csv_file_object:
data.append(row)
data = np.array(data)
# Creating bins for gender, class, fare
fare_ceiling = 40
data[data[0::,9... |
a702ad406b371729655c39acc3f711d8b1658813 | haochen208/Python | /pyyyy/07 循环语句、while循环/01while循环.py | 680 | 3.90625 | 4 | # print("妈妈我错了")
# print("妈妈我错了")
# print("妈妈我错了")
# print("妈妈我错了")
# print("妈妈我错了")
# while 条件:
# 执行语句
# i = 0
# while i < 10000:
# print("妈妈我错了")
# print("请原谅我")
# i += 1
# i = 0
# while i < 10:
# print("当前是第%d次循环" % (i+1))
# print("此时i=%d" % i)
# i += 1
# ★★★★★★★★... |
6523c81b3c78db3aba188aa50fd2e65c890eb0d9 | Tnoriaki/pyintro | /chap04/4.6.py | 246 | 3.53125 | 4 | # coding: utf-8
nameHandle = open('kids', 'w')
for i in range(2):
name = raw_input('Enter name: ')
nameHandle.write(name + '\n')
nameHandle.close()
nameHndle = open('kids', 'r')
for line in nameHandle:
print line
nameHandle.close()
|
950ce41ac11162d097c70ee30c78bdb0480965d6 | AnneMay/DESS-bioinfo | /INF8212/Agenda_tel/agenda.py | 3,402 | 3.9375 | 4 | #! bin/bash/python3
###Introduction au programme
print(#Présentation du programme
"""
Agenda télephonique éphémère
Auteur: Anne-Marie Roy
Date: automne 2019
"""
)
###Package/import
#import csv
###Variables
choix = 0
###Fontions
##Charger le carnet de Contact
def charger_contact(agenda):
file = open(agenda, "r")... |
5153f7ad44f468c974d5ec8c1e6dbbd8f3842f1a | ThompsonNJ/CSC231-Introduction-to-Data-Structures | /Lab 7/in_order_list.py | 1,915 | 4.15625 | 4 | # Add item to a_list in the appropriate slot. Items must be in ascending order.
def add_in_order(a_list, item):
i = 0
while i < len(a_list) and a_list[i] < item:
i += 1
a_list.insert(i, item)
# Add item to a_list in the appropriate slot. Items must be in ascending order.
# item is a str... |
bc0875307df470cff44da37aa7c38a59dea8ece0 | palcode/opencv_python_tutorials | /core_operations/arithmetics_operations_on_images/demo_image_arithmetics.py | 733 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 21 15:57:02 2015
@author: Johnny
"""
#%%
import cv2
import numpy as np
#%%
# mage Addition
# There is a difference between OpenCV addition and Numpy addition.
# - OpenCV addition is a saturated operation (clamped between min and max)
# - Numpy addition is a modulo ope... |
f5710dbf01ff3f6ef09822d09df8d850b5186edc | hsi-tzu/-numerical-analysis-project | /副程式/平方根牛頓法.py | 423 | 3.96875 | 4 | #Q3.13
#a=float(input('輸入a,(a不可小於0)=')) #輸入a
def square_root(a):
es=(0.5*10**(2-16))/100 #es的值
x=1 #x0的位置,可填任意數字,這裡填1
while True: #無限迴圈
xold=x #x回傳至xold,這樣才可計算ea
x=(x+(a/x))/2 #迭代公式
print('a的平方根=',x)
ea=((x-xold)/x) #ea的值
print('ea=',ea)
if abs(ea)<es: #ea的絕對值小於es就跳出迴圈
break
|
9328a625c5e2f01e73b8cf730ee0ae9ccc080621 | childe/leetcode | /3sum/solution.py | 1,979 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
https://leetcode.com/problems/3sum/
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ... |
99a5328bc0b8ecb1baa151f2dcb5570b7b35875a | LazyAssassin445/pibox | /wooddesign/dimensions.py | 2,139 | 3.90625 | 4 | #!/usr/bin/python3
import math as maths
thickness = int(input("How thick is your wood in millimetres? "))
overhang = int(input("How much do you want the top plank to overhang in millimetres? "))
#work out bird section dimensions
birdfr1 = 200+thickness
birdfr2 = 150
birdba1 = 200+thickness
birdba2 = 150
birdbo1 = 15... |
371f7250db3db5a1ed091f2cfa2d49854ae3ca24 | NeilWangziyu/Leetcode_py | /findDuplicates.py | 724 | 3.53125 | 4 | class Solution:
def findDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
dict = {}
for each in nums:
if each not in dict:
dict[each] = 1
else:
dict[each] += 1
res = []
for e... |
84de19c1446d7ec7ab6f717427d232ebd282151c | dinka14/project-2 | /english_latin_dict.py | 571 | 3.59375 | 4 | from collections import defaultdict
lines = int(input())
english_dict = {}
for i in range(lines):
line = input()
word = line[:line.index(' - ')]
english_dict[word] = line[len(' - ') + line.index(' - '):].split(', ')
latin_words_dict = defaultdict(list)
latin_dict = {}
for key in english_dict:
for word... |
04a89847418bd7865670ba1ebdc1435bc64627b8 | Amruta-Pendse/Python_Exercises | /Functions/NumberSquare.py | 190 | 4.21875 | 4 | #Program to print square of numbers between 1 and 30
def num_sq():
l=[]
n=0
i=1
while (i<=30):
n=i*i
l.insert(i-1,n)
i+=1
print(l)
num_sq() |
2ade32ffe404bbd9054740a40ff926584579a485 | mredig/CS-Sprint2-Guided-Projects | /bubbleSort.py | 672 | 4.125 | 4 | import random
myList = [8, 6, 2, 3, 7, 9, 5, 0, 1, 4]
def bubbleSort(items):
# iterate over the array
# compare each element to neighbor, swap if the item on right is lower
# track if there were any swaps or not
# if there aren't, sorting done
swapped = True
while swapped:
swapped = ... |
02d7cfc2acef5ebe52b507794df5cd43497a106f | kgukevin/tjhsst | /Artificial Intelligence I & II (2018-19)/Labs/Lab03 Informed_Search/15Puzzles.py | 20,393 | 3.578125 | 4 | import collections
import time
import random
import cProfile
import math
import sys
from heapq import heappop, heappush
# global variables
goal = "012345678"
size = 3
def goal_test(state): # returns goal test if state is equal to goal
if state[-1] == goal:
return True
return False
def swap_tiles(s... |
d6612bcd32d8c138fd726206048250954d02d91e | anumala2/cs3b | /CS3B/aadithyaAnumalaLab5.py | 1,402 | 3.84375 | 4 | ###############################################
# CS 21B Intermediate Python Programming Lab #5
# Topics: web urllib
# Description: This program finds the html source
# from nasonline.org and finds the
# frequency of certain key terms and
# prints that out for the user.
# Input... |
8ba90a50182e5779d24e4ab1bb8503a89c7790a5 | aa88bb/Learn_Python_From_0_to_1 | /2.2.1.py | 274 | 3.84375 | 4 | import random
def compareNum(num1,num2):
if(num1 > num2):
return 1
elif(num1 == num2):
return 0
else:
return -1
num1 = random.randrange(1,9)
num2 = random.randrange(1,9)
print(num1,num2,compareNum(num1,num2))
print(str(num1)+str(num2)) |
f6fd2ca35e0789161ed99a5e13aa6dcba7c7d557 | maru12117/python_practice | /210611_practice_1.py | 332 | 3.78125 | 4 | '''stone = list(map(float,input("돌의 무게를 입력해주세요 : ").split()))
total=0
i = 0
for x in stone:
i+=1
print(i,"번쨰 돌\n 무게(g): ", x)
total = total+x
avg = total/len(stone)
print("\n평균", avg)'''
'''s = map(int,input("입력해주세요 : ").split())
print(type(s))
print(s)'''
|
bd1d0796086780f97ea4fef81e145b29672a3590 | gitzx/Data-Structure-Algorithm | /LeetCode_Python/Math/Super_Pow.py | 413 | 3.625 | 4 | '''
Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.
Example1:
a = 2
b = [3]
Result: 8
Example2:
a = 2
b = [1,0]
Result: 1024
'''
class Solution(object):
def superPow(self, a, b):
ans, pows = 1, a
for x in b[::-1]... |
cca820ed893eb2ad3073586720e694ab3d323d89 | OwenBowler/BCPR301A2 | /module.py | 1,028 | 3.53125 | 4 | class Module:
"""create a module that will hold all the classes
>>> a = Module()
>>> a.create_module('test_module', ['classOne', 'classTwo', 'classThree'])
>>> print(a.module_name)
test_module
>>> print(len(a.all_my_classbuilders))
3
"""
module_name = str
def __init__(self):
... |
02c35bb47654b319c845fa4b4783ad4530f04091 | Harshad141/Maths-Programs | /Factorial.py | 213 | 4.0625 | 4 | Factorial
def recur_func(n)
if n==1
return 1
else
return n*recur_func(n-1)
num = int(input(value of n))
if num<0
print(no factorial)
elif num==0
return 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.