blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
36d3744bc4b6716b37dfa2d000646232e655a596 | ANKITkundu/sdet | /python/Activity5.py | 148 | 4.0625 | 4 | Number = input('Enter a number:')
Z= int(Number)
for i in range(1,11):
X=Z*i
print("The first 10 multiplication of numbers are:"+str(X)) |
7bc5081e8420591f41933b2302a0d83e429e0a85 | pablods90/ThePythonChallenge | /02/challenge02.py | 618 | 3.609375 | 4 | #!/usr/bin/env python
# @Patan
# Challenge 02: http://www.pythonchallenge.com/pc/def/ocr.html
# Comments: - You need to inspect the HTML and get the raw text from there.
# - Be careful the string is UNICODE!
# Imports
import codecs
import string
# Variables
alphabet = tuple(string.ascii_letters + st... |
8e245a193a86e6b470a23aecb29e7ed23fb960c5 | carolineorsi/Week-1-Project | /ex1.py | 727 | 4.21875 | 4 | """Included in the exercise is a zipfile, 'files.zip'. It contains 200 files with random character strings for names, all lowercase. First, unzip this file into a directory named 'original_files'.
Your job is to write a program, ex1.py, that does the following things:
Create 26 directories in the current directory, o... |
77c49c7a4f1392ebfedf88fd115b5ff1fea475bd | JB29N/-Number-Game-JB | /numbergameJB.py | 650 | 4.0625 | 4 | # NUMBER GAME JB
from random import randint
guess = int(input("Choose a number between 1 and 100")) # Ask the user
secret_number = randint(0, 100) # generate secret number
a = 1 # a is use to count number of attempts
while guess != secret_number:
if guess < secret_number:
print("The secret n... |
4ffd00a35aaee6e51c5a02c0a8e41ba740c2fea7 | neeraj1909/learn-python | /Shaw - Learn Python 3 the Hard Way/Chapter-39 Dictionaries, Oh Lovely Dictionaries/exercise_39_3.py | 436 | 4.34375 | 4 | """
Find out what you can’t do with dictionaries. A big one is that they do not have order, so try
playing with that.
"""
print("1. We can use list as a dictionary key. Because in a list, items can be canged by accessing it with ")
print("indexing while in dictionary, the must be immutable. ")
print("2. Order of the d... |
468440b151d7d6a25d7e7103a974e62f28cbf0b8 | neeraj1909/learn-python | /Think-Python-Exercises/Chapter-15 Classes and Objects/distance_between_points.py | 624 | 4.15625 | 4 | #write a function called distance_between_points that takes two Points as arguments and
#returns the distance between them
from math import sqrt
class Point(object):
"""Represents a point in 2-D space."""
def __init__(self, x, y):
self.x = x
self.y = y
class Distance(object):
def __in... |
caa65e9ade822cebc093d3f6b5501ec3ba6b2ab3 | neeraj1909/learn-python | /Think-Python-Exercises/Chapter-16 Classes and Functions/exercise_16_1.py | 1,803 | 4.5 | 4 | """
Write a function called mul_time that takes a Time object and a number and returns a
new Time object that contains the product of the original Time and the number.
Then use mul_time to write a function that takes a Time object that represents the
finishing time in a race, and a number that represents the distance,... |
6e969e8a367fa9b1d680cdfc9a0966f8f3675c73 | jlcatx512/python-challenge | /PyPoll/main.py | 2,021 | 3.703125 | 4 | # Jadd Cheng August 10, 2019
# Import dependencies
import os
import csv
# Create file path variable
csv_path = os.path.join('Resources', 'election_data.csv')
csv_path
with open (csv_path, newline='') as f: # f refers to the file
csv_reader = csv.reader(f, delimiter=',')
next(csv_reader) # skip header row
... |
3ca9b6374f8f5839c3e15ad6981500cae7db193f | leepard1130/Python-Project | /assignment1/a1.py | 5,927 | 4.25 | 4 | """
CSSE1001 Assignment 1
Semester 2, 2017
Sample Solution
"""
# Import statements go here
def load_words(filename, length):
""" Returns a list of all words contained in filename that have the given length.'
Parameters:
filename: words.txt
length(int): the number of character in th... |
9781f0f1916803be28ece805168158ea5938698b | leepard1130/Python-Project | /assignment1/PromptGuess.py | 409 | 4 | 4 | def prompt_guess(position, length):
x = position+1
y = position+length+1
while True:
guess = input('Now guess'+ ' '+str(length)+' ' +'letters corresonding to letters' +' '+ str(x) +' '+ 'to' +' '+ str(y)+' ' + 'of the unknown word:')
if len(guess) != length:
print ('Invalid')
... |
ce34c71895130071c839d22e7870142f86581f9b | amoor22/patterns | /Bday cake pattern.py | 444 | 3.78125 | 4 | num = int(input("How big do you want the cake? "))
num2 = 2
for x in range(num):
for y in range(2):
for i in range(num * 2 - 2):
print(' ', end='')
for a in range(num2):
print('*',end='')
if y == 0:
print()
num2 += 4
num -= 1
print()
# input: ... |
7294e74302495cb6aba7f654afe5407a64f50e60 | amoor22/patterns | /rectangle with divider.py | 582 | 4.09375 | 4 | height = int(input('Height: '))
width = int(input('Width: '))
print()
for x in range(1,height + 1):
for y in range(1,width+1):
if x == 1 or y == 1 or y == width or x == height:
print('* ',end='')
elif y == width // 2 and width % 2 == 0:
print(' *',end='')
elif y == (w... |
b41e5a9ad12baff64c263275ceb043541fd5d439 | ilsankusnarto/Antrian | /prime.py | 255 | 3.875 | 4 | def prime (bilanganka):
count = 0
for i in range (1,bilanganka+1):
if (bilanganka % i ==0):
count+=1
if(count==2):
return "prime"
else:
return "not prime"
tes = prime(2)
print(tes)
#komentarkami
haloooo |
a80002241d8ef5c48084cf35ab033ab7548bcef1 | Stardustlv8/RSA_Algoritmo | /RSA_1/CRIPTO/isPrim.py | 368 | 3.84375 | 4 | def mcd(a,b):
"""Determina si 2 valores son coprimos entre si.
ENTRADA:(2 VALORES)
numeros a analizar
SALIDA:(TRU/FALSE)
devuelve un valor boleano con la respuesta.
"""
r=1
if a<b:
c=a
a=b
b=c
while r > 0:
c=a/b
r=a%b
a=b
b=r
... |
5f7766d46d64e4b49c2dc1276a3351c9a3f0b185 | radhikam/DSIP | /example.py | 260 | 3.71875 | 4 | def binto8(x,y):
#code to make a binary number 8 bit binary
n = bin(int(x))
m = list(n)
count = len(m) - 2
for i in range(0,count):
m.insert(2,0)
m = m[y+1]
return m
# x=no. in the image array here p.item(x,y), y=r
|
44ea1a5f951a2ce3160c0640fd610abe38e4aa31 | gyaanibuddy/Pune-University | /Computer Engineering/Third Year/Designing & Analysis of Algorithms/Python/digital differential analyzer.py | 2,014 | 3.703125 | 4 | ### Drawing line using Digital Differential Analyzer Line Drawing Algorithm in Computer Graphics.
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
w, h = 25,25
m=0
def ROUND(a):
return int(a + 0.5)
def drawDDA(x1,y1,x2,y2):
x,y = x1,y1
length = abs((x2-x1) if abs(x2-x1) > abs(y2-y... |
dde90dc127d4d9858baa35fe8e1605d58be9bde5 | sunnivmr/tdt4110 | /oving5/primtall.py | 566 | 4.03125 | 4 | import math
print("a)")
def divisable(a, b):
if a % b == 0:
return True
else:
return False
print(divisable(10, 3))
print(divisable(10, 5))
print("b)")
def isPrime(a):
for b in range (2, a):
if divisable(a, b):
return False
return True
print(isPrime(11))
pri... |
4c8358ab3818ef441b92d56340c991a1e998adad | sunnivmr/tdt4110 | /oving1/tallkonvertering.py | 1,550 | 3.75 | 4 | # print("a)")
#
# tall1 = float(input("Skriv inn et flyttall: "))
# tall2 = float(input("Skriv inn enda et flyttall: "))
# tall3 = float(input("Skriv inn et siste flyttall: "))
#
# int1 = int(tall1)
# int2 = int(tall2)
# int3 = int(tall3)
#
# print("Konvertert til heltall blir det ", int1, int2, int3)
#
# int4 = int(in... |
a73a0c80cc6d4762b9405d30f3bfce77bbae917f | sunnivmr/tdt4110 | /oving7/tekstbehandling.py | 802 | 3.6875 | 4 | print("\na)")
def blokk_bokstaver(string):
return string.strip().upper()
print(blokk_bokstaver(" \n The Sky's Awake So I'm Awake \t "))
print("\nb)")
def splitt_ord(string, char):
return string.split(char)
print(splitt_ord("Hakuna Matata", 'a'))
print("\nc)")
s1 = "eat"
s2 = "I want to be like a ... |
3db956d1cdf132ba0c9c4b5a7b3e04b821239bad | sunnivmr/tdt4110 | /oving2/grafikktrekant.py | 787 | 3.921875 | 4 | import time
from turtle import *
# importerer funksjoner fra turtle
print("Hei, jeg kan tegne en trekant")
vinkel = 0
svar = input("Ønsker du spissen på trekanten opp eller ned? (O/N)")
if (svar.lower() != "n" and svar.lower() != "o"):
print("Feil input")
elif (svar.lower() == "n"):
vinkel = - 120
else:
... |
7c15a434a52bae0439c45813d8b989c3561755be | lane128/n-_and_0 | /NFactorial.py | 318 | 3.640625 | 4 | #coded by Wang Lei
#lane128@gmail.com
def Find5(n):
z=n/5
if n/5.0>=1.0:
z=z+Find5(z)
pass
return z
if __name__ == '__main__':
n=raw_input('input a postive int number:')
if str.isdigit(n):
n=int(n)
if n>=0:
zero=Find5(n)
print "The {0}! result contains {1} '0' .".format(n,zero)
else:
print "Inpu... |
1401e6fc6d7018f453468ce16b2c27b20a6a7c63 | imanhussain27/CSV | /sitka1.py | 576 | 3.578125 | 4 | import csv
open_file= open("sitka_weather_07-2018_simple.csv","r")
csv_file=csv.reader(open_file,delimiter=",")
header_row=next(csv_file)
print (type(header_row))
for index,column_header in enumerate(header_row):
print(index,column_header)
highs=[]
for x in csv_file:
highs.append(int(x[5]))
print(highs)... |
f86bf5abebc13e1b748f36e9f39313e30cd7e8f2 | Thorid/Advent-of-Code-2018 | /AoC 2018 Day1 - part1.py | 420 | 3.578125 | 4 | puzzleInput = open('AoC 2018 Day 1 - input.txt').read().split('\n')
def calculateResultingFrequency(calibrationInstructions):
result = 0
for instruction in calibrationInstructions:
number = int(instruction[1:])
if instruction[0] == '+':
result += number
else:
... |
52d19363795621a19a408d77604a9fedc0320d93 | mikebird28/annt-python | /annt/color.py | 1,597 | 3.859375 | 4 |
def idx_to_hue(idx, color_num=24):
""" Convert color index to hue
"""
if not isinstance(idx, int) or idx < 0 or idx > color_num-1:
raise ValueError('idx should be integer between 0 and color_num-1')
used = [-1] * color_num
used[0] = color_num - 1
i = 0
result = 0
while i < i... |
b99e18ea7d07c3bdf5327dd34a92dfdac8a67445 | krishardy/pyinputsanitizer | /test/inputsanitizer_test/__init__.py | 2,591 | 3.671875 | 4 | import unittest
from inputsanitizer import *
class InputTestCase(unittest.TestCase):
def test__init__(self):
uut = Input()
def test_sanitize(self):
uut = Input(str)
self.assertEqual(uut.sanitize(""), "")
self.assertEqual(uut.sanitize("a"), "a")
uut = Input(str, requi... |
0bf6d890aae43b6d069a5cf0ac3cb65ede79163c | SW-418/EulerProject | /src/Python/SmallestMultiple.py | 587 | 3.921875 | 4 |
def main():
print(calculateSmallestFactor(20))
def calculateSmallestFactor(input):
allMultiples = False
counter = 1
while not allMultiples:
currentValue = counter * input
if not ensureDivisibility(currentValue, input):
counter += 1
else:
return currentV... |
1cfacaef766ed2d76f844ac96cb6214c00b4f62f | PrathyushaKasam/LU-Assignments | /Day3.py | 225 | 4.0625 | 4 | altitude=int(input("What's the height of the plane?"))
if altitude <= 1000:
print("Safe to land")
elif altitude>1000 and altitude<=5000:
print("Bring down to 1000ft")
else:
print("Go around and try later")
|
62f614d8f72dc10e2faac42954013bcf6e81567e | tennessysherry/datascience-test | /Lesson2.py | 448 | 4.28125 | 4 | #if statement
age = 20
if age >=18:
print ("adult")
else:
print ("Not an adult")
#adding numbers with an if condition
number1 = 12
number2= -15
if number1>=0:
print(number1+number2)
else:
print(number1-number2)
#number when there is an if condition
num = input("enter a number")
print("You entere... |
93624d410b4da4497e9e75eb4a5aa2cf7f8b03ce | tennessysherry/datascience-test | /Lesson1.py | 303 | 4.1875 | 4 | class_name="data science class"
print (class_name)
#Arithmetics
#are of a circle
pi = 3.142
radius = 10
area = pi * radius*radius
print ("The area is " +str(area) +" square cm")
#this is the method for simple interest= p*r*t
#p=10000, r 10/100,t=3
p=10000
r=10/100
t=3
interest= p*r*t
print (interest)
|
c9f786dfd026956f5b0558a3b2a225abaac5927b | ohchangwook/porb101-130 | /prob101~130/prob128.py | 338 | 3.84375 | 4 | #주민등록번호의 뒷 자리 7자리 중 두번째와 세번째는 지역코드를 의미한다.
#주민 등록 번호를 입력 받은 후 출생지가 서울인지 아닌지 판단하는 코드를 작성하라
code=input("지역코드:")
if code<=08
print("서울")
elif code>=09
print("부산")
|
e82796e017d7ba7a939a39db1d0ee43f1c35b761 | AnushaManda-27/Basic_Core_Programs | /prime_factorization.py | 1,272 | 4.25 | 4 | '''@Author: Anusha Manda
@Date: 05-08-2021 12: 00: 30
@Last Modified by: Anusha Manda
@Last Modified time: 05-08-2021 18: 00: 30
@Title:Factors
a. Desc -> Computes the prime factorization of N using brute force.
b. I/P -> Number to find the prime factors
c. Logic -> Traverse till i*i <= N instead of i <= N for efficien... |
bf14fdac177a434a0c3196b31d3fa532965f8c1c | rgb-jona/Dijkstra-Algorithm | /dijkstra.py | 14,875 | 4.5 | 4 | """ This is a module demonstrating the dijkstra algorithm by generating a grid of random nodes, connected with edges
with random weights.
Start the calculation with: dijkstra.Solver(NUM). NUM represents the number of nodes which will be
created in the net.The program limits the number to a minimum of five and a maximu... |
d60428a0c0cca4c2cbc208b680fb163370576c53 | Abhishekmishra-17/pattern-problems-with-python | /pattern/pattern33.py | 217 | 3.875 | 4 | for i in range(0,5):
for j in range(0,5):
if((j==0 or j==4) and i in range(0,3)) or(i==3 and (i-j)%2==0)or(i+j==6):
print("*",end="")
else:
print(end=" ")
print()
|
67f602e0406d75436e2761fb0da9031aeb91b809 | Abhishekmishra-17/pattern-problems-with-python | /pattern/pattern3.py | 160 | 3.875 | 4 | for i in range(1,9):
for j in range(1,3):
if((i+j)%2==0):
print("*",end="")
else:
print(end=" ")
print()
|
ee0966aa6fb3aa48590efc94b18488d4fb8cd275 | Abhishekmishra-17/pattern-problems-with-python | /pattern/pattern7.py | 187 | 3.71875 | 4 | for i in range(0,7):
for j in range(0,4):
if((i-j==0)or(i+j==6)or(j==0 and i%6!=0)):
print("*",end="")
else:
print(end=" ")
print()
|
5f8516f10c5d24e4f358ad2c0765ab679ac37dfe | Abhishekmishra-17/pattern-problems-with-python | /pattern(numerical_0_to_9)/6.py | 206 | 3.96875 | 4 | for i in range(5):
for j in range(3):
if((i==0 or i==4 or j==0 or (j==2 and i in range(2,5)) or i==2)):
print("*",end="")
else:
print(end=" ")
print()
|
4495e966fd23d90eb92f32da8828b635e3913423 | Abhishekmishra-17/pattern-problems-with-python | /pattern(numerical_0_to_9)/5.py | 233 | 3.984375 | 4 | for i in range(6):
for j in range(3):
if(i==0 or ((i==2 or i==5)and j in range(2))or(j==2 and i in range(3,5))or(i==1 and j==0)):
print("*",end="")
else:
print(end=" ")
print()
|
a34cb02704752606582ca48169365c39c72869a9 | renderance/tic-tac-toe-python | /tictactoe.py | 5,586 | 3.53125 | 4 | import os
# A little googling yielded this to clear interpereter window:
def cls():
os.system('cls' if os.name=='nt' else 'clear')
# The game consists of tiles changing values.
class tile:
def __init__(self):
self.state = ' '
def set_state(self,player):
if play... |
af3c1356a7305972ca587ab618b9a017bca2a929 | MrMilo900/Projekt-Euler | /Euler010_1.py | 344 | 3.75 | 4 | # The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
#
# Find the sum of all the primes below two million.
primes = [2]
for x in range(3,2000001,2):
prime = True
for y in range(2,x):
if x % y == 0:
prime = False
break
if prime == True:
primes.append(... |
c8fbd2006a3cb3a30f0ac9d31b5fbc9af9120dba | Kirushanr/Python | /Python Crash Course/name.py | 220 | 4.25 | 4 | name ="ada lovelace"
name =" First Bug ";
#prints the name with first character of a word
#capitalized
print(name.title())
#prints the name in upper case
print(name.upper())
#prints the name in lowercase
print(name.lower())
|
302ff4d0b32c62e27e3780899834e7877db7360a | Kirushanr/Python | /Python Crash Course/dimensions.py | 326 | 4.0625 | 4 | """ Examples on tuples"""
dimensions = (200, 50)
#print(dimensions[0])
#print(dimensions[1])
#looping through a tuple
print("Original dimensions")
for dimension in dimensions:
print(dimension)
#writing over a tuple
dimensions = (300, 20)
print("\nModified dimensions")
for dimension in dimensions:
print(dimen... |
57ce81204413ce173e9e888d1414aa4a45b06077 | Kirushanr/Python | /Python Crash Course/Ty8-9.py | 214 | 3.75 | 4 | def show_magicians(magician_list):
"""Prints the name of each magician"""
for magician in magician_list:
print(magician)
magicians = ['Ron', 'Harry', 'Hermoine', 'Luna']
show_magicians(magicians)
|
99a3e782133d7780c1cee6aacd65bca859459f3d | Kirushanr/Python | /Python Crash Course/Ty4-2.py | 145 | 4 | 4 | animals = ['dog', 'cat', 'rabbit']
for animal in animals:
print(animal + " is a great pet")
print("Any of these animals would make great pet")
|
c1add63c043b2f662bc2241ac41cc70053ba088c | Kirushanr/Python | /Python Crash Course/Ty8-12.py | 249 | 3.78125 | 4 | def get_sandwiches(*items):
""" Prints summary of sandwiches that's being ordered"""
print("\nSandwiches ordered: ")
for value in items:
print("-" + value)
get_sandwiches("egg", "fish")
get_sandwiches("egg", "bacon", "potatto")
|
36c2afe2daf3d1e12d374b1513e3aa122cbe686f | Kirushanr/Python | /Python Crash Course/Ty7-2.py | 214 | 4.28125 | 4 | no_of_people = input("How many people are in the dinner group? ")
no_of_people = int(no_of_people)
if no_of_people > 8:
print("\nYou will have to wait for a table")
else:
print("\nYour table is ready !!")
|
3b3c9f68485a99b8ada016a3fdc37ec2b90eb03f | ianoti/Andela_Camp | /BinarySearch.py | 1,040 | 3.75 | 4 | class BinarySearch(list):
def __init__(self, a, b):
self.a = a #the length of the list
self.b = b #the step or difference between consecutive values
self.customlist = []
i = b
while i <= (a*b):
self.append(i)
i += b
self.length = len(self)
def __call__(self):
return self.customlist
def search... |
c93be5e9c8cbddb5611df8ee7d3e5e11d1dc2e80 | Woofiee/putri_post_exam_activity_bot | /app.py | 2,504 | 4.21875 | 4 | print("Title of program: Post Exam Activity bot")
print()
while True:
description = input("Could you describe how you feel in a sentence?")
list_of_words = description.split()
feelings_list = []
encouragement_list = []
counter = 0
for each_word in list_of_words:
if each_word == "bored":
... |
8edb9b15760cf9b3e4efe24af968652525d0de2a | huangjing2016/leetcode_python | /test/test_implement_strStr.py | 934 | 3.625 | 4 | import unittest
from src import implement_strStr
class TestImplementstrStr(unittest.TestCase):
def test_return_index(self):
haystack = 'hello'
needle = 'll'
solution = implement_strStr.Solution()
output = solution.strStr(haystack, needle)
assert output == 2
def test_no... |
b2b814eb9b21cf3b269dd756f37b4e8437e0cd00 | sudarshan-jha/add_number | /a.py | 270 | 4.09375 | 4 | #taking user input
first_num=int(input("enter First number"))
second_num=int(input("enter second number"))
#sum function
def sum(first_num, second_num):
return first_num + second_num
#driver code
x=sum(first_num, second_num)
print('sum of two number is {}'.format(x))
|
60e18e574f6a6656b0fc653e564e6b41d556dad8 | Nasnini/KatasChallenges | /Excercise 5.py | 564 | 4.21875 | 4 | # 5 Excercise: Draw a icosceles triangle
#Defining function
def icos_triangle():
# Prompt user to enter input
size = int(input("Please enter the number of rows: "))
# For loop
m = (2 * size) - 2
for i in range(0, size):
for j in range(0, m):
print(end=" ")
... |
998c83c1fa278e8b6a714f8c7a34e6f7d29d7dce | ultimateshark/O.S-With-Python | /dinningphilosopher.py | 826 | 3.515625 | 4 | import threading
from threading import Thread
#wait and signal functions
def wait(sem):
while chopstick[sem]<=0:
pass
chopstick[sem]=chopstick[sem]-1
return chopstick[sem]
def signal(sem):
chopstick[sem]=chopstick[sem]+1
return chopstick[sem]
#main code
chopstick=[1]*5
def pro1():
p... |
9d2249a746de84fb33893330758236fc1138264d | alysonNBS/codigos-avulsos | /find_words.py | 349 | 3.953125 | 4 |
# return a list contains all words in the text
def find_words(text: str):
my_words = []
i = 0
len_text = len(text)
while i < len_text:
if text[i].isalpha():
j = 0
while i+j < len_text and (text[i+j].isalpha() or text[i+j] == '-'):
j+=1
my_words.append(text[i : i+j])
i+=j
... |
7c71fc68c3acb537b974fc5324d6f5576e705587 | sanchezolivos-unprg/t07_Sanchez.Ramos | /ramos/repetitivas_iteracion10.py | 415 | 3.65625 | 4 | import os
#mostrar el codigo oculto
# 1 = el codigo
# 5 = oculto
# 6 = es:
# 9 = codigo12345.
#input
msg=os.sys.argv[1]
#bucle
for letra in msg:
if letra == "1":
print("el codigo")
if letra == "5":
print("oculto")
if letra == "6":
print("es:")
if letra == "9":
print("cod... |
27357fdeb91ce5f1a0f6fa49a0a518a2384a33bd | sanchezolivos-unprg/t07_Sanchez.Ramos | /sanchez/repetitivas_iteracion02.py | 476 | 3.734375 | 4 | # DECODIFICAR MENSAJE A TRAVES DE NUMEROS
# 1 = quererse
# 2 = es el primer
# 3 = paso
# 4 = para ser
# 5 = feliz
mensaje="12345"
# input
import os
mensaje=os.sys.argv[1]
# bucle
for numero in mensaje:
if numero == "1":
print("querese")
if numero == "2":
print("es el primer")
if numero ==... |
8ad776eda8be9598f5075bc855842957a20aea92 | sanchezolivos-unprg/t07_Sanchez.Ramos | /sanchez/repetitivas_iteracion_rango05.py | 411 | 3.859375 | 4 | # IMPRIMIR DOS NUMEROS POR TECLADO Y MOSTRAR TODOS LOS NUMEROS PARES COMPRENDIDOS ENTRE AMBOS
numero1=int(input("introduce el primer numero: "))
numero2=int(input("introduce el segundo numero: "))
# input
import os
numero1=int(os.sys.argv[1])
numero2=int(os.sys.argv[2])
# iterador en rango
for n in range(numero1, nu... |
e330ad7a866cbeb2c3f02a20a42f0d6f32f74282 | mtcle/py-learning | /learn-set.py | 411 | 4.0625 | 4 | # set 学习,不允许重复元素
# set 使用大括号,没有key就是集合
set1 = {1, 2, 3, 4}
print(type(set1))
num1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 9]
# 去除重复元素,
num1 = list(set(num1))
print(num1)
# 常用方法
# add
# remove
set2 = {2, 3, 4, 5}
print(set2)
set2.add(99)
print(set2)
# 不可变集合
# 这样的set是不允许增删元素的
set3 = frozenset({1, 2, 3, 4, 5})
|
988a2b893857d98f3b1c5d2c0ed6580c09627d7a | ShubhangiDhurve/nested-list | /odd or even.py | 439 | 3.5 | 4 |
from cgi import print_directory
elements = [23, 14, 56, 12, 19, 9, 15, 25, 31, 42, 43]
i=0
count=0
while i<len(elements):
if elements[i]%2==0:
count=count+elements[i]
print(elements[i],"it is even number")
else:
print(elements[i],"it is odd number ")
... |
1f0a361779d5162a2eb32535695b7db8b9d01f1d | TeaganShepherd/TicTacToe | /main.py | 2,937 | 4.09375 | 4 | #------------Global Variables--------------
#board
board = ["-","-","-",
"-","-","-",
"-","-","-"]
#Player going
letter = "X"
#Is game still playable?
gameGoing = True
#The winner
winner = None
#-----------End Global Variables-----------
def displayBoard():
print(board[0] + "|" + board[1] + "|" ... |
8b9842fb2d1eab011cf441f4ccbdf6cabab7dd88 | rohan1410/Practice | /hackerrank/word_order.py | 291 | 3.640625 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
from collections import OrderedDict
od = OrderedDict()
n = input()
for _ in range(n):
c = raw_input()
if c in od:
od[c] += 1
else:
od[c] = 1
print (len(od))
for _ in od.values():
print _,
|
b2b08cb40aae05dff73f8cc9885eabde4080dab0 | rohan1410/Practice | /hackerrank/the_minion_game.py | 349 | 3.609375 | 4 | def minion_game(string):
cnt = 0
cnt1 = 0
vowel = 'AEIOU'
for i in range(len(string)):
if(string[i] in vowel):
cnt += len(string) - i
else:
cnt1 += len(string) - i
if(cnt < cnt1):
print "Stuart", cnt1
elif(cnt1 < cnt):
print "Kevin", cnt
... |
90cc49b6f777b1ddfd9ebf698cdfed622de3dcb8 | rohan1410/Practice | /hackerrank/runner_up_score.py | 285 | 3.515625 | 4 | if __name__ == '__main__':
n = int(raw_input())
arr = map(int, raw_input().split())
mx = -200
mx1 = -200
for item in arr:
if mx < item:
mx1 = mx
mx = item
elif mx1 < item and mx != item:
mx1 = item
print mx1
|
0310539de6deb2b8b86dec50f8c2799fa03714b0 | antilectual/CodingPractice | /LeetCode/520. Detect Capital (easy).py | 644 | 3.84375 | 4 | # LeetCode problem 520. Detect Capital (easy)
# Algorithm: Using python built-in methods to test all upper, or lower except first char (upper or lower case on first char is okay)
# For not using built-ins could iterate the characters in the word to test all within the bounds of upper case,
# or a... |
960b8822e2df388eb34515afea630f555e36b78b | antilectual/CodingPractice | /LeetCode/859. Buddy Strings (easy).py | 2,060 | 3.953125 | 4 | # LeetCode problem 859. Buddy Strings (easy)
# Algorithm: Test if 2 characters can be swapped in string A to result in string B by:
# 1) Making sure the strings are equal length (swap won't change length so it can never be equal)
# 2) Counting the number of characters that are different. (a string... |
f52167882229573046460ea77f21f587f695b607 | antilectual/CodingPractice | /LeetCode/1351. Count Negative Numbers in a Sorted Matrix (easy).py | 486 | 3.640625 | 4 | # LeetCode problem 1351. Count Negative Numbers in a Sorted Matrix (easy)
# Algorithm: Iterate from bottom right counting negatives in each row from right to left. When 0+ is found, move up to next row.
class Solution:
def countNegatives(self, grid: List[List[int]]) -> int:
count = 0
for row in gri... |
9d22dd46869c1e98f108bfc76680129d9d5e0e3c | antilectual/CodingPractice | /LeetCode/338. Counting Bits (medium).py | 608 | 3.5 | 4 | # LeetCode problem 338. Counting Bits (medium)
# Algorithm: Count bits by modulo 2 and divide by 2 until no more bits are left. Store calculated bits in fullList to reduce repeated calculations
class Solution:
fullList = []
def countBits(self, num: int) -> List[int]:
length = len(self.fullList)
... |
e0293c73c89dacb7485bb56fe1292bebde34e0ec | airblair94/DataScienceExamples | /project/clustering2/change_headings.py | 1,037 | 3.65625 | 4 | import get_data as gd
"""
This is a simple python script to remove all of the spaces in the headings of my csv
so that I can easily use them with the given functions.
"""
def cleaned_headers():
headers = gd.get_headers()
new_headers = []
for entry in headers:
final = ""
for i in entry:
if (i == " ... |
d9aaedfd4db18b88b43ce9b8055cc72fac934084 | hus0124/RaspberrySource | /P_source/servoMotor.py | 734 | 3.546875 | 4 | import RPi.GPIO as GPIO
import time
pin = 18
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(pin, GPIO.OUT)
p = GPIO.PWM(pin, 50)
p.start(0)
left_angle = 12.5
center_angle = 7.5
right_angle = 2.5
def doAngle(angle):
p.ChangeDutyCycle(angle)
print ("Angle: %d" %angle)
time.sleep(0.5)
try :
... |
add21bb8bd6de6e397301717a977fbf01e120bb7 | Arundhati1Sharma/ML-algo-projects | /google text to speech.py | 1,305 | 3.859375 | 4 | #gtts - google text to speech , it converts the text into audio
##file->setting->project name->project interpreter ->+ ->pygame->install package
from gtts import gTTS
from tkinter import*
from pygame import mixer
root=Tk()
root.geometry("1000x400+0+0") ##window size
root.title("my text to speech co... |
46b67cbfc7a7eccfac3df1303a1e4bb3c2cbf0f2 | hope-crichlow/Python | /fundamentals/oop/bank_account/users_with_bank_accounts.py | 2,386 | 4 | 4 |
class BankAccount:
bank_account_list = []
def __init__(self, int_rate=1, balance=0):
self.int_rate = int_rate/100
self.balance = balance
BankAccount.bank_account_list.append(self)
def deposit(self, amount):
self.balance += amount
return self
def withdraw(sel... |
9742e52ac18f3c32f2be5ae8735f0dbe30b4f9fa | xiaoxue11/python_learning | /basic/database.py | 1,289 | 3.859375 | 4 | import sys,shelve
def store_person(db):
pid=input('Enter unique ID number:')
person={}
person['name']=input('Enter name:')
person['age']=input('Enter age:')
person['phone']=input('Enter phone number:')
db[pid]=person
def lookup_person(db):
pid=input('Enter ID number:')
field=in... |
f8b467daa068f326de9cb2e60c46eb7e4e5da204 | ayushmatsoni/acadview | /w2l3.py | 184 | 3.96875 | 4 |
n=int(input("ENTER THE LIMIT"))
def fact(n):
if n==1:
return 1
else :
return (n * fact(n - 1))
dict={'number':n,'Factorial':fact(n)}
print(fact(n))
print(dict) |
be7b4ea1609448a571c03f95e65e7d87d7d2f320 | ayushmatsoni/acadview | /assignmentERRORHANDLING.py | 1,215 | 3.921875 | 4 | #question1
print("QUESTION 1")
a=3
try:
if a<4:
a=a/(a-3)
print(a)
except ZeroDivisionError:
print("THIS IS ZERO DIVISION ERROR")
print("")
print("QUESTION2")
#question2
try:
l=[1,2,3]
print(l[3])
except IndexError:
print("THIS IS INDEX ERROR")
print("")
print("... |
7d641604128db367e0146211e66465b2588a59d5 | Jack-lss/LeetCode_method | /012Sum_0f_paths/012Sum_0f_paths.py | 883 | 3.8125 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def hasPathSum(self, root: TreeNode, sum: int) -> bool:
if root is None:
return False
if root.left is None and root.ri... |
0481fb37f090b65c76c7c637120135485f8cd883 | wh4044/Algorithm | /p.321 럭키 스트레이트.py | 216 | 3.765625 | 4 | num = input()
half_index = len(num) // 2
left, right = 0, 0
for i in range(len(num)):
if i < half_index: left += int(num[i])
else: right += int(num[i])
print("LUCKY" if left == right else "READY") |
ac3fd9c4c8ea9a1e4a0d1fe262b88d97793b323a | sazzadahmed/algorithm_implementation | /mathematic/divideby7.py | 562 | 4.3125 | 4 | '''
A number can be divided 3 if the if the absolute different of even and odd bit will multiple of 3
'''
def SevenMultiple(x):
y=(x<<3)-x
return y
def multiple_of_three(x):
even=0
odd=0
flag=False
while(x):
if(x%2):
if (flag):
even=even+1
fla... |
f43c303a90050de3f1dff53eb144a9fb82c0c466 | sazzadahmed/algorithm_implementation | /all algorithm here/prims.py | 767 | 3.609375 | 4 | class Edge:
def __init__(self,u,v,w=1):
self.u=u
self.v=v
self.w=w
class Graph:
def __init__(self,v,dircted=False,weight=False):
self.V=v
self.Adjacecy_Matrix={}
for i in range(v):
self.Adjacecy_Matrix[i]=list()
def __str__(self):
return '... |
0dd0394f813edd80df0accca40a6c54196ab52f1 | carvalhopatrick/MC102_2s2019 | /lab09/lab09.py | 9,627 | 3.578125 | 4 | # lab09 MC102 - 2s2019
# https://www.ic.unicamp.br/~mc102/labs/roteiro-lab09.html
# Função recursiva para busca de palavras
# entradas: x posição horizontal no diagrama onde é inicializada a busca
# y posição vertical no diagrama onde é inicializada a busca
# index_palavra indice da palavra buscada na lista ... |
f885319460c8526179079bd3906b8ed89c45f82e | don-juancito/BrainsToBytes_CodeSamples | /DeepLearningBasics/NeuralNetwork_5_Gen_Gradient_desc/gradient_descent_singleinput_multioutput_naive.py | 2,254 | 4.125 | 4 | def neural_network(input, weight):
predicted_value = input * weight
return predicted_value
input = 0.2
expected_value_1 = 8
expected_value_2 = 46
expected_value_3 = 0.1
weight_1 = 10
weight_2 = 20
weight_3 = 3
while True:
# Because of how python handles floating point, we round the values
predict... |
4759f231fda859bab441b9cf30d137f849182743 | don-juancito/BrainsToBytes_CodeSamples | /DeepLearningBasics/NeuralNetwork_5_Gen_Gradient_desc/gradient_descent_singleinput_multioutput.py | 2,399 | 3.8125 | 4 | def neural_network_multi_output(input, weights):
predicted_values = []
for weight in weights:
predicted_value = round( input * weight, 2)
predicted_values.append(predicted_value)
return predicted_values
def calculate_errors(predicted_values, expected_values):
errors = []
for pred_... |
c8f1a16f2cb374352b37fa73d8bc923e38ccf712 | iam-Raghav/sentimentanalysis_lstm | /Text_cleaner.py | 930 | 3.546875 | 4 | import io
from nltk.corpus import stopwords
from nltk.stem import PorterStemmer
ps = PorterStemmer()
#word_tokenize accepts a string as an input, not a file.
stop_words = set(stopwords.words('english'))
filepath = "E:\Sentiment_analysis\data.csv" #KEY IN PATH OF SOURCE FILE
outfile = "E:\Sentiment_analysis\data_... |
f50397c0c87dfd47439213c6c71e75bf49ea075f | j-217/python | /codewars/55_mixbonacci.py | 1,327 | 3.625 | 4 | def mixbonacci(pattern, length):
if all([pattern, length]):
dict = {'fib': fibonacci(), 'pad': padovan(), 'jac': jacobstahl(), 'pel': pell(), 'tri': tribonacci(), \
'tet': tetranacci()}
lst = []
while length:
for k in pattern:
if length > 0:
... |
bd2b650eee6bca689548091499772106faea5e00 | j-217/python | /codewars/10_stop_spinning_my_words.py | 364 | 3.765625 | 4 | def spin_words(sentence):
words_list = sentence.split(" ")
spin_sentence = ""
for word in words_list:
if len(word) >= 5:
spin_word = "".join(reversed(word))
else:
spin_word = word
spin_sentence += spin_word + " "
print(spin_sentence.strip())
# return s... |
585cbb3028bcf8de842158772661256739d03299 | j-217/python | /codewars/50_weight_for_weight.py | 476 | 3.703125 | 4 | def order_weight(strng):
lst = strng.split(" ")
dict = {}
for n in lst:
weight = str(sum(int(x) for x in n))
if weight not in dict:
dict[weight] = [n]
elif weight in dict:
dict[weight].append(n)
weight_lst = sorted(map(lambda k: int(k), dict.keys()))
b... |
e159490993bada97e871a027aac0712b3c2919e2 | j-217/python | /codewars/03_mumbling.py | 631 | 4.09375 | 4 | def accum(s):
"""
This time no story, no theory. The examples below show you how to write function accum:
Examples:
accum("abcd") -> "A-Bb-Ccc-Dddd"
accum("RqaEzty") -> "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
accum("cwAt") -> "C-Ww-Aaa-Tttt"
The parameter of accum is a string which includes ... |
7dc89be452a88e210dc6266c4df0e274f3f235fe | j-217/python | /codewars/82_k_primes.py | 933 | 3.703125 | 4 | def Kprime(k, num):
prime_factors = []
count = 0
p = 2
while p <= num and count < k:
if num % p == 0:
prime_factors.append(p)
num /= p
count += 1
else:
p += 1
# print(prime_factors if num == 1 and count == k else False)
return prime... |
3fe3e6dd585457b6194cefd2af8d5478742467dc | olivier555/projet_metaheuristiques | /visualization.py | 2,850 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Class that used matplotlib to visualize the data and the solutions.
"""
import matplotlib.pyplot as plt
class Visualizator:
def __init__(self, data, solution):
self.data = data
self.solution = solution
def print_sensors(self):
""" Draw all the targets and ... |
f92ef286f936a0919fdf38ad761e7e67950173ff | robertpiazza/ProfessionalDevelopment | /Exploring Data Science/2-1-3 Correlation.py | 8,400 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jan 5 11:30:10 2018
@author: 593787 Robert Piazza - Booz Allen Hamilton
"""
## Data Science Examples from ExploringDataScience.com
#Describe-Correlation Section 2.1.3
#Correlation is not causation
#Pearson Product-Moment Correlation Coefficient-r-
#Measures the strength o... |
f8ec548d9d721eddaef607ccd020b5ee33e0a82d | robertpiazza/ProfessionalDevelopment | /Jupyter Notebooks/Extras/Supervised Learning with Scikit-Learn/Regression.py | 10,089 | 3.9375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 5 10:22:18 2018
@author: 593787 Robert Piazza - Booz Allen Hamilton
"""
"Datacamp-Supervised Learning with Scikit-learn: Regression
#%%Introduction to regression
#Boston housing data
X = boston.drop('MEDV', axis=1).values
y = boston['MEDV'].values
##Predicting house... |
3044cb72f40cfdc48019d19bec2980d9a03dcb79 | robertpiazza/ProfessionalDevelopment | /Exploring Data Science/4-1-4 Neural Networks.py | 32,282 | 3.953125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 18 15:40:19 2018
@author: 593787 Robert Piazza - Booz Allen Hamilton
"""
##Predict-Neural Networks Section 4.1.4
#%% Use neural networks for classification problems
#We first look at some quick applications of neural networks; then we move on
#to building our own neur... |
641bfce970f72a987f49da0e02dcb30c47500c9f | shashwat-1234/ARK-task-round | /task1.py | 2,877 | 3.609375 | 4 | #!/usr/bin/env python
import sys
import click
#player = true is max, player = false is min agent
from env import TicTacToeEnv, agent_by_mark, check_game_status,\
after_action_state, tomark, next_mark
class HumanAgent(object):
def __init__(self, mark):
self.mark = mark
def act(self, state, ava_actions):
whi... |
f09926b9c4d72da94098f6e11200a7f5c0d38878 | fergusfrl/COSC326-projects | /PeanutsAndPretzels/PeanutsAndPretzels.py | 927 | 3.8125 | 4 | # Fergus Farrell
# Etude 4 - Peanuts and Pretzels
#Prints W/L table - will be unessessary in final product
def printtable(table):
for x in table:
print x
def generatetable(size, moves):
table = []
for i in range(size):
table.append('W')
for i in range(len(moves)):
... |
c3791c5dc2cdacd8fe6ad9347fd2f4a1501051b9 | HsuTungHsun/Code | /password.py | 267 | 4.0625 | 4 | password = 'a123456'
i = 3
while i > 0 :
i = i - 1
pwd = input('Enter your password: ')
if pwd == password:
print('Success')
break
else:
print('Error')
if i > 0:
print('You still have', i ,'Times chance')
else:
print('You are not the user')
|
f0c8ba2075b3da7e9c7670c0189a5cd0f9f91473 | Zejjs/VigenereCrack | /languageFunctions.py | 4,918 | 4.375 | 4 | import string
def check_for_spaces(text):
"""
Utility function ussed for checking whether text contains spaces.
Args:
text: a string to be checked for whether it contains spaces
Returns:
bool: True if text has spaces, False if not
"""
for char in text:
i... |
fc3836525588fd644efc1b5a6adc6dd712f7bf93 | saucec0de/sifu | /Challenges/chal_lib/cflowcheck.py | 6,456 | 3.53125 | 4 | #!/usr/bin/python3
#
# Copyright (c) Siemens AG, 2020
# tiago.gasiba@gmail.com
#
# SPDX-License-Identifier: MIT
#
import os
import re
import subprocess
DEFAULT_ARGUMENTS = ['--omit-symbol-names', '--omit-arguments']
DEFAULT_TIMEOUT = 3
def check_if_called_by(source_files_list, parent_function_name, function_nam... |
624be90541c17e474af1061337fd34582ce679c5 | thatpaiguy/Wordification | /matching_game/word2.py | 709 | 3.625 | 4 | #word2.py
class Word():
def __init__(self, _word, _phoneme, _grapheme, _sounds):
self.word = _word
self.phoneme = _phoneme
self.spelling_pattern = _grapheme
self.sounds = _sounds
def __str__(self):
return "%s" %self.word
def __eq__(self, other_word_str):
return self.word == other_word_str... |
ded2fa7eb7470cbe3c03f4a725dbd482e00ccbff | DanielSOhara27/DataBootcamp-PythonVanilla-Module | /PythonClass2/netflixLookup.py | 635 | 3.734375 | 4 | import csv
import os
csvPath = os.path.join("netflix_ratings.csv")
found = False
with open(csvPath, newline="") as netflix:
csvReader = csv.reader(netflix, delimiter=",")
csv_headers = next(csvReader)
#csv_data = next(csvReader)
searchVid = input("What is the exact name of the movie you ar... |
8cbe7c0a25ff5880eee578f378e3631763e894ec | DanielSOhara27/DataBootcamp-PythonVanilla-Module | /PythonClass2/ClassActivity1_ForLoops.py | 240 | 4.25 | 4 | option = "y"
while option != "n":
numbers = int(input("How many numbers should I print?"))
for x in range(numbers):
print(f"{x}\n")
option = input("Do you want to print another range of numbers? (y)es or (n)o?")
|
1ec7ecd4c05b1cf46242bccd03a01bc59f642af6 | Abutalibhasan/Module10 | /Employee.py | 2,211 | 3.984375 | 4 | class Employee:
'''Employee Class '''
# Constructor
def __init__(self, lname, fname, addr, phone, salaried, st_date, sal):
self.last_name = lname
self.first_name = fname
self.address = addr
self.phone_number = phone
self.salaried = salaried
self.start_da... |
5481d205472b46b7c169988fa2e57af4f7afb658 | MauHylian/tareas-info | /frecuencias-de-entrada/frecuencias.py | 1,124 | 3.90625 | 4 | # Suponiendo que se tiene una matriz de probabilidades de transición
# este programa calcula las frecuencias de salida.
import numpy as np
import math
# Contruye una matriz de probabilidades de transición
filename = './datos.txt'
with open(filename, 'r') as f:
matriz = [[float(num) for num in line.split(... |
7b987fb712884ec97598941922b3a93d2a3cc2da | jncornett/autorun | /autorun/metadata.py | 539 | 3.53125 | 4 | class Map(dict):
"""
>>> m = Map()
>>> m
{}
>>> m['key'] = ('left', 'right')
>>> m['key']
'left'
>>> m['/key']
'right'
>>> m['missing']
''
>>> m['/missing']
''
>>> m[''] = '[]'
>>> m['']
'['
>>> m['/']
']'
"""
def __getitem__(self, key):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.