blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
55c5746789509bff263142b162e84ff4fb33bda9 | ImJoaoPedro/RaspArd-FireFighter | /TestStuff/Rasp+ArdComms.py | 1,364 | 3.53125 | 4 | import smbus
import time
import io
import fcntl
# for RPI version 1, use “bus = smbus.SMBus(0)”
bus = smbus.SMBus(1)
# This is the address we setup in the Arduino Program
address = 0x04
def writeNumber(value):
bus.write_byte(address, value)
# bus.write_byte_data(address, 0, value)
return -1
def readNumb... |
74322d334ba92809d050b0fd960880622597e5de | LeonMac/Principles-of-Data-Science_forPython3 | /Test_Matrix.py | 476 | 3.515625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
x=np.array([3,6,8])
y=np.array([4,7,0])
multi=x*y
add =x+y
sub =x-y
dot =x.dot(y)
dot_1=y.dot(x)
cross=np.cross(x,y)
cross_1=np.cross(y,x)
print ('x = ',x)
print ('y = ',y)
print ('\n')
print ('x+y = ',add)
print ('x-y = ',su... |
09b9854b9578e862107747778f65e94e36455bd0 | tiagosouza1984/ADS_2D_LPII | /com/tiago/hackerRank01.py | 565 | 3.90625 | 4 | import re
for i in range (int(input())):
var_1 = input()
passUpper = 0
passNum = 0
flag = False
if var_1.isalnum() and len(var_1) == 10 :
for i in var_1:
if i.isupper():
passUpper+=1
if i.isnumeric():
passNum+=1
if var_1.cou... |
48f81ee68b1150c34bb8d7b99c4148723c2e8334 | gtoutin/gt6422-coe332 | /midterm/generate_animals.py | 1,512 | 3.640625 | 4 | #!/usr/bin/env python3
# Author: Gabrielle Toutin
# Date: 1/27/2021
# Homework 1
import petname
import random
import json
import uuid
import datetime
#animals = { "animals": [] } # initialize animals dictionary
animals = []
heads = ["snake", "bull", "lion", "raven", "bunny"] # get head choices
bodies = petn... |
48796c87e55fa3f45b0f90334b4b38f49f4e3675 | Ksaur12/Link_finder | /links in links.py | 1,313 | 4.09375 | 4 | import urllib.request, urllib.parse, urllib.error
import re
import ssl
#Made by Ksaur12
print('''You can use this program to find links in a webpage, the links can be used for downloading
For example:''')
print(' If you want to download something but')
print(' the website keep your see ads, ')
print(' th... |
ae0a22b8754a7bb813605c0ec2c1eee29fef6263 | bimalka98/Data-Structures-and-Algorithms | /Mini-xtreme-2021/Answers/Drone.py | 1,080 | 3.59375 | 4 | def check_order(dest, order):
countL=0
countR=0
countU=0
countD=0
for i in order:
if i=='L':
countL+=1
if i=='R':
countR+=1
if i=='U':
countU+=1
if i=='D':
countD+=1
# print("... |
b4bde21241f2bb9e7ef018f4a480ff3ba601584c | 4ON91/MathNotes_and_3D-related-scripts | /Linux/Python/Math Notes/Basic Square Root Algorithm.py | 810 | 3.921875 | 4 | #https://youtu.be/rAuoJCiPiGU
#based on this youtube video on how to do square roots without a calculator
#Only works with integer values
def SquareRootAlgorithm(VARIABLE):
for i in range(0, VARIABLE+1):
if( pow(i,2) >= VARIABLE):
MULTIPLE = i-1
PROBLEM = VARIABLE-pow(i-1,2)
... |
0281da2e0ae0faf2a060eab924d71a1e37ebfe51 | JamesALin/2020-Classes | /edxbasics/problems2.py | 162 | 3.953125 | 4 | print('Please enter a number from the hex number system: ')
user = input()
output_sentence = 'The decimal number for ' + str(int(user, 16))
print(output_sentence) |
529992c5ac16bfefa9db7b50d35ae0b45541975f | Oindry/Pythin-Basics | /L20_practice.py | 159 | 3.609375 | 4 | numbs=[1,2,3,4,5,6,7,8,9,10]
square=numbs.copy()
for i in numbs:
print(numbs[i])
square[i] = numbs[i]**2
print(square[i])
print("s",square)
|
2bf1624de15ab8bffac86c21b49709b541143681 | theXYZT/codejam-2018 | /Practice Session/steed-2-cruise-control.py | 858 | 3.734375 | 4 | # Codejam 2018, Practice Session: Steed 2: Cruise Control
class Horse():
"""Class for Horse."""
def __init__(self, position, speed, destination):
self.position = position
self.speed = speed
self.time_to_destination = (destination - self.position) / self.speed
def find_max_speed(horses... |
db6d2b8ef699f5b36d9af4be7cd3e047915ff962 | RyanLongRoad/Functions | /Currency converter.py | 1,061 | 4.09375 | 4 | #Ryan Cox
#02/12/14
#Currency converter
def information():
print("Please enter the currency you have out of: GBP, USD or EURO: ")
currency = input("Please enter the currency you have that you wish to convert: ")
amount = int(input("how much do you have?"))
return currency, amount
def choice(currency, ... |
c75ed9f79dd1cecf3fe937751a11f0ac5493407a | daliborstakic/randwiki-python | /gui_rand.py | 510 | 3.78125 | 4 | """ Importing Tkinter """
import tkinter as tk
from tkinter import Button, Label
from wiki_app import *
# Main root window
root = tk.Tk()
root.title("Randow Wikipedia Article")
# Label
button_label = Label(root, text="Press the button to generate a Wikipedia page")
# Button
gen_button = Button(root, text="Generate"... |
651ab949cb32a9428fee502ff5c5e7d0232e6401 | saemideluxe/adventofcode_2017 | /9.py | 645 | 3.515625 | 4 | with open('input') as f:
_in = f.read().strip()
score = 0
level = 0
ignorenext = False
ingarbage = False
garbage = 0
for c in _in:
if not ingarbage:
if c == '{':
level += 1
elif c == '}':
score += level
level -= 1
elif c == '<':
ingarbage... |
380f26309294df9ec90109b61b57c4353c2d4d72 | Mpendulo1/Error-Handling | /main.py | 1,672 | 3.71875 | 4 | from tkinter import *
root = Tk()
root.title('Login Center')
root.geometry("600x600")
root.config(bg="OrangeRed2")
# Creating a widgets
l1 = Label(root, text='Login Details:', bg='OrangeRed2', fg='honeydew', font=('Arial', 20, 'bold'))
l1.place(x=120, y=10)
# Username
l2 = Label(root, text='Enter Username : ', bg='Or... |
ffe24156489d5063ee564b1b5c558585363a7944 | directornicm/python | /Project_4.py | 572 | 4.28125 | 4 | # To calculate leap year:
# A leap year is a year which is divisible by 4 but ...
# if it is divisible by 100, it must be divisible by 400.
# indentation matters - take care of it
year = int(input("Give the year to be checked for leap year"))
if year % 4 == 0:
if year % 100 == 0:
if year % 400 ==... |
e0d2ea85430376143f9401e1742311bf4f5e6c1e | sthapliyal37/my_Programs | /repetitions.py | 190 | 3.71875 | 4 | string=input()
maximum=0
count=1
for i in range(len(string)-1):
if string[i]==string[i+1]:
count+=1
else:
maximum=max(count,maximum)
count=1
#print(count)
print(max(maximum,count))
|
a03f5cdd70d061ba507a45d3560e624349146e5c | sthapliyal37/my_Programs | /binary.py | 616 | 3.625 | 4 |
def count_changes(string,n):
count=0
sum_s=0
#for i in range(n):
# sum_s+=int(string[i])
x=int(string,2)
sum_s=int(bin(x).count('1'))
if(sum_s==0):
count=(len(string)/n)
elif(sum_s!=len(string)):
p=string[0:n]
x=int(p,2)
sum_s=int(bin(x).count('1'))
if(sum_s==0):
count+=1
sum_s=1
string=stri... |
2ddaf7038f2a8c696f36d55c4ecaa6e740b415c8 | RayanSt/SingletonMultiHilos | /Hilos.py | 675 | 3.859375 | 4 | import threading
class Singleton(object):
_instance = None
def __new__(self):
self.lock.acquire()
if not self._instance:
self._instance = super(Singleton, self).__new__(self)
return self._instance
self.lock.release()
def Accion(accion):
for vuelta in ... |
e7f908a2eb4199049c3e408ee9f97bceb0356966 | ally17/assignments | /assignment6.py | 226 | 3.65625 | 4 | n = 100
prime_list = []
for i in range(1, n + 1):
count = 0
for j in range(1, i + 1):
if i % j == 0:
count += 1
if (count < 3) and (i != 1):
prime_list.append(i)
print(prime_list)
|
a9c78ffcc211b5250aca8ce492dab0cabfb0a4be | msa190/pydraw | /Circle.py | 483 | 3.5 | 4 | from Vector import *
from Curve import Curve
class Circle(Curve):
#Center
C=Vector([0.0,0.0])
#Radius
r=0.0
def __init__(self,r=1.0,C=None,NP=0):
if (C): self.C=C
if (NP): self.NP=NP
self.r=r
self.Closed=True
return
def R(self,t... |
918c516681dbcf0a4bfcca706a7037a0fef2f97b | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-Arianna0206 | /Trabajo02/Ejercicio10.py | 125 | 3.765625 | 4 | """
Ejemplo17
"""
nombre = str(input("Ingrese el nombre de la persona: "))
print("El nombre ingresado es %s\n" % nombre) |
f4f5cc063109a82ef9d6183ef1a8478544533574 | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-Arianna0206 | /Trabajo05/Ejemplo09.py | 299 | 3.703125 | 4 | """
Ejemplo13
"""
numerador = 1
denominador = 1
contador = 1
while(contador <= 5):
if((contador % 2)==0):
print("%s%d/%d" % ("-", numerador,denominador)
else:
print("%s%d/%d" % ("+", numerador,denominador)
contador = contador + 1
denominador = denominador + 2
|
7e5f120cc287f73d161a88e62f972df9d1676b13 | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-Arianna0206 | /Trabajo05/Ejemplo10.py | 201 | 3.765625 | 4 | """
Ejemplo14
"""
bandera = True
salir = ""
while(bandera):
salir = str(input("Desea salir del ciclo; digite: si: "))
salir = salir.lower()
if(salir == "si"):
bandera = False
|
6b477349143e3f91d8e85698faa71af16e0d1ab0 | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-Arianna0206 | /Trabajo04/Ejemplo07.py | 223 | 3.703125 | 4 | """
Ejemplo12
"""
contador = 1
while contador <= 10:
if (contador%2)==0:
print("El número %d es par\n" % contador)
else:
print("El número %d es impar\n" % contador)
contador = contador + 1 |
6ed204b50af3dd7d8058e0abafe05449ba6c28e2 | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-Arianna0206 | /Trabajo05/Ejemplo22.py | 196 | 3.65625 | 4 | """
Ejemplo22
"""
tabla = int(input("Ingrese la tabla a generar: "))
for i in range(5,30,contador++):
operacion = tabla * contador
print("%d * %d = %d\n" % (tabla,contador,operacion)) |
e14e55d0194aa92952b05410d8ffffd19ee0fe94 | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-Arianna0206 | /Trabajo02/Ejemplo05.py | 215 | 3.609375 | 4 | """
Ejemplo10
"""
nombreEstudiante = str("Arianna Marikrys")
apellidoEstudiante = str("Ramón Ramón")
nacimiento = str("2001")
print(nombreEstudiante+"\n\n"+apellidoEstudiante)
print(nombreEstudiante+"\t"+apellidoEstudiante) |
3fcb2c95de85a8103b36d601c8f555401b7008e0 | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-Arianna0206 | /Trabajo01/Ejercicio10.py | 122 | 3.625 | 4 | """
Ejercicio10
Salida de datos
"""
import math
print((math.sqrt(25)*10)>=100 and (True) or (False) or (10/5 >=2))
|
f505b186498a023cfd306f319ce810150b45f175 | elioenas/Python | /Estrutura de repeticao/For e Range/Votos.py | 733 | 4.09375 | 4 | """Numa eleição existem três candidatos.
Faça um programa que peça o número total de eleitores.
Peça para cada eleitor votar e ao final mostrar o número de votos
de cada candidato."""
"""criar a variavel"""
eleitores = int(input('numero de eleitores:'))
votos =[]
"""um for onde o ira contar numero de eleit... |
ffed5af17f0fad7393a2928b9e545d415ab8f83e | peruguanvesh/Assignment | /divisible.py | 210 | 3.515625 | 4 | def func_multiples(begin,end):
output_values=[]
for j in range(begin,end+1):
if j%7 == 0 and j%5 != 0:
output_values.append(str(j))
return ','.join(output_values)
print(func_multiples(3000,5300))
|
b0beed001a2b92c2770e863690799397ce682581 | kkowalsks/CS362-Homework-7 | /leapyear.py | 603 | 4.1875 | 4 | def leapCheck(int):
if int % 4 != 0:
int = str(int)
print(int + " is not a leap year")
return False
else:
if int % 100 != 0:
int = str(int)
print(int + " is a leap year")
return True
else:
if int % 400 != 0:
... |
60a933754cf205750439a80ab4357dd3e60ce389 | CruzerNexus/Repo | /pythonFullStack/simpleCalculator.py | 414 | 4.09375 | 4 | def calculator(x, y, z):
if x == ("+"):
return y + z
elif x == ("-"):
return y - z
elif x == ("*"):
return y * z
else:
return y / z
x = input("Welcome! What opperation would you like to preform (+, -, *, /)? ")
y = input("What is the first number? ")
y = float(y)
z = in... |
96a99e284e212fdc90eb117a02849b60e8fb451d | CruzerNexus/Repo | /pythonFullStack/pick6.py | 965 | 3.609375 | 4 | import random
def pick6():
randCount = 0
lotto = []
while randCount < 6:
lotto.append(random.randint(1,99))
randCount += 1
return lotto
def num_matches(lotto, ticket):
winnings = 0
for i in range(len(lotto)):
if lotto[i] == ticket[i]:
winnings += 1
return winnings
balance = 0
winBalance = 0
tryCount ... |
0a1fc80a2fafb907673599e2b4d42939d6aec372 | CruzerNexus/Repo | /pythonFullStack/rotCipher.py | 947 | 3.53125 | 4 | userLetter = ['a', 'b', 'c', 'd', "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
cipherLetter = ["n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", 'a', 'b', 'c', 'd', "e", "f", "g", "h", "i", "j", "k", "l", "m"]
def encode(userInput):
pcO... |
92f0e2b6757f6b812e9e7c5e6477ee121507b440 | CruzerNexus/Repo | /pythonFullStack/spythonMadLib.py | 1,599 | 3.734375 | 4 | madlib = ""
a = input("Verb ending in 'ing': ")
madlib += f"Espionage is the formal word for {a}. "
b = input("Adjective: ")
madlib += f"In the shadowy world of spies, a/an {b} organization like the US government "
c = input("Adjective: ")
madlib += f"uses spies to infiltrate {c} groups "
d = input("Plural Noun: ")
mad... |
d0c948552ba6d559aac56c2970d3dc110ad40a9c | CruzerNexus/Repo | /pythonFullStack/numberToPhrase.py | 1,058 | 3.953125 | 4 | ones = {1: "one", 2: "two", 3: "three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine"}
tens = {2: "twenty", 3: "thirty", 4: "fourty", 5: "fifty", 6: "sixty", 7: "seventy", 8: "eighty", 9: "ninety"}
def intToEng(x):
word = ""
if x == "10":
return("ten")
elif x == "11":
return("eleven")
elif ... |
a7852816dd48f6c67888180eb9be6489fa8b2c78 | mahack-gis/GISProgramming6345_WK5 | /Exercise 9.1_redo.py | 592 | 3.734375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
file = open('words.txt', 'r') #locates the file and 'r' reads each line
f = file.readlines()
#print(f)
# In[4]:
newList = [] #creates an empty list
for line in f:
if line[-1] == '\n':
newList.append(line[:-1])
else:
newList.append(... |
76262d582cce4a4d8cd821ea35b0ff9cea1b7a17 | mahack-gis/GISProgramming6345_WK5 | /Exercise 9.2_redo.py | 1,794 | 3.953125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
def has_no_e(word): #creates a function called has_no_e
for letter in word: #traverses each letter in word
if letter == 'e': #if the letter is 'e' returns False
return False
return True #else it returns true
#... |
a168748c4be85b53e6f97007b0b6e20d332833dd | pokoli/adventofcode2020 | /day1/resolve.py | 645 | 3.53125 | 4 | import os
from itertools import combinations
expenses = []
with open(os.path.join('.', 'input.txt')) as f:
for line in f.readlines():
expenses.append(int(line))
for a, b in combinations(expenses, 2):
if a + b == 2020:
print('Found two numbers ({a}, {b}) that sum 2020'.format(**locals()))
... |
76759518bd53b697e0b7592d04df04ed5b1af2aa | goldandelion/learn-python | /ex3.py | 812 | 4.0625 | 4 | # -*- coding:utf-8 -*-
# 每个程序媛都有把程序写优雅的义务
print "I will now count my chickens:"
print "Hens",25+30/6 # 30除以6是5 25加5是30
print "Roosters",100-25*3%4 # 25乘3是75 75除4的余数是3 100减3是97
print "Now I will count the eggs:", 3+2+1-5+4%2-1/4+6
print "Is it true that 3+2<5-7 ?"
print 3+2 < 5-7
print "What is 3+2?",3+2
print "Wha... |
67eb2e0043b1c1d63395df0de8f4e39a98930a7e | luthraG/ds-algo-war | /general-practice/17_09_2019/p16.py | 996 | 4.1875 | 4 | '''
Given a non-empty string check if it can be constructed by taking a substring of it and
appending multiple copies of the substring together.
You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.
Example 1:
Input: "abab"
Output: ... |
a5a7621f089aeef12a7b1d304f904a012a90d5db | luthraG/ds-algo-war | /general-practice/10_09_2019/p10.py | 528 | 3.890625 | 4 | import operator
import re
ops = {
'+': operator.add,
'-': operator.sub
}
pattern = re.compile(r'([0-9]+)([+-]*)')
expression = str(input('Enter mathematical expression containing plueses and minues :: '))
stack = 0
operation = None
for number, operator in re.findall(pattern, expression):
if operation:
... |
2e0b50d0d233545a278ca3874bf2523da2d2ddbd | luthraG/ds-algo-war | /problems/leet/string/p1.py | 1,573 | 3.75 | 4 |
'''
https://leetcode.com/problems/roman-to-integer/
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the... |
b5a690bcf29a1d7227d20a1db56e5ce1afee3fc1 | luthraG/ds-algo-war | /general-practice/22_08_2019/p6.py | 1,412 | 3.953125 | 4 | # coding: utf-8
'''
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10 001st prime number?
Algorithm is based on idea that prime numbers are always of the form 6*k + 1
So we would only check those numbers which can be expressed in 6*k + 1 form
'''
from... |
3316019f3994b8404396a16cfeac53ce0bb3a82d | luthraG/ds-algo-war | /general-practice/28_08_2019/p6.py | 1,340 | 3.703125 | 4 | from timeit import default_timer as timer
import math
def rwh_prime(upper_bound, number):
primes = [True] * upper_bound
primes[0] = False
primes[1] = False
i = 3
limit = int(upper_bound ** 0.5) + 1
while i <= limit:
if primes[i]:
primes[i*i::2*i] = [False] * ((upper_bound-... |
dd67cc4be7876eb5b448ca6cb7d1e9b1263d0eb0 | luthraG/ds-algo-war | /general-practice/28_08_2019/p1.py | 708 | 3.859375 | 4 | from timeit import default_timer as timer
if __name__ == '__main__':
test_cases = int(input('Enter test cases :: '))
for t in range(test_cases):
number = int(input('Enter number :: '))
start = timer()
# since we need multiples below
number -= 1
mux3 = number // 3
... |
fea3eb8962250ac66a1d519c751f53e1f5119379 | luthraG/ds-algo-war | /general-practice/11_09_2019/p6.py | 1,163 | 3.9375 | 4 | '''
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10001st prime number?
'''
from timeit import default_timer as timer
import math
def prime_rwh(upper_limit, number):
primes = [True]* upper_limit
primes[0] = False
primes[1] = False... |
31ea62752ea462b775c16a6a7a1f0fb61d8eecc8 | luthraG/ds-algo-war | /general-practice/24_08_2019/p5.py | 1,069 | 4.0625 | 4 | '''
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes not greater than given N.
Input Format
The first line contains an integer T i.e. number of the test cases.
The next T lines will contains an integer N.
Constraints
1 <= T <= 10^4
1 <= N <= 10^6... |
c970b948cc1ceaff2b10aedd36807e277b69ff98 | luthraG/ds-algo-war | /general-practice/11_09_2019/p22.py | 509 | 3.84375 | 4 | import operator
import re
ops = {
'+': operator.add,
'-': operator.sub
}
expression = str(input('Enter mathematical expression(containing pluses and minues) :: '))
pattern = re.compile(r'([0-9])+([+-])*')
operation = None
stack = 1
for number, op in re.findall(pattern, expression):
if operation:
... |
9ad1b5b8b960b7a144624a8f77de063b758fe7a7 | luthraG/ds-algo-war | /general-practice/22_08_2019/p13.py | 1,200 | 3.90625 | 4 | # coding: utf-8
'''
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
Algorithm 4:: Use prime decompositions
'''
from timeit import... |
bd48564a03e15ec4c6f2d287ec3b651947418118 | luthraG/ds-algo-war | /general-practice/20_08_2019/p1.py | 861 | 4.125 | 4 | # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
# The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 10 Million.
from timeit import default_timer as timer
if __name__ == '__main__':
start = timer()
number = 1000
# Since... |
2232e32a65b40db29c0004e11d449da832d2cf39 | luthraG/ds-algo-war | /problems/euler/p10/solution.py | 603 | 4.0625 | 4 | from timeit import default_timer as timer
import math
def isPrime(number):
if number % 2 == 0 and number != 2:
return False
for x in range(3, int(math.sqrt(number)) + 1, 2):
if number % x == 0:
return False
return True
if __name__ == '__main__':
start = timer()
numbe... |
3ec6fd0dcd97904b08c95fe17cac67b03a75a61f | luthraG/ds-algo-war | /general-practice/11_09_2019/p11.py | 648 | 4.15625 | 4 | '''
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 2^1000?
'''
from timeit import default_timer as timer
power = int(input('Enter the power that needs to be raised to base 2 :: '))
start = timer()
sum_of_digits = 0
number = 2 << (power - 1)
numb... |
ddc31bfd69d17e5f07a602d330ed39b644d0a372 | luthraG/ds-algo-war | /problems/hackerrank/competition/euler/solution2.py | 733 | 3.96875 | 4 | from timeit import default_timer as timer
if __name__ == '__main__':
number = int(input("Enter the upper limit of number :: "))
start = timer()
addition = 0
sequence = [1, 2]
term = 0
if number <= 1:
sequence = []
# Let us add value of 2
addition = addition + 2
while term... |
56a73740d003c13f2c8f0ad569fd6afbfd2c6b78 | luthraG/ds-algo-war | /problems/euler/p2/solution.py | 735 | 3.78125 | 4 | from timeit import default_timer as timer
def additionFabonacii(limit):
sequence = [1, 2]
term = 0
addition = 0
if limit > 0:
addition = addition + 2
while term < limit:
length = len(sequence)
term = sequence[length - 1] + sequence[length - 2]
if term < limit:
... |
33f5c2d803562730098d3b4393d5843d9d2f9d4a | luthraG/ds-algo-war | /general-practice/14_09_2019/p18.py | 1,586 | 4.34375 | 4 | '''
https://leetcode.com/problems/unique-email-addresses/
Every email consists of a local name and a domain name, separated by the @ sign.
For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name.
Besides lowercase letters, these emails may contain '.'s or '+'s.... |
743148624d001ae5c9bbea10f8d70b7074e9ddb0 | luthraG/ds-algo-war | /general-practice/10_09_2019/p20.py | 450 | 4.0625 | 4 | '''
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 2^1000?
'''
from timeit import default_timer as timer
number = int(input('Enter power :: '))
start = timer()
exp = 2 << (number - 1)
sum = 0
while exp != 0:
sum += (exp % 10)
exp //= 10... |
72fd0e2052800e60a55b2bfeca7a54eee9aa59f6 | luthraG/ds-algo-war | /general-practice/11_09_2019/p16.py | 481 | 3.8125 | 4 | class ArraySetOps:
def mean(self, items):
length = len(items)
sum_of_items = 0
for item in items:
sum_of_items += item
return (sum_of_items / length)
if __name__ == '__main__':
arraySetOps = ArraySetOps()
numbers = str(input('Enter list of numbers(separa... |
2016817647c32c5e148437225c826b39f2ce8ee4 | luthraG/ds-algo-war | /general-practice/10_09_2019/p3.py | 2,228 | 4.125 | 4 | class Node:
def __init__(self, data = None):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.start_node = Node()
def add_to_start(self, data):
node = Node(data)
node.next = self.start_node.next
self.start_node.next = node
... |
07e1d267b9b5d0dadb0e2b797a40ae148ba695a5 | luthraG/ds-algo-war | /general-practice/28_08_2019/p8.py | 973 | 3.796875 | 4 | from timeit import default_timer as timer
def sumOfPrimes(number):
number += 1 # Since we want primes equal to number
primes = [True] * number
sum = [0] * number
i = 3
limit = int(number ** 0.5) + 1
while i <= limit:
if primes[i]:
primes[i*i::2*i] = [False] * (((number - i... |
d331095ee862fa325c24109df312a94f269af343 | luthraG/ds-algo-war | /sorting/quickSort.py | 1,136 | 3.875 | 4 | from timeit import default_timer as timer
def partition(input, low, high):
# print("low {} and high {}".format(low, high))
i = low - 1 # Index of smaller element
pivot = input[high]
j = low # loop variable
while j < high:
elem = input[j]
if elem <= pivot:
# Increment th... |
b3aaf2652c1cfda99a9c3b3c8e1d7d47b358abb4 | luthraG/ds-algo-war | /general-practice/18_09_2019/p12.py | 1,035 | 4.15625 | 4 | '''
Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string "".
Example 1:
Input: ["flower","flow","flight"]
Output: "fl"
Example 2:
Input: ["dog","racecar","car"]
Output: ""
Explanation: There is... |
65fa7232117759419f49d208b8bcd19e9c35e064 | Throrus/Calculator | /calculator.py | 5,876 | 4 | 4 | import tkinter as tk
from tkinter import font
# window setup
window = tk.Tk()
window.title("Calculator")
window.geometry('500x500')
window.resizable(0, 0)
# setting up the grid
rows = 0
while rows < 5:
window.rowconfigure(rows, weight=1)
window.columnconfigure(rows,weight=1)
rows += 1
# f... |
06840ed3effeba83a48b27d1b9f5fdce3b940f82 | hluaces/cntg-python | /practicas/Ejercicios complementarios 1/programs/ej7.py | 603 | 4 | 4 | #!/usr/bin/env python
def _get_input():
words = []
while len(words) == 0:
x = input("Imprime una lista de palabras separadas por espacios: ")
y = [x.strip() for x in x.split(' ')]
if len(y) == 1 and y[0] == '':
print("Entrada inválida.")
continue
words... |
95766d349262a1517cd3d4dee2470e92d39011a7 | hluaces/cntg-python | /practicas/Ejercicios complementarios 2/ej13.py | 188 | 3.625 | 4 | #!/usr/bin/env python
def main():
x = input("Introduce texto:")
if x.lower() == "yes":
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
|
0150bb0f24cece88f5dd912701d927e30af20439 | kubeflow/testing | /py/kubeflow/testing/yaml_util.py | 482 | 3.515625 | 4 | """YAML utilities
"""
import requests
import urllib
import yaml
def load_file(path):
"""Load a YAML file.
Args:
path: Path to the YAML file; can be a local path or http URL
Returs:
data: The parsed YAML.
"""
url_for_spec = urllib.parse.urlparse(path)
if url_for_spec.scheme in ["http", "https"]:
... |
df6f00a9ec76db2997df11d0e31f7f448bacd7fc | arifaulakh/Competitive-Programming | /DMOJ/dealing_with_knots/main.py | 430 | 3.546875 | 4 | G = {}
for i in range(1,1003):
G[i] = set()
visited = [False for i in range(1003)]
def dfs(graph, node):
if visited[node]==True:
return
visited[node] = True
for v in G[node]:
dfs(graph, v)
N = int(input())
for i in range(N):
a, b = map(int, input().split())
G[a].add(b)
X, Y = m... |
bc8beb8ee2874764216e03c0467f0ef776a96721 | arifaulakh/Competitive-Programming | /DMOJ/bruno_and_trig/brunoandtrig.py | 227 | 3.796875 | 4 | a = int(input())
b = int(input())
c = int(input())
x = []
x.append(a)
x.append(b)
x.append(c)
x.sort()
if x[0] + x[1] > x[2]:
print("Huh? A triangle?")
elif x[0] + x[1] <= x[2]:
print("Maybe I should go out to sea...")
|
5ebb5fe066d3af6b3467c61f030497ae7c889e2f | arifaulakh/Competitive-Programming | /DMOJ/deficient_abundant_perfect/deficientabundantperfect.py | 361 | 3.71875 | 4 | n = int(input())
for i in range(0,n):
count = 0
each = int(input())
for j in range(1, each + 1):
if each%j == 0 and each != j:
count +=j
if count == each:
print(str(each) + " is a perfect number.")
elif count > each:
print(str(each) + " is an abundant number.")
elif count < each:
prin... |
b2657646e162f2ada6cb62bae50bd8e894591865 | arifaulakh/Competitive-Programming | /DMOJ/interlace_cypher/main.py | 140 | 3.734375 | 4 | for i in range(10):
n = input()
if n=="encode":
p = input().split(" ")
print(p)
elif n=="decode":
p = input().split(" ")
print(p) |
6d53601a7fc6a0c2fb2e35f5685770bd5e771798 | stollcode/GameDev | /game_dev_oop_ex1.py | 2,829 | 4.34375 | 4 | """
Game_dev_oop_ex1
Attributes: Each class below, has at least one attribute defined. They hold
data for each object created from the class.
The self keyword: The first parameter of each method created in a Python program
must be "self". Self... |
0f227ae102e644024608c93a33dac90b39f2dcb9 | greenblues1190/Python-Algorithm | /LeetCode/14. 비트 조작/393-utf-8-validation.py | 1,893 | 4.15625 | 4 | # https://leetcode.com/problems/utf-8-validation/
# Given an integer array data representing the data, return whether it is a valid UTF-8 encoding.
# A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:
# For a 1-byte character, the first bit is a 0, followed by its Unicode code.
# Fo... |
56ead187d3484a44effec2bbe6b3b3835a42e87f | greenblues1190/Python-Algorithm | /LeetCode/18. 다이나믹 프로그래밍/53-maximum-subarray.py | 628 | 3.921875 | 4 | # https://leetcode.com/problems/maximum-subarray/
# Given an integer array nums, find the contiguous subarray(containing at least one number)
# which has the largest sum and return its sum.
# A subarray is a contiguous part of an array.
# Constraints:
# 1 <= nums.length <= 3 * 104
# -105 <= nums[i] <= 105
from ty... |
d220f727d9ae11f1f6add855328aeb8c98e98aa3 | greenblues1190/Python-Algorithm | /LeetCode/18. 다이나믹 프로그래밍/509-fibonacci-number.py | 1,147 | 3.734375 | 4 | # https://leetcode.com/problems/fibonacci-number/
# The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence,
# such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,
# F(0) = 0, F(1) = 1
# F(n) = F(n - 1) + F(n - 2), for n > 1.
# Given n, calcul... |
800919799222a6c3a4952517b1ceb6d456e7ed4b | greenblues1190/Python-Algorithm | /LeetCode/16. 그리디 알고리즘/455-assign-cookies.py | 994 | 3.640625 | 4 | # https://leetcode.com/problems/assign-cookies/
# Assume you are an awesome parent and want to give your children some cookies.
# But, you should give each child at most one cookie.
# Each child i has a greed factor g[i], which is the minimum size of a cookie\
# that the child will be content with; and each cookie j ... |
94aee979799f19ca2c565a953db0ae0ab2554ffa | greenblues1190/Python-Algorithm | /LeetCode/15. 슬라이딩 윈도우/424-longest-repeating-character-replacement.py | 956 | 3.515625 | 4 | # https://leetcode.com/problems/longest-repeating-character-replacement/
# You are given a string s and an integer k. You can choose any character of
# the string and change it to any other uppercase English character.
# You can perform this operation at most k times.
# Return the length of the longest substring cont... |
6fa07cdd779d571b36128048ae6bac5412d60885 | greenblues1190/Python-Algorithm | /LeetCode/16. 그리디 알고리즘/134-gas-station.py | 1,108 | 3.84375 | 4 | # https://leetcode.com/problems/gas-station/
# There are n gas stations along a circular route, where the amount of gas
# at the ith station is gas[i].
# You have a car with an unlimited gas tank and it costs cost[i] of gas to travel
# from the ith station to its next (i + 1)th station. You begin the journey with
# a... |
7c7e14e587885e4e8d7650478e5d984c41f032c9 | greenblues1190/Python-Algorithm | /LeetCode/15. 슬라이딩 윈도우/76-minimum-window-substring.py | 1,068 | 3.84375 | 4 | # https://leetcode.com/problems/minimum-window-substring/
# Given two strings s and t of lengths m and n respectively,return the minimum window substring
# of s such that every character in t (including duplicates) is included in the window.
# If there is no such substring, return the empty string "".
# The testcases... |
3e950535ae360cbb9d8f0d7c0b842d150d8c2066 | greenblues1190/Python-Algorithm | /LeetCode/13. 이진 검색/167-two-sum-ii-input-array-is-sorted.py | 1,446 | 3.875 | 4 | # https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/
# Given an array of integers numbers that is already sorted in non-decreasing order,
# find two numbers such that they add up to a specific target number.
# Return the indices of the two numbers (1-indexed) as an integer array answer of size 2,
# where... |
7b7e86e454016e2821fac3104c5211372387169a | greenblues1190/Python-Algorithm | /LeetCode/15. 슬라이딩 윈도우/1695-maximum-erasure-value.py | 1,064 | 3.6875 | 4 | # https://leetcode.com/problems/maximum-erasure-value/
# You are given an array of positive integers nums and want to erase a subarray
# containing unique elements. The score you get by erasing the subarray is
# equal to the sum of its elements.
# Return the maximum score you can get by erasing exactly one subarray.
... |
c0840913eaaa0126aa39fac8e391c812725196b2 | NSatoh/Pascal_triangle_ps | /color.py | 1,083 | 3.59375 | 4 | class Color:
def __init__(self, name, r, g, b):
"""
:param str name: color name
:param float r:
:param float g:
:param float b:
"""
self.name = name
self.r = r
self.g = g
self.b = b
RED = Color(name='red', r=1, g=0, b=0)
BLUE... |
1ed53802fa9c216eb6f19a05a67afd19d3abfd69 | madhuripr21/day2assignment | /day2/pangram.py | 328 | 4.09375 | 4 | import string
def ispangram(str):
alphabet = "abcdefghijklmnopqrstuvwxyz"
for char in alphabet:
if char not in str.lower():
return False
return True
string = 'the five boxing wizards jump quickly.'
if (ispangram(string) == True):
print ("yes")
else:
print ("no")... |
bf9cebcb99452aa75d9fa70280aa7f7d2ce2f572 | jeffreywugz/code-repository | /python/matplotlib/demo.py | 439 | 3.640625 | 4 | #!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = 10 * np.outer(np.cos(u), np.sin(v))
y = 10 * np.outer(np.sin(u), np.sin(v))
z = 10 * np.outer(np.ones(... |
bf67b98e1c8d67e03db25488893518e5fd2e3a36 | GaiBaDan/GBD-GoodMan | /demo1.py | 599 | 4.5625 | 5 | #1.注释:代码中不会被编译执行的部分(不会起到任何程序作用,用来备注用的)
#在说明性文字前加#键可以单行注释
'''
'''
"""
A.对程序进行说明备注 B.关闭程序中的某项功能
"""
#建议:写程序多写注释
print("HELLO world") ;print("hello python") #每条语句结束后可以没有分号r如果一行要写多条语句,那么每条语句之间用分号隔开
# print("hello world")
print("hello world")
# print("hello world")
print('dandan')
# print('hahahahahaha')\
list1 = [... |
d565e04077e8f1f14b75375a35df836e09f70c15 | SomeStrHere/HauntedHouse | /CharacterCreator.py | 1,489 | 3.78125 | 4 | import random
from Character import Character
class CharacterCreator :
def createCharacter() :
print('Please enter the following information to setup your character...\n')
firstName = input('What is your first name? ')
heightInFeet = float(input('What is your height in feet approx? '))
... |
02bd64d1871d08a5ef5354e4962074dc01363b8e | darrenthiores/PythonTutor | /Learning Python/level_guessing.py | 2,170 | 4.125 | 4 | # membuat app number guessing dengan level berbeda
import random
def low_level() :
number = random.randint(1,10)
chances = 3
while (chances > 0) :
guess = int(input('Your guess : '))
if (guess == number) :
print ('Congratss you win the game!!')
break
elif (g... |
6fb53f0a54f65a983132e65fac54d9f6f29deff0 | darrenthiores/PythonTutor | /Learning Python/CRUD_learn_2.py | 1,417 | 3.5625 | 4 | #CRUD (3)
materi_bio = []
#function
def list_materi() :
if (len(materi_bio) <= 0) :
print ('MATERI KOSONG')
else :
for i in range(len(materi_bio)) :
print (i,'.', materi_bio[i])
def input_materi() :
materi = str(input('Materi Bio : '))
materi_bio.append(materi)
def ralat_... |
3d0b17e4a0dab5efa5d148901600acd6ea19cfc3 | darrenthiores/PythonTutor | /Learning Python/Max.py | 1,181 | 3.953125 | 4 | # Max() function
# untuk mencari angka tertinggi
angka = [1, 2, 4, 5, 34, 45, 23, 31]
tertinggi = max(angka)
terendah = min(angka)
print (tertinggi)
print (terendah)
# Contoh programnya (mencari pendapatan tertinggi dan terendahdidalam suatu bulan)
bulan = {
'januari' : 0,
'februari' : 0,
'maret' : 0,
... |
40be613671a47f1dff0d5378527ffe929c583221 | ramatssm47/Python | /Stocks/Stocks/test.py | 96 | 3.75 | 4 | mylist = [["a","b"],["a1","b1"]]
for x in mylist:
print "flower of "+ x[0]+" is "+x[1]
|
c1df1f9642c7fa669bfeaf69632813ad8a6f0237 | henneyhong/Python_git | /python수업내용/test0521.py | 1,137 | 3.890625 | 4 | print("Hello VSCode")
a=1
b=2
c=a+b
print(c)
t=[1,2,3]
a,b,c=t
print(t,a,b,c)
#if
score = 92
if score >=90 :
print('합격')
else :
print('불합격')
#for문
for i in[0,1,2,3,4,5,6,7,8,9,10] :
print(i)
for i in range(0,11):
print(i)
favorite_hobby = ['reading','fishing','shopping']
for hobby in favorite_h... |
103ef065e932aeecb8c7d9e414ec4a64689cbe72 | mehmettuzcu/measurement_problems | /rating_product_and_sorting_reviews.py | 3,749 | 3.5625 | 4 | ################ Data Understanding ################
##### Importing Libraries
import pandas as pd
import math
import scipy.stats as st
# Making the appearance settings
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
pd.set_option('display.width', 500)
pd.set_option('display.expand... |
44882456dbccb64858e28b41f745624cb75546ec | yahusun/p0427 | /13_Numpy/generals.py | 594 | 3.890625 | 4 | import numpy as np
'''
mat1 = np.zeros((3,4)) #3*4的矩陣
print(mat1)
print(mat1.ndim)
print(mat1.shape)
mat2 = np.ones((2,3)) * 2
mat2_2 = mat2 * 2
mat2_3 = mat2 * mat2_2
print(mat2)
print(mat2_2)
print(mat2_3)
#對角矩陣
mat3 = np.eye(3,4)
print(mat3)
#真的矩陣運算
#print(np.matmul(mat2, mat3))
'''
#亂數矩陣
import matplotlib.pyp... |
ec1ffc53f6f1a71fc3989a28770c4aa3566e9dec | JosefinaMedina/EjerciciosComputacion-Python | /p3_10c.py | 350 | 3.9375 | 4 | import math
m1=int(input("Pendiente de la recta 1: "))
b1=int(input("Ordenada al origen de la recta 1: "))
m2=int(input("Pendiente de la recta 2: "))
b2=int(input("Ordenada al origen de la recta 2: "))
if m1!=m2:
x=(b2-b1)/(m1-m2)
print(f"El punto de interseccion es {x}")
if m1==m2:
print(f"L... |
468bd59a2638ecc6487f0c9850fc9880262b35ed | JosefinaMedina/EjerciciosComputacion-Python | /p3_8c.py | 364 | 3.703125 | 4 | x1=int(input("Elemento x del primer vector: "))
y1=int(input("Elemento y del primer vector: "))
x2=int(input("Elemento x del segundo vector: "))
y2=int(input("Elemento y del segundo vector: "))
def resta1 (x1,x2):
return x2-x1
def resta2 (y1,y2):
return y2-y1
x=x2-x1
y=y2-y1
def modulo(x,y):
ret... |
c8926c80c5c408c06aaf769c2729afb8e3bd8e62 | PrasadGinnarapu/python_automation | /10.webscraping.py | 551 | 3.90625 | 4 | """imported the requests library"""
import requests
DATA_URL = "https://simple.wikipedia.org/wiki/Rose"
# URL of the image to be downloaded is defined as image_url
OBJECT= requests.get(DATA_URL) # create HTTP response object
# send a HTTP request to the server and save
# the HTTP response in a response object cal... |
1fa509ec2b939331f18a1b41496e81023572a7de | PrasadGinnarapu/python_automation | /6.morning_setup.py | 569 | 3.609375 | 4 | """importing webbrowswer module"""
import sys
import webbrowser
def opensetup():
"""function for open user specified website"""
var = input("Enter g-google, 'd'-darwin, o-office: ").strip()
if var == 'g':
webbrowser.open("www.google.com")
elif var == 'd':
webbrowser.open("https://ojas... |
e385c0d52b417af217ce978a978c66f0e3a395f0 | stefanulloa/skL_tutor | /main.py | 9,859 | 4.15625 | 4 | #from tutorial: https://www.dataquest.io/blog/pandas-python-tutorial/
# %%
import pandas as pd
import matplotlib.pyplot as plt
import math
import numpy as np
def pandasPart1():
#read data on DataFrame type
reviews = pd.read_csv(".\data\ign.csv")
#shape of dataframe
shape = reviews.shape
#obta... |
ff6d900694a6fa4d85f1fec76496abfc36d9779d | Kunal-Kumar-Sahoo/PyWeather | /weather.py | 1,605 | 3.65625 | 4 | import tkinter as tk
import requests
import time
def getWeatherInfo(window):
city = textField.get()
API = ""
# To get your API visit: https://openweathermap.org/
jsonData = requests.get(API).json()
weatherCondition = jsonData["weather"][0]["main"]
temperature = int(jsonData["main"]["temp"... |
60ec4bc36f8b1c57135e68b7a645e414a33a01d2 | jdvalenzuelah/VacationDestination | /Fase2/Destino.py | 759 | 3.859375 | 4 | class Destino(object):
"""
Destino posible al que se puede ir.
Attributes:
nombre (String): nombre del destino.
ubicacion (String): ubicacion deonde se encuentra.
tags (list): categorias a las cuales puede ser asignado el destino.
clima (String): clima del destino.
"""
def __init__(self, nombre, ubicaci... |
9d181fdb0694acfd6d1fe06f91666e8881612bb0 | goodsosbva/BOJ_Graph | /11724.py | 1,205 | 3.515625 | 4 | def DFS(num):
# print(num, end=' ') # 처음 방문한 그 지점을 출력
visited[num] = 1 # 방문했을 때 그 방문리스트에 0으로 되어있을 텐데, 그것을 1로 바꾸어준다.
for i in range(N):
if visited[i] == 0 and connectList[num][i] == 1:
DFS(i)
import sys
N, M = map(int, sys.stdin.readline().split())
connectList = [[0] * (... |
9b39f95066e6bf5919683302f61adc5f40300a60 | younism1/Checkio | /Password.py | 1,673 | 4.15625 | 4 | # Develop a password security check module.
# The password will be considered strong enough if its length is greater than or equal to 10 symbols, it has at least
# one digit, as well as containing one uppercase letter and one lowercase letter in it.
# The password contains only ASCII latin letters or digits.
# Input: ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.