blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
2f5aa37e954fb70f4e79c7e8cb20f38a2ecea505 | blackdragonbonu/ctcisolutions | /ds/queue.py | 799 | 3.78125 | 4 |
class Queue():
def __init__(self):
self.size=0
self.top=None
self.data=[]
def push(self,data):
if not data:
try :
raise ValueError("Should supply an integer or string, but was supplied None")
except ValueError:
print ("Exception encountered")
self.size+=1
self.data.append(data)
return d... |
c9be1a47a097dd919adee84d73defe966d4b5e45 | You-NeverKnow/algorithmPractice | /binaryTree/trials.py | 1,222 | 3.8125 | 4 | import random
from binaryTree import BinaryTree
from node import Node
# -----------------------------------------------------------------------------|
def check_sort(some_list, sorted_list):
"""
"""
for each_element in some_list:
if each_element not in sorted_list:
return False
... |
26e7320e8a1ce927ca724e5f0a6e7bdff5f66344 | gundogduelif/total_comprehension | /total_comprehension.py | 1,072 | 3.84375 | 4 | # total_comprehension.py
my_numbers = [1, 2, 3, 4, 5, 6, 7]
print("--------------")
print("ORIGINAL LIST:", my_numbers)
print("--------------")
print("TOTAL COMPREHENSION...")
maplist = [n * 100 for n in my_numbers]
print("--------------")
print("MAPPED LIST:", maplist)
greater_than_three = [n f... |
c7fa85fa92c1067fbc53dde8f51e2c7b60bea3aa | MaxKircher/RL-project | /MORE/plot_data.py | 857 | 3.65625 | 4 | import numpy as np
from matplotlib import pyplot as plt
def plot(rewards, list_of_parameter, n, b_history):
'''
If the dimension of the parameters is 2,
this function plots the current memory samples and the means of all previous search distributions.
:param rewards: {list} the rewards, corresponding ... |
7e8cf310893c959860df7a9436bdbe09256dd7a3 | FerranElias/Machine-Learning | /ClusteringFindingRelatedPosts.py | 6,907 | 3.53125 | 4 | from sklearn.feature_extraction.text import CountVectorizer
import scipy as sp
vectorizer=CountVectorizer(min_df=1) #min_df means that words that occur less than 1 time will be dropped. it could also be a frequency
print(vectorizer)
content=["How to format my hard disk","Hard disk format problems"]
X=vectoriz... |
783115f92f803d5efd2419c02d71062b3a9079f3 | JiarongChang/main | /0323_Class5-3.py | 3,444 | 3.671875 | 4 | #繼承
"""
class Member: #父類別
def __init__(self,new_gender,new_major,new_id):
self.__gender = new_gender
self.major = new_major
self.id = new_id
def set_gender(self,new_gender):
if new_gender == 'M' or new_gender == 'F':
self.__gender = new_gender
else:
... |
6aa56313f436099121db045261afc16dbcac9595 | Adrianbaldonado/learn_python_the_hard_way | /exercises/exercise_11.py | 304 | 4.25 | 4 | """Asking Qestions
The purpose of this exercise is to utilize all ive learned so far
"""
print("How old are you?", end=' ')
age = (' 22 ')
print("How tall are you?", end=' ')
height = ( 5 )
print("How do you weigh?", end=' ')
weight = ('160')
print(f"So, you're{age} old, {height} tall and {weight}") |
7d918e1e0c33650003a6b169a43bfbd99c704d63 | anonim9878/FindALittleFox | /SearchFox/Objects/objects_in_game.py | 17,305 | 3.640625 | 4 | import random
#Класс доски.
class Board:
def __init__(self, xsize, ysize):
self.__xsize = xsize
self.__ysize = ysize
def print_board1(self, lis_obj):
#Заполняем список для отоброжения объектов. Сначала заполняем его пустотой, чтобы потом её заменить на символы объектов без помех.
... |
4e4175253990a829cf7bf4161ea8eb7f4b7c0527 | Gagangithub1988/Python | /Python_basics/test.py | 82 | 3.53125 | 4 | ex=input("Enter some expression:")
result=eval(ex)
print("The result:",result)
|
943f8cbdbbaf78edec5bbdde5f589b8cdb71e399 | Gagangithub1988/Python | /Python_basics/math_factorial.py | 127 | 4 | 4 | from math import factorial
f=int(input("Enter a number: "))
fact=factorial(f)
print("Factorial of given number is",fact)
|
c5252784a62dc2feb81188c4a186450b28f3ac2e | Gagangithub1988/Python | /Python_basics/test4.py | 108 | 3.96875 | 4 | name = input("Enter a name:")
i=0
for x in name:
print('The character present at',i,'index is',x)
i+=1 |
7e37cf300e8718b90c568af5389bd5274efd683f | Gagangithub1988/Python | /Python_basics/test2.py | 122 | 3.734375 | 4 | from sys import argv
print(type(argv))
args=argv[1:]
sum=0
for x in args:
n=int(x)
sum+=n
print("The sum=",sum) |
5047f993f52b45e1d96e66664c40bc33e49bf431 | Gagangithub1988/Python | /Python_basics/test3.py | 124 | 3.65625 | 4 | name="Gagan"
salary=10000
gf="sima"
print("Hello {} is getting salary {} and my gf {} is waiting".format(name,salary,gf)) |
fd5bd2acc11881de02fe6138828bdd17e980b404 | Gagangithub1988/Python | /Python_basics/concat.py | 137 | 3.6875 | 4 | def concat(list):
result=""
for element in list:
result+=str(element)
return result
print(concat([1,2,3,4,676])) |
bf6dcecae6f3a14a73dd6e8b072e390cd9d3d576 | Gagangithub1988/Python | /Python_basics/type_error.py | 169 | 3.796875 | 4 | def integer_type(a,b):
if not(isinstance(a,int) and isinstance(b,int)):
raise TypeError("Inputs must be integer")
return a+b
print(integer_type(3,8)) |
75b42f3daf3f7a3bd8f2a837256c104da171ce26 | Empty0Qc/New-Empty | /Python/calc.py | 758 | 3.890625 | 4 | """class Student:
def __int__(self):
self.name = ''
self.id = 0
self.subject = ''
class ClassRoom:
def __int__(self):
self.name = ''
self.pos = ''
class School:
def __init__(self):
self.students = [Student() for _ in range(0,)]"""
class Computer:
de... |
7866251dc7ff7718afed796c3270de4ccce0167d | grnbeltwarrior/Caesar_Cipher_Python_Broken | /Caesar_Cipher.py | 1,848 | 3.90625 | 4 | # Reverse Cipher
# Use python3
import sys
import optparse
parser = optparse.OptionParser()
parser.add_option('-c',
action="store",
dest="caesar")
# Key Shift
parser.add_option('-s',
action="store",
dest="shift")
# Encrypt or Decrypt
parser.add_option('-m',
action="store",
dest="mode")
# Placeho... |
e03f4d4f9d44fcb1e2d91f640f6d569cb2c2ca73 | L200150056/Algoritma-dan-Struktur-Data-Python | /tugas-02.py | 339 | 3.5 | 4 | print "\tDaftar KODE ASCII"
print("---------------------------------------")
print("%9s | %7s | %4s | %9s |" %("character","decimal","hex","binary"))
print("---------------------------------------")
for i in range(32,126):
print("%9c | %7d | %4s | %9s |" %(i, i, hex(i),bin(i)))
print("----------------------------... |
35a8521f9997e8ad51229ad55d37cc905cf15767 | selenadali/DataBase-and-Statistics-Utilities | /MatrixMultiplication.py | 2,405 | 3.5 | 4 | #Input Format
#
#First line of the input will contain the number of test cases, for each test case, there will be two matrices. For each matrix, the first line will contain the number of rows and columns and from the second line, row*column number of elements of matrix will be given. We have already written the input h... |
f2a7fd7fb6de22789cefaf3fa70805cb53164254 | kellybrower/crypto_alg | /shanks_bin.py | 797 | 3.671875 | 4 | import math as m #for floor and square root functions
def fast(N, g, A):
'''find g^{A} mod N using successive squares algorithm'''
a = g #set a to g
b = 1 #set b to 1
while A>0: #as long as A > O
if A % 2 == 1: #if A is odd
b = (b*a) % N
a = pow(a, 2, N) #a gets squared mod N
A = A//2 #A gets cut in ... |
c0f94cf99dab17bcd3ee64bb69252e9a9c91d965 | kellybrower/crypto_alg | /congruential.py | 1,026 | 3.765625 | 4 | #oreviously seen on web https://en.wikibooks.org/wiki/Algorithm_Implementation/Mathematics/Extended_Euclidean_algorithm#Python
def xgcd(a, b):
"""return (g, x, y) such that a*x + b*y = g = gcd(a, b)"""
x0, x1, y0, y1 = 0, 1, 1, 0
aye = a
bee = b
while a != 0:
q, b, a = b // a, a, b % a
... |
4db8bc81eaba2f47526c3f910480fba931ce483a | dpiskosz/codewars | /anagram.py | 437 | 3.75 | 4 | te = "Creative"
org = "Reactive"
def is_anagram(test, original):
len_or = len(original)
len_test = len(test)
if len_or == len_test:
for x in test.lower():
if x not in original.lower():
return False
else:
new_org = original.lower().replace(x, ... |
b4c4d34528626fa7cd0899684b4ac6f533e5f678 | Cemeria/my_spyderfile | /untitled9.py | 155 | 3.578125 | 4 | list1=[]
def my_range(x):
a=0
while a<x:
a+=1
return a
for b in my_range(20):
list1.append(b)
print(list1)
|
b69fe6135d5d17fc809878070145b20bd7580c1d | Cemeria/my_spyderfile | /untitled13.py | 134 | 3.53125 | 4 | list1=['qwer','erer','yiyu','asdf']
def e(a,i=0):
for b in a:
yield i,b
i=i+1
print(list(e(list1,1)))
|
7698e0b9b61f53c6e23fedde9a865e1773d38c73 | DiggingSteve/PyPlayground | /Ten/ten/basic2_grad.py | 638 | 3.703125 | 4 | import tensorflow as tf
#在机器学习中,我们经常需要计算函数的导数。TensorFlow 提供了强大的 自动求导机制 来计算导数。在即时执行模式下,TensorFlow 引入了 tf.GradientTape() 这个 “求导记录器” 来实现自动求导。以下代码展示了如何使用 tf.GradientTape() 计算函数 y(x) = x^2 在 x = 3 时的导数:
x = tf.Variable(initial_value =3.)
with tf.GradientTape() as tape: # 在 tf.GradientTape() 的上下文内,所有计算步骤都会被记录以用于求导
y... |
52ed48dd7ec69fee3c9a9fb7d221686c16bc8c63 | atique08642/Basic-Common-Codes | /Sum of First N Natural numbers.py | 155 | 3.828125 | 4 | def sum(number):
counter=0
for i in range (0,number+1):
counter+=i
return counter
number=int(input())
result=sum(number)
print(result) |
8fea985ba7979287dc8f9e5231da4fbe595ece57 | atique08642/Basic-Common-Codes | /Leap Year.py | 194 | 4.1875 | 4 | def LeapYear(year):
if (year%4==0 and year%100!=0 or year%400==0):
return True;
year=int(input())
if (LeapYear(year)==True):
print("leap year")
else:
print("not a leap year") |
18b210811e067834d980f7b80b886d36e060d65b | deepikaasharma/unpacking-list | /main.py | 310 | 4.34375 | 4 | # Create a list
some_list = ['man', 'bear', 'pig']
# Unpack the list
man, bear, pig = some_list
'''
The statement above is equivalent to:
man = some_list[0]
bear = some_list[1]
pig = some_list[2]
'''
# Show that the variables represent the values of the original list
print(man, bear, pig)
print(some_list) |
8d73fa94c4c7f8ce7c9522d02d7e68aa47cfa215 | AadamBodunrin/Python-Analytics | /Hello_world.py | 11,911 | 4.15625 | 4 | #Using the max function, which is higher 5 or 23?
x = 5
y = 23
z = max(x,y)
print(z)
#Use the math function to find the square root of 74
#Option 1
import math
x = 74
y = math.sqrt(x)
print(y)
#Option 2
import math as m
x = 74
y = m.sqrt(x)
print(y)
#option 3
from math import sqrt
x = sqrt(74)
print(x)
#Use the ea... |
47b02d458cfc1dc5b64334fad6fd57cb2169fde5 | linseb325/Wallpaper | /WallpaperGenerator.py | 3,233 | 4.125 | 4 | # Generates a matrix of characters based on three arguments. Capable of both 2 and 3-color wallpaper.
class WallpaperGenerator:
__corna = None
__cornb = None
__side = None # The side argument is an upper bound on (i * self.__side / 10) and (j * self.__side / 10)
# in ... |
1a6dfa2fb7db6a3d0d4c349afc09c7868dc3af5e | micha-wirth/Lecturio | /loops.py | 422 | 4.15625 | 4 | # for x in list
for x in [1, 2, 3]:
print(x)
# for c in string
for c in 'abc':
print(c)
# for i in range(0, 3, 1):
for i in range(3):
print(i)
print(list(range(3)))
# while-loop
x = 0
while x < 3:
print(x)
x += 1
# break-statement
while True:
if x == 3:
print('End of while-loop')
... |
eb0ba706baa251c56bbaaaafa25110ae5b7d18db | micha-wirth/Lecturio | /sequences.py | 248 | 4.1875 | 4 | text = 'abcdefghiklm'
print('a' in text)
print('x' in text)
t = tuple(range(3))
print(0 in t)
print(3 in t)
# Last element of a sequence.
print(text[len(text) - 1])
print(text[-1])
print(max(text))
print(t[len(t)-1])
print(t[-1])
print(max(t))
|
3044a25340b9c3f6f1619189ee02b42a5e1cebbf | benpm/advent-of-code-2020 | /original_solutions/day_3/day_3B.py | 436 | 3.578125 | 4 | def f(r, d):
with open("input_3.txt") as f:
i = 0
trees = 0
lines = [line for line in f]
print(len(lines))
for x in range(d, len(lines), d):
line = lines[x]
i = (i + r) % (len(line) - 1)
if line[i] == "#":
trees += 1
... |
dc54020447467d8c25d9391e8c4bc8af9b29ef8e | schadr/interview | /q009.py | 1,467 | 3.859375 | 4 | # find the x-percentile in a given list of numbers
import sys
import random
def swap(l,i,j):
h = l[i]
l[i] = l[j]
l[j] = h
def partition(numbers):
pivot_index = random.randint(0,len(numbers)-1)
swap(numbers,0,pivot_index)
pivot_index = 0
end = len(numbers) - 1
while pivot_index < end:
if numbers[... |
8f9a45a4af0fc53ad1a0ec16e4c05317984dda93 | Viveekk1223/Shipt-Take-Home-Interview-Questions-Solutions---Python | /Q6.py | 2,174 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 23 16:10:17 2019
@author: shah1
"""
#Setting directoy to the folder that contains the data
#Importing pandas and json libraries
import pandas as pd
import json
parsing_data = pd.read_csv('InterviewData_Parsing.csv')
'''
For this question, I tried to sol... |
68d522b9898e61db50042452e5fba185a2188b3d | satheesh-krishnan/Python-Introspection | /introspection/uselambda.py | 122 | 3.53125 | 4 | def sumfunc(f,l):
e=0
for each in l:
e+=f(each)
return e
print sumfunc(lambda x: x*x*x,[3,5,6,7,8])
|
9ee2d6ea090f939e7da651d7a44b204ff648168a | ShumbaBrown/CSCI-100 | /Programming Assignment 3/guess_the_number.py | 874 | 4.21875 | 4 | def GuessTheNumber(mystery_num):
# Continually ask the user for guesses until they guess correctly.
# Variable to store the number of guesses
guesses = 0
# loop continually ask the user for a guess until it is correct
while (True):
# Prompt the user of a guess
guess = int(input('En... |
fb4c7fb1ed013464f9fe3ff32582a169f28aa569 | ShumbaBrown/CSCI-100 | /Lab 4/get_next_date_extra_credit.py | 2,468 | 3.90625 | 4 | def GetNextDate(day, month, year, num_days_forward):
# Return next date as a str.
while (num_days_forward != 0):
if (num_days_forward > 0): #Where the days need to be subtracted
day = day + 1
num_days_forward = num_days_forward - 1
maxDay = 28
if ... |
d02467d8e5ec22b8daf6e51b007280d3f4c8a245 | malav-parikh/python_programming | /string_formatting.py | 474 | 4.4375 | 4 | # leaning python the hard way
# learnt the basics
# string formatting using f
first_name = 'Malav'
last_name = 'Parikh'
middle_name = 'Arunkumar'
print(f"My first name is {first_name}")
print(f"My last name is {last_name}")
print(f"My middle name is {middle_name}")
print(f"My full name is {first_name} {middle_name}... |
9bb206159234a31c63432e2d2827abf83bf20a95 | sandeep24789/Python | /Python/Python customized/DAY1/Demo1_scripts/Day1_scripts/16_rangefunc2.py | 191 | 4.21875 | 4 | # Program to iterate through a list using indexing List of genre
genre = ['pop','rock','jazz']
# iterate over the list using index
for i in range((len(genre))):
print("I like",genre[i]) |
09ea58e6d6b6f6a7054cf399ce43b623d02ba8ce | sandeep24789/Python | /Python/Python customized/DAY1/Demo1_scripts/Day1_scripts/20_break.py | 88 | 3.75 | 4 | for val in "string":
if val == "i":
break
print(val)
print("The end") |
755534b372a57f959d5c5fd3432b79dd592e7975 | sandeep24789/Python | /Python/Demo1.py | 126 | 3.578125 | 4 | print("welcome to python training")
a=int(input("enter a value"))
b=int(input("enter b value"))
c=a+b
print(type(c))
print(c)
|
61136a4d7909f2022a83b7aeff512fab0ae28110 | sandeep24789/Python | /Python/Python customized/DAY1/Demo2/Day5DemoScritps/DemoExcel1.py | 448 | 3.71875 | 4 | #import relevant module
import openpyxl
#Opening excel workbook
wb = openpyxl.load_workbook('c:/Training/PyFiles/example.xlsx')
#Accessing a specific sheet
sheet = wb.get_sheet_by_name('Sheet1')
print(sheet.title)
#Different ways to get to cells
print(sheet['A1'])
print(sheet['A1'].value)
print(sheet.cell(row=1, c... |
b79a10f76760df2f287fb6422325266bf75632c4 | angelika22/if_for_while | /2py.py | 122 | 3.765625 | 4 | import math
a=int(input("dati numarul "))
s=0
for b in range (1, a+1):
s+=math.factorial(b)
print("suma este", s) |
e4e80522ce19e03c1c6bceee954741d324d79b44 | ffabiorj/desafio_fullstack | /desafio_parte_1/question_1.py | 504 | 4.1875 | 4 | def sum_two_numbers(arr, target):
"""
The function receives two parameters, a list and a target.
it goes through the list and checks if the sum of two numbers
is equal to the target and returns their index.
"""
number_list = []
for index1, i in enumerate(arr):
for index2, k... |
9e9f0e24bb215558d38a22a64e56b4639cae754f | jiangliqin/boyu-platform-pytorch-lessons | /Scripts/lesson_28_DCGAN.py | 12,669 | 3.5625 | 4 | Deep Convolutional Generative Adversarial Networks
we introduced the basic ideas behind how GANs work. We showed that they can draw samples from some simple, easy-to-sample distribution, like a uniform or normal distribution, and transform them into samples that appear to match the distribution of some dataset. And whi... |
0ddce913c1e7e98e9cee507999dc40ef36f98049 | AnhVuH/vuhonganh-fundamental-c4e16 | /session02/maze.py | 131 | 3.84375 | 4 | from turtle import *
shape("turtle")
length = 20
for i in range(30):
forward(length)
left(90)
length += 5
mainloop()
|
fc1dbd3d51983fc1908799003240f42171d27e8d | AnhVuH/vuhonganh-fundamental-c4e16 | /session03/homework/ex2_6.py | 895 | 3.828125 | 4 | flock = [5, 7, 300, 90, 24, 50, 75]
def shearing(month,last_month):
if month == 0:
print("Hello, my name is Hong Anh and here is my flock")
print(flock)
print()
else:
print("MONTH {} :".format(month))
print('One month has passed, now here is my flock')
for i in r... |
836b0ef11b1e389e78b91511b9fcbfe167b3d420 | AnhVuH/vuhonganh-fundamental-c4e16 | /session05/homework/ex3.py | 258 | 4.15625 | 4 | bacterias = int(input('How many B bacterias arer there? '))
minutes = int(input('How much time in minutes will we wait? '))
for time in range(1,minutes,2):
bacterias *= 2
print("After {} minutes, we would have {} bacterias".format(minutes, bacterias))
|
b3e5a19eb9c9d5cf6326972d352ef7aa91ae731f | AnhVuH/vuhonganh-fundamental-c4e16 | /session05/homework/ex2_without_count.py | 221 | 4.09375 | 4 | numbers = [1, 6, 8, 1, 2, 1, 5, 6]
count = 0
num_count = int(input("Enter a number? "))
for num in numbers:
if num == num_count:
count += 1
print("{0} appears {1} times in my list".format(num_count, count))
|
e3c20aa1677c13d4c0ccf63d2f7180e717a39cb4 | AnhVuH/vuhonganh-fundamental-c4e16 | /session02/yob.py | 259 | 4.125 | 4 | yob = int(input("Your year of birth: \n"))
age = 2018 - yob
print("Your age: ",age)
if age < 10: #conditional statement
print("Baby")
elif age <= 18:
print("teenager")
elif age ==24:
print("asfsdfsdf")
else:
print("Not baby")
print("Bye")
|
9bd07190836f147e0e1fc401d19bc0d4c5c91b36 | AnhVuH/vuhonganh-fundamental-c4e16 | /session05/homework/ex4.py | 221 | 3.890625 | 4 |
def rabbits(month):
if month == 0 or month ==1:
return 1
else:
return rabbits(month -1) + rabbits(month-2)
for i in range(5):
print('Month {}: {} pair(s) of rabbit'.format(i, rabbits(i+1)))
|
d7b55cb1fcfe6ab3df53a71dcf82912cd00b4238 | AnhVuH/vuhonganh-fundamental-c4e16 | /session04/prime_number.py | 442 | 4.09375 | 4 | #input
number = int(input("Enter a number: "))
#process
is_not_prime = False
# for i in range(2,number):
# if number % i == 0:
# is_not_prime = True
# break
i = 2
while i <= (number**0.5): # dung while de tranh khai can ra so le
if number % i ==0:
is_not_prime = True
break
... |
f388af7884f54b799c5538fc30bc65762206f111 | AnhVuH/vuhonganh-fundamental-c4e16 | /session02/homework/3d_2.py | 198 | 3.8125 | 4 | n = int(input("Enter a number: "))
for i in range(n):
for j in range(n):
if (i + j) % 2 == 0:
print(1, end = " ")
else:
print(0, end = " ")
print()
|
a44e68c7cd563d146c6ffe1c63ec63c07104c79f | AnhVuH/vuhonganh-fundamental-c4e16 | /session01/homework/turtle_1.py | 547 | 3.875 | 4 | from turtle import *
import turtle
sc = turtle.Screen()
sc.bgcolor("green")
sc.title("star & clock")
a = turtle.Turtle()
a.shape("blank")
a.color("black")
a.pensize(5)
b = turtle.Turtle()
b.shape("turtle")
b.color("pink")
b.pensize(10)
a.penup()
a.setpos(100, 100)
a.pendown()
a.fillcolor("blue")
a.begin_fill()
for i... |
7a3f28ae1d57d3f409a176fdaf38a5555fbcb0a1 | mkaraev/data_structures_stepik | /stack_with_max_naive.py | 971 | 3.71875 | 4 | # python3
import sys
from collections import namedtuple
Pair = namedtuple("Pair", ["first", "second"])
class StackWithMax:
def __init__(self):
self.__stack = []
def push(self, a):
if len(self.__stack) == 0:
self.__stack.append(Pair(a, a))
else:
max_ = max(sel... |
58f0290c093677400c5a85267b1b563140feda85 | FrancescoSRende/Year10Design-PythonFR | /FileInputOutput1.py | 1,512 | 4.53125 | 5 | # Here is a program that shows how to open a file and WRITE information TO it.
# FileIO Example 3
# Author: Francesco Rende
# Upper Canada College
# Tell the user what the program will do...
print ("This program will open a file and write information to it")
print ("It will then print the contents to the screen for y... |
2306ffb05eecd0dc048f36c8359b7684178f0634 | MuhammadRehmanRabbani/Python | /Average of 2D Array python/average.py | 1,260 | 4.28125 | 4 |
# defining the average function
def average(matrix,matrix_size):
my_sum = 0 # declaring variable to store sum
count = 0 # declaring variable to count total elements of 2D array
# this for loop is calculating the sum
for i in range(0, matrix_size):
for j in range(0, matrix_size):
... |
981d6e3e7bd1100f3946ef73a501a86a08195cf3 | ryankupyn/eulerprobs | /euler21/Amicablechecker.py | 153 | 3.625 | 4 | import math
def factorsum(num):
total = 0
for hop in range(1,int(num/2)+1):
if num % hop == 0:
total += hop
return total
|
356a8c8ecc88afd964c5a83dc438890a3326b483 | girishsj11/Python_Programs_Storehouse | /Daily_coding_problems/daily_coding_2.py | 737 | 4.125 | 4 | '''
Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.
For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expect... |
e84d57cd9fa56d4d7ff746d0f12d4503aea78776 | girishsj11/Python_Programs_Storehouse | /special_chars_in_string.py | 1,025 | 3.953125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 10 12:20:37 2021
@author: giri
"""
def main():
string = str(input("Enter the string : "))
lower_letters = [chr(x) for x in range(97,97+26)]
special_char = dict()
for i in string.lower():
if (i in lower_letters):
... |
c7e2a1289a0dd76385e19c244c026532c413d78e | girishsj11/Python_Programs_Storehouse | /student_ranking_series/input_file_creation.py | 2,705 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 10 15:22:13 2020
@author: gshambul
"""
student_count = int(input("Enter the students count in a class : "))
subject_count = int(input("Enter the subjects count which each student has on this academic year : "))
student_name_list = list()
subject_name_list = l... |
9d3dad6f365a6e73d00d90411f80a1a6e165f0cf | girishsj11/Python_Programs_Storehouse | /codesignal/strstr.py | 1,378 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 26 12:33:18 2021
@author: giri
"""
'''
Avoid using built-in functions to solve this challenge. Implement them yourself, since this is what you would be asked to do during a real interview.
Implement a function that takes two strings, s and x, as a... |
1f75ec5d58684cd63a770bd63c7aab3ee7b26de6 | girishsj11/Python_Programs_Storehouse | /codesignal/largestNumber.py | 569 | 4.21875 | 4 | '''
For n = 2, the output should be
largestNumber(n) = 99.
Input/Output
[execution time limit] 4 seconds (py3)
[input] integer n
Guaranteed constraints:
1 ≤ n ≤ 9.
[output] integer
The largest integer of length n.
'''
def largestNumber(n):
reference = '9'
if(n==1):
return int(reference)
eli... |
478ed1b0685ac4fda3e3630472b2c05155986d50 | girishsj11/Python_Programs_Storehouse | /codesignal/Miss_Rosy.py | 2,510 | 4.15625 | 4 | '''
Miss Rosy teaches Mathematics in the college FALTU and is noticing for last few lectures that the turn around in class is not equal to the number of attendance.
The fest is going on in college and the students are not interested in attending classes.
The friendship is at its peak and students are taking turns fo... |
c2a75ef51bbded2f3d0226531d2480807e956270 | girishsj11/Python_Programs_Storehouse | /Find_who_tweeted_the_most/Find_who_tweeted_the_most.py | 3,046 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Oct 19 20:26:25 2020
@author: giri
"""
'''
Assignment: Find who tweeted the most
You will be given a list of tweets
Your program should find the user who has tweeted the most
Note:
If multiple users are having same number of tweets, then print all the users in ... |
b986d60ff29d4cf7ff66d898b5f0f17a29a168cb | girishsj11/Python_Programs_Storehouse | /prime_numbers_generations.py | 577 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 14 16:00:24 2021
@author: giri
"""
def is_prime(num):
"""Returns True if the number is prime
else False."""
if num == 0 or num == 1:
return False
for x in range(2, num):
if num % x == 0:
return False
... |
35be823ee064e70ecf91ba8a3175e22210693370 | dk-master/pythonday | /algo/이상한문자.py | 332 | 3.625 | 4 | def solution(s):
answer = []
temp_list = s.split(" ")
for temp in temp_list :
s = ""
for i in range (len(temp)) :
if i%2 == 0 :
s += temp[i].upper()
else :
s += temp[i].lower()
answer.append(s)
answer =' '.join(answer)
r... |
0eecd16e02816be659f35df5e7441d9a7bd698d6 | dk-master/pythonday | /algo/키패드누르기.py | 1,214 | 3.609375 | 4 | def solution(numbers, hand):
answer = ''
phone = {1 : (0,0) ,2 : (0,1) ,3 : (0,2),
4 : (1,0), 5 : (1,1), 6 : (1,2),
7 : (2,0) ,8 : (2,1), 9 : (2,2),
'*' : (3,0) , 0 : (3,1), '#' : (3,2)}
left = '*'
right = '#'
for i in numbers :
if i in [1,4,7]:
... |
8b6aad04e70312c2323d1a8392cef1bc10587b2e | Stone1231/py-sample | /loop_ex.py | 413 | 4.125 | 4 | for i in [0, 1, 2, 3, 4]:
print(i)
for i in range(5):
print(i)
for x in range(1, 6):
print(x)
for i in range(3):
print(i)
else:
print('done')
#A simple while loop
current_value = 1
while current_value <= 5:
print(current_value)
current_value += 1
#Letting the user choose when to qu... |
73ea99af5ea85fb3d9c3dfd2a09f15210e00c94d | Stone1231/py-sample | /oop/multiple_inheritance.py | 435 | 3.953125 | 4 | class Foo(object):
foo = 'attr foo of Foo'
def get_str(self):
return "hello~"
class Bar(object):
foo = 'attr foo of Bar' # we won't see this.
bar = 'attr bar of Bar'
def get_str(self):
return "hi~"
def output(self):
s = self.get_str() # 會call Foo
print(f"{s} {self.... |
3e8279a7b1602b9bc6f58257381160a8eca0e210 | Stone1231/py-sample | /oop/inheritance.py | 825 | 3.953125 | 4 | from class_ex import Dog
class SARDog(Dog):
"""Represent a search dog."""
def __init__(self, name, heigh, weight):
"""Initialize the sardog."""
super().__init__(name, heigh, weight)
def search(self):
"""Simulate searching."""
print(self.name + " is searching.")
... |
11fecda841a0e39ae55ecbc36f62adaa130ec728 | alexsoulfear/classwork_6 | /lesson_sandbox.py | 316 | 3.8125 | 4 | import re
while True:
date = input("Enter date [DD.MM.YYYY]: ")
if re.match('([0-2][0-9]|3[01]).\d\d\.\d\d\d\d', date):
date_lst = date.split('.')
date_lst[1], date_lst[0] = date_lst[0], date_lst[1]
print('.'.join(date_lst))
break
else:
print('Incorrect date!')
|
14526825452575817d44723b6bdbfe1472ca1e8b | mikvikpik/Project_Training | /name.py | 467 | 3.84375 | 4 | # practice printing name
name = "ada lovelace"
print(name.title())
# practice changing string properties
name = "Ada Lovelace"
print(name.upper())
print(name.lower())
# practice concatenating strings
first_name = "ada"
last_name = "lovelace"
full_name = first_name + " " + last_name
print(full_name)
# practice concat an... |
ded47265e7eda94698d63b24bd4665b2e8afb16e | mikvikpik/Project_Training | /whitespace.py | 308 | 4.1875 | 4 | """Used in console in book"""
# Print string
print("Python")
# Print string with whitespace tab: \t
print("\tPython")
# Print multiple whitespaces and strings
print("Languages:\nPython\nC\nJavaScript")
# variable set to string and call variable without print
favorite_language = "python"
favorite_language
|
da6100373b58e2e684174d46173c3f77bc345a9c | stereoabuse/Advent-of-Code-2020 | /solutions/day_15.py | 531 | 3.859375 | 4 | """ day_15.py -- Advent of Code 2020 Day 15: Rambunctious Recitation
Author: Chris Bowman
Last Modified: 12/15/2020
License: MIT
"""
import utils
def part_1(data):
spoken = data
while len(spoken) < 2020:
if spoken[-1] not in spoken[:-1]:
spoken.append(0)
else:
... |
47944420d739137b71b229c8f88329f0301d173b | daveswork/pythonforeverybody | /chapter-11/excercise-02.py | 864 | 4.09375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Exercise 2: Write a program to look for lines of the form
`New Revision: 39772`
and extract the number from each of the lines using a regular expression and
the findall() method. Compute the average of the numbers and print out the
average.
Enter file:mbox.txt
3854... |
05f604653134f01667f2568bb8906c933f72a8ec | daveswork/pythonforeverybody | /chapter-03/excercise-02.py | 826 | 4.09375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Exercise 2: Rewrite your pay program using try and except so that your program
handles non-numeric input gracefully by printing a message and exiting the
program. The following shows two executions of the program:
Enter Hours: 20
Enter Rate: nine
Error, please en... |
d10a0cd4693e2b11c9709544d37a6694f55c98f8 | daveswork/pythonforeverybody | /chapter-02/excercise-02.py | 317 | 4.0625 | 4 | """
Exercise 2: Write a program that uses input to prompt a user for their name
and then welcomes them.
Enter your name: Chuck
Hello Chuck
Severance, Charles. Python for Everybody: Exploring Data in Python 3 (Kindle
Locations 564-566). Kindle Edition.
"""
name = input("Enter your name: " )
print("Hello " + name) |
eb15a586e75ffcf4acf8bef427b7456552aba556 | daveswork/pythonforeverybody | /chapter-12/excercise-01.py | 918 | 3.828125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Exercise 1:
Change the socket program socket1.py to prompt the user for the URL so it can
read any web page. You can use split('/') to break the URL into its component
parts so you can extract the host name for the socket connect call. Add error
checking using try ... |
6dd29dbd81cf1aaea7a860b462d6b9596f9f3f35 | morgancjwhite/Monte-Carlo-Portfolio | /WeightGen.py | 2,476 | 3.6875 | 4 | """
This module has wieght generating functions
Recur provides a recurisve solution to produce all iterations of weights
i.e weightLength 2 with a weightMax of 2 has [1, 1], [2, 1], [1, 2], [2, 2]
Also want to try randomly generated weights, specifed with arguement
"""
#==========================
# Imports
impo... |
31922efe78d8cfe3bfcbead7bb7c5ef1f27ceca6 | jscsegura/Plataformas | /Lab8/tres.py | 556 | 3.734375 | 4 | def random():
from random import randint
x=randint(0,50)
return x
def obtenerInt():
y = int(input("Ingrese su adivinanza: "))
return y
def respuesta(respuesta,intento):
if respuesta==intento:
print("Ha adivinado el numero. ")
exit()
elif respuesta > intento:
print("El numero ingresado es menor que la re... |
a04f8f35bbf453915ac761a1adbcacd188b47029 | wwpjm06/TestingCode | /CharAttribs.py | 3,437 | 3.78125 | 4 | # Program to buy/redeem Character Attributes C5.C2
# Plyer can buy/sell BUT can't own more than x1 Attribute OR all Attributes
sCarryOn="C"
while sCarryOn == "C":
CHARATTS={"Dexterity" : 14,
"Health" : 10,
"Strength" : 8,
"Wisdom" : 12}
ExistAtts={"Health" : 10,
... |
21ce12df35a7c796e90646193b4d02377bb69b10 | HenrickyL/fn_2020_1 | /s02e02_sucesso/rec.py | 431 | 3.609375 | 4 |
def print_head(lista):
if len(lista) == 0:
return
print_head(lista[1:])
print(lista[0], end = " ")
def soma(lista):
if len(lista) == 0:
return 0
return lista[0] + soma(lista[1:])
def inverter(lista, inicio, fim):
if fim - inicio < 2:
return
lista[inicio], lista[fim... |
defc02c3432b993bc5fed41d5b66474e724dfb71 | Amily-Wang/Python_Levelwise_Exercises | /Solution/40.py | 103 | 4.0625 | 4 | def printTuple():
li=list()
for i in range(1,21):
li.append(i**2)
print(tuple(li))
printTuple() |
d0f345d0dab1a921122988986d808c422d288168 | Amily-Wang/Python_Levelwise_Exercises | /Solution/34.py | 111 | 3.84375 | 4 | def printDict():
d=dict()
for i in range(1,21):
d[i]=i**2
for (k,v) in d.items():
print(v)
printDict() |
42882e5a4d73db6709aae24f2746bf7e80bc4f27 | Amily-Wang/Python_Levelwise_Exercises | /Solution/63.py | 89 | 3.65625 | 4 | n=int(input())
sum=0.0
for i in range(1,n+1):
sum += float(float(i)/(i+1))
print(sum) |
88b8c47065b2f9b9bb901f1709550f45a78b8a14 | Amily-Wang/Python_Levelwise_Exercises | /Solution/30.py | 215 | 4 | 4 | def printValue(s1,s2):
len1 = len(s1)
len2 = len(s2)
if len1>len2:
print(s1)
elif len2>len1:
print(s2)
else:
print(s1)
print(s2)
printValue("one","three") |
d61893d78fa4768f31101db1f28d408c7c85cde5 | yes77lee/- | /lotto.py | 641 | 3.921875 | 4 | import random
#로또 번호는 1~45, 총 6개 당첨번호
today = []
# today.append(random.randrange(1,46,1))
# today.append(random.randrange(1,46,1))
# today.append(random.randrange(1,46,1))
# today.append(random.randrange(1,46,1))
# today.append(random.randrange(1,46,1))
# today.append(random.randrange(1,46,1))
# start = 0
# while s... |
737bc6479aa83b2ca7cdbb3664d1aa6d410351a3 | kangah-codes/to-do | /main.py | 4,676 | 3.53125 | 4 | __author__ = "Joshua Akangah"
from database import *
import guizero
# creating an app and creating an instamce of the database class
app = guizero.App(title="ToDo", width=400, height=600)
database = Database("todo.sqlite")
# creating a table in the database, if a table already exists, we will get an sqlite Operation... |
a2a13ee6982fd37240758bb92e7a0e0390a260b4 | desaidipen/Python | /PY_TEST/Pandas/DataFrame_Example1.py | 828 | 3.90625 | 4 | import numpy as np
import pandas as pd
from numpy.random import randn
np.random.seed(101)
# Setting up DataFrame
df = pd.DataFrame(randn(5,4),['A','B','C','D','E'],['W','X','Y','Z'])
print(df)
# Selecting specific columns
print(df[['W','Z']])
# Adding a New Column
df['dd'] = df['W'] + df['Y']
prin... |
470728be606297f6780b381fac01da2dfc3c6136 | desaidipen/Python | /PY_TEST/Basic/reverse_integer.py | 1,082 | 3.78125 | 4 | # class Solution(object):
# def reverse(self, x):
# """
# :type x: int
# :rtype: int
# """
# default_insert = 0
# ret_str = ''
#
# if (x < 0):
# ret_str = '-'
# default_insert = 1
# s = str(x)
#... |
90ee903b3483140d02c80fb54f631dd15beb5fc2 | desaidipen/Python | /PY_TEST/Basic/reverse_string.py | 700 | 4.0625 | 4 | st = "One Two Three Four Five Six"
print ('Original:\n\t{0}'.format(st))
""" Reversing String by Words | Dipen Desai > Desai Dipen """
# r = st.split(' ')
# r = r[::-1]
# r = ' '.join(r)
# # OR
r = ' '.join(st.split(' ')[::-1])
print ('Rerser Words:\n\t{0}'.format(r))
""" Reversing Words and Then by Characters | Di... |
ebd4658239901260532a24631c2a316d8cd50e60 | desaidipen/Python | /PY_TEST/Basic/binary_search.py | 989 | 3.71875 | 4 | def time_it(func):
""" Time it Function """
import datetime
def wrapper(*args, **kwargs):
start = datetime.datetime.now()
result = func(*args, **kwargs)
end = datetime.datetime.now()
print ('Function: {0} > Time Taken: {1}'.format(func.__name__, end - start))
return r... |
357fe9d6693ba3eeecc3cb51bb0aacda3785a7e8 | desaidipen/Python | /PY_TEST/Pandas/Missing_Data.py | 492 | 3.546875 | 4 | import numpy as np
import pandas as pd
d = {'A':[1,2,np.nan],'B':[5,np.nan,np.nan],'C':[1,2,3]}
df = pd.DataFrame(d)
print(df)
# Drop Null values from AXIS = 0 (ROWS)
print(df.dropna())
# Drop Null with minimum available data (If minimum 2 columns has data then show in result)
print(df.dropna(thresh=2))... |
d05bcbdbd64e6718a72befaf618b94fb4780ee39 | Itaay/bnn | /simulation/simulation.py | 1,870 | 3.6875 | 4 | import time
from simulation.environment import Environment
from simulation.agent import Agent
import pygame
class Simulation:
def __init__(self, space, screen):
self.screen = screen
self.environment = Environment(space, screen)
self.agents = []
pass
def iterate(self, t):
... |
1eadd668022a685aeb71a0c95472ac8e58f09c68 | Guru-21/Egg-Catcher-Game-Using-Python | /main.py | 4,349 | 3.609375 | 4 | from itertools import cycle
from random import randrange
from tkinter import Tk , Canvas , messagebox , font
canvas_width = 1000 # width of the canvas creating
canvas_height = 500 # height of the canvas creating
win = Tk() # tkinter windows open
c = Canvas(win, width = canvas_width , height = canvas_h... |
a9dd8dca675a7077d317bb8d8a98521afae05d87 | labhra/labhragram | /python_intro.py | 163 | 3.921875 | 4 | girls = ['rachel' , 'monica', 'sinead']
def hi(name):
print("hi there! " + name)
for name in girls:
hi(name)
for i in range(3,6):
print(i)
|
d6fb88eff6cfe1f6b76a7b245cbdbfc852068e2f | swisetch/python | /Week 1/StateTax.py | 265 | 3.734375 | 4 | #my first program work
#hello class
print("Sirinda Wisetchat")
print("Sales Tax Rates")
print("_______________")
print("Kansas: "), 6.5,("%")
print("Iowa: "), 6.0,("%")
print("Hawii: "), 4.0,("%")
print("Colorado:"), 2.9,("%")
print("Michigan:"), 6.0,("%")
input() |
7fd8578347f284fa99f71fb9f4eff927a6484895 | xieziwei99/py100days | /day01_15/multi/multiprocessDemo1.py | 1,060 | 3.59375 | 4 | """
Created on 2019/6/18
完成1~100000000求和的计算密集型任务
@author: xieziwei99
"""
from multiprocessing import Queue, Process
from time import time
def main():
total = 0
number_list = [x for x in range(1, 10000001)]
start = time()
for number in number_list:
total += number
print(total)
end = time()
print('Execute time... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.