blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
9e24114ac8e1034624bb9a7bc4026cbae69ef824 | smallest-cock/python3-practice-projects | /End-of-chapter challenges in ATBS/Chapter 05 – Dictionaries and Structuring Data/Inventory.py | 966 | 3.84375 | 4 | stuff = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12}
dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby']
def displayInventory(inventory):
print('Inventory:')
total = 0
for item, amount in inventory.items():
print(str(amount) + ' ' + item)
total += ... |
8a9fbaf1bc291a9eea13e12e59077d9c8b13eac9 | smallest-cock/python3-practice-projects | /End-of-chapter challenges in ATBS/Chapter 07 – Pattern Matching with Regex/Regex Version of strip().py | 481 | 3.609375 | 4 | #! /usr/bin/python3
import re
def regexStrip(string, optChars= "no"):
whiteBeginRegex = re.compile(r'^\s*|\s*$')
optBeginRegex = re.compile('^(' + optChars + ')*|(' + optChars + ')*$')
mo1 = whiteBeginRegex.sub('', string)
mo2 = optBeginRegex.sub('', string)
if optChars == "no":
print('2nd ... |
9101a599c7f1f3f4cd1ca3124b8a15b1d76c84ea | smallest-cock/python3-practice-projects | /End-of-chapter challenges in ATBS/Chapter 09 – Organizing Files/FillingtheGaps/FillingtheGaps.py | 2,951 | 3.875 | 4 | #! /usr/bin/python3
# FillingtheGaps.py - Finds all files with a given prefix, such as spam001.txt, spam002.txt,
# and so on, in a single folder and locates any gaps in the numbering
# (e.g. spam001.txt and spam003.txt, but no spam002.txt). Renames all the later files to close this gap.
import os, re, shutil
# Prompt... |
8ebb4ef0d0283e66aaf75005a698eac364d88b49 | Adeola-Oni/MACHINE-LEARNING | /Polynomial Regression/DSN_Polynomial_regression.py | 823 | 3.546875 | 4 | #import libraries
import pandas as pd
import matplotlib.pyplot as plt
datasets= pd.read_csv('Position_Salaries.csv')
X = datasets.iloc[:,1:2].values
Y = datasets.iloc[:,2].values
#fit the linear regression into the datasets
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit... |
ab81afdb9e721cc621536365250eef97c20dd474 | Adeola-Oni/MACHINE-LEARNING | /Simple Linear Regression/DSN_Simple_Linear_Regression.py | 777 | 3.796875 | 4 | # import libraries
import pandas as pd
import matplotlib.pyplot as plt
#get datasets
datasets = pd.read_csv('Salary_Data.csv');
X = datasets.iloc[:, :-1].values
Y = datasets.iloc[:,1].values
#split dataset into test and train sets
from sklearn.cross_validation import train_test_split
X_train, X_test, Y_train, Y_test ... |
5c6d9d6d411434c201829a276eaf8da5e6307cab | filhomarlon/python | /exercicio-2.py | 204 | 3.890625 | 4 | """
Organize os numeros 2,3,4,5,10,12 para obter a saída 18
em uma única operação:
x = 12*3
x = x + 4
x = x//10
x = x*5
x = x - 2
print(x)
"""
x = ((((12*3)+ 4)//10)*5)-2
print(x)
|
79e3b59cdf26eb6bec87da06d11f5acaafb68da2 | jreaa/ClasesCiIsaPythonAvanzado | /Unidad 1/ATM.py | 957 | 3.765625 | 4 | ##atm ciisa
class ATM():
nombrePersona = "jose"
nCuenta = "12345"
def mostrarOpciones(self):
ADORNO = "=" * 20
print(ADORNO)
print("Por favor selecciona una de las opciones a realizar en tu ATM")
print(ADORNO)
print("1.-Ver estado cuenta")
opcion = int(inp... |
202df341e4a1043790a0d55ea354d75b6eedc5df | hcarvente/jtc_class_code | /class_scripts/bootcamp_scripts/Strings_2.py | 424 | 4.28125 | 4 | # make a string
my_string - 'hi'
#print(type(my_string))
# type conversion -- convert one variable type to another
a = 2
# str() converst to a string
#b = str(a)
print(a)
print(type(a))
print(b)
print(type(b))
# float() to convert to a float
c = '2'
d = float(c)
print(c)
print(type(c))
print(d)
print(type(d))
#... |
3d444ef285fda5968c698bae94e722744e19c45f | hcarvente/jtc_class_code | /challenges/23_oop/checking_challenge.py | 1,827 | 4.125 | 4 | print('Question 1')
class CheckingAccount():
def __init__(self, account_holder, account_number):
self.account_holder = account_holder
self.account_number = account_number
self.withdrawal_limit = 2000
self.balance = 0
def deposit(self, amount):
try:
self.balance += amount
return self.balance
excep... |
0d07ce3ee542a4e3c5e8efe1d9ecc8476329c221 | TrueNought/AdventOfCode2020 | /Day2/Day2.py | 1,081 | 3.953125 | 4 | import re
def read_input(file):
with open(file, 'r') as text:
password_list = text.read().splitlines()
for index in range(len(password_list)):
password_list[index] = re.split(' |-|: ', password_list[index])
return password_list
def part_one_check(passwords):
valid = 0
for... |
d3fa54cbcbe8add5cdfa5e8856ab257facbe1482 | GiTJiMz/Advanced-programming | /10-09-2020/W37/prodof.py | 797 | 3.84375 | 4 | def prodof(numbers):
product = 1
# product should containt the
# product of all numbers seen so far.
for number in numbers:
product = product * number
return product
def indexof(lst, item):
index = -1
# index should see the index of the
# first item in the li... |
a819ce7655334024f91b3291ca31011126669ea2 | wefoust/pi-wrf-gui | /src/pi-wrf/calculate_distance_backup.py | 813 | 3.75 | 4 | from math import sin,cos,sqrt,atan2,radians,degrees
import geopy.distance
def calculate_distances(lon1_input,lon2_input,lat1_input,lat2_input):
R=6373
lat1=radians(lat1_input)
lon1=radians(lon1_input)
lat2=radians(lat2_input)
lon2=radians(lon2_input)
distance_lon=abs(lon2-lon1)
... |
4bdd92ef111032e66aecb0c634881b400de492a8 | Artem01011991/ITStep_Python | /Black Jack/functions.py | 7,069 | 3.75 | 4 | # functions' file
from random import shuffle
from random import randint
from os import system
from time import sleep
class Player:
hand = []
def __init__(self, name, money):
self.name = name
self.money = money
def sum_card(self):
def init_player():
while True:
try:
... |
71cb9e6690d3a1ecf2107f837a4b28932d29f146 | idzia/Advent_of_code | /day_7/day_7.py | 1,314 | 4 | 4 | """
What is the name of the bottom program?
For example, if your list is the following:
pbga (66)
xhth (57)
ebii (61)
havc (66)
ktlj (57)
fwft (72) -> ktlj, cntj, xhth
qoyq (66)
padx (45) -> pbga, havc, qoyq
tknk (41) -> ugml, padx, fwft
jptl (61)
ugml (68) -> gyxo, ebii, jptl
gyxo (61)
cntj (57)
"tknk" is at the bo... |
04ca4c896c6b2ded1834d79f7b5e1e14efb5d87b | dovewing123/LehighHacksFall2016 | /map.py | 1,200 | 3.96875 | 4 | import turtle
import sys
def map(p):
p.hideturtle()
p.speed(9)
p.up()
p.goto(-300,-100)
p.down()
p.showturtle()
p.left(90)
for i in range (8):
p.color("black")
p.forward(200)
p.right(45)
color=""
if i==0:
color="yellow"
... |
644e2b53e450a6ee6759500a44607c0ac02602c6 | GentlemanToad/Python-Projects | /turtleRace.py | 873 | 3.921875 | 4 | import turtle
from random import randint
wn = turtle.Screen()
wn.title('Turtle Race')
t = turtle.Turtle()
t.speed(0)
t.penup()
t.goto(-140, 140)
for step in range(15):
t.write(step, align='center')
t.right(90)
t.forward(10)
t.pendown()
t.forward(150)
t.penup()
t.backward(160... |
6d66b53399db1dc91ad12cdf207125aa1d9edfba | pursh2002/data--engineering | /hello.py | 1,943 | 4 | 4 | In your README.md answer the following questions with True or False.
(5)==(5,) returns True False
Any of the following: (integer, string, list) can be the key of a dictionary. False
Any of the following: (integer, string, list) can be the value of a dictionary. True
Any of the following: (integer, string, list) can be... |
26741978dff3282dc933e258a5548dff6604a5e7 | kelg1/Geoloc | /datatool.py | 1,013 | 3.5625 | 4 | import pandas as pd
import numpy as np
import sys
class DataTool:
"""
In order to convert DataFrame to an other in which each row (msg)
give the rssi value to each bs
"""
def __init__(self):
pass
def describe(self, df):
st = """Number of BS:\t {nbs}\t \n
========================== \n
Number of msg:\t {... |
368e69da4b2c6777cbf47bc33d88e1d66c246466 | ranjithkumar97/Functions | /Assignment.py | 491 | 4.25 | 4 | """ This
is
a casting"""
int(5.6)
print('ranjith') #using single quotation
b = " Hello World! "
print(b[2:6]) #print the character position of 2 to 6
print(b.strip()) #rremoves whitespace front or end
print(len(b)) #print length of b
print(b.lower()) #print lower similarly upper
print(b.replace("Hello","r... |
30d0250e47b0f67f26156fd2d729a45eae559458 | L0ganhowlett/Python_workbook-Ben_Stephenson | /17 Heat capacity.py | 444 | 3.875 | 4 | #17 Heat Capacity
#Asking for masss of water.
m = float(input("Enter the mass of water in grams = "))
T = float(input("Enter the temperature change in degree celsius = "))
C = 4.186 * (2.7777e-7)
q = m * T * C
print("Total energy required to raise ",m," grams of a material by ",T," degrees Celsius is ",q," kilowa... |
51a72bcd22f62fda7f6a88338022da38dcc5fbfc | L0ganhowlett/Python_workbook-Ben_Stephenson | /24 Units of Time.py | 385 | 4.25 | 4 | # 24 Units of Time.
# Asking for number of days, hour, minutes and seconds.
d = float(input("Enter the no=umber of days = "))
h = float(input("Enter the number of hours = "))
m = float(input("Enter the number of minutes = "))
s = float(input("Enter the number of seconds = "))
print('The total number of seconds = ... |
4e78ce83e00ae7e4cfd960826a549518ef8ad7d5 | L0ganhowlett/Python_workbook-Ben_Stephenson | /57 Is it a leap year.py | 240 | 4.03125 | 4 | #57: Is it a Leap Year?
a=int(input("Enter the year:"))
if a%400==0:
x=True
elif a%100==0:
x=False
elif a%4==0:
x=True
else:
x=False
if x:
print("It is leap year")
else:
print("It is not a leap year.")
|
3111d865708db1c7012405e478c63c0ef9cb26f2 | L0ganhowlett/Python_workbook-Ben_Stephenson | /7 Sum of the First n positive integers.py | 233 | 4.03125 | 4 | #Sum of the First n positive integers
#Ask for a positive integer
n = int(input('Enter a positive integer:'))
#Computing sum of all integers from 1 to n
x = int(n*(n+1)/2)
print('Sum of the numbers from 1 to n is =',x)
|
e1a0577e680affea14053a352ae00300ea798f25 | L0ganhowlett/Python_workbook-Ben_Stephenson | /16 Area and Volume.py | 228 | 4.21875 | 4 | #16 Area and Volume
#Asking for radius
import math
r = float(input("Enter the radius = "))
print("Area of circle = ",math.pi * ( r ** 2)," sq.m")
print("Area of sphere = ",math.pi * (r ** 3) * (4/3)," sq.m")
|
bca1245aba8e1df09f0d124dc4fecabbfce9f865 | L0ganhowlett/Python_workbook-Ben_Stephenson | /42 Note to Frequency..py | 538 | 4.28125 | 4 | #42 Frequency to note
#Asking for frequency of note
x = float(input("Enter the frequency of note = "))
if x == 261.63:
print("The note of frequency is C4.")
elif x == 293.66:
print("The note of frequency is D4.")
elif x == 329.63:
print("the note of frequency is E4.")
elif x == 349.23:
print("... |
3de4ba15e917b66fa241ec22f7711d7c73ce33a4 | L0ganhowlett/Python_workbook-Ben_Stephenson | /21 Area of Triangle.py | 235 | 4.28125 | 4 | #Area of Triangle
#Asking for Breadth(b) and Height(h) of triangle.
b = float(input("Enter the breadth of the triangle = "))
h = float(input("Enter the height of the triangle = "))
print('Area of triangle = ', h * b / 2," sq.m ")
|
53228764e0b600cdd0e8519e161def602c313daa | L0ganhowlett/Python_workbook-Ben_Stephenson | /59 Is a License Plate Valid.py | 370 | 4 | 4 | #59: Is a License Plate Valid?
a = input("Enter license plate number:")
if a[:3].isupper() and a[3:].isnumeric() and len(a)==6:
print("It is an old style license plate.")
elif a[:4].isnumeric() and a[4:].isupper() and len(a)==7:
print("It is newer style of license plate.")
else:
print("It is not vali... |
eafbe374da13201afa884e8b2942d9af0754e34f | moisotico/Python-excercises | /excersices/binary_trees/is_BST.py | 1,314 | 4.09375 | 4 | # Importing dependancies
import sys
# A tree node
class Tree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
# Print tree and return heigth method
def TreeResult(Node, level=0):
if Node is not None:
TreeResult(Node.left, level + 1)
if... |
0b4765a925b7e3303c80f06ee1e31df53d2e0211 | kristof-becode/PyDrills | /04 Numpy and Pandas/Pandas/01_Getting_&_Knowing_Your_Data/World Food Facts/Pandas Drills 1 World Food Facts.py | 1,069 | 3.5 | 4 | import numpy as np
import pandas as pd
food = pd.read_table('/home/becode/data/pandas/en.openfoodfacts.org.products.tsv') # sep='|')
print(" \n first 5 : \n",food.head(5))
print(" \n number observations with food.shape : \n",food.shape)
print(" \n number of rows with food.shape[0] : \n",food.shape[0])
print(" \n numbe... |
ed07b54fa0eb6c8315dec1e6694796a443da1bbd | kristof-becode/PyDrills | /02 Python Advanced/Python Advanced 5.Web Scrapping/Web Scraping- parse XML.py | 1,320 | 4.0625 | 4 | from lxml import etree
def main():
# open .xml
file = open("/home/becode/data/data.xml", "r")
print(file.read())
file.close()
# parse 1
# I define my source document
tree = etree.parse("/home/becode/data/data.xml")
# I look at my document and identify the tag path to get to the "user" ... |
800b0a271535e1ced61bfb93bc77d7362b97fd4c | ivan-paz/incrementalAlgorithm | /generate_edges.py | 838 | 3.90625 | 4 | def generate_edges(graph):
edges = []
for node in graph:
for neighbour in graph[node]:
edges.append([node, neighbour])
return edges
#graph = {'0': [1, 2], '1': [0], '2': [0]}
def simplify_edges(edges):
simplified_edges = [ ]
for edge in edges:
# print('edge : ', edge)
#... |
9b8c8ff47379bd8971d340942f7d80e7a7004b62 | arelemegha/python-programs | /factorial.py | 146 | 4.25 | 4 | n = int(input("Enter a number : "))
fact=1
if(n>0):
for i in range(1,n+1):
fact = fact * i
print("Factorial of a number is : ", fact)
|
88165e0072808e1a583e1873a504f028abcf3d59 | luuthanhvan/Machine-Learning | /src/Perceptron.py | 1,309 | 3.515625 | 4 | import numpy as np
import matplotlib.pyplot as plt
def initData():
X = np.array([
[0, 0],
[0, 1],
[1, 0],
[1, 1],
])
Y = np.array([0, 0, 0, 1])
return X, Y
def showData(X, Y):
colorMap = np.array(["red", "green"])
plt.axis([0, 1.5, 0, 2])
# print(X[0])
p... |
1e9f489c86898b85854df53ba053a4136299bb05 | Danzip/Axon-Course | /ex9.py | 508 | 3.953125 | 4 | from random import *
guesses=0
while True:
r = randint(1, 9)
while True:
guess=int(raw_input("guess a number between 1-9"))
guesses+=1
if guess>r:
print "you guessed to high try again"
elif guess<r:
print "to low"
else:
pr... |
2d68715d69bb24958ea6757baf28f6edbc642028 | kaurtanvir/Udacity-technical-interview-practice | /solutions.py | 7,829 | 4.21875 | 4 | """
Question 1
Given two strings s and t, determine whether some anagram of t is a substring
of s. For example: if s = "udacity" and t = "ad", then the function returns
True. Your function definition should look like: question1(s, t) and return a
boolean True or False.
"""
# Helper function to check if two strings are... |
6500e0e350f291beb7028c1fd81bc3013f64d44f | python240419/07.06.2019 | /HW/targil3.py | 711 | 3.921875 | 4 |
targil = input("Enter 1st number: ") # 3 + 4 = 7
list = targil.split() # [3, +, 4, =, 7]
a = int(list[0]) # 3
oper = list[1] # +
b = int(list[2]) # 4
c = int(list[-1]) # 7
if oper == "+":
if a + b == c:
print("Correct!")
else:
print("wrong!")
elif oper == "-":
if a - b == c:
p... |
4a8dc669f5708a34b271b5842c8b57f8a071f0a3 | thintom/Hello-world | /first steps.py | 2,170 | 3.984375 | 4 | # -*- coding: utf8 -*-
#print("hello")
"""
quotes = [
"Ecoutez-moi, Monsieur Shakespeare, nous avons beau être ou ne pas être, nous sommes !",
"On doit pouvoir choisir entre s'écouter parler et se faire entendre."
]
characters = [
"alvin et les Chipmunks",
"Babar",
"betty boop",
"calimero"... |
895a1d9cf5c6607c82f961ca3303ea7443d86005 | malpeczka/umbrella_hash_lookup | /hash_lookup.py | 5,264 | 3.546875 | 4 | #! /usr/bin/env python3
"""
Umbrella hash lookup - 2020, Nien Huei Chang
hash_lookup.py - main program
"""
import re
import sys
import select
import requests
import argparse
UMBRELLA_TOKEN_FILENAME = "umbrella_token.txt"
UMBRELLA_URL = "https://investigate.api.umbrella.com"
def load_umbrella_token():
""" L... |
abb082012d2d021716414f3c6b5a182c5695ab09 | ooguz/essential-functions | /essential-functions/math.py | 134 | 3.90625 | 4 | import math
def square(num):
if type(num) != int:
raise Exception("Input must be a number.")
return math.sqrt(num)
|
9dbe84fb268e4df07dc2ccd7c6a6d6b99ba2cfd2 | nogigen/ArtificialIntelligienceAlgorithms | /cannibal missionary problem - a star search and more/hw2.py | 14,756 | 3.65625 | 4 | # Group Members
# Nogay Evirgen
# Engin Deniz Kopan
# Mehmet Ege Acıcan
# Gökçe Sefa
# Alper Mehmet Özdemir
# problem : x number of missionaries and y number of cannibals should cross a river. There is a boat capacity. When the number of cannibals exceed the number of missionaries in one side, cannibals will ki... |
ea89f8467337e80fc95d8e1e2a86b39ad1b3d6d0 | eclairsameal/TQC-Python | /第1類:基本程式設計/PYD104.py | 346 | 3.953125 | 4 | import math
r=eval(input())
print("Radius = {:.2f}".format(r))
print("Perimeter = {:.2f}".format(2*r*math.pi))
print("Area = {:.2f}".format(r*r*math.pi))
import math
r = eval(input())
print("Radius = {:.2f}".format(r))
perimeter = 2*r*math.pi
print("Perimeter = {:.2f}".format(perimeter))
area = r*r*math.pi
print("Are... |
971fde6d73d339c6517e7b7f1e168e5063f7f5a6 | eclairsameal/TQC-Python | /第7類:數組(Tuple)、集合(Set)以及詞典(Dictionary)/PYD705.py | 373 | 3.859375 | 4 | # TODO
def input_n(n):
s = set()
for i in range(n):
x = int(input())
s.add(x)
return s
print("Input to set1:")
# TODO
set1 = input_n(5)
print("Input to set2:")
# TODO
set2 = input_n(3)
print("Input to set3:")
# TODO
set3 = input_n(9)
print("set2 is subset of set1:",set2.issubset(set1))
pri... |
f638d580e883be66808427fd5fd2e563f9f58e4b | eclairsameal/TQC-Python | /第6類:串列(List)的運作(一維、二維以及多維)/PYD608.py | 430 | 4.125 | 4 | n_l = []
for i in range(9):
n_l.append(int(input()))
max_n = max(n_l)
print("Index of the largest number {} is: ({}, {})"
.format(max_n, n_l.index(max_n)//3, n_l.index(max_n)%3))
min_n = min(n_l)
print("Index of the smallest number {} is: ({}, {})"
.format(min_n, n_l.index(min_n)//3, n_l.i... |
2ebf081fcb33d6a403fbc0cbe87e5a768b30226b | eclairsameal/TQC-Python | /第2類:選擇敘述/PYD210.py | 135 | 3.765625 | 4 | a = eval(input())
b = eval(input())
c = eval(input())
if a+b>c and a+c>b and b+c>a:
print(a+b+c)
else:
print('Invalid')
|
3143f0d8a1a5fd5e377a96638799b220d7281219 | eclairsameal/TQC-Python | /第8類:字串(String)的運作/PYD801.py | 107 | 3.984375 | 4 | string = input()
for i in range(len(string)):
print("Index of '{:s}': {:d}".format(string[i], i))
|
1b04fafa4fd8f03e8926632f657c93c9da3b06a8 | eclairsameal/TQC-Python | /第8類:字串(String)的運作/PYD805.py | 120 | 3.6875 | 4 | string = input()
print('|{:<10}|'.format(string))
print('|{:^10}|'.format(string))
print('|{:>10}|'.format(string)) |
a2cfc68ae4cdecf689db0c573759250d1dbe6641 | eclairsameal/TQC-Python | /第1類:基本程式設計/PYD105.py | 420 | 3.828125 | 4 | h = eval(input())
w = eval(input())
print("Height = {:.2f}".format(h))
print("Width = {:.2f}".format(w))
perimeter = 2 * (h + w)
print("Perimeter = {:.2f}".format(perimeter ))
area = h * w
print("Area = {:.2f}".format(area))
h = eval(input())
w = eval(input())
print("Height = {:.2f}".format(h))
print("Width = {:.2f}... |
46c11275a6dc7cd4943be2a631be11b8f9654271 | Axect/Euler | /Mixed/Python_Rust/pure/p001.py | 188 | 3.765625 | 4 | def answer():
s = 0
for number in range(1, 1000):
if number % 3 == 0 or number % 5 == 0:
s += number
return s
if __name__=='__main__':
print(answer())
|
d4c945b14e60581069fe049e5d30c5600827a409 | mahmoud791/DSproject | /formate.py | 3,524 | 3.71875 | 4 |
def shift_amount(numberOfSpaces):
shift = ""
for i in range(numberOfSpaces):
shift += " "
return shift
def formate(s):
s = s.replace('\\', '/')
path = str(s)
file = open(path, "r")
file = file.readlines()
try:
formatted_file = open("formatte... |
795afc839dccf66d9841de8b245e9b488e8bf258 | trendsttler/flask-prectice | /exercise1.py | 151 | 3.5 | 4 |
y = int(input("YOUR BIRTH YEAR")) + 1
m = int(input("YOUR BIRTH MONTH"))
CRT= 2018
agy = (CRT-y)
agm = 12-m
AGE = print(agy,"years and",agm,"months")
|
ba39bc1fcdbec66ebf1cd98a625838575acbc995 | MarauderOne/Alex-s-Flatterer | /flatterer.py | 211 | 3.890625 | 4 | def flatterer(flattererDef):
print("Welcome to",flattererDef)
myName = input("What is your name?")
if(myName == "Alex"):
print(myName,"is great!")
else:
print("Hello",myName)
flatterer("Alex's Flatterer") |
ef15f2fed740a8c82472dbfe6a20561891b36512 | JBurns7/quiz_adventure | /quiz.py | 2,752 | 4.09375 | 4 | # Our quiz!
score = 0
name = ""
def quiz():
global score
global name
print("Welcome to Pointless Quiz, where it's three out of four to win to win")
name = input("Enter your name: ")
print("Hello", name)
question1()
question2()
question3()
question4()
def question1():
g... |
99c648d70caaddb758e854f62d0cfce5e9285a13 | baewonje/iot_bigdata_- | /python_workspace/01_jump_to_python/4_input_output/1_function/3_164_3.py | 371 | 3.671875 | 4 | a=10
def vartest(a):
print(a) # 전역 변수를 단순히 조회하는 것은 문제가 없다.
# def vartest2():
# print(a)
# a = a+1 # 지금과 같은 방식으로 전역 변수의 값을 수정 할 수 없다.
# print(a)
def vartest3():
global a
print(a)
a=a+1
print(a)
vartest()
vartest2()
|
29cc3ca89dad7bb9bf8bda98ce6ea8d7f8e80c62 | baewonje/iot_bigdata_- | /python_workspace/01_jump_to_python/4_input_output/3_file_io/q3.py | 193 | 3.640625 | 4 | input1 = int(input("첫번째 숫자를 입력하세요:"))
input2 = int(input("두번째 숫자를 입력하세요:"))
total = input1 + input2
print("두 수의 합은 %s 입니다." % total) |
7a47e472ca9b6d68970814d36ed7eed05a566667 | baewonje/iot_bigdata_- | /python_workspace/01_jump_to_python/3_control/3_for/exer/q3.py | 584 | 3.734375 | 4 | #coding=cp949
num = 1
while True:
odd = int(input("Ȧ Էϼ.(0 <- ): "))
max = int(odd/2)
if odd == 0:
print(" α ̿ ּż մϴ.")
break
if odd != 0:
print(' '+odd * "-"+' ')
for star in range(0,max+1):
print('|'+' '*(max-star) +'*'*((star*2)+1)+' '*(max-star)+'|')
... |
d4d4678db415220cbd5ad437f6ae718a41ed1847 | baewonje/iot_bigdata_- | /python_workspace/01_jump_to_python/5_APP/5_native_function/q3.py | 170 | 3.875 | 4 | import random
lotto_list = []
for i in range(6):
number= random.randint(1,45)
if number not in lotto_list :
lotto_list.append(number)
print(lotto_list) |
314f6ea61d29aaf9f28aa6c4a8d7f8fbcc6b0b5a | baewonje/iot_bigdata_- | /python_workspace/01_jump_to_python/4_input_output/3_file_io/q6.py | 227 | 3.515625 | 4 | user_input = input("저장할 내용을 입력하세요: ")
f = open('test.txt','a',encoding='UTF-8')
f.write(user_input)
f.write("\n")
f.close()
f2 = open("test.txt", 'r',encoding='UTF-8')
print (f2.read(),end='')
f2.close() |
07ddbe1d729990137da13e4d4c72b37d696f99af | baewonje/iot_bigdata_- | /python_workspace/01_jump_to_python/5_APP/q/q5.py | 221 | 3.5 | 4 | list = [0,1]
min = 0
max = 1
number = int(input("입력 : "))
while True:
if number >=list[min]+list[max]:
list.append(list[min]+list[max])
min +=1
max +=1
else:
break
print(list)
|
47b5ad2f15c98369d0065322d352e8bd62cd9ba7 | baewonje/iot_bigdata_- | /python_workspace/3_bigdata/02_Standardization_Analysis/03_DB/3_statistics_basic_template.py | 5,694 | 3.65625 | 4 | import csv
import math
data_type_list = """
<원하는 서비스를 입력하세요.>
1. 행
2. 열
3. 총합
4. 평균
5. 최대값
6. 최소값
7. 편차
8. 분산
9. 표준편차
10. 정렬(오름차순,내림차순)
11. 종료
: """
def get_row_index(search_key):
index = 0
while True:
if big_data[index][0] == str(search_key):
break
else:
index += ... |
0e4c982b8e1deedbde457f44612c64abb05cab4e | baewonje/iot_bigdata_- | /python_workspace/3_bigdata/01_Collection/03_web_crawling/02_regular_expression/01_basic/12_299_1.py | 223 | 4.125 | 4 | import re
p = re.compile('[a-z]+')
m = p.match('python')
# m = p.search('3 python')
print(m)
if m:
print('Match found',m.group())
else:
print('No match')
p = re.compile('[a-z]+')
m = p.match('3 python')
print(m) |
9d0ba694ce83cb88e84c3a6b64edd4de65326b27 | baewonje/iot_bigdata_- | /python_workspace/3_bigdata/04_AI/03. Deep Learning/3. Keras/1. basic/3. seed.py | 661 | 3.578125 | 4 | import numpy as np
# seed 적용하기 전
print('seed 적용하기 전')
print('최소 데이터셋 생성')
print(f'데이터셋1: {np.random.rand(3)}')
print(f'데이터셋2: {np.random.rand(5)}')
print('데이터셋 재생성')
print(f'데이터셋1: {np.random.rand(3)}')
print(f'데이터셋2: {np.random.rand(5)}')
# seed 적용한 후
print('\nseed 적용한 후')
np.random.seed(0)
print('최소 데이터셋 생성')
prin... |
e25e24747fe78fbf06d86d957c6bdfc74f8edfa0 | nickbassett/mlProject | /logRTest.py | 800 | 3.625 | 4 | # Import required libraries
import matplotlib.pyplot as plt
import pandas as pd
def load_data(path, header):
marks_df = pd.read_csv(path, header=header)
return marks_df
if __name__ == "__main__":
# load the data from the file
data = load_data("datasets/marks.txt", None)
# X = feature values, all the columns ex... |
32d0b7078a710d28c68441fb209d8c6207df6697 | dschuan/python-workshop | /hello_world.py | 351 | 3.765625 | 4 | def hello_world():
print("Hello World")
def greet(message, name="insert name here"):
print(message, " ", name)
#Comment this code out and see what happens!
if __name__ == "__main__":
hello_world()
name = "Derp"
message = "Good morning"
greet(message, name)
#greet(name=name, message=message)... |
ba87e2f30ff03fbfc0b229d20870943a4bfb4788 | Devdutt/Python-Proj | /test-py/py_lists.py | 291 | 4.21875 | 4 | alist = list()
someNumbers = input("Type a number:")
while someNumbers != "done":
someNumbers = int(someNumbers)
alist.append(someNumbers)
someNumbers = input("Type a number:")
continue
averageNumber = sum(alist) / len(alist)
print("The average number is: ", averageNumber)
|
a3a43e22f49cc50a81d61ab399ca4f985770d638 | v13aer14ls/webscrapping | /wikisearch.py | 951 | 3.984375 | 4 | '''
Uma função individual que o getLinks recebe um URL de artigo da wikipedia na forma /wiki/nomedoartigo e retorna ua lista de todos URLS de artigos vinculados,com o mesmo formato
Uma função principal que chame getLinks com algum artigo inicial, selecione um link de artigo aleatorio na lista retornada e chame GetLink... |
792fe2f99587e3c87918ec3a66226ce2953a2622 | Didilan/CalendrierGregorien | /Calendrier.py | 2,047 | 3.734375 | 4 | from MoisConversionString import * # Import de toutes les fonctions
date = input("Entrez une date valide : JJ/MM/AAAA : ") # Saisie d'une Date
if "/" in date : # Verification Validité Format
Jour,Mois,Année = date.split("/")
else: # Réécriture Date
date = input("Entrez une date valide : JJ/MM/AAAA")
... |
cffd8a626fa67d5f019242923a41828407a94733 | vindennl48/TermGui | /TermGui.py | 3,999 | 3.78125 | 4 | ################################################################################
#
# Requirements
# - FancyOut.py | github.com/vindennl48/fancyout
#
################################################################################
# The easiest and least painful way to use this
# module is by the following method:
#... |
d23ca199cab7e39e1e871b2b508e01dc51d014e1 | KKKing-Z/Lintcode | /415/415.py | 740 | 3.84375 | 4 | class Solution:
"""
@param s: A string
@return: Whether the string is a valid palindrome
"""
def isPalindrome(self, s):
# write your code here
i = 0
j = len(s) - 1
while i < j :
if 'A' <= s[i] <= 'Z' or 'a' <= s[i] <= 'z' or '0' <= s[i] <= '9':
... |
393a4352f7a84ac08332c1ae040dbd44cfa6829c | ylongly7/XJTUSE_AgileWeb_Assignment2 | /Fibonacci.py | 247 | 3.8125 | 4 | class Fibonacci:
@classmethod
def of(cls,n):
a,b = 1,1
i = 2
while i<=n:
a,b = b,a+b
i+=1
return a
if __name__ == '__main__':
for i in range(1,201):
print(Fibonacci.of(i)) |
66144b8a29b1cf0ac95f1661bc709ead63c4b8db | japanesemankind/100knock | /chap4/q34.py | 847 | 3.625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[10]:
from q30 import parse_mecab
ans = set()#重複を無視するため、集合型に抽出
sentences=parse_mecab()
for sentence in sentences:
juncture = ''
n = 0
for morph in sentence:
if morph['pos'] == '名詞': #連接(juncture)に連結
juncture = ''.join([juncture, morph['s... |
1cef535eb7cb95c98ea630f65fc871b2f0b96e01 | japanesemankind/100knock | /chap4/q35.py | 594 | 3.6875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[5]:
from q30 import parse_mecab
from collections import defaultdict
def count_words():
sentences=parse_mecab()
ans = defaultdict(int)#初期値0の辞書
for sentence in sentences:
for morpheme in sentence:
if morpheme['pos'] != '記号':
a... |
30ef9ae16e68dc904156911490d5f50b87173f1d | japanesemankind/100knock | /chap1/q6.py | 838 | 3.765625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[14]:
from q5 import q5 as n_gram
def q6(str_A,str_B,calc):
set_A=set()
set_B=set()
for element in n_gram(str_A,2):
set_A.add(element)
for element in n_gram(str_B,2):
set_B.add(element)
if(calc=="&"):
return set_A&set_B
... |
ea5e782534fc29059fbc8161997b18400c66aa83 | jonprairie/cts2 | /application/packages/screen/widgets/sidescrollwidget.py | 955 | 3.53125 | 4 | """
this is a widget container widget.
allows scrolling between widgets, focusing (and displaying)
one at a time.
"""
import container
class sidescrollwidget(container.container):
def __init__(
self, widget_list, key_dict=dict(
scroll_left="<",
scroll_right=">",
)
):
... |
3df61a924c4a6e9892a3b556380ea344feec2e95 | jonprairie/cts2 | /application/packages/menu/arch/menudriver.py | 1,035 | 3.78125 | 4 | import node
class menudriver:
"""in charge of moving up and down the menu tree, executing the functions of external nodes where necessary"""
def __init__(self, name, menu_list):
"""menu_list is a list of the 'first children' of the menu to be created"""
self.name = name
self.root_node =... |
8b9add1b4d4011475755e5429bea6afc5216545e | jonprairie/cts2 | /application/packages/screen/screens/screen.py | 911 | 3.671875 | 4 | """
representation of a screen.
a screen has two primary responsibilities:
1. to stringify itself
2. to receive input
"""
class screen:
def __init__(self, name, widget_list=[]):
self.name = name
self.widget_list = widget_list
self.key_dict = None
self.exit = False
def __str__... |
852432da3b2227fb638993680287f944a41f99bd | cheeyeo/learn_more_python_the_hard_way | /chapter15_stacks_queues/test_stack.py | 985 | 3.5 | 4 | import unittest
from unittest import TestCase
from stack import *
class TestStack(TestCase):
def test_push(self):
stack = Stack()
stack.push(1)
self.assertEqual(stack.count(), 1)
self.assertEqual(stack.top.value, 1)
stack.push(2)
self.assertEqual(stack.count(), 2)
self.assertEqual(stack.top.value, 2)
... |
876509f5e22b9260e7097914e5cf7bb7816b64fa | coderSuhaib/FizzBuzz | /FizzBuzz.py | 236 | 3.75 | 4 |
x = 3
y = 5
for count in range(1,101,1):
if count % x == 0 and count % y == 0:
print("FizzBuzz")
elif count % x == 0:
print("Fizz")
elif count % y == 0:
print("Buzz")
else:
print(count)
|
643d76ddf60d9e6ae939bb9abcef555b059f6a27 | rdsim8589/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/1-search_replace.py | 142 | 3.984375 | 4 | #!/usr/bin/python3
def search_replace(my_list, search, replace):
return ([(lambda x: replace if x == search else x)(i) for i in my_list])
|
2c1dfc1a257e2968d4bd5536bd1f02a1d2632369 | LeoAcioli/Alien-Invasion | /bullet.py | 885 | 3.671875 | 4 | import pygame
from pygame.sprite import Sprite
class Bullet(Sprite):
def __init__(self, al_game):
super().__init__()
self.screen = al_game.screen
self.settings = al_game.settings
self.color = self.settings.bullet_color
#create bullet rect at (0,0) and then s... |
311b111fa6efa95969a07365b9862a78a798efb5 | ruddyadam/prometheus | /project_euler/007_10001th_prime.py | 1,685 | 3.953125 | 4 | #http://projecteuler.net/problem=7
#What is the 10001st prime number?
#each target factored and checked if it is prime, then target is iterated once (repeat until while loop is satisfied)
#factoring - get all factors of each target, by dividing each of 1 to the sqrt(target) into target to see if % == 0
#if the only fa... |
8fe934b829d1051de9aa38423cf2d2d44a2e34e5 | ruddyadam/prometheus | /fishGame/Util/fishEat/fishEat.py | 3,012 | 3.6875 | 4 | # fishEat.py
#this program will take resources from drawFish.py and drawFood.py and make them work together to make a fish eat food.
#fish and food need to be blittable objects.
import pygame, sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640,480),0,32)
bg_image = 'aquarium.jpg'
ba... |
17d710d7f726797c56b4c5a5cbe1116255853820 | washiz99/solid-principles | /examples/srp/srp_good.py | 978 | 3.78125 | 4 | # SRPに準拠した例
class User:
"""
ユーザ情報を保持するという役割
"""
def __init__(self, name, age, address):
self.name = name
self.age = age
self.address = address
def __str__(self):
return "{}, {}, {}".format(
self.name, self.age, self.address
)
... |
cb3633609786104b93695d6aae67a586d222f083 | RahmatDarmawan/labpy03 | /latihan1.py | 169 | 3.5 | 4 | import random
jumlah = int (input("Masukkan Jumlah N: "))
for i in range(jumlah):
i = random.uniform(0.0,0.5)
print(i)
print ("******* SELESAI *******")
|
69f0ef4deba9f082038d77b34bb739025f1003e8 | CandyMandy28/Code-Ada-2019 | /alarmManager.py | 847 | 3.84375 | 4 | import alarm
# AlarmManager class - keeps track of alarms
class AlarmManager:
# alarm list
list = []
# initializer
# constructor
def __init__(self, alarm):
self.list = [alarm]
# addList function
# adds alarms the user creates into the list
def addList(alarm):
# appends... |
ec6cb823d20a234da2e7cf4660964dc4dd79498f | kkolute/cohort-11 | /Andela bootcamp labs/Homesession3/missingNumber.py | 471 | 3.84375 | 4 | '''
author : Kennedy kolute
class : Andela bootcamp 11
'''
def find_missing(list1,list2):
# initialize missing to zero
missing = 0
# find and display missing number if first list is smaller
if len(list1) < len(list2):
miss = (set(list2) - set(list1))
absent = miss.pop()
return absent
#find and display miss... |
4224e8fd2fd82aea53dca630f06dfcd3566f48f1 | kkolute/cohort-11 | /Andela bootcamp labs/Homesession2/wordcount.py | 480 | 3.53125 | 4 | '''
author : Kennedy kolute
class : Andela bootcamp 11
'''
def words(sentence):
# initialize an empty dictionary
d = {}
# loop through the elements in the sentence separated by white space
for word in sentence.split():
# separate word and digits while looping and store them in variable word
word = in... |
d56c5806b255792517c99484d7693e6904606426 | rhps/hackerrank | /algorithms/02Implementation/02apple-and-orange.py | 984 | 3.921875 | 4 | #!/bin/python3
import os
import sys
#
# Complete the countApplesAndOranges function below.
#
def countApplesAndOranges(s, t, a, b, apples, oranges):
#
# Write your code here.
#
'''
ct_ap = 0
ct_or = 0
for x in apples:
if (x + a) >= s and (x + a) <= t:
ct_ap = ct_ap + 1... |
8ebeb6e0dbe94c1a6f04c856caf453bdeeb0b110 | rhps/hackerrank | /Cracking the Coding Interview Challenges/ALGORITHMS/merge_sort.py | 585 | 3.5625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the countInversions function below.
def countInversions(arr):
itr = 0
n = len(arr)
for i in range(0,n):
for j in range(0,n-1):
if (arr[j] > arr[j+1]):
arr[j], arr[j+1] = arr[j+1], arr[j]
itr = itr + 1
return itr
if... |
b822976e8633b9e9262e627fc2f977c0b0540276 | Remosy/Algorithms_Code | /a0/truth_tables.py | 2,567 | 4.5625 | 5 | """ File name: truth_tables.py
Author: Yangyang Xu
Date: 23/02/2018
Description: This file defines a number of functions which implement Boolean
expressions.
It also defines a function to generate and print truth tables
using these functions.... |
cb6bd3df2341fcced5a261c346965fcb4fab1d5a | Remosy/Algorithms_Code | /a0/health_agents.py | 6,332 | 3.703125 | 4 | """ File name: health_agents.py
Author: Yangyang Xu
Date: 23/02/2018
Description: This file contains agents which fight disease. It is used
in Exercise 4 of Assignment 0.
"""
import random
import disease_scenario as DisScn
import copy
class HealthAgent:
""" A simple di... |
a6dfb525c64b717d1b455714a5ecde1d5c969630 | ZinkNotTheMetal/TypicalInterviewQuestions | /Python/IsNullOrEmpty.py | 346 | 3.671875 | 4 | # Quick function to give us the ability to check IsNoneOrEmpty on a variable in Python
def IsNoneOrEmpty( input ):
if input == None:
return True
elif len(input) == 0:
return True
else:
return False
print(IsNoneOrEmpty(None))
print(IsNoneOrEmpty(""))
print(IsNoneOrEmpty("hello"))
pr... |
a3c9f3ce343625d494f25c86570e990b31678a5d | ryo-ARAKI/CCSP_in_Python | /Chap_02/dna_search.py | 1,954 | 3.671875 | 4 | from enum import IntEnum
from typing import Tuple, List
Nucleotide: IntEnum = IntEnum('Nucleotide', ('A', 'C', 'G', 'T'))
Codon = Tuple[Nucleotide, Nucleotide, Nucleotide] # Type alias of codon
Gene = List[Codon] # Type alias of DNA
gene_str: str = "ACGTGGCTCTCTAACGTACGTACGTACGGGGTTTATATATACCCTAGGACTCCCTTT"
def... |
9d656ba089923e12c54310e1cdcf3bc6b6b6b3ef | ilam1/CS_School- | /Python/dual_sort.py | 2,516 | 3.6875 | 4 | from random import randrange
from timeit import default_timer
m = []
s = 0
def quick_sort(l):
dual_sort(l,0,len(l)-1,3)
return l
def swap(l,lo,hi):
l[lo],l[hi] = l[hi],l[lo]
#temp = l[lo]
#l[lo] = l[hi]
#l[hi] = temp
def dual_sort(l,lo,hi,div):
length = hi - lo
if... |
71056adaecd1df7deff73ff6af473d75f7c384f0 | Tomyzon1728/Games | /Games/jumper_game.py | 1,122 | 3.8125 | 4 | import turtle
wn = turtle.Screen()
wn.title("My first turtle Peoject")
wn.bgcolor("sky blue")
wn.setup(height= 50,width=70)
wn.tracer(0)
GROUND_LVL=-40
# Drawing ground
pen=turtle.Turtle()
pen.speed(0)
pen.pensize(3)
pen.shape("square")
pen.color("red")
pen.penup()
# Darwing line
pen.goto(-400,GROUND_LVL)
pen.pendo... |
221fecb2f546ea53be437abdabd22a1e94206b24 | bhavikjadav/Python_Crash_Course_Eric_Matthes_Chapter_4 | /4.2_Animals.py | 948 | 4.6875 | 5 | #!/usr/bin/env python
# coding: utf-8
# # 4-2. Animals: Think of at least three different animals that have a common characteristic. Store the names of these animals in a list, and then use a for loop to print out the name of each animal.
# # • Modify your program to print a statement about each animal, such as A dog ... |
4164dd1baf161bd58116ce7321351b88dc620fb9 | bhavikjadav/Python_Crash_Course_Eric_Matthes_Chapter_4 | /4.5_Summing a Million.py | 535 | 3.609375 | 4 | #!/usr/bin/env python
# coding: utf-8
# # 4-5. Summing a Million: Make a list of the numbers from one to one million, and then use min() and max() to make sure your list actually starts at one and ends at one million. Also, use the sum() function to see how quickly Python can add a million numbers.
# In[1]:
million... |
743f54c38f95cd51b8bbdd5c9571aab7cadbda36 | smileyoung1993/Posco_Bigdata | /AI_bigdata_class/class_homework/homework1/day1_test1.py | 161 | 3.546875 | 4 | #1
#온도 변환
F = int(input("화씨 온도 : "))
C = (F - 32)*(5/9) # 화씨를 섭씨로 변환
print("섭씨 온도 : %f" %C) # 섭씨 온도 출력
|
a1fb6fc7d0d23b9047a76f29b215327028d828b0 | smileyoung1993/Posco_Bigdata | /AI_bigdata_class/class_homework/homework5/day5_hw1.py | 700 | 4 | 4 | #1
# 연산자 오버로딩
class Set:
def __init__(self,member = []):
self.member = member
# def append(self,a): # 하나의 변수에 원소 추가
# self.a = a
#
# def delete(self, a):
# self.a = a
def union(self, s2): # 두개 set의 합집합
c = []
for i in range(0,len(self.member)):
ret... |
6a93ba6773f57710f4daab2853738dfb75eaae18 | raymondboswel/ai_exercises | /8-puzzle.py | 6,300 | 4 | 4 | import queue
import copy
class Node:
def __init__(self, state, parent_node, action, depth):
self.state = state
self.parent_node = parent_node
self. action = action
# self.path_cost = path_cost
self.depth = depth
# Fringe -> empty queue
def tree_search(initial ,fringe):
... |
8ee07c367fb3d80a7c00e309e9dbb3358e770ac8 | rpatel26/Cogs118A | /Assignment3/assignment3.py | 4,231 | 3.984375 | 4 | ''' Importing python packages '''
import scipy.io as sio
import matplotlib.pyplot as plt
import numpy as np
''' Loading Data '''
data = sio.loadmat('data.mat')
x = data['x'].reshape([-1, 1])
y = data['y'].reshape([-1, 1])
X = np.hstack((np.ones((len(x),1)), np.power(x,1)))
class assignment3(object):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.