blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
50e5e8d1276a039f0502688d69fe42b98d2d5227 | NoahBeckerman/data-prework-labs | /duel/Raw Python/duel-of-sorcerers-solved-NoahBeckerman.py | 2,032 | 4.1875 | 4 | # Assign spell power lists to variables
gandalf = [10, 11, 13, 30, 22, 11, 10, 33, 22, 22]
saruman = [23, 66, 12, 43, 12, 10, 44, 23, 12, 17]
# Assign 0 to each variable that stores the victories
score_gandalf = 0
score_saruman = 0
total_matches = 0
# Execution of spell clashes
spell_options = range(len(gandalf)) # cr... |
3243087521dfeba279703cec2566c423b6fd51f2 | joelcnz/GameIntro | /ball.py | 1,086 | 3.546875 | 4 | import pygame
class Ball(pygame.sprite.Sprite):
# Constructor
def __init__(self, width, height):
# Call the parent class (Sprite) constructor
pygame.sprite.Sprite.__init__(self)
self.speed = [2, 2]
self.width = width
self.height = height
self.ball = pygame.image.load("intro_ball.gif")
self.ballrect = s... |
68614ca97c216789c16f288742fdad61275ecc42 | asymmetry/leetcode | /0089_gray_code/solution_1.py | 575 | 3.703125 | 4 | #!/usr/bin/env python3
class Solution:
def grayCode(self, n):
"""
:type n: int
:rtype: List[int]
"""
if n == 0:
return [0]
results = [0]
current = 0
i = 0
while i < n:
next_current = current ^ (2**i)
if... |
893ad93e796a1e7ac5fd1df23c8ab4a4c432a454 | SebastianStaab/AEMLproject | /tetris/testing.py | 806 | 3.515625 | 4 | cols = 10
rows = 20
board = [
[ 0 for x in range(cols) ]
for y in range(rows)
]
board += [[ 1 for x in range(cols)]]
def join_matrixes(mat1, mat2, mat2_off):
off_x, off_y = mat2_off
for cy, row in enumerate(mat2):
for cx, val in enumerate(row):
mat1[cy+off_y-1 ][cx+off_... |
9a010baa9a6b60f8c82d16aeb43e43f2ff7c08c0 | selvi7/samplepyhon | /s66.py | 98 | 4.09375 | 4 | x=int(input("enter the num:"))
y=int(input("enter the num:"))
for x in y:
z=(x*y)
print(z) |
c519741c2058f1d09c1b9603d96bca34ade1c347 | nikoGao/Leetcode | /144. Binary Tree Preorder Traversal/AC_Answer.py | 641 | 3.9375 | 4 | # User recursion
# 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 preorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: L... |
24074346790df4cd0c5e33e6cf24e860530d4355 | adampower48/codeforces | /Caps Lock.py | 178 | 4.09375 | 4 | word = input()
if word.isupper():
print(word.swapcase())
elif word[0].islower() and (word[1:].isupper() or len(word) == 1):
print(word.swapcase())
else:
print(word)
|
8d7396101a37d0bcd832bed9b3cc3ac141c5620b | sharleenprice/Python | /E1006/hw 1/problem4.py | 840 | 3.875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 21 00:24:04 2017
@author: sharleenprice
"""
import random
import math
rand_num=random.random()*10
ceil_rand = math.ceil(rand_num)
user_guess = 0
counter = 0
while counter < 5:
user_guess = int(input("Enter your guess number: "))
if abs(ce... |
dafa4e743e0736947f343a0916a751fbaac0c021 | d3zd3z/euler | /python3/pr031.py | 884 | 3.984375 | 4 | #! /usr/bin/env python3
"""
Problem 31
22 November 2002
In England the currency is made up of pound, £, and pence, p, and there
are eight coins in general circulation:
1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).
It is possible to make £2 in the following way:
1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + ... |
707bc11c15ecc677a400399b4497377ab5a8ead6 | swNotJoao/FP_PROJ_2 | /proj2.py | 12,351 | 3.703125 | 4 | ###################################################
# Joao Carlos Lopes #
# Num: 90732 #
# 2º projeto #
###############################################... |
fb3f8252d470fd90e9e2308cd850eb35850fb1ca | ketkat001/BaekJoon | /14499.py | 2,927 | 3.546875 | 4 | # 삼성 A형 코딩 테스트 : 주사위 굴리기
def is_wall(x, y):
if 0 <= x < N and 0 <= y < M:
return True
return False
def solve(d_top, d_east, d_north, d_west, d_south, d_bottom, d_x, d_y):
for di in direction_list:
next_d_x = d_x + dx[di]
next_d_y = d_y + dy[di]
if di == 1: # 오른쪽으로 굴릴경우
... |
90fe7fe3724f46c9ff0bb51fb5da2e0a6c020431 | rviana84/dailylog | /studies/2018_udacity_introduction_to_data_science/chicago_bikeshare_pt_resposta_limpo.py | 5,991 | 3.71875 | 4 | # coding: utf-8
import csv
import matplotlib.pyplot as plt
with open("data/chicago.csv", "r") as file_read:
reader = csv.reader(file_read)
data_list = list(reader)
print("Número de linhas:", len(data_list)) # Imprimindo a quantidade de registros
print("Linha 0: ", data_list[0]) # Imprimindo a primeira linha (... |
b1a8c191a0bcfe26c815202f3a1d2eefd5cfebe2 | GND95/Python-Challenge | /PyPoll/main.py | 3,686 | 3.84375 | 4 | import os, csv
filePath = os.path.join('Resources', 'election_data.csv')#import csv block of code
with open(filePath) as csvfile:#open the path to the CSV file as a new object
csvreader = csv.reader(csvfile, delimiter=',') #pass the csvfile object to a new variable, csvreader
csv_header = next(csvreader) #skip... |
c4f13d3d4d6e7268cb05fcedab2201cae3c6d19e | pyopoly/3522_A00699267 | /Labs/Lab4/user.py | 3,235 | 4.0625 | 4 | """This module houses the User."""
__author__ = "Jack Shih & Tegvaran Sooch"
__version__ = "Feb 2021"
from bank_account import BankAccount
class User:
"""
Represents a user.
"""
def __init__(self, name, age, user_type, bank_account, budget):
"""
Initializes the User.
"""
... |
6a53fbfb8b069505c9570f4028b09b4dcc13228c | Felix-xilef/Curso-de-Python | /Desafios/Desafio64.py | 281 | 3.859375 | 4 | qtd = -1
soma = n = 0
while n != 999:
soma += n
qtd += 1
n = int(input('\tDigite um número (999 para encerrar): '))
print('\n\tQuantidade de números digitados = {}\n\tSoma dos números digitados = {}'.format(qtd, soma))
input('\n\nPressione <enter> para continuar')
|
a812c567230d8d31a8d9d5370d01c302758e5529 | wmontanaro/ProjectEuler | /Problem0060.py | 7,256 | 3.875 | 4 | '''
Project Euler Problem 60:
The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes
and concatenating them in any order the result will always be prime. For
example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four
primes, 792, represents the lowest sum for a set of four pr... |
ab3baa855e2803a1ea20a65928900532233ba5b6 | mulgyeolTest/Algorithm | /[20-1] algorithms/GCD 계산_ 3가지 방법.py | 484 | 3.6875 | 4 | def gcd_sub(a, b):
while a!= 0 and b!=0:
if a>b:
a = a-b
else:
b = b-a
return a+b
def gcd_mod(a, b):
while a!= 0 and b!=0:
if a>b:
a = a%b
else:
b = b%a
return a+b
def gcd_rec(a, b):
if b==0:
return a
else:
return gcd_rec(b, a%b)
# a, b를 입력받는다
# gcd_sub, gcd_mod, gcd_rec을 각각 호출... |
83459cc1c6881fcea3116338b0ed0b440d6cc320 | andrewmaybe/Euler-code | /Euler 8.py | 447 | 3.671875 | 4 |
def getproduct(string13):
product = 1
for n in (string13):
product = product * int(n)
return product
length = 4 #change to 13 after testing
bigstring = "2817298474837389405485057973636"
value = 0
ss = ""
for c in (bigstring):
ss = ss+c
print "ss",ss
if len(ss) == ... |
355d833db812aaf005cb17dd6471d41e07284765 | Faiz-AR/Sending-Email-Using-Python | /send_email.py | 977 | 3.640625 | 4 | import smtplib
import getpass
def emailLogin():
"""
Login to your gmail account using the app password
"""
smtp_object = smtplib.SMTP('smtp.gmail.com', 587)
smtp_object.ehlo()
smtp_object.starttls()
email = getpass.getpass("Enter your email: ")
password = getpass.getpass("Ent... |
2cc5da97763f6b192b861dd5c1287de948bf41a1 | jibinsmannapuzha765/Myproject | /PHYTON FILES/flow controls/looping/while loop.py | 144 | 4.03125 | 4 | print("hello")
print("hello")
print("hello")
print("hello")
i=1
while(i<=10): #1<=10(true) 1<=10(true) up to 10
print("Hello")
i+=1 |
65b9959fa4ec0f37fccd531f21ff07ea2256559f | parthnvaswani/Hacktoberfest-2020-FizzBuzz | /Python/largeFizzBuzz_AsOutput.py | 4,323 | 3.671875 | 4 | '''A large FizzBuzz as an output using small FizzBuzz numbers.(FizzBuzz=FizBuz for better alignment
and make sure your output terminal covers the entire length of the screen to avoid automatic newlines)'''
# Author: @AmanMatrix
def iCheck(i):
if i%15==0:
i='FizBuz'
elif i%3==0:
i='Fizz'
eli... |
79fd4cc1dafe3e84526ab057bbba98672800daf7 | georgehsin/Algorithms-in-Python | /Arrays_and_Strings/Ransom_Note.py | 872 | 3.765625 | 4 | # Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false.
# Each letter in the magazine string can only be used once in your ransom note.
class... |
500a82a7a65ec692131a56c91e05bf75d5e5dfc6 | LaxmanRaikar/PythonPrograms | /bridge/quadratic.py | 411 | 4.0625 | 4 | """
this program is used to find the quadratic roots
author:Laxman Raikar
since:8 JAN,2019
"""
from tech import functional
try:
a = int(input("Enter the value of a "))
b = int(input("Enter the value of b "))
c = int(input("Enter the value of c "))
functional.quadraticFunctions(a,b,c) # calls... |
0a77e67a371ed793c3825569846701eeb3e21c4d | kamojiro/atcoderall | /petrozavodsk/001/D.py | 1,624 | 3.65625 | 4 | def find(A,x):
p = A[x]
if p == x:
return x
a = find(A,p)
A[x] = a
return a
def union(A, x, y):
# bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)だと無限ループ。
if find(A,x) > find(A,y):
bx, by = find(A,y), find(A,x)
else:
bx, by = find(A,x), fin... |
4000a4c8bb19feb4ac609f9e7dae5e2d8e58a439 | iromman7777/awe | /zzzz.py | 391 | 3.734375 | 4 | """
a = int(input())
b = 0
c = 100
d = 0
e = 50
while a!=e:
b = b +1
e = (c + d)//2
if a < e:
c = e
if a > e:
d = e
print("{}번 만에 찾았습니다".format(b))
2차원 리스트
a = [[1,2,3], [4,5,6]]
print(a[1][2])
딕셔너리
a = {'kkk': 170, 'age': 100, 'velue': 200}
print(a['kkk'])
함"""
def add_test(x, y):
... |
d1c66cdf30696831949b3f9be7f32350c66554bb | Aasthaengg/IBMdataset | /Python_codes/p02747/s283818147.py | 110 | 3.765625 | 4 | s = input()
hi = ['hi', 'hihi', 'hihihi', 'hihihihi', 'hihihihihi']
print('Yes') if s in hi else print('No') |
4841829ccad9509d8f48a98c73f0a6367fc98b3b | aymane081/python_algo | /binarySearch/sqrt.py | 829 | 3.609375 | 4 | class Solution:
def sqrt(self, n):
if n == 0:
return 0
left, right = 1, n
# while True:
# mid = (left + right) // 2
# if mid * mid > n:
# right = mid - 1
# else:
# if (mid + 1) * (mid + 1) > n:
#... |
fd7fdd79670d2c2ac2ede25648bac0f9eb6b8ae1 | fallisd/lesson_four | /example_four.py | 459 | 4.21875 | 4 | import re
sentence = "Hello. My name is David. I am 26 years old."
# re.search(pattern, string)
# Scan through string looking for the first location where the regular expression pattern produces a match,
# return a corresponding MatchObject instance.
# Return None if the string does not match the pattern;
# note t... |
eed6c59ee0e78d161133e607f8579aba80b94b4d | zsyc/LeetAlgo | /0058_LenLast.py | 596 | 3.5625 | 4 | # 简单地通过两次循环,获得末尾单词前后索引
class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# 48ms:
# slist=s.split(" ")
# for i in reversed(slist):
# if i!="":
# return len(i)
# return 0
# idea from c++:... |
dbfbd79f591b983e01b808ad04629dfc15f0cbf1 | HAKSOAT/EpubToPdf | /manage.py | 1,305 | 3.859375 | 4 | import os
import zipfile
import shutil
class FileManager(object):
"""
This class is used for file interactions.
It has the following methods:
epub_to_zip() --- Which converts the epub file to a zip file
extract_zip() --- Which extracts the content of the zip file
get_directory() --- Which gets the... |
d2fae902473c27dc0e957d3ed504be60926c0d53 | TonyCoopeR-62/Python-temp | /while.py | 276 | 3.859375 | 4 | number = 23
running = True
while running:
guess = int(input('Some number'))
if guess == number:
print('Great job')
running = False #stop loop
elif guess < number:
print('bigger')
else:
print('smaller')
else:
print('ending')
|
98a65c12a1021e698c35561640967f45e39f35cc | jiinmoon/Algorithms_Review | /Archives/Leet_Code/Old-Attempts/0144_Binary_Tree_Preorder_Traversal.py | 601 | 3.796875 | 4 | """ 144. Binary Tree Preorder Traversal """
class Solution:
def preorderTraversal(self, root):
# recursive solution is trivial; iterative approach using DFS.
if not root:
return []
result = list()
stack = [ root ]
while stack:
currNode = stack.pop()
... |
f4c1fcf6a3d2d391f405f997a1568dd941cf7ffd | Ak2303/Hangman | /main.py | 3,225 | 3.5 | 4 | import pygame
import math
import random
#initialise
pygame.init()
#display
WIDTH, HEIGHT = 800,600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
#Title
pygame.display.set_caption("Hangman")
#FPS
FPS = 60
clock = pygame.time.Clock()
#images
images = []
for i in range(7):
image = pygame.image.load("images\ha... |
f3d1139f4ea187885cb38f70e83cfd12f3d4564c | daniel-reich/ubiquitous-fiesta | /GC7JWFhDdhyTsptZ8_13.py | 685 | 3.84375 | 4 |
# function that takes two numbers as argument, the set length n (2 for
# pairs, 3 for triplets), and the limit. Return a list of sorted tuples of
# sexy primes up to (but excluding) the limit.
def sexy_primes(n, limit):
primes, result = [], []
def isPrime(a):
return all(a % i for i in range(2, a)) if a... |
d5c5f41d5abb554784824e7d4ea28a1fbdfbf303 | jermarino16/LearnPython | /Exercises/ListMethods/slices.py | 262 | 3.875 | 4 | my_list = list(range(1, 10))
#slice starting at the 1st index
print(my_list[1:])
#slice at the 5th index
print(my_list[5:])
#slice the whole thing? :O
print(my_list[:])
#slice from 4 to 8
print(my_list[4:8])
#slice it all with a 2 step
print(my_list[0:9:2]) |
7cd04f93197f520dc8b75ab20f901b56ad22469c | govindarajanv/shared | /python_ruby/exercise002.py | 462 | 4.125 | 4 | sample_str = "goviNd"
# reverse a string
print ("Reversed string:")
print (sample_str[::-1])
print ("\nString length:")
print (len(sample_str))
print ("\ncapitalized string:")
print (sample_str.capitalize())
print ("\nuppercase")
print (sample_str.upper())
print ("\ndowncase")
print (sample_str.lower())
print ("\ni... |
3056bbb762555001c0dc713a13f072f31d0ab218 | otisscott/1134 | /Homework/Homework 1/oms275_hw1_q5.py | 211 | 3.625 | 4 | def fibs(n):
second, last = 1, 1
for num in range(n):
yield second #Not sure if I'm allowed to use this, but it makes the solution so much more simple
second, last = last, second + last
|
81e1570d8c8a6b7a1a05606b5c028af3cd00b691 | shsma/python-courses | /flask-api/sections/rest-api-sections/section2/4_if_statements.py | 1,143 | 4.21875 | 4 | my_known_people = ["John", "Rolf", "Anne"]
user_name = input("Enter your name: ")
if user_name in my_known_people:
print("Hello, I know you!")
if user_name in my_known_people:
print("Hello {}, I know you!".format(user_name))
if user_name in my_known_people:
print("Hello {name}, I know you!".format(name=... |
c0b2922c0b1e192cf7ee6eaf8163c9b0d11dbf06 | asadmshah/cs61a | /week8/discussion.py | 3,479 | 4.125 | 4 | """
Discussion CS61A
"""
class Skittle(object):
""" A skittle object has a color to describe it. """
def __init__(self, color):
self.color = color
class Bag(object):
"""
A bag is a collection of skittles. All bags share the number
of bags ever made (sold) and each bag keeps track of its skittles
in a list.
"... |
927d8bdcdbb05babf13692dfbc0e5e5f168ab26e | lluxury/P_U_S_A | /1_intro/oo.py | 522 | 3.609375 | 4 | #!/usr/bin/env python
# v 3.0
class Server(object):
def __init__(self, ip, hostname):
self.ip = ip
self.hostname = hostname
def set_ip(self, ip):
self.ip = ip
def set_hostname(self, hostname):
self.hostname = hostname
def ping(self, ip_addr):
print ("Pinging %s ... |
7c1d65f83a4d2681cca0c69450df6dd2a4943946 | mebusw/Test-Driven-Development | /python/src/harryPotter/harryPotterTest.py | 3,175 | 4.3125 | 4 | """
To try and encourage more sales of the 5 different Harry
Potter books they sell, a bookshop has decided to offer
discounts of multiple-book purchases.
One copy of any of the five books costs 8 EUR.
If, however, you buy two different books, you get a 5%
discount on those two books.
If you buy 3 different book... |
8f0025d88714c341578e0370abf9b1d359cc0bdd | Aasthaengg/IBMdataset | /Python_codes/p02971/s027559480.py | 470 | 3.53125 | 4 | # coding: utf-8
def main():
N = int(input())
fir, fir_i, sec, sec_i = 0, 0, 0, 0
for i in range(N):
tmp = int(input())
if tmp > fir:
sec = fir
sec_i = fir_i
fir = tmp
fir_i = i
elif tmp > sec:
sec = tmp
sec_i =... |
7a573d5c639e7216d2cd22bc1cdfc51b9f38a5d3 | TzahiBHM/python | /tasks/checkStringMax.py | 945 | 3.953125 | 4 | #------------------TASK-----------------
"""
- given the following list: ["abcabcabcabc","abcabc","abababab"]
- get from the user a string as input
- print the index of the element that contains the given input - the highest times
"""
#----------------FUNCTIONS-----------------
def check(mainS,st):
rezef = 0
c... |
b192811b3bd616c6532588caecc386dbc828d22e | fossilet/leetcode | /binary_tree_inorder_traversal.py | 1,364 | 4.0625 | 4 | #! /usr/bin/env python3
"""
http://oj.leetcode.com/problems/binary-tree-inorder-traversal/
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
\
2
/
3
return [1,3,2].
Note: Recursive solution is trivial, could you do it iteratively?
... |
f61a62a147f7e35cbed00c874a998a58aa5f79a6 | muhtasimMutasim/parlay-rest-api | /tests/test.py | 5,100 | 3.546875 | 4 | #!/usr/bin/env python
"""
This script was created to test the REST API.
This script also allows text to be translated with
functionality that aut detects the language being
pushed through the
"""
import requests
import pathlib
import re
import sys
# Path of current directory script is located in
script_dir = pathl... |
407867f7cd460952eaab14ef3b2c9b1bae455822 | DaniilNesterenko/ProjectHillel | /Hillel - HW №10/Tenth_HW.py | 1,779 | 3.609375 | 4 | from random import randint
def sort(array, sum):
for k in range(len(sum) - 1):
for l in range(len(sum) - 1 - k):
if sum[l] > sum[l + 1]:
sum[l], sum[l + 1] = sum[l + 1], sum[l]
for m in range(len(array)):
array[m][l], array[m][l + 1] = array[m... |
6980449c3d292f58b8e46f87a5f63ccfea005c9f | takupaku/pythonCrashCourseCptrSeven | /deli.py | 332 | 3.828125 | 4 | sandwich_orders=['Hero', 'hoagie','submarine']
finished_sandwiches=[]
while sandwich_orders:
sandwich=sandwich_orders.pop()
print("Your "+sandwich+" sandwich has been made.")
finished_sandwiches.append(sandwich)
print("The following sandwiches have been made.")
for sand in finished_sandwiches:
... |
f7b95be5656ba3ef2d1eadd1169c919d4ad90676 | SeanHildreth/CodingDojo | /python_stack/python_fundamentals/for_loop_basic1.py | 561 | 3.546875 | 4 | for basic in range(151):
print("Number is ", basic)
fives = 5
for count in range(1000001):
print('Number is ', fives)
count += 5
for dojo in range(1,101):
... if dojo % 5 == 0 and dojo % 10 == 0:
... print('Coding Dojo')
... elif dojo % 5 == 0:
... print('Coding')
... e... |
a4561a50c251ffe264e3183b9bda08116b1d5f7e | Johnsamuel86/log_analysis-Project | /log_analysis.py | 1,460 | 3.546875 | 4 | #!/usr/bin/env python3.5
# Importing needed modules
import psycopg2
# Connection to the database
db = psycopg2.connect("dbname=news")
# Creating a cursor
with db.cursor() as c:
# Looping over the output
def loop_over_output(output):
for line in output:
print("{}: {}".format(line[0], line[1... |
1e0fae5daed82e229d3b3acba013b83b2eb568d8 | Muuuuu2011/homework2 | /homework2.py | 2,096 | 3.859375 | 4 | #要求一
def caculate(min,max):
sum = 0
nums= min
for _ in range(max+1-min):
sum = nums+sum
nums+=1
print(sum)
caculate(1,3)
caculate(4,8)
#要求二
def avg(data):
# 請用你的程式補完這個函式的區塊
employees = data['employees']
count = data['count']
sum = 0
for item ... |
507c23f29e4f1847da6d5a3498780031cbc169e4 | michelle0515/Singular-python | /homework/20210328/t1_turtle_stamp.py | 278 | 3.984375 | 4 | """
Topic:請使用turtle及loop印出下列圖形
e.g.
turtle_stamp.jpg
可利用turtle.home()會回到原點(0.0)的特性
"""
import turtle as t
i=0
a=0
t.penup()
while i<8
t.home()
t.right(a)
t.foward(150)
t.stamp()
t.speed(5)
i+=1
a+=45
t.home()
t.stamp()
|
c6ec17725fead624a1ee1ad18a5f5a0b357aad29 | AndreiR01/Recursion-Practise | /recusion stack calls.py | 850 | 4 | 4 | #We are building our own recursion stack
def sum_to_one(n):
result = 1
call_stack = []
#the below loop represents the recursive calls which lead to the base case
while n != 1:
execution_context = {"n_value": n}
call_stack.append(execution_context)
n -= 1
print(call_stack... |
8202c5d480f83249118fd7732bbc221a738ac44b | hpoleselo/TheGathering | /filter-synthesis/passive-lowpass/Source/normalizedComponents.py | 1,328 | 4.125 | 4 | from math import pi, sin
""" Simple Python program to calculate the normalized values for capacitors and inductors given the
minimum order of a Butterworth approximation. Used during Circuit Synthesis at Universidade Federal da Bahia """
def extractK(n):
# Generating the list to extract the odd and even nu... |
214462e7c0586e20525cff816232e4c500b286b9 | Madndev/myfirstproject | /factors-even-odd.py | 692 | 4.0625 | 4 | #factors of even and odd numbers
num1=int(input("enter the starting number::"))
num2=int(input("enter the last number"))
es=os=0
for i in range(num1,num2+1):
if(i%2==0):
es=es+i
print("even numbers are",i)
print("the factors of ",i,"are")
for j in range(1,i+1):
... |
c18d0373b88182ba3e104b4790bd4cb3d92ebc74 | paragshah7/Python-CodingChallenges-LeetCode | /InterviewCake/DataStructuresAlgorithms/binary_search_tree.py | 3,710 | 4.25 | 4 | """
Implement binary search tree
https://www.youtube.com/watch?v=f5dU3xoE6ms&list=PLEJyjB1oGzx3iTZvOVedkT8nZ2cG105U7&index=5
"""
from queue import Queue
import time
class Node:
def __init__(self, value=None):
self.value = value
self.left = None
self.right = None
class BST:
""" root in ... |
600e540a74a51049ad13f91dede56efe44afbbb0 | twtrubiks/leetcode-python | /Count_and_Say_038.py | 823 | 4.09375 | 4 | import itertools
'''
The count-and-say sequence is the sequence of integers with the first five terms as following:
1. 1
2. 11
3. 21
4. 1211
5. 111221
1 is read off as "one 1" or 11.
11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.
The following are the terms from ... |
b3d9854387f203d67891339aacbe8cf9cb16a337 | shubhangi2803/Practice_Python | /Exercise 9.py | 909 | 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.
# (Hint: remember to use the user input lessons from the very first exercise)
# Extras:
# 1. Keep the game going until the user types “exit”
# ... |
9ea7a37f1482ec05dbbbb07b43629fbfe8a83016 | Otavioarp/BCC-701 | /Caderno de Exercicios/4-5.py | 840 | 4 | 4 | '''
Otávio Augusto de Rezende Pinto
Email: otaviopqsi@gmail.com
'''
v=float(input(' Entre com o valor da passagem: '))
c=int(input('Entre com o número do cupom de brinde(0-3): '))
if(c==0):
vf=v
elif(c==1):
vf=95/100*v
elif(c==2):
vf=92.5/100*v
elif(c==3):
vf=90/100*v
else:
print(f'ERROR: Cupom inv... |
452661ca7646b1298c96aa72012030e55a899fa5 | bigqdel/python | /zaj3zad4.py | 318 | 3.9375 | 4 | import numpy as np
import matplotlib.pyplot as plt
#a= int(input("Podaj a: "))
a=int (1)
b=int (-3)
c= int(1)
x = np.arange(-10, 10, 1)
#x2 =np.arange (0,10,0.5)
y=(a*x*x + b*x + c)
#y2=(x2*x2/3)
plt.plot(x,y)
plt.title('f(x) = a*x^2 + b*x + c')
plt.xlabel ('x')
plt.ylabel ('y')
plt.show() |
36feb4e2077ac5eb0d75268bf34e33ec18ae748a | sting1000/ml-2018-project1- | /implementations.py | 15,726 | 4.0625 | 4 | import numpy as np
import itertools as it
import matplotlib.pyplot as plt
def calculate_predicted_labels(x, w, val=0, do_sigmoid=False):
"""
Calculate predict labels by passing in the weights calculated by the model.
:param: x: input data
:param: w: weights calculated by the model
... |
06ff544af33ce6882c7e51f24368bee4039da5f3 | Adam5-5/Python | /01_piramida2_przyklad_chr.py | 250 | 3.578125 | 4 |
#PIRAMIDA
literyList=[]
n = int(input('Podaj losc pieter: '))
for i in range (27):
literyList.append(chr(97+i))
for i in range(n):
print((n-1-i)*" "+''.join(literyList[:(i+1)]),end='')
print(''.join(reversed(literyList[:i])))
|
dffd5e8ed56953700c5fa442b7bc8d52c065cf6d | s4git21/Binary-Search-4 | /Problem-1.py | 2,934 | 3.78125 | 4 | from collections import defaultdict
"""
Approach: hash map
TC: O(n + m) ie O(n) | n -> len of larger list, len of smaller list
SC: O(m)
"""
class Solution:
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
n1 = len(nums1)
n2 = len(nums2)
if n1 < n2:
retur... |
354b50bb1e088358586b6b3ad802e0f0cec6f198 | Njokosi/python-scripts | /print_tree.py | 1,005 | 3.859375 | 4 | #!/usr/bin/python
#
# From:
#
# 5
# / \
# 2 4
# / \ \
# 8 3 5
#
# To:
#
# 5
# 2 4
# 8 3 5
class Node(object):
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def print_tree(root):
elements = []
out =... |
160598c4c98d84a65b811b0f4c3711610e93b877 | iNouvellie/python-avanzado | /01_Introducción/03_Conjuntos.py | 404 | 3.90625 | 4 | #Imprime los datos, pero como conjunto
conjunto = set ('1831')
#Se puede observar que solo muestra un 1. Y los separa en comillas
print (conjunto)
#Lo muestra como conjunto, pero realmente no lo es, ya que el 1 se repite
conjunto2 = {'1', '4', '3', '2'}
print (conjunto2)
#Interseccion (primera forma)
print (conjunto... |
5ac9d6b079bcb93afcf4c229d288a7ccd540a95a | songdanlee/python_code_basic | /day04/1my_code_tuple.py | 1,263 | 3.703125 | 4 | # 元组内元素不可变,也是有序序列
# 格式 t = ()
# 如果元组中只有一个元素,后面要加','
# 元组操作 可以连接,重复,索引,切片,遍历
t = (1, 2, 3, 4)
# print(t * 2)
# print(t, type(t))
#
# t2 = ('a','b','c','d')
# res = t + t2
# print(res)
#
# print(res[0])
# print(res[-1])
#
# print(res[::-1])
# 遍历元组
# for i in t:
# print(i)
# 求元组数字和
sum1 = 0
for i in t:
sum1 += ... |
79b3151ecf451ae27a98f1a571dea9b09468d521 | gdh756462786/Leetcode_by_python | /HashTable/FindTheDifference.py | 625 | 3.59375 | 4 | '''
Given two strings s and t which consist of only lowercase letters.
String t is generated by random shuffling string s and
then add one more letter at a random position.
Find the letter that was added in t.
'''
class Solution(object):
def findTheDifference(self, s, t):
"""
:type s: str
... |
2d97b111b2ca4f80613b29c373ebcb72b90b9784 | shreben/hometasks | /Task2_shreben.py | 1,643 | 3.671875 | 4 | import re
import operator
# =============== Task 1 ============================
keys = ['a', 'b', 'c', 'd']
values = ['1', '2', '3', '4', '5', '6', '7']
values2 = ['11', '22', '33']
def createDict(keyList, valuelist):
d = {}
for i in range(len(keyList)): d[keyList[i]] = 'None'
if len(valuelist) <= len(ke... |
2fce6e5817bcdd4df89ff7793c3dd6ef6f409214 | Cortella/Python | /Trabalho/Exercicio_2/Carro.py | 200 | 4.03125 | 4 | idade = int(input("Digite a idade do seu carro: "))
if (idade>=0) and (idade <= 3):
print("Seu carro é novo")
elif idade > 3:
print("Seu carro é velho")
else:
print("Valor invalido")
|
5972fc4e40285355325bc5a6f26eab320f58798d | xiaoqing928/leetcode | /排序/2.1荷兰国旗问题.py | 462 | 3.75 | 4 | '''
给定一个数组array和一个数num,将小于等于num的数放在数组左侧,大于的放在右侧
要求时间复杂度O(N),额外空间复杂度O(1)
'''
def swap(array, i, j):
temp = array[i]
array[i] = array[j]
array[j] = temp
array = [2,5,6,7,1,3,8,5,5]
num = 5
stat = -1 #记录左侧的边界
for i in range(len(array)):
if array[i] <= num:
stat += 1
swap(array, stat, i)
p... |
240e42ef38ad6e004af8524fe715e3ae1f81811e | danielstorey533/BookRecWebApp | /connection.py | 438 | 3.734375 | 4 | import sqlite3
def connection():
conn = sqlite3.connect('test.db', check_same_thread=False)
c = conn.cursor()
c.execute("SELECT * FROM books")
return conn, c
#conn = sqlite3.connect('test.db')
#Cursor which is used to execute SQL queries.
#c = conn.cursor()
#Wrap SQL in three quotation marks: allow... |
cdbcb6033245927977ff57389e48f3a8afc86b61 | weixiaojianghu/zhangsan | /demo01.py | 400 | 3.84375 | 4 | """
print("你好") #字符串
print(123)
print(2.33)
print(True)
print(())
print({})
print([])
print("哈哈",123,2.33)
print("哈哈"+"姐姐")
print("哈哈"*100)
name="咳咳"
print(name)
"""
# a=float(input("请输入:"))
# b=float(2input("请输入:"))
# print("内容为",a+b)
a=input("请输入一段话:")
b=input("请输入第二段话:")
print("您的话长度为",len(a)+len(b)) |
8ea21371eede4a10674189c908475950fe87c133 | SurendraGoutham/HackerRank-Solved-Problems | /ConnectingTowns.py | 763 | 3.640625 | 4 | <<<<<<< HEAD
'''
Created on 10-Feb-2015
@author: 00003179
'''
def getCitiesCount(numbers):
product = 1
for each in numbers:
product *= each
return product%1234567
T = input()
res = []
for i in range(T):
N = input()
cities = raw_input().split()
numbers = map(int, cities)
... |
5e1f9b62128469eda7a52c2bc6fcb7d10af6f580 | Harithas-developer/Python-Datastrucutres | /python datastructures and algorithms problems/fibonacci.py | 329 | 3.625 | 4 | # def fibo(n):
# if n == 0 or n==1:
# return n
# else:
# return fibo(n-1)+fibo(n-2)
# b = fibo(10)
# print(b)
# using Memonization
n =10
cache = [None]*(n+1)
def fibo(n):
if n==0 or n==1:
return n
if cache[n] != None:
return cache[n]
cache[n] = fibo(n-1) + fibo(n-2)
return cache[n]
b = fibo(10)
pr... |
82851c44daefc7b9a1130359c6289a7cd1ddd2b6 | jclippincott/Competition-Problems | /prva.py | 346 | 3.5 | 4 | vals = list(map(int,input().split()))
cols = ["" for x in range(vals[1])]
words = []
for i in range(vals[0]):
line = input()
for j in range(len(line)):
cols[j] += line[j]
words.extend([x for x in line.split("#") if len(x) > 1])
for col in cols:
words.extend([x for x in col.split("#") if len(x)... |
f345bed14e54fc27520d586b64f919e79005770d | dasien/mfc6502 | /memory.py | 3,895 | 3.5625 | 4 | class Memory(object):
def __init__(self, maximum):
# -1 means uninitialized memory. 64k allocated.
self._memmap = [0] * maximum
def readbyte(self, address):
# Retrive value from memory address.
return self._memmap[address]
def readtwobytes(self, address):
# Ret... |
054851b681af91528ccd35d7f579267920ea1d3c | elllot/Algorithms | /Graphs/LongestPathUnweighted.py | 2,003 | 3.671875 | 4 | from collections import defaultdict, deque
def makeGraph(edges):
graph = defaultdict(set)
for e in edges:
graph[e[0]].add(e[1])
graph[e[1]].add(e[0])
return graph
def BFS(G, start):
queue = deque([(start,0)])
visited = set()
V, farthest = None, 0
# find far... |
e07fa46233ff45f3969ca61c890aee14fdd2dcde | Alexvi011/CYPHugoPV | /libro/ejemplos/capitulo3/ejemplo3_2.py | 184 | 3.703125 | 4 | NOMINA=0
for i in range(1,11,1):
SUE=float(input(f"Ingresa tu sueldo trabajador {i}: "))
NOMINA+=SUE #NOMINA=NOMINA+SUE#
print(f"La nomina de la empresa es:${NOMINA}")
|
b9d2842ca3ef5197e58d5e762c4bd7be293fb25d | Farusea/project | /我的python/算法设计.py | 2,342 | 3.796875 | 4 | import time
import random
import threading
# 选择排序
def selectSort(myList):
starttime = time.time()
length = len(myList)
for i in range(0, length-1):
min = i
for j in range(i+1, length):
if myList[i]>myList[j]:
myList[i], myList[j] = myList[j], myList[i]
print("选择排序后:{0}".format(myList))
endtime = time.ti... |
16c803d87464270c597f7cfea3d408b645eaec9d | JosephSM/funPython | /Euler_py/euler3.py | 537 | 3.5 | 4 | # what is the largest prime factor of 600851475143??
from math import sqrt
def largestfactors(n):
uptonum = int(sqrt(n))
cleaned = [i for i in range(2, uptonum) if n % i == 0]
return [x for x in cleaned if x%2 != 0]
def isPrime(n):
for i in range(2, n):
if(n%i == 0):
return False
... |
2e0cb37db33ef2f412fbabc241df8546a0e166b2 | thangngoc1504/Ftech_Training | /venv/exercises.py | 9,190 | 3.6875 | 4 | print("Hello World 123")
# Exercises
#Cơ bản:
# 1.Cho hai số nguyên trả về tích nếu chúng tích nhỏ hơn 1000,nếu tích lơn hơn 1000 thì trả về tổng của chúng
# s1=lambda a,b:a*b if (a*b<1000) else (a+b)
# print("Kết quả là : ",s1(12,10))
# 2.Cho một dãy 10 số đầu tiên, Làm lại từ số đầu đến số cuối và in ra tổng của số... |
709a7fa706bf3a309195623869ca571d59bcb625 | nadimhoque/hackerrank | /Interview_Preparation_Kit/Warm-up_Challenges/Sock_Merchent/src/sockmerchant.py | 1,067 | 3.765625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the sockMerchant function below.
def sockMerchant(n, ar):
count=0
#create a new dictionary pairs. The keys will be the sock type and value is the number existing
pairs = dict()
#iterate through the array and do the fo... |
e788abe5a86d449eb534d6a17de4415adb4a5d2b | Python-aryan/Hacktoberfest2020 | /Basic Algorithms using Python.py | 4,437 | 4.03125 | 4 | # Binary Search
def binarySearch(num,arr):
beg = 0
end = len(arr)-1
while(beg<=end):
mid = (beg+end)//2
if(arr[mid]==num):
return mid
elif(arr[mid]>num):
end = mid - 1
else:
beg = mid + 1
return -1
#Binary Search Using Recursion
d... |
075c01e72d6b9561e90468c09cc4d9e2be4709d6 | sathayas/PythonClassFall2019 | /ifExamples/Password.py | 185 | 3.828125 | 4 | truePassword = 'password'
userPassword = input('Please enter the password: ')
if userPassword==truePassword:
print('Correct password entered')
else:
print('Invalid password')
|
f243b427631d6e6e9354a9516b3b6891167acae1 | rohanwarange/Python-Tutorials | /make_Flexible_Finction/Exercise1.py | 382 | 3.828125 | 4 | # define function
# input
# num,iterable(tupal,list)
# example
# num=[1,2,3]
# to_power 3
# output
# list=[1,8,27]
# if youser not pass any args then print ,message you have didnt pass any args
def cube(num,*args):
if args:
return[i**num for i in args]
else:
return "Yoy dont write anything"
n... |
5b5fa2a9547e6df8a6e8524e38153b80f626f1d5 | WonyJeong/algorithm-study | /kkxxh/basic/b83.py | 225 | 4.21875 | 4 | list1 = [1,2,3,4,5]
list2 = [1,2,3,4,5]
print(list1 is list2) # False
# is 는 식별번호의 동일성
list1 = [1,2,3,4,5]
list2 = list1
print(list1 is list2) #True
list1[2] = 9 # 3 -> 9 변경
print(list1)
print(list2) |
2d4bf827ef96a677fa6596fb61fc4b3a8940f487 | sarahcodebyte/sdsPractice1 | /q13.py | 163 | 3.859375 | 4 | S = 'Python-is-a-programming-language'
char = '-'
k = 0
while(k < len(S)):
for i in S:
if(i == char):
print(S[:k])
|
ae304fe8200c4c0b12619a9ef8e14240f10be0ba | imatyukin/python | /PythonCrashCourse/chapter_08/exercise8_06.py | 331 | 4 | 4 | #!/usr/bin/env python3
def city_country(city, country):
capital = city.title() + ", " + country.title()
return capital
capital = city_country('Santiago', 'Chile')
print(capital)
capital = city_country(country = 'Russia', city = 'Moscow')
print(capital)
capital = city_country('Ho Chi Minh City', 'Vietnam')
pri... |
520a5996e8c1c6b15f7628623015057fba3a4a5d | jcshott/udemy_python_algorithms | /russian_peasant.py | 1,102 | 4.03125 | 4 | def russian_peasant_multiplication(num1, num2):
""" My initial solution"""
# these actually don't need to be max & min, works either way.
divide_num = max(num1, num2)
multiply_num = min(num1, num2)
div_list = [divide_num]
mult_list = [multiply_num]
while divide_num > 1:
div_list.append(divide_num/2)
mult_l... |
3e0de65f5bd5e531a5cf37a098185dd0493028be | aleks225/BD | /SP/Lessons3/sp1.py | 126 | 3.828125 | 4 | a=float(input("введите A "))
n=int(input("введите N "))
b=1
while n>0:
b=b*a
n=n-1
print("итог ",b)
|
e99b0adc3ece9d873daf9552562a54bd7c7391aa | eshim/Algorithms | /Trees.py | 2,707 | 4.03125 | 4 | """
Trees
Implementation of a Binary Search Tree with associated methods.
"""
class Node:
def __init__(self, value = None, left = None, right = None):
self.left = left
self.value = value
self.right = right
@property
def isLeaf(self):
if self.left == None and self.right == None:
return True
else:
r... |
74428f426a0f97dc44b1b6253c17a8e40dbd74a3 | daddyawesome/CodingP | /Python For Everbody/py4e/ex3-1.py | 178 | 4.0625 | 4 | hrs = input("Enter Hours:")
h = float(hrs)
r = input("Enter your rate:")
rate = float(r)
if h > 40:
pay = 40*rate + (h-40) * rate * 1.5
else:
pay = h*rate
print(pay)
|
a2a8d2459bd318e1e8a127ef79d2802a9c111127 | DominicB-yte/Misc-Classwork | /test_Work09.py | 1,650 | 3.921875 | 4 | # def Addition():
# ListAdd = [1, 2, 3, 4, 5]
# sumn = 0
# for i in ListAdd:
# sumn += i
# return sumn
# print(Addition())
# def Multiplication():
# ListMul = [1, 2, 3, 4, 5]
# sumn = 1
# for i in ListMul:
# sumn = sumn * i
# return sumn
# print(Multiplication())
# de... |
442efb54457c3bdf93c1c19c52534eb8aadc6063 | Exia01/Python | /Self-Learning/functions/exercises/unpacking_exercise.py | 1,168 | 3.875 | 4 | # with the given function call it twice
def count_sevens(*args):
return args.count(7)
#first time pass arguments 1,2,4 or 1,4,7 second time pass the list below:
nums = [90,1,35,67,89,20,3,1,2,3,4,5,6,9,34,46,57,68,79,12,23,34,55,1,90,54,34,76,8,23,34,45,56,67,78,12,23,34,45,56,67,768,23,4,5,6,7,8,9,12,34,14,15,16,... |
5decb31d37be5741b27c3640deff24d9cceee4a1 | nimab16/MySql-in-python | /src/model/customer.py | 950 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 30 13:59:12 2021
@author: Nima
"""
class Customer:
def __init__ (self, Num_Customer: int = 0, Name: str = '', City: str = ''):
self._Num_Customer = Num_Customer
self._Name = Name
self._City = City
@property... |
e60de601cf87cf5458bdee70bd8582cd42ad5157 | AishaGhayas/Artificial-Intelligence | /bookexercises/csvpractice.py | 178 | 3.75 | 4 | import csv
with open("data.csv") as f:
a = csv.reader(f)
l = []
for i in a:
l += i
print(l)
q = l.index("2005")
q += 1
print("month of 2005 is", l[q])
|
1cc201c88b3efe058f90adee7d4976a36b4bdfd1 | solomonli/PycharmProjects | /The Absolute Basics/Chapter 2/Section 3.py | 564 | 3.859375 | 4 | __author__ = 'phil'
added = 40 + 2
subtracted = 100 - 50.5
multiplied = 3.142 * 4.5
divided = 4 / 2
print(added, subtracted, multiplied, divided)
# Keep final value as an integer
divided_int = 4 // 2
print(divided_int)
# Modulo
divided_mod = 7 % 3
print(divided_mod)
# Building statements
print(4 * 86)
print(divide... |
be4cbbd81c8a424dddf51ef1ca062a675ab61ddc | pashatsyganenko/main | /2021-10/codeforces/996A.py | 318 | 3.921875 | 4 | def f(x):
if x >= 100:
return int(x/100) + f(x%100)
elif x >= 20:
return int(x/20) + f(x%20)
elif x >= 10:
return int(x/10) + f(x%10)
elif x >= 5:
return int(x/5) + f(x%5)
else:
return x
print(f(int(input())))
|
3f6b07cc49719148da69ea05667758099da1a3b3 | Binteldata/python-intro | /for.py | 279 | 4.375 | 4 | for i in range(0, 3):
print(i)
for a in range(0, 3):
print('...hello')
my_list = [1, 2, 3, 4, 5]
for i in my_list:
print(i)
print('-hut')
for i in range(0, 10, 2):
print(i)
print('>hello')
string = 'hi '
for i in string:
print(i)
print('hi') |
c2132d02f4af639a2e09715fb7967ecbd1e475d1 | brenolemes/exercicios-python | /exercicios/CursoemVídeo/ex063.py | 422 | 4.21875 | 4 | '''
Escreva um programa que leia um número n inteiro qualquer e mostre na tela os n
primeiros elementos de uma sequência de fibonacci.
ex:
0 >> 1 >> 1 >> 2 >> 3 >> 5 >> 8
'''
t1 = 0
t2 = 1
cont = 3
n = int(input('Quantos termos de fibonacci você quer que mostre? '))
print(f'{t1} >> {t2} ', end='')
while cont <= n:
... |
2441a71e1672ee1a7606428edc52fa9af3ea76fb | FreeFlyXiaoMa/personal_project | /test1.py | 3,561 | 4 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/12/18 21:07
# @Author : Ma
# @File : test1.py
# @Software: PyCharm
arr=[]
def quick_sort(arr):
if len(arr) < 2: return arr
mid = arr[len(arr) // 2] # 基准值
left, right = [], [] # 定义左右两个子列
arr.pop(len(arr) // 2) # 去掉这个基准值
for ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.