blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
7bd54a47b0950d29f681a2819a18fa7fe7a084a3 | ChrisMcK1/shutTheBox | /shutTheBox.py | 6,061 | 4.09375 | 4 | #! /usr/bin/python3
import random
import sys #to trigger game over for incorrect input
import time
import itertools #to calculate all possible play comibinations based on available board integers
#setting up the Board to show which number slot we're in, which will have an integer
#until it is selected by the user to ... |
4c1571e0eb11d604f630c2ef8627165b73db14a5 | SinigribovS/Rezolvarea-problemelor-IF-WHILE-FOR | /3.py | 434 | 3.703125 | 4 | #Se dau numerele naturale m şi n, unde m <n. Să se verifice dacă n este o putere a lui m.
m=int(input('Dati numarul natural m (baza): '))
n=int(input('Dati numarul natural n (puterea): '))
if (n<m):
print('Eroare: n<m')
else:
a=True
for i in range(1,n+1):
if(m**i==n):
print('Da,... |
5aea25fbfc44841612b271c36b61f15b6c52d552 | s4yhii/jesus-repo-clase | /jes.py | 637 | 3.75 | 4 | #ejercicio7
antiguedad=5
sueldo=300
if antiguedad>5:
print(sueldo*1.2)
if antiguedad<=5 and antiguedad>1:
print(sueldo*1.1)
else:
print(sueldo)
#ejercicio9
control1=int(input("ingrese el primer peso"))
control2=int(input("ingrese el segundo peso"))
control3=int(input("ingrese el tercer peso"))
... |
dd6b8c830ace6f94415534cdc3e650c1911537bd | s4yhii/jesus-repo-clase | /ejercicio8.py | 425 | 3.9375 | 4 | #ejercicio8
num1=int(input("ingrese un numero menor que 1000: "))
num2=int(input("ingrese otro numero menor que 1000:"))
if num1<1000 and num2<1000 :
a=int((num1/10)%10)
b=int((num2)%10)
c=int((num2/100)%10)
suma=a+b+c
union=(f"{a}{b}{c}")
print(f"el numero formado es: {union}")
pr... |
ad353b9d60b68942de19669b70c19147b59ba6ba | c3drive/my_scraping | /python_scraper.py | 3,543 | 3.671875 | 4 | import csv
import re
import sqlite3
from typing import List
import requests
import lxml.html
def main():
"""
メインの処理。fetch(), scrape(), save()の3つの関数を呼び出す。
"""
url = 'https://gihyo.jp/dp'
html = fetch(url)
books = scrape(html, url)
save('books.db', books)
save_file('books.csv', books)
de... |
17f0ed42a9f3b1bb9d7ec6fa25aa6fb1915e08d1 | dev2404/Babber_List | /heap4.py | 347 | 3.515625 | 4 | import heapq as hp
def kLargest(arr, n, k):
# code here
q = []
for i in range(n):
hp.heappush(q, arr[i])
if len(q) > k:
hp.heappop(q)
q.sort(reverse=True)
return q[-1]
#[hp._heappop_max(q) for i in range(len(q))]
N = 7
K = 3
Arr = [1, 23, 12, 9, 30, 2, 50, 89]... |
f136808d4f9f2e6bc029dd6034841761557a10cb | dev2404/Babber_List | /three_sum.py | 824 | 3.578125 | 4 | # solution-1
def triplet(arr, n, k):
count = 0
for i in range(0, n-2):
for j in range(i+1, n-1):
for x in range(j+1, n):
if arr[i]+arr[j]+arr[x] == k:
return 1
return 0
# Solution-2
def triplet(arr, n, k):
count = 0
arr.sort()
... |
dff4a52d4660596cf585512cf527b27ea21a686f | dev2404/Babber_List | /heap.py | 671 | 3.734375 | 4 | def heapify(arr, i):
largest = i
left = (2 * i) + 1
right = (2 * i) + 2
if left < len(arr) and arr[left] > arr[largest]:
largest = left
if right < len(arr) and arr[right] > arr[largest]:
largest = right
if largest != i:
arr[largest], arr[i] = arr[i], arr[largest]
... |
51ae8c3f304209e5d867be6d3fbf13a6d9fa4778 | dev2404/Babber_List | /dublicate.py | 422 | 3.53125 | 4 | def findDuplicate(self, nums: List[int]) -> int:
# X = set(nums)
# for i in X:
# if nums.count(i) > 1:
# return i
# for i in range(len(nums)):
# x = nums.pop(0)
# if x in nums:
# return x
while nums[n... |
d00e37f34de2103a220f1fc5f15009c1a5ed2013 | wlsanders/dsp | /python/advanced_python_regex.py | 2,022 | 4.09375 | 4 |
# Q1. Find how many different degrees there are, and their frequencies: Ex: PhD, ScD, MD, MPH, BSEd, MS, JD, etcimport csv
#
import csv
facultyFile = open('faculty.csv')
facultyReader = csv.reader(facultyFile)
facultyData = list(facultyReader)
def differentDegrees(facultyData):
degreeType = []
count = 0
for row ... |
cfdd6598e2c3adcfea9b5e9a9a4e7cff38ababdb | commutatif/ctf_2019 | /challs/123-anticaptcha-et-vernam/guess.py | 1,449 | 3.609375 | 4 | #!/usr/bin/env python3
from random import choice
from string import ascii_lowercase
# on peut deviner KEY_LENGTH en chiffrant plein de fois la même minuscule
KEY_LENGTH = 6
TXT = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
C = [
"g:ydkzunydkzunydkzunydkzunydkz",
"h:zunydkzunydkzunydkzunydkzuny",
"f:xmhalqxmhalqxmhalqxmhalqxmha... |
7f37652057d62733f72c52572916954f098693e6 | lupetimayaraturbiani/EstudoPython | /Ex_EstruturaSequencial/ex6.py | 166 | 3.828125 | 4 | # -*- coding: utf-8 -*-
l = int(input("Informe a medida do lado do quadrado: "))
area = l * l
print("O dobro da medida da área do quadrado é de " + str(area * 2)) |
66daf6e7b080b52000fb5b7c5056bf89cd6d7891 | lupetimayaraturbiani/EstudoPython | /Ex_EstruturaSequencial/ex5.py | 169 | 4 | 4 | # -*- coding: utf-8 -*-
r = float(input("Digite o valor do raio do círculo: "))
area_c = 2 * 3.14 * r
print("A área do círculo corresponde a: " + str(area_c) + ".") |
f9de5ebacd27919f7966554c3597d56f2c0e2e05 | chaminnk/Project-Euler | /20)sum of digits of 100!.py | 231 | 3.65625 | 4 | import time
start = time.time()
total = 1
for num in range(1,100):
total*=num #getting 100!
total2 = 0
for digit in str(total):
total2+=int(digit) #getting sum of digits in 100!
print total2
print (time.time() - start),'s'
|
5c94921ebb2ef33abac1c369670d5f878cbd2aa2 | hscannell/MHW-tableau | /code/LSTM/marineHeatWaves.py | 44,481 | 3.53125 | 4 | '''
A set of functions which implement the Marine Heat Wave (MHW)
definition of Hobday et al. (2016)
'''
import numpy as np
import scipy as sp
from scipy import linalg
from scipy import stats
import scipy.ndimage as ndimage
from datetime import date
def detect(t, temp, climatologyPeriod=[None,None], pctil... |
bca49786c266839dc0da317a76d6af24b20816e5 | mtahaakhan/Intro-in-python | /Python Practice/input_date.py | 708 | 4.28125 | 4 | # ! Here we have imported datetime and timedelta functions from datetime library
from datetime import datetime,timedelta
# ! Here we are receiving input from user, when is your birthday?
birthday = input('When is your birthday (dd/mm/yyyy)? ')
# ! Here we are converting input into birthday_date
birthday_date = datet... |
2937f2007681af5aede2a10485491f8d2b5092cf | mtahaakhan/Intro-in-python | /Python Practice/date_function.py | 649 | 4.34375 | 4 | # Here we are asking datetime library to import datetime function in our code :)
from datetime import datetime, timedelta
# Now the datetime.now() will return current date and time as a datetime object
today = datetime.now()
# We have done this in last example.
print('Today is: ' + str(today))
# Now we will use tim... |
e797aa24ce9fbd9354c04fbbf853ca63e967c827 | xtdoggx2003/CTI110 | /P4T2_BugCollector_AnthonyBarnhart.py | 657 | 4.3125 | 4 | # Bug Collector using Loops
# 29MAR2020
# CTI-110 P4T2 - Bug Collector
# Anthony Barnhart
# Initialize the accumlator.
total = 0
# Get the number of bugs collected for each day.
for day in range (1, 6):
# Prompt the user.
print("Enter number of bugs collected on day", day)
# Input the number... |
6e7401d2ed0a82b75f1eaec51448f7f20476d46e | xtdoggx2003/CTI110 | /P3HW1_ColorMix_AnthonyBarnhart.py | 1,039 | 4.40625 | 4 | # CTI-110
# P3HW1 - Color Mixer
# Antony Barnhart
# 15MAR2020
# Get user input for primary color 1.
Prime1 = input("Enter first primary color of red, yellow or blue:")
# Get user input for primary color 2.
Prime2 = input("Enter second different primary color of red, yellow or blue:")
# Determine secon... |
fb64f35e7947840cb7bd32c847fdfb17b45a022e | Near-River/robot_spider | /spider/url_manager.py | 734 | 3.71875 | 4 | # 管理待爬取和已爬取的URL集合
class UrlManager(object):
def __init__(self):
self.urls = set() # 待爬取的URL集合
self.over_urls = set() # 已爬取的URL集合
def add_url(self, root_url):
if root_url is None:
return
if root_url not in self.over_urls and root_url not in self.urls:
se... |
d8e20c074639e3a4a224cf67640e9c54d2a666bb | wasi-9274/DL_Directory | /DL_Projects/ETL_scripts/Load_excercise_script_important.py | 10,623 | 3.515625 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from pycountry import countries
from collections import defaultdict
import sqlite3
sns.set()
# read in the projects data set and do basic wrangling
gdp = pd.read_csv('/home/wasi/ML_FOLDER/DSND_Term2-master/lessons/ETLPipelines... |
4172fba04d1af39171f32cdaabbda8bdf3618556 | wasi-9274/DL_Directory | /DL_Projects/dummy_data_storage/recommendations_script_2.py | 4,468 | 3.640625 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# read in the datasets
movies = pd.read_csv("/home/wasi/ML_FOLDER/Udacity-DSND-master/Experimental Design & Recommandations/Recommendations/"
"1_Intro_to_Recommendations/movies_clean.csv")
reviews = pd.read_csv("/home/wasi/ML... |
453748851a21420a9d7aa3851a803e2294b2feea | SandeshKulung/User_Interface | /user_interface.py | 3,031 | 3.734375 | 4 | from tkinter import*
from tkinter import messagebox
def cancel():
messagebox.showinfo("Cancelled")
def display():
messagebox.showinfo("Registered")
window=Tk()
window.geometry("760x550")
window.resizable(width=0,height=0)
window.title("ADMISSION")
name=StringVar()
l1=Label(window, text="Student Admis... |
816ede0c29039d73385b94472d973fbc1c10424a | waynegakuo/nlp2018_waynegakuo | /lab_2/med.py | 1,125 | 3.5 | 4 |
# coding: utf-8
# In[1]:
import sys
def medistance(source, target):
#length of the source and target assigned to n and m respecitvely
n= len(source)
m= len(target)
#initializing the costs of insertion, substitution and deletion
ins_cost=1
sub_cost=2
del_cost=1
#creation o... |
c81f6eb1684183e44bae7c816777c73231c365ea | btalahmb/.PyFiles | /tablePrinter.py | 1,341 | 3.78125 | 4 | #tablePrinter.py
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alicia', 'Bert', 'Czech', 'David'],
['Dogs', 'chicken', 'moose', 'goose']]
def printTable():
colWidths = [0] * len(tableData)
#Solve for longest string in each column and store values in a list
for i in ra... |
c3ffa8b82e2818647adda6c69245bbc9841ffd76 | tsuganoki/practice_exercises | /strval.py | 951 | 4.125 | 4 | """In the first line, print True if has any alphanumeric characters. Otherwise, print False.
In the second line, print True if has any alphabetical characters. Otherwise, print False.
In the third line, print True if has any digits. Otherwise, print False.
In the fourth line, print True if has any lowercase char... |
c8e30738d8f5ec2f26a5ff285890983a6a1c9c16 | tsuganoki/practice_exercises | /ProjectEuler/024.py | 524 | 3.796875 | 4 | """
A permutation is an ordered arrangement of objects. For example, 3124 is one
possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are
listed numerically or alphabetically, we call it lexicographic order. The
lexicographic permutations of 0, 1 and 2 are:
012
021
102
120
201
210
What is th... |
7bdca56dc7a7e86e3a94977552da4b739b98949f | tsuganoki/practice_exercises | /yahtzee.py | 12,116 | 3.875 | 4 | from random import randint
import pdb
#import numpy as np
"""import pandas as pd
import json"""
# with open("somefi")
"""
import logging
logging.basicConfig(
filename="yahtzeelog.txt",
level = logging.DEBUG)
logging.disable(logging.CRITICAL)
"""
# rolls all 5 dice and returns a dictiona... |
653a376baa3e3f30164ba6f4b9bdf6006b572a34 | verepcode/Computer-Vision-Projects | /Put a glass on a face.py | 3,103 | 3.515625 | 4 | #The aim is to put any size of glasses on any size of frontal face image. The code has already been developing,
#and for future, I want to help people choose their glasses by just looking a front facing camera at the end of the work.
import cv2
import numpy as np
face_cascade = cv2.CascadeClassifier('Haarcas... |
ae99131ca37b4c71f72cd387438590cafac01423 | rgvsiva/learn | /func_arguments.py | 469 | 3.875 | 4 | def update(a):
print(id(a))
a=10
print(id(a))
print ('a',a)
def update1(a):
print(id(a))
a[1]=10
print(id(a))
print ('lst',a)
x=8
print(id(x))
update(x)
print ('x',x) #id's of variables are changing inside and outside of function.
#pass by value, pass by reference---n... |
3feecc6c94f430f3c15ded3290fe00e67387c72a | rgvsiva/learn | /fibonacci assign.py | 417 | 3.984375 | 4 |
x=int(input("upto which fibonacci no's u want: "))
def fib(x):
a=0
b=1
if x<=0:
print('not possible')
elif x==1:
print(a)
elif x>=2:
print(a)
print(b)
for i in range(2,x):
c=a+b
if c<=x:
pri... |
864cd59a002cd981a74c84813d6ba9837c1d8b10 | rgvsiva/learn | /break,cont,pass.py | 367 | 3.875 | 4 |
x=int(input('how many u want: '))
i = 1
av=5
while i<=x:
if i>=av:
print ('out of stock')
break
print ('biryani')
i+=1
print ('bye')
print ()
for i in range(1,31):
if i%3==0 or i%5==0:
continue
print (i)
print()
for i in range(1,16):
if i%2!=0:... |
bcfa60b524376285629d2208c7e9ee29dfccc339 | rgvsiva/learn | /global keyword.py | 345 | 3.875 | 4 | #scope
a=10 #global variable
print(id(a))
def some():
# global a # to access global variable
a = 23 #local variable
x = globals()['a']
print(id(x))
print('inside:',x)
print('ins:',a)
globals()['a']=45 #to change the global variable without effecting local variable
so... |
a652cc7c4fb44c7da3cdb40bf62729709a7fc170 | Dennisdoug/trandangdung-fundamental-c4e15 | /Session 1/Homework 1/temperatureconverter.py | 148 | 3.890625 | 4 | def Temperature():
F = input('Enter temperature in Fahrenheit')
C = ((5.0/9.0)*(F - 32))
print "Temperature in degree Celsius is %f" %C
|
ff83fb8d53ed313c4887468e722c753454890782 | Dennisdoug/trandangdung-fundamental-c4e15 | /Session 2/session02/maze.py | 142 | 4.03125 | 4 | from turtle import *
shape('turtle')
speed(0)
length = 10
for i in range (100):
forward(length)
length += 5
left(90)
mainloop()
|
36822cf538431e720fb90e7bc07dd4b0e4e41985 | Dennisdoug/trandangdung-fundamental-c4e15 | /Session 3/Session 3/randoom.py | 284 | 3.921875 | 4 | from random import randint
x = randint(1, 100)
loop = True
while loop:
num = int(input("Enter a number 1 - 100: "))
if num == x:
print("Bingo")
loop = False
elif num < x:
print("A little too small")
else:
print("A little too large")
|
33599a05c8a0eb38df5c56e430582ac5b77e786d | Dennisdoug/trandangdung-fundamental-c4e15 | /Session 5/Homework/count.py | 227 | 4.03125 | 4 | numbers = [1, 6, 8, 1, 2, 1, 5, 6, 1, 4, 5, 2, 7, 8, 4, 5, 9, 2, 1, 6, 8, 0, 0, 5, 6]
x = int(input("Enter a number? "))
count = numbers.count(x)
print(x, "appears " + str(count) + " times in the list")
#With count() function
|
03d426f76941366bdf75cae2ff1cbed5fad9b0ef | PLJTZS/AI | /DeepLearning/1-ImprovingNeuralNetworks/Initialization.py | 6,720 | 4.28125 | 4 | #coding:utf8
import numpy as np
"""
- Understand that different regularization methods that could help your model.
- Implement dropout and see it work on data.
- Recognize that a model without regularization gives you a better accuracy on the training set but nor necessarily on the test set.
- Understand th... |
4d1605f77acdf29ee15295ba9077d47bc3f62607 | zakwan93/python_basic | /python_set/courses.py | 1,678 | 4.125 | 4 | # write a function named covers that accepts a single parameter, a set of topics.
# Have the function return a list of courses from COURSES
# where the supplied set and the course's value (also a set) overlap.
# For example, covers({"Python"}) would return ["Python Basics"].
COURSES = {
"Python Basics": {"Pytho... |
b9feb110f9df7260309a94d18bd3994aa18f8037 | zakwan93/python_basic | /python_collection/slices_in_python.py | 681 | 3.890625 | 4 | favorite_things = ['raindrops on roses', 'whiskers on kittens',
'bright copper kettles','warm woolen mittens',
'bright paper packages tied up with string',
'cream colored ponies', 'crisp apple strudels']
# Question 1. Create a new variable named slice1 that has the
# second, th... |
2e183f4fe20f994cdde4f50993b5ea410a39966b | cliefsengkey/text_preprocessing | /elongated.py | 2,300 | 3.59375 | 4 | #!/usr/bin/env python
"""Remove consecutive duplicate characters unless inside a known word.
"""
import fileinput
import re
import sys
from itertools import groupby, product
import enchant # $ pip install pyenchant
tripled_words = set(['ballless', 'belllike', 'crosssection', 'crosssubsidize', 'jossstick', 'shellless',... |
55abc569fa46bcce6c6f4220398cabeaa1b208d2 | Jeevan1351/Python_Bootcamp | /Activity_05.py | 110 | 3.890625 | 4 | string = input().split()
numbers = [int(num) for num in string]
print(f"Sum of all numbers is {sum(numbers)}") |
ba18b9f9762a1ba1508498c9477a70231f0b0551 | Jeevan1351/Python_Bootcamp | /Activity_16.py | 404 | 3.53125 | 4 | def get_cs():
return input()
def cs_to_lot(string):
separated = string.split(';')
listOt = [tuple(i.split('=')) for i in separated]
return listOt
def lot_to_cs(listOfTuples):
string = ""
for (a, b) in listOfTuples:
string += a+"="+b+";"
return string
def display(l):
print(l... |
a3758742978f5c16ff5458b081d608ffbf94f3b9 | mayukhpankaj/python-course | /variables.py | 431 | 4 | 4 | print("hello world")
# x = 1 # int
y = 2.5 # float
# name = 'john' #string
# is_cool = True # bool
#multiple assignment
x,y, name, is_cool = (1,2.5,'john',True)
# print(x+y)
# x= str(x)
''' type casting '''
# y = int(y);
# z = float(y)
# print(y,z)
""" arguments by po... |
8864c656c917602b6add9f62aa7ae489c9513e8d | N8Brooks/lcs_hash_search | /lcs_finder.py | 1,458 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Nov 23 13:50:03 2019
@author: Nathan
"""
import sys
import serial_hash_search
import parallel_hash_search
PARALLEL = False
# function to read in utf-8 txt file
def read_text(file_name):
with open(file_name, 'r', encoding='utf-8') as file:
return file.read()
if... |
c994d133c51deeeaa55531bb945cde1661e6be87 | sleumas2000/FF2-Code | /ff2 encode.py | 5,428 | 3.953125 | 4 | version = "v. 0.1.0"
#Error #01 textinput() - Invalid Input (empty)
#Error #02 keyinput() - Invalid input (02.1: Invalid Length ;02.2: Char1 Bad ;02.3: Char2 Bad)
#Error #03 keygen() - Unspecified Error
import string
import time
import random
from datetime import datetime
alphabet = list(map(chr, range(ord('a'),... |
d633cbd6250f0bc4db56d073cc59c7ecb9eb3b51 | krvavizmaj/codechallenges | /src/codesignal/areSimilar.py | 283 | 3.734375 | 4 | def areSimilar(a, b):
da = []
db = []
for i,n in enumerate(a):
if a[i] != b[i]:
da.append(a[i])
db.append(b[i])
return len(da) <= 2 and len(db) <= 2 and sorted(da) == sorted(db)
a = [1, 1, 4]
b = [1, 2, 3]
print(areSimilar(a,b)) |
728d2995b0d5d34a4a71e85f8050e50d784e2047 | krvavizmaj/codechallenges | /src/codesignal/naturalNumbers.py | 230 | 3.859375 | 4 | def naturalNumbersListing(n):
s = 0
i = 1
t = 2
while i <= n:
s += i
if i < n: s += i + 1
i += t
t += 1
i += t
t += 1
return s
print(naturalNumbersListing(3)) |
6119f7a769b58aeae30c9f31e7f4bbcbf945da0a | IrfanChairurrachman/CS50x-2020 | /pset7/houses/roster.py | 713 | 3.734375 | 4 | # TODO
import sys, cs50
# check argv
if len(sys.argv) != 2 or sys.argv[1] not in ['Gryffindor', 'Hufflepuff', 'Ravenclaw', 'Slytherin']:
sys.exit("Usage: python roster.py [house name] or there's no house name")
sys.exit(1)
# connect to db
db = cs50.SQL("sqlite:///students.db")
# execute SQL command and store ... |
8b3133a4c9d25ef07b543e50c9e870c5c8d624f3 | Helyosis/ChessBot | /utils.py | 2,562 | 3.6875 | 4 | import random
alphabet = "abcdefghijklmnopqrstuvwxyz1234567890"
VIDE, PION_BLANC, PION_NOIR, TOUR_BLANC, TOUR_NOIR, CAVALIER_BLANC, CAVALIER_NOIR, FOU_BLANC, FOU_NOIR, REINE_BLANC, REINE_NOIR, ROI_BLANC, ROI_NOIR = \
'O', 'P', 'p', 'T', 't', 'C', 'c', 'F', 'f', 'R', 'r', 'K', 'k'
def generate_random_name():
... |
be7cfbeedb0c2a6df04bb57e4bf7539fe0438ce0 | ligb1023561601/CodeOfLigb | /OOP.py | 3,875 | 4.1875 | 4 | # Author:Ligb
# 1.定义一个类,规定类名的首字母大写,括号是空的,所以是从空白创建了这个类
# _init_()方法在创建类的新实例的时候就会自动运行,两个下划线是用来与普通方法进行区分
# self是一个自动传递的形参,指向实例本身的引用,在调用方法时,不必去给它传递实参
# 以self作前缀的变量称之为属性
# 命名规则
# object() 共有方法 public
# __object()__ 系统方法,用户不这样定义
# __object() 全私有,全保护方法 private protected,无法继承调用
# _object() private 常用这个来定义私有方法,不能通过import导入,可被继承... |
f67f4de0d26bc09bf7e9aed47455b94f222d8417 | otterchurchill/CircleCITest | /scopeChecker.py | 1,358 | 3.625 | 4 | def isOpener(chara, openers):
return (chara in openers)
def isCloser(chara, closers):
return(chara in closers)
def scopeCheck(scopeSequence, scopeMatch):
s = []
for x,chara in enumerate(scopeSequence):
print(chara)
if isOpener(chara, scopeMatch.values()):
print(... |
cba1b0b5f23f3f4044813a11a1dd4c973856ee84 | kawsing/mypython | /radom-learn.py | 638 | 3.765625 | 4 | import random
#從列表隨機取一個資料
data=random.choice([1,4,6,9])
print(data)
#從列表中隨機取n個資料,n < 列表數量
data=random.sample([1,2,3,4,5,6], 5)
print(data)
#隨機調換資料(修改原列表) ,就地修改data列表
data=[1,2,3,4]
random.shuffle(data)
print(data)
#取0~1中的隨機數字,每個數字出現機率『相同』,random.random()=random.uniform(0.0,1.0)
print(random.random())
print(random.unifo... |
f99b66ba14100c318077afb9c03dbdddbbda55f6 | kawsing/mypython | /function.py | 273 | 3.546875 | 4 | #-*- coding: utf-8 -*-
#範例
def sayHello():
print("Hello")
#使用parameter
def sayIt(msg):
print(msg)
#two parameter
def add(n1, n2):
result=n1+n2
print(result)
sayHello()
sayIt("你好,python")
sayIt("第二次呼叫python")
add(3,5)
add(1000,18090) |
86a0653f30732b468566eb5dc9758a88bfddca8d | luciano00filho/python-homeworks | /questao4.py | 980 | 3.71875 | 4 | #/usr/bin/python3.6
import sys
def montaMatriz(linhas,colunas):
matriz = [0.0] * linhas
for i in range(linhas):
matriz[i] = [0.0] * colunas
return matriz
def geraNumeros(vmin,vmax,linhas,colunas):
for x in range(vmin,(linhas * colunas),1):
print("x1 =",x)
def main():
dimension, interval, matrix, rows, cols,... |
5019da761a24822a02a49ac8a7abca2e5d12b28c | aryan2412/sample | /evenoroddinlist.py | 272 | 3.984375 | 4 | even=0
odd=0
a=[]
b=int(input("Enter no. of elements=")) #User Input for list size
for i in range(0,b):
t=int(input("Enter in list=")) #User Input for elements of List
a.append(t)
for i in a:
if(i%2==0):
even+=1
else:
odd+=1 |
ecb83cf2aaf43a4610880ade0ec6d222f9eb6fef | jswojcik/Py4e | /Assignment 7.2.py | 361 | 3.765625 | 4 | # Use the file name mbox-short.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
count = 0
tot = 0
for line in fh:
if not line.startswith("X-DSPAM-Confidence:"): continue
pos = line.find(' ')
num = line[pos:]
num = float(num)
count = count + 1
tot = num + tot
print(tot)
ans = tot / count... |
ceb571472cd16c49dc15cb002126dff8e2b50da9 | imn00133/PythonSeminar19 | /Users/softwareMaestro/convert_fahrenheit_celsisus/convert_fahrenheit_celsisus.py | 611 | 3.75 | 4 | #-*- coding: utf-8 -*-
inputNumber=float(input("변환할 화씨온도(℉를) 입력하십시오: "))
print("%0.2f℉는 %0.2f℃입니다." %(inputNumber, (inputNumber-32)*5/9))
# 1. #-*- coding: utf-8 -*-은 python2.x버전에서 인코딩을 알려주는 규약입니다.
# python3에서는 사용하지 않으셔되 됩니다.
# 2. 1번 줄에서의 빨간 줄은 # 뒤에 공백이 없어서 발생합니다.
# 3. 2번 줄에서의 빨간 줄은 '=' 연산자 주변에 공백이 없어서 그렇습니다.
# 4. 3번 ... |
0cb3637b005033512e14949647e04b08a78d4f5a | imn00133/PythonSeminar19 | /Users/Miya/times_table/times_table.py | 170 | 3.640625 | 4 | for i in range(1, 10):
for j in range(2, 10):
print("%d * %d = %2d" % (j, i, j*i), end=' ')
print("")
# 잘 해결하셨습니다.
# 주강사 김재형
|
82912fd6df868d125842abaf22b4fc50b60073ea | imn00133/PythonSeminar19 | /Users/Miya/BMI_calculator/BMI_calculator.py | 625 | 3.921875 | 4 | height = float(input("본인의 키를 입력하세요.(m): "))
weight = int(input("본인의 몸무게를 입력하세요.(kg): "))
calc = float("%.1f" % (weight / pow(height, 2)))
if calc < 18.5:
print("저체중")
elif calc < 23:
print("정상")
elif calc < 25:
print("과체중")
elif calc < 30:
print("경도비만")
elif calc < 35:
print("중증도 비만")
elif calc >= 3... |
28cc003d0526bb94d79c3e77f0d4c3dbbec6d880 | ReviewEdge/Text-Based-Operating-System | /main.py | 18,535 | 3.78125 | 4 | # -*- coding: utf-8 -*-
import time
import requests
import datetime
import smtplib
import imapclient
import imaplib
imaplib._MAXLINE = 10000000
import pprint
import pyzmail
# Declares globals
global logged_in
logged_in = False
global has_email
has_email = False
# creates date and time variables
now = datetime.date... |
51a566cd2d6025d7bc557df0ba0a29f4087a7f17 | Bsq-collab/k05 | /util/Occ.py | 2,304 | 3.8125 | 4 | '''
Team B2-4ac- Bayan Berri, Alessandro Cartegni
SoftDev1 pd7
HW03: StI/O: Divine your Destiny!
2017-09-14
'''
import random
def makedict(filename):
"""
makes a dictionary from csv file param
arg:
string filename csv file
ret:
dictionary d keys: jobs values: percents
"""
d = dict(... |
2221806a1f358e55afa5692220f4586f03872c96 | firewebteam/main-repository | /figury.py | 901 | 3.828125 | 4 | class Figury():
def __init__(self, kolor, x, y):
self.kolor = kolor
self.x = x
self.y = y
def prostokat(self):
print("Pole prostokata to", self.x*self.y)
print("Kolor prostokąta to", self.kolor)
def trojkat(self):
print("Pole trójkąta to", (self... |
ae91e9d855546eb8121f06b75df88f41b8e337d4 | firewebteam/main-repository | /J.Karasek/Zadanie_6_Jasiek.py | 156 | 3.703125 | 4 | t = float(input("Czas:"))
v = 3.8
s = v*t
if t <= 100:
print("Jasiek przeszedł %s metrów" %s)
else:
print("Jasiek przeszedł całą drogę")
|
8cc66caa916630c06f511596bf7c55f5d9c9314d | firewebteam/main-repository | /Kamil Ko-odziej/6_Jasiek - 2.py | 293 | 3.640625 | 4 | v = ((3 ** 2) + (2 ** 2)) ** (1 / 2)
t = int(input('Podaj sekundę ruchu Jaśka:'))
if t > 100:
print('Jasiek przeszedł już całe %.3f metrów' % (100*v))
elif t < 0:
print('Jasiek jeszcze nie zaczął się poruszać')
else:
print('Jasiek przeszedł %.3f metrów' % (t*v)) |
59a32850a0e162a0085c334b200747d300e5e9c0 | firewebteam/main-repository | /J.Karasek/Zadanie_3_konto_bankowe.py | 878 | 3.859375 | 4 | x = input("Imię: ")
y = input("Hasło: ")
z = 2130
while True:
if x == "Arnold" and y == "icra2013":
print ("Saldo:", z)
print("Jaką czynność chcesz wykonać?\nA - wpłata\nB - wypłata")
czynnosc = input("Czynność: ")
if czynnosc == "A":
wplata = int(input("Podaj kwotę: "))
... |
6ce838e30b83b79bd57c65231de2656f63945486 | prashant2109/django_login_tas_practice | /python/Python/oops/polymorphism_info.py | 2,144 | 4.40625 | 4 | # Method Overriding
# Same method in 2 classes but gives the different output, this is known as polymorphism.
class Bank:
def rateOfInterest(self):
return 0
class ICICI(Bank):
def rateOfInterest(self):
return 10.5
if __name__ == '__main__':
b_Obj = Bank()
print(b_Obj.rateOfInterest()... |
5cb6c9094fd1d69972f5369331082a8af7892156 | o0Marianne0o/cp1404practicals | /prac_02/files.py | 921 | 4.09375 | 4 | # program 1 - Enter a name and save to text file
username = input("Enter your name: ")
output_file = open("name.txt", 'w')
print("{}".format(username), file=output_file)
output_file.close()
# program 2 - open file and print the stored name
open_file = open("name.txt", 'r')
print("Your name is {}".format(open_file.rea... |
1ce7099585cf1f42ae66519907fdf2b5d720afb2 | KrisCheng/HackerPractice | /Python/oop/hello.py | 483 | 3.75 | 4 | # OOP basic
class Student(object):
def __init__(self, __name, score):
self.__name = __name
self.score = score
def print_score(self):
print('%s %s' % (self.__name, self.score))
def get_name(self):
return self.__name
def set_name(self,name):
self.__name = name
... |
390ebfe44b76ebfcebe368a92c3a6002c1f077c7 | KrisCheng/HackerPractice | /Python/module/itertools.py | 135 | 3.859375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import itertools
cs = itertools.cycle('ABC')
for c in cs:
print(c) #无限重复
|
710b2baa4bd86c79b91492c061f4ebb183ad5688 | WeihanSun/python_sample | /standard/zip.py | 2,070 | 3.703125 | 4 | # zip and unzip file and folder
# zip is to loop list meanwhile (see container)
import zipfile
import os
import shutil
# zip folder
def zip_directory(path):
zip_targets = []
# pathからディレクトリ名を取り出す
base = os.path.basename(path)
# 作成するzipファイルのフルパス
zipfilepath = os.path.abspath('%s.zip' % base)
# ... |
9aa02643ad00c618f323b127bdb01fb076c86e0e | redoctoberbluechristmas/100DaysOfCodePython | /Day27 - TKInter, Args, Kwars/main.py | 309 | 4 | 4 | import tkinter
# Create a window
window = tkinter.Tk()
window.title("My First GUI Program")
window.minsize(width=500, height=300)
# Create a label
my_label = tkinter.Label()
#mainloop is what keeps window on-screen and listening; has to be at very end of program.
window.mainloop() |
f7b7853e9332ef9fd2a5c16733f1908c00ea2a04 | redoctoberbluechristmas/100DaysOfCodePython | /Day03 - Control Flow and Logical Operators/Day3Exercise3_LeapYearCalculator.py | 826 | 4.375 | 4 | #Every year divisible by 4 is a leap year.
#Unless it is divisible by 100, and not divisible by 400.
#Conditional with multiple branches
year = int(input("Which year do you want to check? "))
if(year % 4 == 0):
if(year % 100 == 0):
if(year % 400 == 0):
print("Leap year.")
else:
print("Not leap... |
d167ac2865745d4e015ac1c8565dd07fba06ef4d | redoctoberbluechristmas/100DaysOfCodePython | /Day21 - Class Inheritance/main.py | 777 | 4.625 | 5 |
# Inheriting and modifying existing classes allows us to modify without reinventing the wheel.add
class Animal:
def __init__(self):
self.num_eyes = 2
def breathe(self):
print("Inhale, exhale.")
class Fish(Animal):
def __init__(self):
super().__init__() # The call to super() ... |
d999a0fd4f5a5516a6b810e76852594257174245 | redoctoberbluechristmas/100DaysOfCodePython | /Day08 - Functions with Parameters/cipherfunctions.py | 846 | 4.125 | 4 | 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', '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'
]
def caesar(start_text, shift_amount, ... |
cd9d2b973f33c724e9b85ebb00acb12ba5dbd2b8 | redoctoberbluechristmas/100DaysOfCodePython | /Day08 - Functions with Parameters/Day8_CaesarCipher.py | 676 | 3.90625 | 4 | from cipherfunctions import caesar
#from roughcipherfunctions import caesar
from art import logo
print(logo)
should_continue = True
while should_continue:
direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
text = input("Type your message:\n").lower()
shift = int(input("Type the shi... |
d47a13ae0fe6c8de5c90852efe91435be06dafca | redoctoberbluechristmas/100DaysOfCodePython | /Day14 - Higher Lower Game/Day14Exercise1_HigherLowerGame.py | 1,390 | 3.9375 | 4 | import random
import art
from os import system
from game_data import data
# Need to select two celebrities
def choose_accounts():
return random.choice(data)
def format_entry(choice):
return f'{choice["name"]}, a {choice["description"]}, from {choice["country"]}'
def compare_accounts(player_choice, not_choic... |
d9d6d4b6b6e623aaa2d8c9a6c11424d8ee2454c8 | tommasopierazzini/projectAI | /DecisionTreeLearning.py | 5,191 | 3.546875 | 4 | import DecisionTree
import math
def DecisionTreeLearner(dataset):
def decisionTreeLearning(examples, attributes, parents_examples=()):
if len(examples) == 0:
return pluralityValue(parents_examples) #returns the most frequent classification among the examples
elif allSameClass(examples)... |
2406a145b15c23937ed8f3887e907f552794a6b5 | Yeahp/nebula | /acrobatic_demo/email_service.py | 1,095 | 3.578125 | 4 | import smtplib
from email.mime.text import MIMEText
from email.header import Header
"""
We send email via SMTP(Simple Mail Transfer Protocol) and MIME(Multipurpose Internet Mail Extensions),
which require that both the sender and receiver should open his SMTP service.
Otherwise, the request for sending email will fai... |
c42e1c0f609302b069f8818fd33412d2e0a4ecd8 | kasra28/emialspammer | /spammer.py | 5,077 | 3.515625 | 4 | # email spammer
# imports
import smtplib
import sys
import time
# start
class bcolors:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'... |
223bc3092d41737c75c588f9fdb6fcc9a82b062f | MaryTalvistu/prog_alused | /1/yl6.py | 426 | 3.671875 | 4 | inimeste_arv = input("Sisestage inimeste arv: ")
kohtade_arv_bussis = input("Sisestage kohtade arv bussis: ")
busside_arv = int(int(inimeste_arv) / int(kohtade_arv_bussis))
j22k = int(inimeste_arv) - int(busside_arv) * int(kohtade_arv_bussis)
print("Inimeste arv " + str(inimeste_arv) + ", kohtade arv bussis " + str(koh... |
55e07398df2ade057dd922bcc853d4c9014094be | MaryTalvistu/prog_alused | /2/2.2.py | 276 | 3.859375 | 4 | perekonnanimi = input("Sisestage oma perekonnanimi: ")
if perekonnanimi[-2:] == "ne":
print("Abielus")
elif perekonnanimi[-2:] == "te":
print("Vallaline")
elif perekonnanimi[-1] == "e":
print("Määramata")
else:
print("Pole ilmselt leedulanna perekonnanimi") |
19ea81db06a5ca5ab5b6af1bdd37f803c9a54b79 | Joftus/CS-474 | /hw3/P3.py | 291 | 3.625 | 4 | import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(10, 5))
x = np.linspace(-50, 50, 1000)
# Problem 3A
plt.plot(x, (1+3*x), color='black')
# Problem 3B
plt.plot(x, (2-x)/2, color='blue')
plt.xlabel('x1')
plt.ylabel('x2')
plt.title('Problem 3 A / B')
plt.show()
|
b3d7ab36cba905360151af3ab3be233dd2e2de9b | Cangozler/PythonHomeWorks | /vebek.py | 355 | 3.6875 | 4 | def enbuyuk(liste1):
sayi = max(liste1)
return sayi
def enkucuk(liste1):
sayi = min(liste1)
return sayi
liste=[]
adet=int(input("kaç adet sayı girmek istiyon :"))
for n in range(adet):
sayi = int(input('Sayıyı Gir: '))
liste.append(sayi)
print("en buyuk sayi",enbuyuk(liste) , "en ... |
d1ac4626ab6b2531788696aa29a9732f65c8e0e0 | Cangozler/PythonHomeWorks | /çarpim.py | 135 | 3.75 | 4 | for i in range(1,10):
print("*************************")
for k in range(1,10):
print("{} x {} = {}".format(k,i,i*k)) |
9f6da873b18a0c733c92f6b929c7c4d5ca3d898a | guihunkun/LearnPythonCrashCourse | /solution_02/changeString-finished.py | 267 | 3.90625 | 4 | '''
定义一个变量sentence,赋值为"I Love you!",然后分别用title(), upper(), lower()函数对变量sentence执行操作后输出。
'''
print("\n")
sentence="I Love you!"
print(sentence.title())
print(sentence.upper())
print(sentence.lower())
|
6cf08fa094cdef5c940c2094d7cc0234c7b02101 | brianwesterman/computer-science-projects | /data_analysis_and_visualization_system/knn_test2.py | 2,589 | 3.59375 | 4 | # Bruce Maxwell
# Spring 2015
# CS 251 Project 8
#
# KNN class test
#
import sys
import data
import classifiers
def main(argv):
'''Reads in a training set and a test set and builds two KNN
classifiers. One uses all of the data, one uses 10
exemplars. Then it classifies the test data and prints out the
... |
d763736bc38eae023d9d17a1ab8fb3c853ab40b0 | Alexsimulation/pulsar-classifier | /main.py | 20,318 | 3.921875 | 4 | # Machine learning - Pulsar detector
# Ref (we all learn somewhere) https://machinelearningmastery.com/implement-backpropagation-algorithm-scratch-python/
# Implements a simple 'multi layer perceptron' neural network (fully connected), with variable number and size of layers
# Datset: https://www.kaggle.com/charitarth/... |
71e8cdbc1f94ae156674d5f53814fe971b87fb52 | ysymi/leetcode | /algorithms/basic/36.valid-sudoku.py | 785 | 3.59375 | 4 | class Solution(object):
def isValidSudoku(self, board):
"""
:type board: List[List[str]]
:rtype: bool
"""
def has_equal_num(s):
s = ''.join(sorted(s)).strip('.')
for i in range(len(s) - 1):
if s[i] == s[i + 1]:
retu... |
3d8c5feb11438fa9bc7adf5a137d9d8bb285d7cf | yngtodd/hacker_rank | /python/ave_distint_elems.py | 533 | 3.78125 | 4 | from __future__ import division, print_function
def average(array):
"""
Compute the average of distinct items in an array.
Parameters
----------
* `array` [list]
array of potentially non-unique numbers.
Returns
-------
Mean of the unique elements in the array. [float]
"""... |
61e11b2986a28391be97631a82b7a81caf71496a | nephidei2/python | /3.py | 623 | 3.734375 | 4 | #!/usr/bin/python
def counting(string):
words_freq = dict()
letters = [str(symbol).lower() for symbol in list(string) if symbol.isalpha()]
for l in letters:
if l in words_freq:
words_freq[l] += 1
else:
words_freq[l] = 1
return words_freq
def main():
with ope... |
9fc0c60e681cd14adb34e100fcd07a85932c672e | behry/hello-world | /Assignment6_Kosar.py | 329 | 3.6875 | 4 | #Exercise_1
Week = ('Monday', 'Tuesday', 'Wednesday', 'Thursday','Friday','Saturday','Sunday')
#Exercise_2
fruits = set(['apple', 'mango', 'orange'])
#Exercise_3
new_fruits = {'chery', 'peach','apple', 'mango'}
#Exercise_4
print(new_fruits.difference(fruits))
#Exercise_5
print(new_fruits.intersection(f... |
e50c1045677d6a8df58caa2e9a16963c4c961093 | Dudo-z/FIrst-Github-Repository | /python_ex1.py | 143 | 3.890625 | 4 | list1 = list(range(5))
list2 = list1
list3 = list1[:]
list1.append(8)
list2.append(11)
list3.append(10)
print(list1)
print(list2)
print(list3)
|
9006fe1d04ceee567b8ced73bddd2562d0239fb8 | zhartole/my-first-django-blog | /python_intro.py | 1,313 | 4.21875 | 4 |
from time import gmtime, strftime
def workWithString(name):
upper = name.upper()
length = len(name)
print("- WORK WITH STRING - " + name * 3)
print(upper)
print(length)
def workWithNumber(numbers):
print('- WORK WITH NUMBERS')
for number in numbers:
print(number)
if number... |
bdfb8412a2af6e326cacb239345afac5d6caf79e | Elsamaxl/Learn_Python | /inherit.py | 992 | 3.921875 | 4 | #Filename:inherit.py
class SchoolMenmber():
'''Represents any school member.'''
def __init__(self,name,age):
self.name=name
self.age=age
print '(Initialized SchoolMenmber: %s)' %self.name
def tell(self):
'''Tell my details.'''
print 'Name: %s,Age: %d'%(self.name,self.age)
class Teacher(SchoolMenmber):... |
af6f78db36a02d7f48b0254839a8012ff0a44b43 | Elsamaxl/Learn_Python | /func_doc.py | 242 | 3.921875 | 4 | #Filename:func_doc.py
def printMax(x,y):
'''Print the maximum of two numbers.
The two values must be integer.'''
x=int(x)
y=int(y)
if x>y:
print x,'is maximum.'
else :
print y,'is maximum.'
printMax(3,5)
print printMax.__doc__
|
e68276092cd593674fb19fa5319fac86c02fb87a | Elsamaxl/Learn_Python | /using_dict.py | 521 | 3.578125 | 4 | #Filename:using_dict.py
#'ab' is short for 'a'ddress'b'ook
ab={'Swaroop':'swaroop@byteopython.info',
'Lary':'larry@wall.org',
'Matsumoto':'matsumoto@ruby-lang.org',
'Spammer':'spammer@hotmail.com'
}
print "Swaroop's address is %s." %ab['Swaroop']
#Adding a key/value pair
ab['Guido']='guido@python.org'
#Deleting a... |
fe5f9eb6a1548706c990cca435649116dbc3945a | ganesh-rk/Python-Assignment-Basic | /String_Ops.py | 267 | 3.875 | 4 |
def main():
str1="Chennai"
str2="city"
for i in str1:
print "\nCurrent letter is ",i
str3=str1[2:5]
print "\nSubstring is ",str3
print "\nRepeated string is ",str1*100
print "\nConcatenated string is ",str1+str2
main()
|
6944c502687c85549642f8ec67cc69d35f923ff7 | ganesh-rk/Python-Assignment-Basic | /Even or Odd.py | 144 | 3.796875 | 4 |
def main():
a=10
b=a%2
if b==0:
print "Given number is even"
else:
print "Given number is odd"
main()
|
b5b8ad763c493b7e79cd419bdc08170b1a11dd58 | TranshumanSoft/quotient-and-rest | /modulexercises.py | 268 | 4.15625 | 4 | fstnumber = float(input("Introduce a number:"))
scndnumber = float(input("Introduce another number:"))
quotient = fstnumber//scndnumber
rest = fstnumber%scndnumber
print(f"Between {fstnumber} and {scndnumber} there's a quotient of {quotient} and a rest of {rest}") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.