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 |
|---|---|---|---|---|---|---|
18dda64b7b423045d6d395173431f0986ee3d90f | adrianadames/Data-Structures | /heap/heap.py | 3,595 | 4 | 4 | class Heap:
# The key is stored in the array representation of the tree (i.e. self.storage)
# such that its index is equal to the level number f(key) of key defined as follows:
# *If key = root of tree, then f(p) = 0
# *If key is the left child of key q, then f(p) = 2 * f(q) + 1
# *If key is ... |
0bf8c2fb0777fa8979c57979e30b7d2bf00f5ac5 | jketchum/webCrawler | /Lesson6/Fibo_numbers.py | 330 | 3.796875 | 4 | '''
Created on Sep 8, 2014
@author: Jason
'''
def fibonacci(n):
a, b, i = 1, 0, 0
while i < n:
i += 1
a, b = b, a+b
return b
#
print (fibonacci(0))
# #>>> 0
print (fibonacci(1))
# # #>>> 1
print (fibonacci(36))
# #>>> 14930352
print (fibonacci(80))
#>>> 2341672... |
798b00502ecd7780481d1cc3cd67ea656c76cf15 | AndyJPG/myPython | /utils.py | 134 | 3.703125 | 4 | def find_max(numbers):
max_no = numbers[0]
for i in numbers:
if i > max_no:
max_no = i
return max_no
|
80410606394a55e4996314aee72a6050e083add0 | hariharan125/python-boot-camp | /rr.python.py | 223 | 4.0625 | 4 | name=input(str())
age=int(input())
marriage_age=int(input())
current_year=int(input())
marriage_year=marriage_age-age+current_year
print(" name is {},age is {},marriage_year is {}".format(name,age,marriage_year))
|
db6f5be9dd0054366e7efcc07fa04a35682ba6a1 | hariharan125/python-boot-camp | /hari.py | 644 | 4.0625 | 4 | print("Calculator")
print("1.Add +")
print("2.Substract -")
print("3.Multiply *")
print("4.Divide /")
calc=float(input("Enter Choice(0-4): "))
if calc==1:
a=int(input("Enter A:"))
b=int(input("Enter B:"))
c=a+b
print("Sum = ",c)
elif calc==2:
a=int(input("Enter A:"))
b=int(input("En... |
e617308eda63ffd24fb4b8c104a8a1316593dab3 | pylover77/passwordgenerator | /passgen.py | 588 | 3.75 | 4 | import string
from random import *
import time
print ("""
*PASSWORD GENERATOR*
""")
def password_gen():
characters = string.digits
characters += string.punctuation
characters += string.ascii_letters
height_pass = int(input("input the lenght of password:"))
passwd = ... |
65deb0521ac18b2ee7393fed66c11f6544ee6d50 | agral/CompetitiveProgramming | /AoC2017/20/ans.py | 4,229 | 3.59375 | 4 | #!/usr/bin/env python3
"""
Solution to the challenge #20 of the "Advent of Code 2017" series.
MIT License
Copyright (c) 2017 Adam Szczerbiak (szczerbiakadam@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), t... |
82ec756685388bfeeda4e068e213ee835713fe02 | agral/CompetitiveProgramming | /AoC2017/01/ans.py | 1,799 | 3.515625 | 4 | #!/usr/bin/env python3
"""
Solution to the task #01 of the "Advent of Code 2017" series.
MIT License
Copyright (c) 2017 Adam Szczerbiak (szczerbiakadam@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to dea... |
b53901bd8d7ea1485accce9cc0d8f0fcb9b56504 | niuneo/sicp-python | /ex1.7.py | 520 | 3.5 | 4 | # http://www.kendyck.com/archives/2005/03/20/solution-to-sicp-exercise-17/
def sqrt_iter(guess, prev_guess, x):
if is_good_enough(guess, prev_guess, x):
return guess
else:
return sqrt_iter(improve(guess, x), guess, x)
def is_good_enough(guess, prev_guess, x):
return (abs(guess - prev_guess... |
73a24b4f8fe8104280a90d4a3142b3caf8c3cb51 | mohammed-ysn/rpg-character-simulator | /app.py | 2,311 | 3.578125 | 4 | import random
import characters
class Simulator:
def __init__(self):
self.classes = [characters.Barbarian, characters.Elf,
characters.Wizard, characters.Dragon, characters.Knight]
self.character_set = [self.generate_characters() for i in range(10)]
self.show_menu_ag... |
009cdcd897a882a10ba8424fa34b1f4906e2a3ae | stenen19/hw1.py | /hw1.py | 2,251 | 4.25 | 4 | from math import sqrt
def greeting():
capture = input("What's your name? ")
print("Hello %s " % capture)
def number():
number = input("enter any real number ")
numberint = int(number)
print("Your number is", numberint )
def average():
first = input("enter your first number ")
firstint = fl... |
f7cd7fadbc174c7c5c24ac9b3a28ba7e540153c8 | PumucklOnTheAir/TestFramework | /power_strip/power_strip.py | 793 | 3.515625 | 4 | from abc import abstractmethod
from network.remote_system import RemoteSystem
class PowerStrip(RemoteSystem):
"""
This class provides the Interface for the basic functions to manage the power strip.
"""""
@abstractmethod
def port_status(self, port_id) -> str:
"""
Returns the statu... |
e9afd433f2f1f138976032ad92990a6aaca27484 | SMAshhar/Lesson1 | /practice_2.py | 1,652 | 3.890625 | 4 | #sample = ["Nice", "Me love it too", "Zoom", "Awesome", "Ah... Always love a classic"]
# b = len(sample)
# cars = []
# x = True
# import random
# while x == True:
# y = input("What car do you like? \n : ")
# if y != "q":
# a = random.randrange(1,b)
# cars.append(y)
# print(sample[a])
# ... |
fd89b806ff51a68f6ec77c28987e21fc60b63707 | AfzalivE/ML-A-to-Z | /Part 8 - Deep Learning/Section 31 - Artification Neural Networks/my_ann.py | 3,913 | 3.859375 | 4 | # Artificial Neural Network
# Insalling Theano
# Installing Tensorflow
# Installing Keras
# Installed using conda
# Part 1 - Data Preprocessing
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Churn_Modelling.csv')
X =... |
89fa015cb0842c4e402b99284b3f2f6ebf46e0a4 | cmcg513/app-sec-assgn01-p2 | /mramdass/fib.py | 1,531 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Munieshwar (Kevin) Ramdass
Professor Justin Cappos
CS-UY 4753
14 September 2015
Compute up to the ith Fibonacci number
"""
def fib(ith): # BAD IMPLEMENTATION
if ith == 0:
return 0
elif ith == 1:
return 1
else:
return... |
ca40ffd23f5ce04c3c11e34d56871d4e7ea3df45 | lcubelongren/projects-self | /section_python/solving_kniffel/players/zero_player/player_computer.py | 2,040 | 3.609375 | 4 |
# the dumb computer agent
import sys, os
sys.path.append(os.path.abspath(os.path.join('..','..','..','solving_kniffel')))
import game
import numpy as np
import matplotlib.pyplot as plt
def ComputerGame0(game, welcome=False): # mean after 1k games: 46
"""everything random"""
game = game.Kniffel(welcome)
... |
eb715a0ce9c64ed815c4cdc1516f7d0ddea2508f | tala20-meet/meet2018y1mini-proj | /greeting.py | 338 | 3.984375 | 4 | my_name= input ("what's your name?")
print ('hello there ' + my_name.capitalize())
letters =len(my_name)
print("your name is "+ str(letters)+" letters long!")
#my_input=input("tala".capitalize())
##print ("hello there,".capitalize())
#var= my_inpt= [4]
#print ("your name is 4 letters long")
#print ("The first letter o... |
435e30a6bf53f40c894e2715936491d39f3a82ed | changchanglccc/HandwrittenRecognization | /neuralNetwork.py | 2,924 | 3.515625 | 4 |
# Neural Network by using pybrain
from pybrain.datasets.supervised import SupervisedDataSet
from pybrain.structure import *
from pybrain.structure.connections.full import FullConnection
from pybrain.structure.modules.linearlayer import LinearLayer
from pybrain.structure.modules.sigmoidlayer import SigmoidLayer
from py... |
783e5c867ccd4c2549ae5e9ea898b85d475e50f2 | ewoodworth/dictionaries | /practice.py | 6,574 | 4.46875 | 4 | """Dictionaries Practice
**IMPORTANT:** these problems are meant to be solved using
dictionaries and sets.
"""
def without_duplicates(words):
"""Given a list of words, return list with duplicates removed.
For example::
>>> sorted(without_duplicates(
... ["rose", "is", "a", "rose", "is", ... |
7e608dbf5c0d15627d9272e73afc33f69b37dfc5 | prabuinet/mit-intro-cs-py | /python_basics.py | 926 | 4.21875 | 4 | # -*- coding: utf-8 -*-
#Scalar objects in python:
5 #int
2.5 #float
True #bool
None #NoneType
type(5)
type(3.2)
type(False)
type(None)
#Type Cast
float(5)
int(2.5)
# operators on ints and floats
i = 5
j = 2
i + j # sum
i - j # difference
i * j # product
i / j # ... |
716bfbca6875bc3e5d6ed42d046833a4d6aea7ec | panc-test/api-test-demo | /utils/common.py | 321 | 3.671875 | 4 | """
获取文件路径
os.path.abspath(__file__)
os.path.dirname(pathname)
"""
import os
def get_rootpath():
"""
返回当前项目的绝度路径
:return:
"""
return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if __name__ == '__main__':
path = get_rootpath()
print(path)
|
1641084a2b3ef0aa1c366b59e95594d152167e5f | erisaran/cosc150 | /primes.py | 393 | 3.875 | 4 | def is_prime(x):
"""
>>> is_prime(2)
True
>>> is_prime(9)
False
>>> is_prime(4)
False
"""
count = 0
y = x - 1
while y>1:
if x%y > 0:
count += 1
y = y-1
if count == x-2:
return True
else:
return False
if __name__ =... |
b008f9150ecedad08faa83738d802fe272398916 | erisaran/cosc150 | /Lab15/meanmeadians.py | 516 | 3.640625 | 4 | def mean_median(number_list):
"""
>>> mean_median([1, 2, 3])
(2.0, 2.0)
>>> mean_median([1, 2, 9])
(4.0, 2.0)
>>> mean_median([8, 2, 2])
(4.0, 2.0)
>>> mean_median([2, 8, 1, 1])
(3.0, 1.5)
"""
values = ()
total = 0.0
x = 0
while x < len(number_list):
total... |
047983b82b4d26b73b2afe14859b5253cce17263 | erisaran/cosc150 | /Lab 05/Divisibleby3.py | 285 | 4.4375 | 4 | def is_divisible_by_3(x):
if x % 3 == 0:
print x,"is divisible by 3."
else:
print "This number is not divisible by 3."
def is_divisible_by_5(y):
if y%5==0:
print y,"is divisible by 5."
else:
print y,"is not divisble by 5."
|
20d17432c3ed62f5757bfd66f43df69cbd397cfc | erisaran/cosc150 | /Lab 05/yes.py | 169 | 4.09375 | 4 | def answer(x):
if x=="yes" or "Yes" or "y" or "Y" or "YES":
print "You choose yes"
else:
print "You choose no"
x=raw_input("Yolo?: ")
answer(x)
|
172f4a99996710394443eede52175f3d15e56e29 | erisaran/cosc150 | /Lab24/program.py | 4,453 | 3.890625 | 4 | import Tkinter
import ScrolledText
import tkFileDialog
class TextEdit:
"""
A simple text editor using a ScrolledText widget.
"""
def __init__(self, parent):
self.parent = parent
self.commandBar = Tkinter.Frame(parent)
self.commandBar.grid(row=0, column=0)
self.openButton... |
c748c2a09f4bd3e8092a8f6a48c930e5542c599c | jhonatangrymuza/TrabalhoPython | /Exer03.py | 423 | 3.5625 | 4 | navio=''
result=''
while (navio!='sair'):
navio = input('Digite o navio:')
if (navio=='sair'):
break
lati = input ('Digite a latitude: ')
long = input ('Digite a longitude: ')
hora = input ('Digite a hora: ')
result += '\n'+ navio + '\t' + lati + '\t' + long ... |
2becf3aec84be1dca2625df23ff2637c340d5a94 | romanpindela/pa-music-library-pa-python-sample-master-progbasic-python-codecool | /music_reports.py | 2,257 | 3.640625 | 4 | artist_id = 0
album_id = 1
year_id = 2
genre_id = 3
time_id = 4
def get_albums_by_genre(albums, genre):
"""
Get albums by genre
:param list albums: albums' data
:param str genre: genre to filter by
:returns: all albums of given genre
:rtype: list
"""
genre_albums = [album for album in... |
d576f4074bb56baf51b82b9bf525db46c494f312 | CarlaCCP/EstudosPython | /Python/aula4_elif.py | 302 | 4.40625 | 4 | numero = int(input("Digite um número: "))
if numero%3 ==0:
print("Numero divisivel por 3")
else:
if numero%5 ==0:
print("Numero divisivel por 5")
if numero%3 ==0:
print("Numero divisivel por 3")
elif numero%5 ==0:
print("Numero divisivel por 5")
|
1dcc3dd935c3abbddefdd9effc9b84bb85505988 | CarlaCCP/EstudosPython | /Python/aula5_ex_while3.py | 207 | 4 | 4 | n1 = int (input("Digite um número: "))
n2 = int (input("Digite o segundo número: "))
cont = n1
soma = 0
while cont < n2:
soma = soma + cont
cont = cont + 1
print("A soma dos valores é: ", soma)
|
9544e87d3f719cff3199d86a19358a716489e02c | 5X5G/LeetCode-By-Python | /26.remove-duplicates-from-sorted-array.py | 420 | 3.5625 | 4 | #
# @lc app=leetcode id=26 lang=python3
#
# [26] Remove Duplicates from Sorted Array
#
class Solution:
def removeDuplicates(self, nums) -> int:
count =0
if(len(nums) > 0):
count = 1
for index in range(len(nums)):
if(index +1 < len(nums) and nums[index] != nums[index+1... |
8d290791511bae513e793036571e8f9a8ff2093b | Isabellahu/Algorithm-Practice-Note | /5-3 虚拟头结点的设置-203|82|21.py | 2,035 | 3.921875 | 4 | # Leetcode - 203. Remove Linked List Elements
# # method 1
# 如果头结点不为空且头结点的值为目标值
while head is not None and head.val == val:
head = head.next
# 如果循环之后头结点为空
if head is None:
return head
# 循环遍历头结点之后的结点
cur = head
while cur.next:
if cur.next.val == val:
delNode = cur.next
cur.next = delNode.next... |
a30d41a0fb137ff0d429621428222a19671f8f31 | JayanthiPriyaS/Jay-Python | /digicount.py | 146 | 3.65625 | 4 | import math
n=int(input("Enter the number:"))
count=0
while(n>0):
n,r=divmod(n,10)
print(n,":n")
count=count+1
print(count)
|
ae4fdbb6ff6eba8c45ac59c1d120a2e0913c3fff | JayanthiPriyaS/Jay-Python | /factorial.py | 199 | 4.15625 | 4 | num=int(input("Enternumber:"))
num2=num
i=1
if(num<=0):
print("Enter a valid number:")
else:
for i in range(i,num):
num= num*i
print "Factorial of %d is %d" %(num2,num)
print(num)
|
09eb0f8acf255d4471a41a56a50bccf24ed4c91c | MissBolin/CSE-Period3 | /tax calc.py | 230 | 4.15625 | 4 | # Tax Calculator
cost = float(input("What is the cost of this item? "))
state = input("What state? ")
tax = 0
if state == "CA":
tax = cost * .08
print("Your item costs ${:.2f}, with ${:.2f} in tax.".format(cost+tax, tax))
|
530e77627a9da5fad0b76fd0ff9c179f60321428 | arjitsrivastava007/game | /utils.py | 1,956 | 4.09375 | 4 | import random
from action import Action, victories
def get_user_selection(selection):
"""
Function to get user selection action object
:param selection: user selection input
:return: action object
"""
try:
action = Action(int(selection))
return action
except Exception as er... |
5cac54ea7b45399b0c31ae0e86ae258f479baa00 | RyanWaltersDev/NSPython_Chapter5 | /favorite_fruit.py | 536 | 3.859375 | 4 | #RyanWaltersDev May 12 2021 -- TIY 5-7
#List of favorite fruits
favorite_fruits = ['banana', 'grapes', 'tomato']
if 'banana' in favorite_fruits:
print("Boy you sure must love bananas!")
if 'pineapple' in favorite_fruits:
print("Who lives in a pineapple under the sea? Haha whats up, Im Craig.")
if 'grapes' in f... |
c2b5b24edd2c091c5751d55de8ae64e28e5b66a9 | EnriqueNueve/ML_Toolbox | /grad_tape_demo.py | 1,933 | 3.9375 | 4 | """
grad_tape_demo.py
A low level example of a Neural Network in Tensorflow
using tf.Variable and tf.GradientTape().
"""
# Import modules
import tensorflow as tf
import numpy as np
#--------------------------#
# Declare optimizer function
opt = tf.optimizers.Adam(learning_rate=.001, decay = 1e-6)
# Declare loss fun... |
9a3a8776f8274dbe6449b1761ea99c0da66fa640 | fyodorbatchkala/python_introduction | /HW2/hw2ex3.1.py | 376 | 3.796875 | 4 | a = int(input('Введите целое число от 1 до 12: '))
my_dict = {'winter': [1, 2, 12], 'spring': [3, 4, 5], 'summer': [6, 7, 8], 'autumn': [9, 10, 11]}
while a < 1 or a > 12:
a = int(input('Пожалуйста, введите целое число от 1 до 12: '))
for m in my_dict.keys():
if a in my_dict.get(m):
print(f"It's {m}... |
589f964ea7dfad69c101febc2848a945775e5571 | fyodorbatchkala/python_introduction | /HW2/hw2ex5.py | 277 | 3.75 | 4 | my_list = [7, 5, 3, 3, 2]
a = int(input('Введите число: '))
for i in range(len(my_list)):
if my_list[i] < a:
my_list.insert(i, a)
break
elif a <= my_list[-1]:
my_list.append(a)
break
else:
continue
print(my_list)
|
1ad1175ded2df0d43ff11636360730e254df87bc | fyodorbatchkala/python_introduction | /HW4/hw4ex6.py | 253 | 3.546875 | 4 | from itertools import count
from itertools import cycle
# a)
for el in count(3):
if el > 10:
break
else:
print(el)
# b)
a = 0
for el in cycle([1, 2, True, (2, 3), 'name']):
if a > 10:
break
print(el)
a += 1
|
393b3676284c70c259b4739575ec213735cca9aa | fyodorbatchkala/python_introduction | /HW1/hw1ex3.py | 136 | 3.515625 | 4 | a = input('Введите своё число:\n')
result = int(a) + int(str(a) + str(a)) + int(str(a) + str(a) + str(a))
print(result)
|
9eb7f6ef0edcaa30e02a37d50c3eb50f4cc36c1c | shanwaixingren/PythonYSL | /addressList.py | 2,227 | 3.859375 | 4 |
# -*- coding: utf-8 -*-
import pickle as p
import sys
import os
class person:
addressfile = "address.txt"
def __init__(self, name, address, phone, email):
self.name = name
self.address = address
self.phone = phone
self.email = email
print("__init__ name = %... |
820e250af9675100563486a6ca2e77393481de1e | laFuenteUNLP/seminario-de-lenguajes | /python/practica1/pract1ej12.py | 860 | 3.609375 | 4 | #!/usr/bin/python
# coding=utf-8
'''
Dado el siguiente diccionario donde las claves son nombres de animales y los valores representan
posiciones:
anim={’Gato Montes’:2,’Yacare overo’:4,’Boa acuática’:5}
Imprimir un string por cada animal de la estructura, reemplazando sus caracteres por el string
’_ ’ (inclusive los e... |
a67b2e1a86ebee6a92f98efdf140a7bdfbe12fb1 | hjben/python-utils | /ben_python_utils/processing/df_process.py | 4,740 | 3.609375 | 4 | import os
import pandas as pd
def check_df(df):
"""
Check if the input dataframe has valid type
Raises
------
ValueError
If the df is not a DataFrame.
Parameters
----------
df : DataFrame
Target dataframe (required)
Returns
-------
None
"""
if ty... |
369992be85637f5e5acc2a0d7225038298ffa6f8 | loachana/quadraticEq | /rootQuest.py | 1,709 | 3.84375 | 4 | #usr/bin/python
from random import random
def generate():
rand = int(100*random())
return rand
def equation(r1,r2):
a = 1
b = r1 + r2
c = (r1)*(r2)
return "x^2 + %dx + %d" % (b, c)
def selectionMixture(a, b, c, d):
rand = int(4*random())
if rand == 0:
return a
elif rand == 1:
return b
elif rand == 2:
... |
8183cb3e55fabba080a39d30fbd9059445424b3e | molychin/LeaningPythons | /Pandas/Learning_pandas/Chapter06.py | 7,876 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 24 15:50:08 2019
@author: Administrator
"""
# import numpy and pandas
import numpy as np
import pandas as pd
# used for dates
import datetime
from datetime import datetime, date
#Indexing Data
#An index is a tool for optimized look up of values from a series or DataFra... |
63eb5df3730534793d5a58196c3b88961e6172c2 | molychin/LeaningPythons | /Pandas/Learning_pandas/2015/Learning pandas-04.py | 13,163 | 4.0625 | 4 |
# coding: utf-8
# ## The pandas Series Object
# In[ ]:
pandas is a high-performance library that provides a comprehensive set of data
structures for manipulating tabular data, providing high-performance indexing,
automatic alignment, reshaping, grouping, joining, and statistical analyses capabilities.
PANDAS是一个高性能... |
c7dae759128de979711cff4ef1b17bb4f71975c4 | molychin/LeaningPythons | /Pandas/Learning_pandas/2015/Learning pandas-07.py | 18,033 | 4.5 | 4 |
# coding: utf-8
# ## Tidying Up Your Data 整理数据
# In[7]:
Data analysis typically flows in a processing pipeline that starts with retrieving data
from one or more sources. Upon receipt of this data, it is often the case that it can be
in a raw form and can be diffcult to use for data analysis. This can be for a mult... |
555fd59a9ad98bfbc15606a0d67e9c1421aae591 | molychin/LeaningPythons | /Pandas/Learning_pandas/2015/Learning pandas-03.py | 13,852 | 4.375 | 4 |
# coding: utf-8
# ## NumPy for pandas
Numerical Python (NumPy) is an open source Python library for scientific computing.
NumPy provides a host of features that allow a Python programmer to work with high-performance
arrays and matrices. NumPy arrays are stored more efficiently than Python lists and
allow mathe... |
99697cc2af869c2190fea62d9cd2ae0697af9943 | nickbeaird/thinkpython | /chapter3-Functions/exercise_3-5.py | 946 | 3.515625 | 4 | #! /Users/nbeaird/.pyenv/shims/python
# Solution 1
def horizontal():
mid_line = ('- ' * 4)
line = '+ ' + mid_line + '+ ' + mid_line + '+'
print(line)
empty_mid = (' ' * len(mid_line))
space_line = ('| ' + empty_mid + '| ' + empty_mid + '|')
print(space_line)
print(space_line)
prin... |
c7b513e3c9498eccab2d2b76f61669f70241adad | Snehabisht/cs269q_radzihovsky_murphy_swofford | /classical.py | 4,146 | 3.796875 | 4 | import numpy as np
def rand_graph(num_cities, percent_connected=.75):
"""
Returns (symmetric) weight and connectivity matrixes.
Weights are set to 0 when two nodes are not connected.
Connectivity matrix has 1's when two nodes are connected
and 0 otherwise.
"""
weights = np.random.rand(... |
4baa08f0e5d3977101a3faff4f3313296a0de743 | MananDesai54/028_MananDesai | /Lab1/lab1Pandas.py | 845 | 3.65625 | 4 | #!/usr/bin/env python3
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv('../Lab2/Data/Datasets/Exercise-CarData.csv')
d = pd.crosstab(index=data['Index'], columns="Price", dropna=True)
print(d)
print(data.info())
# Count Total Null values in each column
print("Total Null Data:", data.isnull().... |
d13ea295cc0738dc65160a430d31826037d8cbe3 | nandhakumar23/YeetCode | /Medium/Set_Matrix_Zero.py | 1,848 | 3.59375 | 4 | ### [73\. Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes/)
Difficulty: **Medium**
Related Topics: [Array](https://leetcode.com/tag/array/)
Given an `_m_ x _n_` matrix. If an element is **0**, set its entire row and column to **0**. Do it .
**Follow up:**
* A straight forward solution using... |
c744b3725b8b08ea0bda98f9f2e9467ec97b0f7d | THUTwenTy/CGRA_tia_trans | /test.py | 1,114 | 3.59375 | 4 | #!/usr bin/env python3
def predicate_list_to_str_trans(predicate_list):
File_predicate = ""
for i in reversed(predicate_list): # list should be reversed
File_predicate = File_predicate + str(i)
return File_predicate
def predicate_str_to_list_trans(File_predicate):
predicate_list = []
for ... |
9cb1118264da0602a532c0c92445208ef18a214c | SonnyBurnett/coding | /problem1.py | 2,013 | 3.796875 | 4 | #
# Euler Problem 1
#
# Author: Taco Bakker
#
# Find the sum of all the multiples of 3 or 5 below 1000.
#
import time
__version__ = 1.0
MAX_NUMBER = 1000
#
# Simple version
#
start1 = time.time()
answer1 = 0
for x in range(MAX_NUMBER):
if x % 3 == 0 or x % 5 == 0:
answer1 += x
print("Answer1:", answer1,... |
cb385040a495b2ecda74862946e3b6d1a17082d3 | gandastik/365Challenge | /365Challenge/suminList.py | 127 | 3.84375 | 4 | # Jan 11, 2021 - find a sum in a given list
lst = [int(x) for x in input().split(' ')]
print(lst, end="")
print(" =", sum(lst)) |
a80c7e9406873cf62fd5591b707a51d9c7cb53a8 | gandastik/365Challenge | /365Challenge/isOrdered.py | 317 | 3.78125 | 4 | #56. Feb 25, 2021 - given a integers array, return true if it is in ascending or descending ordered.
from typing import List
def isOrdered(nums: List[int]) -> bool:
rev = sorted(nums)
rev.reverse()
return nums == sorted(nums) or nums == rev
nums = [int(x) for x in input().split()]
print(isOrdered(nums)) |
0d9d2316085bffe2257d0f7e4d7211ad38f9911f | gandastik/365Challenge | /365Challenge/countStringCondition.py | 747 | 3.96875 | 4 | #45. Feb 14, 2021 - take string as an input.
#return 1 when upper case alphabet is presence more
#return 2 when lower case alphabet is presence more
#return 3 when number presence more
#return 4 when two or more type have the greatest amount of presence
def countStringCondition(s: str) -> int:
lower = 0
upper =... |
5e6da896622bbea9fa482038426ebaa1ccbf93ea | gandastik/365Challenge | /365Challenge/sumOfUnique.py | 508 | 4.03125 | 4 | #39. Feb 8, 2021 - You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.
# Return the sum of all the unique elements of nums.
from typing import List
def sumOfUnique(nums: List[int]) -> int:
ret = 0
arr = [0 for x in range(101)]
for i in... |
b9884eae05e9518e3ec889dd5280a8cea7c3c1d7 | gandastik/365Challenge | /365Challenge/insertElementes.py | 382 | 4.125 | 4 | #Jan 24, 2021 - insert a elements according to the list of indices
from typing import List
def createTargetArray(nums: List[int], index: List[int]) -> List[int]:
ret = []
for i in range(len(nums)):
ret.insert(index[i], nums[i])
return ret
lst = [int(x) for x in input().split()]
index = [int(x) ... |
20644bc6631d5eb8e555b1e2e61d1e0e6273bd00 | gandastik/365Challenge | /365Challenge/matrixDiagonalSum.py | 762 | 4.21875 | 4 | #37. Feb 6, 2021 - Given a square matrix mat, return the sum of the matrix diagonals.
# Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.
from typing import List
def diagonalSum(mat: List[List[int]]) -> int:
... |
1e389c67829acf8aa29bf55429bef792deec6e35 | gandastik/365Challenge | /365Challenge/isInteger2.py | 197 | 4.53125 | 5 | # Jan 8, 2021 -check if the square root of the input if Integer or not.
num = float(input())
if int(num**(1/2)) == num**(1/2):
print("Yes, It's Integer")
else:
print("No, It's not Integer") |
fb5ac6e49d0c5724362a41e2b004286e6a11478d | gandastik/365Challenge | /365Challenge/if-else.py | 409 | 4.34375 | 4 | # Jan 6, 2021 -if n is odd print Weird, n is even and inbetween 2 and 5 print Not Weird,
# n is even and inbetween 5 and 20 print Weird, n is even and greater than 20 print Not Weird
n = int(input())
if(n % 2 != 0):
print("Weird")
elif(n % 2 == 0 and n > 2 and n <= 5):
print("Not Weird")
elif(n % 2 == 0 and n ... |
411b9d8e752093dd4ac0f503995edd042cbb41ed | gandastik/365Challenge | /365Challenge/luckyNumber.py | 867 | 3.84375 | 4 | #59. Feb 28, 2021 - Given a m * n matrix of distinct numbers, return all lucky numbers in the matrix in any order.
# A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.
from typing import List
def luckyNumbers (matrix: List[List[int]]) -> List[int]:
l... |
21cdeeb0435537a743546024e17fcbd3268c1224 | gandastik/365Challenge | /365Challenge/numberListing.py | 320 | 3.828125 | 4 | #37. Feb 6, 2021 - sorting the list input in ascending order.
nums = [int(x) for x in input().split()]
for i in range(len(nums)):
for j in range(len(nums)):
if(nums[i] < nums[j]):
temp = nums[i]
nums[i] = nums[j]
nums[j] = temp
for i in nums:
print("%d " % i, end="") |
f8b1a75dbde4fce4a249511d6f5ce76720de8a50 | gandastik/365Challenge | /365Challenge/isEmpty.py | 184 | 3.875 | 4 | #Jan 15, 2021 - find out if the input list is empty or not
from typing import List
def isEmpty(lst: List[int]) -> bool:
return True if len(lst) == 0 else False
print(isEmpty([])) |
e63e701e5da75f652c442dce0b29a54735811add | jorgeescorcia/Suma_Digitos_2_Numeros_Enteros | /Suma digitos de 2 numeros enteros.py | 307 | 3.6875 | 4 | #Escribe el código para leer dos números enteros(x, y)
# de dos dígitos y determina a cuánto es igual la suma de todos los dígitos. Imprime el resultado.
def reto4(x,y):
x1=x//10
x2=x%10
y1=y//10
y2=y%10
resultado =x1+x2+y1+y2
return resultado
reto4(3,4)
|
5c89cbd938ddde5a8bd4b61db5314a6d712cb0b1 | sachin221190/100DaysOfCode | /interviewbit-python/flip.py | 1,951 | 3.890625 | 4 | # Flip
# You are given a binary string(i.e. with characters 0 and 1) S consisting of
# characters S1, S2, …, SN. In a single operation, you can choose two indices
# L and R such that 1 ≤ L ≤ R ≤ N and flip the characters SL, SL+1, …, SR.
# By flipping, we mean change character 0 to 1 and vice-versa.
# Your aim is t... |
b8004c479fc57b0e4ce11f51546505798417497a | sachin221190/100DaysOfCode | /interviewbit-python/maximum-absolute-difference.py | 641 | 3.796875 | 4 | # Maximum Absolute Difference
# You are given an array of N integers, A1, A2 ,…, AN. Return maximum value of f(i, j)
# for all 1 ≤ i, j ≤ N.
# f(i, j) is defined as |A[i] - A[j]| + |i - j|, where |x| denotes absolute value of x.
# For example,
# A=[1, 3, -1]
class Solution:
# @param A : list of integers
# @... |
67785b62ff624d4c9f16537107b44c05279b417d | dremdem/pythons_handy_stuffs | /slicing.py | 53 | 3.75 | 4 | a = [1, 2, 3, 4]
print(a[:-1])
a.append(5)
print(a) |
d054699b9f1262f2d0a451c447b7827ac9fa6534 | tomasflopes/algorithms_testing | /binary_search.py | 977 | 3.78125 | 4 | import time
def binary_search(arr, n, left, right):
mid = (left + right) // 2
if(arr[mid] == n):
return mid
if(len(arr) == 1):
return -1
if(arr[mid] > n):
return binary_search(arr, n, left, mid-1)
else:
return binary_search(arr, n, mid+1, right)
def sequencial_... |
ceac177428196dcf641a5f193f5b0d092107469c | peilingjiang/BFS_Large_Database_Search | /helper_data_reorganize.py | 865 | 3.546875 | 4 | # Last edit: Sat Feb 16 02:35
import json
def helper_data_reorganize():
"""
Help reorganize the raw data mined from IMDB to a structure the BFS function can handle easily and fast.
pre-converted: [[actor_id_1, actor_id_2, movie_id]]
post-converted: {actor_id_1: {actor_id_2, actor_id_3, actor_id_4}}
... |
c1be13f090598d8e5614c65e41ec81de8092eca4 | xaneon/func | /Stats/monte.py | 3,158 | 3.59375 | 4 | #!/usr/local/bin/env python
# -*- coding: utf-8 -*-
"""
Monte Carlo simulations and statistics.
.. module:: monte.py
.. moduleauthor:: Bonne Habekost <b.habekost1@ncl.ac.uk>
.. modulemodified:: April 27, 2015
"""
import setpath
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
F = setpath.s... |
ce88d6f7881d37191f373faed4dc6142f770590c | StarSkyLight/MALF_works | /recover.py | 1,825 | 3.734375 | 4 | """This file is for i of Question 1.
It is a method that recovers the text file from the stego-image.
"""
from PIL import Image
import numpy as np
def recover():
# input the name of the stego image.
temp1 = input("Please input the name of the stego image:")
stego_image = str(temp1)
# open image fi... |
9fdedda65ec74a7ac9d9ab1510dcc1b63adf502d | ovidubya/Coursework | /Python/Programs/assign5part1.py | 560 | 4.46875 | 4 | def find_longest_word(wordList):
print("The list of words entered is:")
print(wordList)
result = ""
i = 0
while(i < len(wordList)): # iterates over the list to find the first biggest word
if(len(result) < len(wordList[i])):
result = wordList[i]
i = i + 1
print("")
... |
6f88bdeb265f98fc749b58856105c1144393e5ad | faelsfernandes/URI | /1035.py | 226 | 3.765625 | 4 | linha = input().split(" ")
A = int(linha[0])
B = int(linha[1])
C = int(linha[2])
D = int(linha[3])
if B > C and D > A and C+D > A+B and C > 0 and D > 0 and A%2==0:
print("Valores aceitos")
else:
print("Valores nao aceitos") |
ac9d0186a8e4dde8b45ee8ea717803ac34eae374 | IJoshuaI/Intelligent_system_development_project | /function_new.py | 8,808 | 3.96875 | 4 | """
Example to introduce how to read a video file
"""
# Import the required packages
import cv2
import argparse
# We first create the ArgumentParser object
# The created object 'parser' will have the necessary information
# to parse the command-line arguments into data types.
#parser = argparse.ArgumentParser()
# We... |
dbf31c440349c470a48438cbe066e059d0602cf0 | michaelhe/micserver | /bthreadpool.py | 2,128 | 3.890625 | 4 | #!/usr/bin/env python
#-*- coding:utf-8 -*-
__author__ = 'luo_t'
import Queue
import threading
import time
'''
这个简单的例子的想法是通过:
1、利用Queue特性,在Queue里创建多个线程对象
2、那我执行代码的时候,去queue里去拿线程!
如果线程池里有可用的,直接拿。
如果线程池里没有可用,那就等。
3、线程执行完毕,归还给线程池
'''
class ThreadPool(object): #创建线程池类
def __init__(self,max_thread=20):#构造方法,设置默认最大的线程数为... |
39ca20c4c4b692a5a618ffc4e2191794df048bd7 | joearc116/PythonDemo | /20181002-01/main3.py | 325 | 3.703125 | 4 | # String API : replace
a = "hello\npython\n3"
b = a.replace("python", "world")
print(b)
# replace(old, new, max) => max 取代個數
a = a.replace("\n", "", 1)
print(a)
# upper() & lower
if "abc" == "ABC".lower():
print("case1")
elif "abc" == "ABC".lower():
print("case2")
elif "fff" == "ABC":
print("case3")
|
4200b12457f250f6d49dbfe48e64514e8375d6e6 | joearc116/PythonDemo | /20181009-01/main2.py | 430 | 4.03125 | 4 | # 鴨子型別
def add(n1, n2):
return n1 + n2
print(add(2, 3))
print(add("Hello", "World"))
# 不定參數 *args
def add_multiple(*nlist):
r = 0
for n in nlist:
r = r + n
return r
# print(add_multiple([1, 2, 3, 8]))
print(add_multiple(1, 2, 3, 8))
# ex:open()
def score(s, div=1, permu=0):
return s/div ... |
d48710f931f654dc8d007950cb8dd6b3d2fb7d2c | rajkumar2521/PF | /reverse_string.py | 441 | 3.796875 | 4 |
a=input('enter string')
def reverse():
List=list(a)
i=0
j=len(List)-1
while(i<j):
if not List[i].isalpha():
i+=1
elif not List[j].isalpha():
j-=1
else:
List[i],List[j]=List[j],List[i]
i+=1
j-=1
return... |
63487d8dd5a282142b709ad82f091242343a3915 | rajkumar2521/PF | /practice18.py | 110 | 3.65625 | 4 |
num1=2
num2=20
count=0
for i in range(num1,num2):
if num1%num2==0:
count+=1
print(count)
|
1298a7243a8af5c54e2f2c4751b5924afd11b5d7 | rajkumar2521/PF | /practice15.py | 270 | 3.546875 | 4 | #PF-Prac-15
def check_22(num_list):
c=0
for i in range(len(num_list)-1):
if num_list[i]==2 and num_list[i+1]==2:
return True
else:
return False
print(check_22([2,2,3,2,5,2,2])) |
5ff9e38af7a363e6b23d9c142b4b82f8ec176840 | dzsone/python-practice | /NewGuess.py | 1,550 | 3.703125 | 4 | '''
import random
secret = random.randint(1,100)
guess = 0
tries = 0
print("AHOY! I'm the Dread Pirate Roberts, and I have secrect!")
print("It is a number from 1 to 99. I'll give you 6 tries.")
while guess != secret and tries < 6:
guess = input("What's yer guess?")
if int(guess) < secret:
print("Too ... |
8fa015657f11c980a8f5b3a0bdeb0ccda30377ba | xabertum/UnicornHatScroll | /UHScroll_custom_colors.py | 4,459 | 4.3125 | 4 | #V1.01
''' This python script provides the functions to display simple scrolling text on
a Pimoroni Unicorn hat, and add-on board for the Raspberry Pi model B+'''
import unicornhat as UH
from bitarray import bitarray
import time
#import letter definitions and mappings
from UHScroll_defs_uppercase import *
from UHScro... |
ac542f69474cefd96668b5fdd6ff6201b8be235d | AntonHub00/Tic_Tac_Toe | /tic_tac_toe.py | 3,887 | 4.25 | 4 | import os
#Functions --------------------------------------------------------------------------------------------------
#Print the board with the update for the position choosen
def print_board(board):
print(f'''
| |
{board[6]} | {board[7]} | {board[8]}
| |
-----------------
... |
6d3693dc72b467e593b511e79bea1a1b6f6d1392 | mcmxl22/Python-doodles | /fun/weird.py | 355 | 4.125 | 4 | #!/usr/bin/env python3
"""
weird version 1.1
Python 3.7
"""
def is_weird():
"""Is a number odd or even?"""
while True:
pick_number = int(input("Pick a number: "))
if pick_number % 2 == 0:
print("Not Weird!")
else:
print("Weird!")
if __name... |
d1ce6e9b8a28f94cb98458548115d47587eaab3c | mcmxl22/Python-doodles | /Security/transfer.py | 913 | 3.6875 | 4 | #!/usr/bin/env python3
"""
transfers Version 1.1
Python 3.7
"""
from Security_Code import main, code_file
code_file()
main()
def replace_line():
"""Removes previous pass type from file."""
with open("transfer.txt", "r+") as file:
lines = file.readlines()
file.seek(0)
for line in line... |
df5c01baedd9962c8bd1cd3deebc988713c628cd | YvonneCollingham/DataPrimer | /helloworld.py | 333 | 3.546875 | 4 |
import sys
personName = sys.argv[1]
print "Hello " + personName
TimeTable = int(sys.argv[2])
NumSteps = int(sys.argv[3])
for i in range (1,NumSteps):
print str(TimeTable) + " x " + str(i) + " = " + str(TimeTable*i)
#print TimeTable, " x ", i, " = ", TimeTable*i
#print str(TimeTable) + " x " + str(i) + " = " + str... |
20075d6d73e2cd9cd7ac121d4d1f91e897861d38 | mozlercelik/Caesar-cipher | /caesar.py | 842 | 4 | 4 | import rot
print("""
_____ _____
/ ____| | __ \
| | __ _ ___ ___ __ _ _ __ | |__) | __ ___
| | / _` |/ _ \/ __|/ _` | '__| | ___/ '__/ _ \
| |___| (_| | __/\__ \ (_| | | | | | | | (_) |
\_____\__,_|\___||___/\__,... |
5ce23cfc2c742c950f423ed37b9a242076866b09 | prabsingh1/CS5010_NBA | /homework4.py | 2,475 | 3.578125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 22 19:21:18 2020
@author: Johnzhang, jz5jx,
@coauthor: Vasudha Manikandan Vm7gc
Assignment:Homework: Python and Web Scraper
"""
from urllib.request import urlopen
from bs4 import BeautifulSoup
import pandas as pd
import numpy as np
import matplotl... |
11acb73f904dd518f73a39ac188421991c916827 | forcvercontigo/leetcode | /014.py | 1,172 | 3.734375 | 4 | from collections import Counter
class Solution(object):
def longestCommonPrefix(self, strs):
"""
:type strs: List[str]
:rtype: str
"""
#firstly handle exception
if len(strs) == 0:
return ''
if len(strs) == 1:
return strs[0]
#com... |
659c76ded1f864c7501d052e4f386c86aafc1173 | sakjur/incode | /prime/prime.py | 639 | 3.96875 | 4 | # -*- coding: utf-8 -*-
import sys
def locatep(n):
if n == 2:
return [2]
if n < 2:
return []
p = [2]
arr = []
for i in range(3, n+1, 2):
arr.append(i)
while len(arr) > 1 and arr[0]**2 <= n:
num = arr.pop(0)
p.append(num)
red(num, arr)
p.extend... |
2d4a3f66c499e39746d90f448678bc0c199f7994 | johnvkennedy/Assignment08 | /Assignment08.py | 7,121 | 3.546875 | 4 | # ------------------------------------------------------------------------ #
# Title: Assignment 08
# Description: Working with classes
# ChangeLog (Jack Kennedy,12/12/2020,Adding Code for Assignment):
# RRoot,1.1.2030,Created started script
# RRoot,1.1.2030,Added pseudo-code to start assignment 8
# Jack Kenned... |
404646e7c6e103fe1b08def0969024a3af8b398f | jinjinwang/python_example | /src/base/dictionary.py | 506 | 3.84375 | 4 | '''
Created on 2015年1月15日
@author: Administrator
'''
dic = {'tom':11, 'sam':57,'lily':100}
# 类型
print(type(dic))
# 获取词典元素
print(dic['tom'])
# 修改词典
dic['tom'] = 30
print(dic)
# 新增元素
dic['lilei'] = 99
print(dic)
# 词典置空
dic = {}
print(dic)
#词典循环
dic = {'lilei': 90, 'lily': 100, 'sam': 57, ... |
1738a232d354b11bc8bb249a78e4f3d87fc1ddc6 | jinjinwang/python_example | /src/base/example.py | 516 | 3.9375 | 4 | '''
练习题一
输出数字,从1到100,其中能被3整除的,显示‘buzz’,其中能被5整除的,显示‘bing’,既能被3整除又能被5整除的,输出‘buzz*bing’
Created on 2015年2月10日
@author: Administrator
'''
i = 0
while i <= 100:
i = i + 1
if i%3 == 0 and i%5 == 0:
print(i,"----buzz*bing")
continue
if i%3 == 0:
print(i,"----buzz")
... |
595857217f355ea8465f99b9a781ced24fe1d0c7 | cmcourville/datamining-hw6 | /problem1.py | 9,147 | 3.71875 | 4 | import numpy as np
from sklearn import metrics,neighbors
import sklearn
from collections import Counter
#-------------------------------------------------------------------------
'''
Problem 1: k nearest neighbor
In this problem, you will implement a classification method using k nearest neighbors.
The ma... |
447bd84bcc429e5b358d8c160407399fb0ef436b | subh-chaturvedi/File-Sorter | /bin/pathhelp.py | 970 | 3.765625 | 4 |
#fullpath is the absolute path of the file
# finds the name of the file with the extension
# user/test/test/python.py becomes python.py
def findname(fullpath):
start=0
slashpos=0
while True:
if fullpath.find('/',start,len(fullpath))==-1:
break
slashpos=fullpath.find('/',start,l... |
a5201821c6cd15088a4b1a4d604531bbcca68c69 | mlrice/DSC510_Intro_to_Programming_Python | /fiber_optic_discount.py | 1,297 | 4.34375 | 4 | # DSC510
# 4.1 Programming Assignment
# Author Michelle Rice
# 09/27/20
# The purpose of this program is to estimate the cost of fiber optic
# installation including a bulk discount
from decimal import Decimal
print('Hello. Thank you for visiting our site, we look forward to serving you.'
'\nPlease provide some... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.