blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
6243c33b32797f5fb4cc4be7f9abcda91c38f646 | JaveedBeargrylls/Indian_StateCensus_Analyser | /Indian_States_Analyser.py | 6,655 | 3.609375 | 4 |
'''
@Author: Javeed
@Date: 2021-08-03
@Last Modified by: Javeed
@Last Modified time: 2021-09-04 16:21:15
@Title : Indian_States_Analyser.
'''
import csv
import os
import json
from dotenv import load_dotenv
load_dotenv()
class Indian_States_Analyser:
def records(self,filename):
'''
Description:
... |
b4b801895b1128f8e0ac3e6208d8de23fa7f32e3 | vmf91/uri-solutions | /Python/1010.py | 320 | 3.65625 | 4 | p1 = input()
p1_code, p1_units, p1_price = p1.split(' ')
p2 = input()
p2_code, p2_units, p2_price = p2.split(' ')
p1_units = int(p1_units)
p2_units = int(p2_units)
p1_price = float(p1_price)
p2_price = float(p2_price)
total = p1_units * p1_price + p2_units * p2_price
print("VALOR A PAGAR: R$ {:.2f}".format(total)) |
91534068649211f2f7c6a74846f4b7c5feba5f05 | andydna/exercism | /python/pangram/pangram.py | 192 | 3.625 | 4 | def is_pangram(sentence):
alphabet = list('abcdefghijklmnopqrstuvwxyz')
for letter in alphabet:
if sentence.lower().count(letter) < 1:
return False
return True
|
ff02b8d84667f8efa233e35e314f020995466512 | SandraTang/Encryptors-and-Cryptology-Practice | /hill-game-spanish.py | 2,011 | 3.703125 | 4 | #Hill Cipher Practice Program (Spanish)
#by Sandra Tang
print "Hill Cipher Practice Program (Spanish)"
from random import randint
alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "Ñ", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
phrases = ["hola", "uno", "dos", "bueno"... |
d8c930ffa2855babdf893ae9d12feed2251f8a89 | astrocorgi/scipro-notes | /fibMods/fibMod.py | 274 | 3.6875 | 4 | import sys
def fib(n):
a,b = 0, 1
while b< n:
print b
a, b = b, a+b
print " "
if len(sys.argv) > 2:
func = sys.argv[1]
x = int(sys.argv[2])
if func == 'fib':
fib(x)
elif func == 'fib2':
fib2(x)
else:
print "incorrect input"
|
fcf866c7bd74ce82bb3a064ae6473a22baa01cce | shreyanshu09/Best-Player-Prediction-in-IPL | /code/best_player.py | 542 | 3.59375 | 4 | import pandas as pd
import best_batsman
import best_bowler
import best_fielder
delivery=pd.read_csv('deliveries.csv')
while(1):
print('''Choose what you want to know:
1)Best Batsman
2)Best Bowler
3)Best Fielder
4)Exit''')
inp=int(input("Enter Choice:"))
if(inp... |
eaf91495daf588cb1245bddfbb3aa4ddaaee1bf4 | elbeejay/entrogrammer | /entrogrammer/classifier.py | 8,841 | 3.921875 | 4 | """Classes and methods for binning and classifying data."""
import abc
import xarray as xr
import numpy as np
class BaseClassifier(abc.ABC):
"""Base classifier class.
Abstract class that exists as a blueprint for classifier classes.
This class defines the expected methods for each classifier class that ... |
dec49e2e0fdd42ef4d5ce99497244b9afa481d07 | mohammadasim/python-course | /function_practice_exercises.py | 2,381 | 4 | 4 | # Lesser of two evens: write a function that returns the lesser of two given numbers if both numbers are even,
# but returns the greater if one or both numbers are odd.
def lesser_of_two_evens(a,b):
if a % 2 == 0 and b % 2 == 0 :
return min(a,b)
else:
return max(a,b)
print (lesser_of_two_evens... |
79c55a46b9e8abd2d0ec5d6554185cd017d6e6dc | mohammadasim/python-course | /functions.py | 1,191 | 4.15625 | 4 | # Creating clean repeatable code is a key part of any development process.
# Fuctions allow us to create blocks of code that can be easily executed many times, without needing of
# constantly rewriting the entire block of code.
# The syntax of writing a function is as follows
def name_of_function():
'''
Docstr... |
e919e8de3bda16ebc74ddedaa53144f6f0ed304d | mohammadasim/python-course | /mile_stone_proj_2/important.py | 418 | 4.0625 | 4 | '''
In python 0 is treated as false and other numbers are treated as true.
Let's check in the following example.
'''
zero = 0
one = 1
two = 2
if zero:
print('You were wrong, zero is not treated as true')
else:
print('You were right, zero is treated a false')
if one:
print('1 is treated as true')
if two:... |
b51bc4a69f47e81297bb7e5115c0c565fde9d242 | mohammadasim/python-course | /tuples.py | 594 | 4.46875 | 4 | # Tuples are very similar to list.
# Unlike list tuple are immutable.
t = (1,2,3,'one')
l = [1,2,3,4]
print (type(t))
print (type(l))
print(t[1])
my_tuple = (1,1,1,2,3,4,5)
print(my_tuple.count(1))
print(my_tuple.index(1))
print(my_tuple.index(2))
'''
We can not append anything to a tuple but we can change a tuple as ... |
d35d7e82206e1645a9252bef727623942e8ca87a | mohammadasim/python-course | /lambda_map_filter.py | 1,413 | 4.5 | 4 | # They are anonymous functions.
# Map function takes a function and apply it over the entire iterable.
# When passing function to map, we pass it as an argument and not execute it inside the map function
# Execution of the function is done by the map function.
def square(number):
return number**2
my_num = [1,2,3,4... |
c7de72471f76bbdc0200b3ff08045ef618fe87f7 | mohammadasim/python-course | /comparison.py | 451 | 4.15625 | 4 | # When comparing strings the capital matters.
print('Bye' == 'bye')
# Similarly '2' is not equal to 2
print ('2' == 2)
# In python the comparison operator is 'and' unlike java where it is &&
print(('h' == 'h') and (2 == 2))
# In python the comparison operatior is 'or' unlike java whre it is |
print(100 == 1 or 2 ==... |
792db112bab82d630a999871cd055ebde1d029b6 | nmarcopo/challenges | /challenge07/program.py | 927 | 3.640625 | 4 | import sys
firstLine: bool = True
for line in sys.stdin:
N: int = int(line)
if N == 0:
break
# Hacky way of not printing a newline after the last line of output
if not firstLine:
print("")
firstLine = False
solutions: bool = False
# Go through every possible five digit numbe... |
cf5986febe16461d61ba971782a5044385a53cd9 | ajay2589/techgig | /WordSearch.py | 1,986 | 3.84375 | 4 | from Trie import Trie
from File import File
from SaveReload import SaveReload
from OutOfRange import OutOfRange
class WordSearch:
def __init__(self):
self.trie = Trie()
def read(self):
print('Enter the input file location. eg: C:/Users/Ajay/Desktop/ph.txt')
inp = str(input())
try:
f = File(inp)... |
665f0112e844b436343be4ad24216d8d95c217a4 | beckytrantham/PythonI | /Final_Lab.py | 1,879 | 4.0625 | 4 | # Function simulating rolling a pair of dice
# First roll 7 or 11 = win
# First roll 2, 3, or 12 = loss
# Any other number = the Point and you must roll again
# On subsequent rolls:
# 7 = loss
# the Point = win
# Any other number = reroll
# Start with $100 and bet $10 each play
# Print all the rolls and wheth... |
af2a596503f59a362409d1df33dcd9cd4061f1b9 | TSLsun/clinical-data-AI-analytics | /homework/hw1-prerequisite/patching.py | 1,061 | 3.578125 | 4 | import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
def get_patch(mask, patch_shape):
"""This is for generate corresponding patches.
Args:
mask (numpy.ndarray): A circle mask array.
patch_shape (numpy.ndarray):
The patch shape will larger than the boundin... |
ef69e1080a27f4411aa2c47f021077f85a4a8074 | YektaAkhalili/Practice_Python | /Ex3.py | 290 | 3.8125 | 4 | n = int(input("Enter a number: "))
l_nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
new_l = []
def new_list(n,l):
for i in range(len(l)):
if l[i] < n:
new_l.append(l[i])
else:
continue
return new_l
print(new_list(n,l_nums))
|
6de53e78ec5cc1f1abf4371ba6802a9661db849b | aaron6347/leetcode_April30Days | /venv/day28_first_unique_number.py | 1,597 | 3.625 | 4 | """day28_first_unique_number.py
Created by Aaron at 28-Apr-20"""
from typing import List
from collections import OrderedDict
import itertools
class FirstUnique:
def __init__(self, nums: List[int]):
self.uni=OrderedDict()
self.non={}
for x in nums:
if x not in self.non and x n... |
ac20e54f3ccfb6854923d8287e8dd5716ba88a95 | Olaxan/S0006D_ai | /ai_fsm_lab1/utils.py | 1,119 | 3.65625 | 4 | class Clamped:
_max = None
_min = 0
_current = 0
def __init__(self, begin = 0, min = None, max = None):
self._current = begin
self._min = min
self._max = max
self._clamp()
def _clamp(self):
if self._max != None and self._current > self._max: self._current =... |
f3e9098eba917ce30d287a40e84609a4b223a4c5 | HYSkyline/wallbase | /wlb_thread.py | 1,512 | 3.609375 | 4 | # -*- coding:utf-8 -*-
from __future__ import division
import time
import threading
import os
def now():
return str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
def loop(count):
t0 = now()
print 'thread %s is running...' % threading.current_thread().name + "\ttime:" + t0
n = 0
while n ... |
679b305f606f5fe9b4202c14ce98f6a97e6e739e | theLoFix/30DOP | /Day13/Day13_Excercise04.py | 462 | 4.28125 | 4 | # Write a function that takes in a single number and returns True or False depending on whether or not the number is prime. If you need a refresher on how to calculate if a number is prime, we show one method in day 8 of the series.
def is_prime(dividend):
if dividend < 2:
return False
for divisor in range(2, d... |
d4b79b0c48ae154440918d24210687836e9673dd | theLoFix/30DOP | /Day20/Day20_Excercise03.py | 236 | 4.15625 | 4 | # Use filter to remove all negative numbers from the following range: range(-5, 11). Print the remaining numbers to the console.
positive_numbers = filter (lambda number: number >= 0, range(-5, 11))
print(*positive_numbers, sep="\n")
|
4d328efd01f74ebf69fa19bc9e3a5ac2f682b28c | theLoFix/30DOP | /Day11/Day11_Excercise4.py | 537 | 3.953125 | 4 | # Find the union, symmetric difference, and intersection of the two sets. Print the results of each operation.
new_set = set()
new_set.update(["one", "two", "three"])
print(new_set)
new_set.add("four")
print(new_set)
second_set = {"four", "one", "five", "six"}
print(second_set)
third_set = new_set.union(second_se... |
b366523cf0f5d16db0bae2767da2494eeaecb0a6 | theLoFix/30DOP | /Day23/Day23_Excercise01.py | 371 | 4 | 4 | # Write a generator that generates prime numbers in a specified range.
def gen_primes(limit):
for dividend in range(2, limit + 1):
for divisor in range(2, dividend):
if dividend % divisor == 0:
break
else:
yield dividend
primes = gen_primes(101)
print(next(... |
672662c9c7be75437a0f4bce422e711c1d71b42d | theLoFix/30DOP | /Day05/Day05_Excercise04.py | 1,047 | 4.4375 | 4 | # Write a program to determine whether an employee is owed any overtime. You should ask the user how many hours the employee worked this week, as well as the hourly wage for this employee.
# If the employee worked more than 40 hours, you should print a message which says the employee is due some additional pay, as wel... |
8da146c4919cc275f11c34b19913ed8c00ee226f | theLoFix/30DOP | /Day03/Day03_Excercise01.py | 221 | 4.09375 | 4 | # Using the variable below, print "Hello, world!".
greeting = "Hello, world"
print(greeting+"!")
greeting = "Hello, world{}"
print(greeting.format("!"))
symbol = "!"
greeting = f"Hello, world{symbol}"
print(greeting)
|
54d3a2fb03dec9bdf01afdae6fe6fbbb07cb27e5 | theLoFix/30DOP | /Day04/Day04_Excercise06.py | 420 | 4.125 | 4 | # Print both movies in the movies collection.
movie = [("Szeregowiec Ryan", "Steven Spillberg", 1998)]
new_title = input("Please provide title of your favourite film: ")
new_director = input("Who direct this film? ")
new_date = input("At what year it was produced? ")
new_tuple = (new_title, new_director, new_date)
... |
d3a4e9b1e9c709759c07f1aa1e9ee431afdca488 | theLoFix/30DOP | /Day07/Day07_Project_Movie-Budgets.py | 1,137 | 4.25 | 4 | """ For this project, your program should do the following:
Calculate the average budget of all movies in the data set.
Print out every movie that has a budget higher than the average you calculated. You should also print out how much higher than the average the movie's budget was.
Print out how many movies spent more... |
a6224583a67cf0de4161371a8028c0cc0aa7b8cb | theLoFix/30DOP | /Day26/Day26_Excercise02.py | 476 | 4.34375 | 4 | # Use a defaultdict to store a count for each character that appears in a given string. Print the most common character in this dictionary.
from collections import defaultdict
word = "piedziesieciocentowka"
char_numbers = defaultdict(int)
for letter in word:
char_numbers[letter] +=1
for key, value in char_num... |
6c3601706957595ae726778fd755c5e7d57b1432 | theLoFix/30DOP | /Day15/Day15_Excercise02.py | 329 | 4.03125 | 4 | # Use a dictionary comprehension to create a new dictionary from the dictionary below, where each of the values is title case.
movie = {
"title": "thor: ragnarok",
"director": "taika waititi",
"producer": "kevin feige",
"production_company": "marvel studios"
}
movie = {key: value.title() for key, value in movie.i... |
6d97dd478bae3a6196d0d76ed2b45ef317a3bd27 | theLoFix/30DOP | /Day23/Day23_Excercise03.py | 1,565 | 4.15625 | 4 | # Write a small program to deal cards for a game of Texas Hold'em.
import itertools
import random
def deal(cards, number_of_players):
deck = shuffle_deck(cards)
deal_to_players(deck, number_of_players)
deal_to_table(deck)
def deal_to_players(deck, number_of_players):
first_cards = [next(deck) for _ in range(n... |
2b66c72d6d9d0245cd116deac57fb68d9554e676 | adriancampos13/UIP-Programacion-III | /clase8/app/ejemplo.py | 538 | 3.65625 | 4 | import unittest
class PruebaCadenas(unittest.TestCase):
def test_upper(self):
self.assertEqual('xopa'.upper(),'XOPA')
def test_isupper(self):
self.assertTrue('XOPA'.isupper())
self.assertFalse('Xopa'.isupper())
def test_split(self):
s = 'x... |
337aeae93a949378d2a2458ba76ebedf5032763e | pssharma/Python_course | /7_functions_loops.py | 415 | 4.21875 | 4 | def explain_strings(list_value):
if list_value:
for v in list_value:
str_len = len(v)
upper_str = v.upper()
print_string = f"The string has a length of {str_len} and uppercase is {upper_str}"
print(print_string)
else:
print("The list is empty")
... |
1383338ef34d982d5b801083097635586ed2d14e | Madhav-Somanath/Anime-Tracker | /debug/archive/code.py | 4,073 | 3.53125 | 4 | import ssl
import re
import requests
from urllib.request import urlopen
from qbittorrent import Client
from bs4 import BeautifulSoup
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
def open_url(url: str) -> object:
"""
A function t... |
5a1f97edb0f13b25973bd8d872c0efa1c4920c4d | vinayvarm/programs | /AreaCircle.py | 309 | 4.1875 | 4 | # area of cirlce a=pi*r*r
'''import math
r= float(input('enter radius'))
a= math.pi*r**2
print("area of circle is", a)'''
# Program to chech given number is btw 1 to 10
x= int(input('enter number'))
if x>=1 and x<=10:
print('number is between 1 to 10')
else:
print("number is not btw 1 to 10")
|
a348013885ce994023f8cc5ce71f3b4652fa2d87 | vinayvarm/programs | /hw..py | 215 | 3.8125 | 4 | import random
# print helloworld
print('hello world')
print("hello66world")
# adding 2 number
a,b=5,6
c=a+b
print(c)
#finding sqare root
n=int(input('enter number'))
n=n*n
print(n)
print (random.randint(0,9))
|
9d9d79e9640bd41ef4633a70d7c3dd0331d98c59 | wiggiddywags/python-playground | /pascals_triangle.py | 779 | 4.46875 | 4 |
# Udacity Exercise: Write a function to produce the next layer of Pascal's triangle
# Each layer is one larger than the previous layer, and each element in
# the new layer is the sum of the two elements above it in the previous
# layer. For example, `(1, 3, 3, 1) -> (1, 4, 6, 4, 1)`.
# Add a layer/row to Pascal's tr... |
8ce661c7a8af98d4bfdf4af3e72d5547570319b9 | haithamabbas1/Python_stackax | /python_fundamentals/for_loops_basic2/forloopsbasic2.py | 1,327 | 3.765625 | 4 | #1 def biggiesize(arr):
# for i in range(0, len(arr)):
# if arr[i]>0:
# arr[i]="big"
# return arr
# print(biggiesize([-1, 1, 4, -5]))
#
#2 xix=[]
# def count_positives(arr):
# for i in range(0, len(arr)):
# if arr[i]>0:
# xix.append(arr[i])
# arr[-1]=len(xix)
#... |
276775f486ecdc6ccd0bb1cc472b7a236a4448cb | chbrandt/bit | /bit/image/image.py | 4,600 | 3.5625 | 4 | # -*- coding:utf-8 -*-
"""
Basic image processing functions.
"""
def normalize(img,unit=1):
"""
Normalize image intensity range. Default is to [0:1]
"""
_min = img.min()
_rng = img.max() - _min
_fc = float(unit)/_rng
img_norm = img - _min
return img_norm * _fc
def float2uint(img):
... |
66816b095036fbd0a13e3b37b3bcf07741f92391 | akinolajaye/libraryManagementSystemCW | /bookweed.py | 3,162 | 3.578125 | 4 | #This Programme was written by Jayeola Akinola on 1st December 2020 - 7th December 2020
import numpy as np
import matplotlib.pyplot as plt
import database as db
import datetime
def bookweed():
"""
This is a function to suggest which books should be removed
it does this by calculating the amount of borrows... |
ee8b6e123ab971f697fccf038ea9e050282cc1cf | Rash-mithaS/PracticeCodes | /Hackerrank/Sock Merchant.py | 783 | 3.5625 | 4 | #!/bin/python3
# Complete the sockMerchant function below.
def sockMerchant(n, ar):
pairs=0
flag=0
ar.sort()
for i in range(len(ar)-1):
if (flag == 0 and ar[i]==ar[i+1]):
flag = 1
pairs += 1
elif flag==1:
flag=0
return pairs
if __name__ == '__ma... |
886e7116ba6798979ddc1f6f5647803652fc9842 | heyu-rise/geek | /advanced/17.py | 2,174 | 3.53125 | 4 | # 装饰器 https://time.geekbang.org/column/article/100914
# def func(message):
# print('Got a message: {}'.format(message))
#
#
# send_message = func
# send_message('hello world')
#
#
# def get_message(message):
# return 'Got a message: ' + message
#
#
# def root_call(func, message):
# print(func(message))
#
#
... |
b3e96ad726d70fe9e0b3816b1a2cda3c553853fb | heyu-rise/geek | /base/12.py | 1,227 | 3.5 | 4 | # 面向对象2 https://time.geekbang.org/column/article/98998
class SearchEngineBase:
def __init__(self):
pass
def add_corpus(self, file_path):
with open(file_path, 'r') as fin:
text = fin.read()
self.process_corpus(file_path, text)
def process_corpus(self, id, text):
... |
8210b1613d8468d35a1346bddab400c100c1ee0d | hassannaveed1997/HackU-1 | /GoogleParser.py | 5,324 | 3.984375 | 4 | """
This program uses the library python-google-places and scrapes data about
businesses that match with the given query, and within a given radius of
a given location. It stores data about businesses in a list.
"""
from googleplaces import GooglePlaces, types, lang
import pprint
API_KEY = 'AIzaSyCtgmj9wswe42uYL3KAQ... |
722c42a4a92f28f0d22606d6d6e2bb9066af07d0 | winston86zhu/cloud-computing-specialization | /cloud-computing-concepts-part1/scripts/vector-timestamps.py | 813 | 3.59375 | 4 | __author__ = 'grokrz'
def is_less(v0, v1):
for idx in [0, 1, 2, 3]:
if not v0[idx] <= v1[idx]:
return False
return True
given = [0, 0, 0, 2]
vectors = [
[1, 0, 0, 0],
[2, 0, 0, 0],
[3, 0, 0, 0],
[4, 3, 2, 1],
[5, 3, 2, 1],
[6, 3, 2, 1],
[0, 1, 2, 1],
[0, 2... |
dc8b3f0d21020b529abd45f449a1b41f6cc88a09 | pruzhinskaya/scientific_python | /scientific_python/b_modules/functions.py | 6,135 | 4.15625 | 4 | #!/usr/bin/env python3
from __future__ import division, print_function, unicode_literals
import copy
### Return ###
def one():
print(1)
return 1
assert one() == 1
# 1
# Functions are variables:
f = one
assert f() == 1
# if not return value or not "return" statement then functions returns None:
def none_fu... |
6ed123dd709a29616f7314b9000dcf3c305add3d | pasha-bolokhov-cs/Udemy | /Python/func.py | 322 | 3.65625 | 4 |
def func(n="Serena"):
"""
Dontcha know this is a cool place
"""
print ("Hey, there, %s" % n)
return "Serena" + " " + "Wonderwoodsen"
func("Sylvia")
func()
print
print
print ("""Super long string
is getting too long cuz
it's like eighty lines long
or maybe a thousand""")
print
print
print func("Annasoph... |
c2c4178f3030c8498190ed7acaf6960ceec8fcae | dmitribichun/QuadraticEquation | /quadratic.py | 427 | 4.03125 | 4 | import math
a = float(input('Enter a: '))
b = float(input('Enter b: '))
c = float(input('Enter c: '))
D = math.sqrt(b**2-4*a*c)
root1 = (-b + D)/(2*a)
root2 = (-b - D)/(2*a)
print('We are solving equation ax^2 + bx + c = 0')
print('with coeffs a = {0} b = {1} c = {2}' .format(a,b,c))
print('({0})x^2 +... |
db2be784b6355bc0ed66b9f37487bab3d6d18a6a | Haosam/hackerrank | /30-days-of-code/python/answer/day9.py | 832 | 4.5625 | 5 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the factorial function below.
def factorial(n):
if n <= 2 or n >= 12:
print('Value error')
else:
n = n*factorial(n-1)
return n
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
... |
c1677e867a9d7fee3a23b678284c2ad218df6869 | bertisalom/Dataquest-Projects | /Investigating Airplane Accidents/main.py | 3,389 | 3.703125 | 4 | '''
The goal of the project is and practice time complexity of algorithms while analyzing airplane accidents.
'''
# Open and read the dataset
f = open("AviationData.txt", "r")
reader = f.read()
aviation_data = reader.split("\n")
# Read each line into a list
aviation_list = [row.split(" | ") for row in aviation_data]... |
3a245954043dea755666ee6f80465ba4dba2675d | asiegman16/raspberry_pi | /physical_projects/traffic_lights/traffic_lights.py | 586 | 3.625 | 4 | """from gpiozero import Button, LED
button = Button(21)
led = LED(25)
while True:
button.wait_for_press()
led.on() # or, led.blink() or, led.blink(2,2) which means 2 seconds on, 2 seconds off
button.wait_for_release()
led.off()"""
from gpiozero import Button, Buzzer, LED
from time import sleep
red = LED(25)... |
63a22eebba24b72e49f79bb62fb882050fa6a0c8 | minupjames/user_registration | /user_registration/leads.py | 1,530 | 4 | 4 | class Leads():
"""
Leads Class
"""
def __init__(self, name, email, phone):
"""
Inits Leads Class
"""
self.name = name
self.email = email
self.phone = phone
class LeadsList(list):
"""
LeadsList: List of Leads objects
"""
def __init__(self... |
e944f572d1195a1e98c35cf0c8d6c30c4ba355db | mciolfi/PL208 | /5 - NaiveBayes/Bayes-ex1.py | 974 | 3.625 | 4 | def Bayes ():
#Definição de valores iniciais e tamanho das matrizes
#Yes = [25.2, 19.3, 18.5, 21.7, 20.1, 24.3, 22.8, 23.1, 19.8]
#No = [27.3,30.1,17.4,29.5,15.1]
name = ['Kate', 'Tom', 'Harry', 'Annika', 'Naomi', 'Joe', 'Chakotay', 'Neelix', 'Kes', 'B´Elanna']
laptop = ['PC', 'PC', 'PC', 'Mac', 'Ma... |
b063a695681f4b99cde27447c0e6b87d2405dfa8 | mciolfi/PL208 | /6 - Perceptron/Perceptron.py | 2,289 | 3.65625 | 4 | # Threshold function: Binary result
def linear (inputs,weights):
output = dot(inputs,weights) #Multiply the inputs with weights
for cont in range(len(output)):
if output[cont][0] > 0.5: output[cont][0] = 1 # Establishes the value of 0.5 as a limit for binary
else: ... |
3d9f3c56418c7112c418eb7eab67ce3de9da7caf | mohamad97mj/PYTHON-deep_dive_part1 | /5.5 Unpacking iterables.py | 222 | 3.71875 | 4 | a = 1,
print(type(a))
b = (1)
print(type(b))
c = ()
print(type(c))
a, b, c = (1, 2, 'hello')
print(a, b, c)
a, b, c = 1, 2, 'hello'
print(a, b, c)
a, b, c = 'xyz'
print(a, b, c)
for e in 1, 2, 'hello':
print(e)
|
dc2ef6cf379a48d6f7052294d425dbaf9daa8a61 | mohamad97mj/PYTHON-deep_dive_part1 | /2.6 Functions.py | 432 | 3.953125 | 4 | def func(a: int, b: int): # this is just for doc
return a * b
print(func('test', 3))
print(func)
def func1():
return func2()
def func2():
return "func2 is running"
func1()
def func3():
return func4()
# func3() this will cause error
def func4():
return "func4 is running"
func5 = func... |
d13ddcc2d850435de7e7bd4d3ab7daf5d87ce013 | mohamad97mj/PYTHON-deep_dive_part1 | /4.32 Comparision Operators.py | 109 | 3.71875 | 4 | from decimal import Decimal
print(1 < 5 > -2)
print(10.0 == Decimal('10.0'))
print(0.1 == Decimal('0.1'))
|
497db69657baf17f79080ffe6b677154c2dee136 | mohamad97mj/PYTHON-deep_dive_part1 | /3.11 Everything is an object.py | 512 | 3.5625 | 4 | a = int()
print(a)
b = int('101', base=2)
print(b)
c = 5
print(id(b))
print(id(c))
def square(a):
return a ** 2
print(type(square))
f = square
print(f(8))
print(id(f))
print(id(square))
print(f is square)
def cube(a):
return a ** 3
def select_function(fun_id):
if fun_id == 1:
return square
... |
cae5041d93a21d7b8811fc29342ca2622fc9426e | mohamad97mj/PYTHON-deep_dive_part1 | /2.8 Break, Continue and the Try statement.py | 313 | 3.625 | 4 | a = 0
b = 10
while a < 4:
a += 1
b -= 1
print('--------------------------')
try:
a / b
except ZeroDivisionError:
print("division by zero")
# continue
break
finally:
print("always execute")
else:
print("code executed without division by zero")
|
aa2f5373525d63051ca4b1a53dbcc63e831280e3 | mohamad97mj/PYTHON-deep_dive_part1 | /5.14 putting it all together.py | 546 | 3.546875 | 4 | def put_it_together(a, b, c=10, *args, d, e=7, **kwargs):
print(a)
print(b)
print(c)
print(args)
print(d)
print(e)
print(kwargs)
print('.......')
put_it_together(10, 20, 30, 40, 50, d=7)
put_it_together(10, 20, d=5)
put_it_together(b=10, a=20, d=5, g=8, h=9)
def put_it_together2(a, b... |
e26e710c6ceb02aafee7e757b5d1d4745beb4685 | tylerem21/isat340_miniproject | /insert_row.py | 353 | 3.546875 | 4 | import sqlite3
conn = sqlite3.connect("celebrities.db")
cursor = conn.cursor()
#insert multiple rows
sql2 = "insert into members values(?,?,?,?,?,?)"
data = ((1,"Erica","Wilder",20,"wilderea@dukes.jmu.edu\
","From Fairfax, VA"),(2,"Ethan","Tyler",21,"tylerem@dukes.jmu.edu","From Leesburg, Va."))
cursor.executema... |
c37ec55be313a17522a0a8a6bc98785c5ac1bbb0 | ryoutoku/real-coded-genetic-algorithm | /src/evaluator.py | 1,468 | 3.734375 | 4 | # -*- coding: utf-8 -*-
from abc import ABCMeta, abstractmethod
import math
from individual import Individual
class Evaluator(metaclass=ABCMeta):
def __init__(self):
Individual.set_evaluator(self)
def evaluate(self, individual):
"""個体を評価する
Args:
individual (individual):... |
eef1fbf418b6bead60a71890ff60c104223ef84e | Alsock/ghMaxi.github.io | /muiv/2/hlp/Seminar04v1/src/card.py | 447 | 3.515625 | 4 | import suit
import rank
class Card:
def __init__(self, _rank: rank.Rank, _suit: suit.Suit):
self.suit = _suit
self.rank = _rank
def __str__(self):
return f'Card({self.print_symbol})'
@property
def print_symbol(self):
return f"{self.rank.print_symbol}{self.suit.print_s... |
b10c26af87360c7f924f5a4e47a7dcaa00c639c0 | austinfarrar/Farrar-MATH361B | /IntroToProgramming/I8_PrimeFunc_Farrar.py | 632 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Feb 21 21:00:35 2019
@author: Owner
"""
def prime_check(x):
if x > 1:
for ii in range(2,x):
if x % ii == 0:
return False
break
else:
return True
else:
return False
numprimes = 20 #number... |
339f58b78193beca9b4d87ce0da94e8cc4ade3dc | austinfarrar/Farrar-MATH361B | /IntroToProgramming/Calculator_Farrar.py | 496 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Feb 1 10:25:55 2019
@author: Owner
"""
x = 1
y = 2
z = 3
mylist = []
comp1 = x + y
mylist.append(comp1)
comp2 = (y * z) + (3 * x)
mylist.append(comp2)
comp3 = (comp1)**2
mylist.append(comp3)
comp4 = (2 * comp2 - .5 * x)/ comp1
mylist.append(comp4)
comp5 = 7 % 3
mylist.appe... |
628f4ff39a045101753e5303c4077953933b0095 | toluwaanimi/30_Days_Of_Code-HackerRank | /Day 1.py | 511 | 4.09375 | 4 |
# Declare second integer, double, and String variables.
# Read and save an integer, double, and String to your variables.
integer_input = raw_input()
double_input = raw_input()
string_input = raw_input()
# Print the sum of both integer variables on a new line.
print int(integer_input) + i
# Print the sum of the doub... |
30712aa58787fd170f9258a01a11ce094fc3ca53 | julia-kraus/Chatbot | /intents.py | 2,165 | 3.65625 | 4 | import json
import word_utils
class Intents:
"""Class for chatbot Intents. An intent is the user's intention when he interacts
with the chatbot.
Attributes:
words: all unique words contained in the documents
documents: examples of user intents we have
classes: possible types of intent (... |
f8c8790a119dce5a47f351cd503f474a31f17e05 | FisherZhongYi/HeadFirstDesignPatterns | /c03_DecoratorPattern.py | 1,488 | 3.71875 | 4 | # DecoratorPattern.py
# Base class of beverage
class Beverage(object):
def __init__(self):
pass
def cost(self):
return 0.0
def description(self):
return "Unknown beverage"
class Decorator(Beverage):
def __init__(self, beverage):
self.beverage = beverage
def... |
74fa8f30d4943c6d6f8299db1d537f80b688f6f4 | HowardWang0915/Python_projects | /ps1/ps1.py | 2,019 | 4.03125 | 4 | ## Problem 1
"""
annual_salary = int(input("Enter your annual salary: "))
portion_saved = float(input("Enter the percent of your salary to save, as a decimal: "))
total_cost = int(input("Enter the cost of your dream home: "))
current_savings = 0.0
monthly_salary = annual_salary / 12
month = 0
while current_savings... |
c3ffd324549cc901c359cc5d850ea5858f67c723 | league-python/Level0-Module1 | /_03_if_else/_5_shape_selector/shape_selector.py | 518 | 4.4375 | 4 | import turtle
from tkinter import messagebox, simpledialog, Tk
# Goal: Write a Python program that asks the user whether they want to
# draw a triangle, square, or circle and then draw that shape.
if __name__ == '__main__':
window = Tk()
window.withdraw()
# Make a new turtle
... |
26f909211e3040413fc899faf927aa4b265f3df3 | azegun/python_study | /chap06/ex_finally.py | 394 | 3.6875 | 4 | try:
number_input_a = int(input("정수 입력 > "))
print("원의 반지름 : ", number_input_a)
print("원의 둘레 : ", 2 * 3.14 * number_input_a)
print("원의 넓이 : ", 3.14 * number_input_a * number_input_a)
except:
print("정수를 입력해달라고 했잖아!!")
else:
print("예외가 발생하지 않음.")
finally:
print("일단 프로그램 끝") |
558c3d9853af044ad5dc71009092cba6530850a9 | itamar19-meet/yl1201718 | /lab 3/lab3.py | 211 | 3.890625 | 4 | import turtle
turtle.pencolor("Yellow")
colors = ["Red","Blue","Green","Purple","Black"]
turtle.pensize(10)
for i in range(5):
turtle.forward(100)
turtle.left(144)
turtle.pencolor(colors[i])
turtle.mainloop() |
fdf42937a532e8887cc292915204c31fa67d6677 | itamar19-meet/yl1201718 | /lab 5/lab5ex2.py | 708 | 3.8125 | 4 | from turtle import *
import random
colormode(255)
class Square(Turtle):
def __init__(self,size):
Turtle.__init__(self)
self.shapesize(size)
self.shape("square")
def random_color(self):
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
self.color(r,g,b)
square1 = Square(15... |
d3d466239c7b19e5b29285aca74963289b2f3100 | Vinaypatil-Ev/Lets-do-DataStructure-and-Algorithm | /Data_Structures_(basic)/stack.py | 774 | 3.9375 | 4 | class Stack:
def __init__(self,size):
self.size = size
self.top = -1
self.array = [None] * self.size
def isEmpty(self):
if(self.top == -1):
return True
else:
return False
def top(self):
return self.array[self.top]
def push(self, data):
if not (self.top < self.size-1):
print('Stack is full... |
0d3182bb65fdcd433550f00d85805c59c741fdbb | uu64/project-euler | /problem012.py | 909 | 3.640625 | 4 | # -*- coding: utf-8 -*-
import eulerlib
def tri_number_generator():
idx = 1
tri_number = 0
while True:
tri_number += idx
idx += 1
yield tri_number
def main():
# TODO: 素数の数をどう決めるか
primes = eulerlib.get_primes(100000)
for number in tri_number_generator():
i = n... |
2c86a94e68684749790114c7be06d46bfe876567 | uu64/project-euler | /problem004.py | 391 | 3.546875 | 4 | # -*- coding: utf-8 -*-
def is_kaibun(number):
if str(number) == str(number)[::-1]:
return True
else:
return False
palindromic_number= []
for i in range(999, 100, -1):
flag = False
for j in range(999, 100, -1):
number = i*j
if is_kaibun(number):
... |
7ceae5a111920521efb8de2544ee4693411b1f4a | uu64/project-euler | /problem029.py | 186 | 3.65625 | 4 | #!/usr/bin/env python
A_MAX = 100
B_MAX = 100
ans = set()
for a in range(2, A_MAX + 1):
n = a
for b in range(2, B_MAX + 1):
n *= a
ans.add(n)
print(len(ans))
|
c18f8a202ae7bb77ab6e388a82aab58825b97bfd | uu64/project-euler | /problem025.py | 229 | 3.625 | 4 | #!/usr/bin/env python
def fib(prev, now):
return prev + now
p1 = 1
p2 = 1
count = 2
while True:
tmp = fib(p1, p2)
p1 = p2
p2 = tmp
count += 1
if len(str(tmp)) == 1000:
print(count)
break
|
70fedb1a155ff6841f3d3e348b04f597b5c713e5 | ritomar/wttd-exercises | /mod02/desafio/atm.py | 3,115 | 3.828125 | 4 | # Desenvolva um programa que simule a entrega de notas quando um cliente efetuar um saque em um caixa eletrônico.
#
# - Os requisitos básicos são os seguintes:
# - Entregar o menor número de notas;
# - É possível sacar o valor solicitado com as notas disponíveis;
# - Saldo do cliente infinito;
# - Quantidade de notas i... |
d22e237184562f71cbad10a1d38dc1826ca9980f | whoden/Python_course | /den02/classes2.py | 851 | 4.09375 | 4 | # Parent class
class Pet:
number_of = 0
number_of_pets = {}
def __init__(self):
Pet.number_of += 1
print("Creating object of ", self.__class__)
Pet.number_of_pets[self.__class__] = \
Pet.number_of_pets.get(self.__class__, 0) + 1
def eats(self):
print("eats")... |
7479ed846a8d790eaea1a9a2763ecfd733b1ffc4 | ghiaog123/BaiTap | /main.py | 2,229 | 3.546875 | 4 |
def read_input(file_name):
with open(file_name, 'r') as f:
lines = f.readlines()
return [line.split() for line in lines]
def find_count_items(transactions):
count_items = {}
for basket in transactions:
for i in basket:
if i in count_items.keys():
coun... |
9679fa8c3b3fb0a11cec868b991b9469f8b1ebd4 | neima1/gwc | /adventure_game.py | 1,365 | 4.125 | 4 | startgame = input("I have a day off! Should I go to the 'beach', the 'park', or the 'city'?")
if (startgame == "beach"):
firstturn = input("Finally! A break! Should I go 'swim' or 'sit and relax'?)
if (firstturn == "swim"):
print("AHH! This water is so cold!")
secondturn = input("I'm bored! S... |
d471b1d17f445c042a7a07f4fe994e008c61231f | wenyan666/wenyan-python | /ex32.py | 959 | 4.5625 | 5 | the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
# this first kind of for-loop goes therough a list
for number in the_count:
print ("This is count %d" % number)
# same as above
for fruit in fruits:
print ("A fruit of type: %s" %... |
904417ac9528e857c8adf45539cba2fee8f69505 | wenyan666/wenyan-python | /ex16.py | 1,791 | 4.125 | 4 | # -*- coding:UTF-8 -*-
from sys import argv
script, filename = argv
print "Now I'm going to eraser you file %r." % filename
print "If you don't want that, hit CTRL-C(^C)."
print "If you want that, hit RETERN."
# 这地方为嘛不用在前面加一个变量来定义?而是直接用raw_input? 想多了,是可以直接用的。
raw_input("Tell me you answer?")
# 以write模式打开文件
print "Op... |
ad933088dbaf2926608d4dcb46975400e2fb8b64 | Hlonela/ID-exercise | /ID_EXERCISE/ID.py | 1,023 | 3.984375 | 4 | id_num = input("Please enter your ID: ")
id_year = id_num [:2]
print("Year: " + "19"+str(id_year))
id_month = int (id_num [2:4])
if id_month == 1:
print("Month: " + "January")
elif id_month == 2:
print("Month: "+ "February")
elif id_month == 3:
print("Month: "+ "March")
elif id_month == 4:
print("Month:... |
d6c0b5b5336a86e9cc92cd8e09c0686172caf551 | uishi/FastHETrace | /cost_analysis/BehaviorGh/gh_behavior.py | 1,011 | 3.5 | 4 | import math
import numpy as np
import sys
import matplotlib.pyplot as plt
def g(h, M):
fl = int(M / h)
pof2 = 1 << fl
r = M % h
return pof2 * (h + r)
if __name__ == "__main__" :
argc = len(sys.argv)
if argc != 2:
print("python3 ./xxxx M ")
exit(1)
logN = 15
M = int(sy... |
6e1b8e6a8550515258c983bd5b945580f1afcc56 | shubham-ricky/Python-Programming---Beginners | /Larger Number.py | 641 | 4.28125 | 4 | """
a) Write a function larger_num() that takes in two number parameters to determine and return the larger number of the two.
b) Write a program to do the followings:
Ask user for two numbers
Use the function in Q1(a) to determine the larger number and display the result.
"""
def larger_num(number1, number2... |
cb7fa50687f9c46c7ee18492576fed74811d9ad0 | azherdeva99/MyRepository | /Vigenère.py | 518 | 3.828125 | 4 | abcEng = 'abcdefghijklmnopqrstuvwxyz'
abcRu = 'абвгдеёжзийклмнопрстуфхцчшщъьыэюя'
text = input('Input text: ').lower()
k = input('Enter key word: ')
new = ''
d=[]
for c in text:
if c in abcEng:
d.append(abcEng[(abcEng.index(c) + len(k)) % (len(abcEng))])
elif c in abcRu:
d.append(abcRu[(abcRu.i... |
89abc762d7dcb7fcd6c829471997c5becc680743 | redbrick/useradm | /scripts/newyear_ldif.py | 247 | 3.5625 | 4 | #!/usr/bin/python
import sys
for i in sys.stdin:
i = i.rstrip()
if i.startswith("yearsPaid:"):
print("yearsPaid:", int(i.split()[1]) - 1)
elif i.startswith("newbie:"):
print("newbie: FALSE")
else:
print(i)
|
a345877f726ae4f4d59766018f7271bbb2368692 | dongjlee/coding-for-dongju | /week-01-python/04-if-statement.py | 606 | 3.546875 | 4 | # # 참과 거짓 boolean
# # if
# # True, False
# # and,or,not
#
# a = True
# b = False
# # A가 참이고 그리고 B가 참이라면 (A나 B가 둘다 참이어야 된다)
# print(a and b)
# # A가 참이거나 혹은 B가 참이라면 (A나 B가 둘 중에 하나라도 참이면 된다)
# print(a or b)
#
# # = & ==
# c = True
# print(c == True)
# print(c is True)
#
# # if
# d = 7
# if d > 10:
# print("숫자는 5보다 큽니다... |
620e23a6a70d8d5af4a0fa0349c7e2952e3d0076 | TanshiSharma/course-work | /data-mining/girvan-newman/Betweenness.py | 3,884 | 3.953125 | 4 | import json
import sys
def get_graph_dict(input_path):
"""Creates a graph dictionary and edge list from the given input.
"""
edge_list = []
dict_graph = {}
file = open(input_path, 'r')
for line in file:
edge = json.loads(line)
source, dest = edge[0], edge[1]
edge_list... |
eea4e1b1f7e08d5741108b9c8a7e17f54fe6fd78 | puranjay123/Python_GUI_Calculator-using-tkitner- | /CALCULATOR.py | 3,771 | 4.09375 | 4 | from tkinter import *
root =Tk()
root.title("Simple calculator_P^K")
e=Entry(root,width=30,fg='yellow',bg='black',borderwidth=50)
e.grid(row=0,column=0,columnspan=3,padx=8,pady=8)
#e.insert(0,"name dalo:")
# def myClick():
# myLabel =Label(root,text="hello "+e.get())
# myLabel.pack()
def button_cli... |
986a3afa4a63f447fe60899335271b4dcd15b483 | BanMing/BanMingPythonLab | /Study/StepOne/DateTimeTest.py | 308 | 3.703125 | 4 | from datetime import datetime ,timedelta
now = datetime.now()
print(now)
dt = datetime(2014, 2, 2, 2, 2, 2)
print(dt)
print(dt.timestamp())
print(now.timestamp())
print(datetime.fromtimestamp(dt.timestamp()))
print(now.strftime('%a,%b %d %H:%M'))
# datetime(2013,3,3,3,3)
print(now+timedelta(hours=10)) |
59a6f059f3b01b9b510638778d4099946ee5c290 | mevlanaayas/hamming-distance | /main.py | 5,997 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: mevlana ayas - mevlanaayas@gmail.com
"""
reference for nj algorithm
http://www.wiki-zero.net/index.php?q=aHR0cHM6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvTmVpZ2hib3Jfam9pbmluZw
##### NJ Algorithm from wikipedia
Neighbor joining takes as input a distance matrix specifying ... |
3bdfa9920c8542a2a9857b3411d15d8e41f660f5 | AayushRishi/ET_class_exercise | /week2/areaCircle.py | 249 | 3.875 | 4 | from areaCircle_module import calcArea
def main():
print("This program calculates the area of circle.")
radius = float(input("Enter the radius of circle: "))
area = calcArea(radius)
print(f"Area of circle is: {area:.2f}")
main()
|
74975a5342146890ed953aadaf9c93cc8c7cfce5 | wilsjame/Euler | /14.py | 1,127 | 4.125 | 4 | # Longest Collatz sequence
# The following iterative sequence is defined for the set of positive integers:
#
# n -> n/2 (n is even)
# n -> 3n + 1 (n is odd)
#
# Using the rule above and starting with 13, we generate the following sequence:
#
# 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1
# It can be seen that... |
f00b5e66f1ba7208bf43161e2dc60ee03a2a47c7 | wilsjame/Euler | /01.py | 165 | 4.15625 | 4 | # Find the sum of all multiples of 3 or 5 below 1000.
sum = 0
for i in range(0,1000):
if i % 3 == 0 or i % 5 == 0:
sum = sum + i
print("The sum is %d." % sum)
|
a65aae02f990667bca2ad9b3d79fa3fe03df4c6c | wilsjame/Euler | /15.py | 491 | 3.59375 | 4 | # Lattice paths
# Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
#
# How many such routes are there through a 20×20 grid?
def main():
# combinatorial solution
# count routes
# 40 choose 20
routes = factorial(4... |
bf16153f69ef0bb80f7d6a2db678378274600293 | derbedhruv/csvFilePlotter | /plotFile.py | 4,696 | 3.625 | 4 | # this is for reading in csv
# first, the import statemtnts
import numpy, scipy.signal
import matplotlib.pyplot as plt
def savitzky_golay( y, window_size, order, deriv = 0 ):
r"""Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
The Savitzky-Golay filter removes high frequency noise fr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.