blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
307bc200a4828e7aa91beaf7815bdeecc7e0d612 | santhoshbabu4546/python | /136.py | 105 | 3.515625 | 4 | x=input()
x.split()
x=x.replace(" ","")
y=[j for j in x if x.count(j)==1]
z=' '.join(y)
print(z.lower())
|
f02ccbf71cca9575222a4106339852c1e8a7fcde | santhoshbabu4546/python | /117.py | 148 | 3.859375 | 4 | d=input()
s1=0
for j in range(len(d)):
if (d[j].isalpha() or d[j].isnumeric() or d[j]==" "):
continue
s1=s1+1
else:
print(s1)
|
828e74b72b1e4aac65391e073efd6625e7af17e6 | santhoshbabu4546/python | /84.py | 122 | 3.71875 | 4 | u=int(input())
word=list(map(str,input().split()[:u]))
word.sort()
word.sort(key=len)
for j in word:
print(j,end=" ")
|
113b3cf597c75e1a9af9e7e757986771a2174b82 | santhoshbabu4546/python | /player.set-7-62.py | 206 | 3.59375 | 4 | g=int(input())
if g%2!=0:
print("1")
else:
y=True
for j in range(2,g):
if g%j==0 and int(g/j)%2!=0:
y=False
print(j)
break
if y:
print(g)
|
d4ff7516fddf2263b6df7199c2575bae42dfe1c4 | santhoshbabu4546/python | /32.py | 78 | 3.84375 | 4 | a=list(input())
b=list(reversed(a))
if a==b:
print("yes")
else:
print("no")
|
1d85ecbeb0d91de86ad48fbdf49b677342f175ef | santhoshbabu4546/python | /player set 5-47.py | 157 | 3.625 | 4 | ru1,ru2,ru3=map(int,input().split(" "))
if(ru1!=0 and ru2!=0 and ru3!=0):
r=ru1+ru2+ru3
else:
r=0
if(r==180):
print("yes")
else:
print("no")
|
1dbb733a0c5cf3fff4370c2c67c480b0b0440c3b | supriadi-yusuf/python-GUI | /extends/dropdown_list.py | 493 | 3.625 | 4 | from tkinter import *
root = Tk()
root.geometry("500x500")
root.title("Drop down list")
fr1 = Frame(root, bg="blue", width=200)
fr1.pack(side=LEFT, fill=Y)
fr2 = Frame(root, bg="red")
fr2.pack(fill=BOTH, expand=1)
#fr = LabelFrame(root, text="User", bg="red", width=300, height=300)
#fr.pack(side=TOP, fill=X)
pilih... |
fcfe306aa844a741720e3162140018379879a95e | Sean-Cesmat/extra_python_exercises | /single_one.py | 548 | 4 | 4 | # Given an array of integers, every element appears twice except for one.
# Implement a program that will print that single one.
# Example: [1,1,2,2,3,3,4,5,5,6,6,7,7] - 4 would be the odd man out
# Note:
# Your algorithm should have a linear runtime complexity.
# *** your code here ***
def odd_man_out(list):
... |
8ca442198d42b54b5aa4ee8538f72201d50fc491 | anasazi/Swarm-AI---Zombies | /vector.py | 2,572 | 4.25 | 4 | #Alice Forehand
#Robert Pienta
#Eric Reed
from math import acos, sqrt, pi, atan2
class Vector:
"""A simple 2d vector
>>> v1 = Vector(1,0)
>>> v2 = Vector(0,1)
>>> print(v1.add(v2))
(1, 1)
>>> print(v1 + v2)
(1, 1)
>>> print(v1.subtract(v2))
(1, -1)
>>> print(v1 - v2)
(1, -... |
c92cc48750af8b42547770e23cd4811b3367308d | weikunliang/CrazySanta | /Sock.py | 993 | 3.71875 | 4 | from Tkinter import*
import random
class Sock(object):
# the dimensions of the sock
width = 20
height = 50
# x and y represents the center coordinates of the sock
def __init__(self, x, y):
self.x = x
self.y = y
# draws the sock
def drawSock(self, canvas, image... |
d0901be426e401097916ceebadf2811cba663818 | DarkZalgo/Work_Sample | /web_get.py | 4,912 | 3.59375 | 4 | #!/usr/bin/env python3
import socket
import sys
import os
def main():
url =''
if not sys.argv[1:]:
usage()
exit(-1)
if "http://" in sys.argv[1] :
url = ''.join(sys.argv[1].split('http://')[1:])
url = url.split('/')
elif "https://" in sys.argv[1]:
url = ''.join... |
ef50e8bb754a50f1b6bd7758ebb8b617c162f629 | odwanodada/Datetime-Python | /DateObject.py | 657 | 3.9375 | 4 | from datetime import date
from datetime import time
from datetime import datetime,timedelta
d = date(2020, 8, 22)
print(d.year)
print(d.month)
print(d.day)
print(d.strftime("%Y %m %d"))#%Y is year %m is month %d is day
t = time(1, 30, 00)
print(t.hour)
print(t.minute)
print(t.second)
print(t.strftime("%H: %M: %S"))#%... |
7c3fbd3d58469bbd9005baa425a4c62794c3f778 | niekp/AdventOfCode | /2019/day3.py | 1,856 | 3.71875 | 4 | class path:
def __init__(self, wire):
self.wire = wire
self.points = []
self.__calculate()
def __calculate(self):
x = 0
y = 0
for p in self.wire.split(","):
direction = p[:1]
amount = int(p[1:])
step = 1
... |
bb362a4a839a668c478072c9ea10d12d4079a311 | undextrois/python-snake | /python-snake.py | 3,228 | 3.75 | 4 | import random
import curses
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN
screen_win = curses.initscr() # initialise screen
screen_h, screen_w = screen_win.getmaxyx() # get window with and height relative to the set by user
w = curses.newwin(screen_h, scr... |
681092f8ce97583b0b50b5ef2fe4a35931715f3d | AlexN1ght/sem3da | /2lr(3)/gensup.py | 256 | 3.78125 | 4 | import random
for i in range(2000):
print('+')
print(random.randint(0, 1000))
print(8)
for i in range(1000):
print('-')
print(random.randint(0, 1000))
for i in range(1000):
print('+')
print(random.randint(0, 1000))
print(8) |
0f2ecafca9c78076a3bbca530db2f7906a27a4b2 | facku24/MyS2016 | /Final/9-9.py | 1,455 | 3.65625 | 4 | import math
from random import random
def funcion(x):
return 1 - math.e**(-x)
def generator_expo_values(n):
values = []
for _ in range(n):
values.append(- math.log(random()))
return values
def generator_d(muestra, f):
'''
Esta funcion me generea el valor d necesario para calcular
el p-valor despues
l - ... |
37a6bea39583990b6987c866fbd380b61f4ae644 | facku24/MyS2016 | /Final/9-3.py | 2,133 | 3.546875 | 4 | import numpy as np
import math
import scipy.stats as st
from random import random
#-----------------------------------------------------
# CONSTANTES
#-----------------------------------------------------
muestra = [0.12, 0.18, 0.06, 0.33, 0.72, 0.83, 0.36, 0.27, 0.77, 0.74]
A = 0
B = 1
N = 10
#---------------------... |
eb9236d732a8abdfa1660d7f71932582854177b8 | facku24/MyS2016 | /Final/parcialitos/par10-3.py | 2,733 | 3.671875 | 4 | from random import random
from scipy.stats.distributions import chi2
import math
N = 5
CANT = 10
MUESTRA = [3, 4, 3, 3, 2, 5, 4, 5, 0, 1]
def generator_vector(values, n):
'''
Esta funcion, dado un vector de observaciones, genera el vector
correspondiente de valores acumulados de las observaciones para
cada uno ... |
8823d92720df24624c76cacedebb18716fac897e | facku24/MyS2016 | /Final/9-5.py | 1,781 | 3.578125 | 4 | import math
from random import random
#-------------------------------------------------
# CONSTANTES
#-------------------------------------------------
muestra = [86, 133, 75, 22, 11, 144, 78, 122, 8, 146, 33, 41, 99]
media = 50
N = 13
def funcion(x):
return 1 - math.e**(-x/float(media))
def generator_expo_val... |
b735e871863e7f2fe735293b21f01ea0158bb9d5 | quydau35/quydau35.github.io | /ds/chunk_6/python_modules.py | 2,618 | 4.53125 | 5 | """
# Python Modules\n
What is a Module?\n
Consider a module to be the same as a code library.\n
A file containing a set of functions you want to include in your application.\n
# Create a Module\n
To create a module just save the code you want in a file with the file extension ```.py```:\n
```
# Save this code in a ... |
fa096dffbef3c9578b693c3b2c07014a53b94ec6 | sandycamilo/SPD1.4 | /Complexity_Analysis/merge_lists.py | 1,027 | 4.125 | 4 | # Merge two sorted linked lists and return it as a new list.
# The new list should be made by splicing together the nodes of the first two lists.
# Input: 1->2->4, 1->3->4
#Create a new linked list:
# Output: 1->1->2->3->4->4
# O(1)
class Solution(object):
def mergeTwoLists(self, l1, l2):
head = ListN... |
bf7e6c85b6c135a357bc7b9a1884f07cfea43549 | uwp-h2021/supplementary_files | /src/py220_supplemental/lessons/lesson07/class_content/threads2.py | 464 | 3.703125 | 4 | import threading
import time
# create a mutable object that is shared among threads
class Shared:
val = 1
def func(lock):
lock.acquire()
y = Shared.val
time.sleep(0.00001)
y += 1
Shared.val = y
lock.release()
lock = threading.Lock()
threads = []
for i in range(99):
thread = threadi... |
228839505df6a3ddb7665c3069c30eba2c4b1418 | uwp-h2021/supplementary_files | /src/py220_supplemental/lessons/lesson02/activities/complicated_example.py | 457 | 3.765625 | 4 | # complicated_example.py
def main():
x = 'main'
one()
def one():
y = 'one'
two()
def two():
z = 'two'
long_loop()
def long_loop():
for i in range(2, int(1e03), 5):
for j in range(3, int(1e03), 7):
for k in range(12, int(1e03)):
z = k / (i % k + j % k)
... |
9fc852e21d4128394abab79e2f8384c24ab90d92 | gcelikmasat/Poll-Analyzer | /ReadFile.py | 6,046 | 3.703125 | 4 | # Read answer keys, student list and report files
import json
import re
from Student import *
from Question import *
from xlrd import open_workbook
from AnswerKey import *
from Poll import *
import csv
class ReadFile:
def __init__(self):
self.students = []
self.allPolls = []
... |
ae54dbe4334c4e3cf53902ef9c0d4a708a2cd337 | IrmaPatton/my-deaf-grandpa | /deaf_grandpa.py | 1,207 | 3.90625 | 4 | from random import randint
def start_talking():
#seting the backdrop for a lovely conversation
print('''You need to speak to Grandpa Jankins ,so you walk up to him.
He is siting by the fireplace, smoking his favorite pipe.
/ '. ' .\\
|_.__'_.|}
(=(_)^(_)=)
... |
9468bf7958e05f647f34bee7842367d4bcb0ea2c | MarcelWPatykII/Week-9-Assignment-CIS175 | /src/exampleModule.py | 2,448 | 3.859375 | 4 | '''
Created on Mar 21, 2018
@author: mpaty
'''
import sys;
def addNumbers():
number = 0;
arrayOfNumbers = [];
while(number != -1):
number = int(input("Please enter a number. Enter -1 to stop."))
arrayOfNumbers.append(number);
return arrayOfNumbers;
def orderNumbersAscend... |
cbd684ec2febe612e750a42bdf144db58d4fc1ca | BorisBorsh/telegram_feeder | /portions_at_schedule.py | 436 | 3.859375 | 4 | def create_portions_on_schedule_dict(FEEDING_SCHEDULE, PORTIONS_TO_DISPENCE):
"""Function is generating dictionary where key is time and value
is portion counter. For FEEDING_SCHEDULE = ['07:00', '13:00', '19:00'] and
PORTIONS_TO_DISPENCE = [2, 1, 2] zip function would
create dict {'07:00' : 2, '13:00' ... |
3aa5a182109b09cf50b9606a6a479af7d1228ada | kevinlondon/refactoring-examples | /toothpaste/toothpaste4.py | 923 | 3.5625 | 4 | class User:
_fields = [
'email',
'first_name',
'last_name',
'phone_number',
]
PHONE_LENGTH = 10
def __init__(self, data):
self.data = data
def validate(self):
for field in self._fields:
validate_field = getattr(self, 'validate_{}'.format... |
62cf7ad9407f66a4a189ae9d8232c10ca64a0043 | capkum/python-calculator | /example/step01.py | 850 | 4.34375 | 4 | '''
example 변수안의 식만을 계산
'''
def calculator(str):
number = []
operation = []
for x in str.replace(' ', ''):
if x.isdigit():
number.append(x)
else:
operation.append(x)
nmbr_len = len(number)
x = int(number[nmbr_len - 2])
y = int(number[nmbr_len - 1])
... |
3030e127802fcb96f0198b044bd19b060e94bc32 | dhuan008/computer-security-projects | /Project1/Versions/mark2.py | 3,236 | 3.546875 | 4 | # https://stackoverflow.com/questions/16347583/how-to-generate-all-possible-strings-in-python
# https://rsmitty.github.io/MD5-password-cracker-in-python/
# team51:$1$hfT7jp2q$CD3hivje3TwA1E32pTFas/:16653:0:99999:7:::
import time
import string
from itertools import product
from string import ascii_lowercase
from hashl... |
e3aecad25605f17b01a6f519e0aa93523919c2df | erinepolley/python-book1-chapter9-classes | /urbanplanner2.py | 993 | 3.578125 | 4 | from urbanplanner import Building
from city import City
hospital_building = Building("200 Street", 8)
school_building = Building("300 St.", 2)
grocery_building = Building("100 St", 60)
church_building = Building("400 St.", 3)
bar_building = Building("500 St", 89)
buildings = [hospital_building, school_building, groce... |
67efe7ad8a69b8b9051fc4020af16cda22919e94 | priyaranjannayak/project | /assignment2.7.py | 568 | 3.984375 | 4 | a=int(input("enter the 1st number "))
s=input("input the operator as[+,-,*,/,%]")
if(s!="%"):
b=int(input("enter the 2nd number "))
if(s=="+"):
a=a+b
print("result="+str(a))
elif(s=="-"):
a=a-b
print("result="+str(a))
elif(s=="*"):
a=a*b
print("result="+st... |
6b72da3f3c9b1bab8552742d8645657511bb7fa6 | jcvitanovic/AntSystem | /util.py | 2,788 | 3.65625 | 4 | """ Module util contains helper functions and classes for solving TSP problem.
"""
class City:
"""Object representation of a city.
Attributes:
x (double) : cartesian coordinate
y (double) : cartesian coordinate
name (string) : city name
"""
def __init__(self, x, y, name = ""):
"""Constructor for cl... |
3369a138408ed3304bfee909369c3ba3215b7876 | CuriousPato/Censor-dispensor | /censor_word_list.py | 693 | 3.625 | 4 | # These are the emails you will be censoring. The open() function is opening the text file that the emails are contained in and the .read() method is allowing us to save their contexts to the following variables:
email_one = open("email_one.txt", "r").read()
email_two = open("email_two.txt", "r").read()
email_three = o... |
09ef59713d8676479902b1f7217fffe4f3ed5fb2 | alejoaquili/bayesian-method | /bayesian-method/models/token_counter.py | 1,066 | 3.53125 | 4 | import re
class TokenCounter:
def __init__(self):
self.word_frequencies = {}
self.total_words = 0
def tokenize(self, texts, words_to_ignore=None):
for text in texts:
for word in text[0].split():
current_word = str.lower(re.sub('[^a-zA-Z ]+', '', word))
... |
491baa4d6d872cfe8d8eac8c75d1d84003bb596f | matamkiran/python2020 | /python_examples/else_if_error.py | 309 | 3.984375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 15 14:39:55 2020
@author: 666292
"""
#
#Example file for working with conditional statement
#
def main():
x,y =8,4
if(x < y):
st= "x is less than y"
else:
st= "x is greater than y"
print (st)
if __name__ == "__main__":
main() |
7d516ddf2dc638f12a02cf9310dfff4094068ee4 | matamkiran/python2020 | /zip_lopping.py | 250 | 3.984375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Nov 5 15:45:40 2020
@author: ad.1201555
"""
numbers=[1,2,3,4]
letters=['a','b','c']
for l,n in zip(numbers,letters) :
print(f'Letter,{n}')
print(f'number,{l}')
|
7e06c09cc6138993d96126cff01f4aff0cdaab85 | matamkiran/python2020 | /zip_dictionarry.py | 330 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Nov 5 15:48:57 2020
@author: ad.1201555
"""
dict1={"name":"virat","age":30,"gender":"male"}
dict2={"name":"ptusha","age":50,"gender":"female"}
zipped=zip(dict1,dict2)
for (k1,v1) , (k2,v2) in zip(dict1.items(),dict2.items()):
print(k1, v1)
pr... |
c63ce4323cae8e2c5fe137a174f5d5b873cfd777 | matamkiran/python2020 | /multi_threading/thread_ex0.py | 417 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jul 11 13:05:19 2020
@author: matam
"""
import _thread
import time
def thread_delay(thread_name,delay):
count=0
while count<3:
time.sleep(delay)
count=count+1
print(thread_name,'----->',time.time())
_thread.start_n... |
e16dfc29eba0e92d412eb2c53f6b08eefacfea33 | matamkiran/python2020 | /functions/function_with_elif_cond.py | 296 | 3.9375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 9 12:18:05 2021
@author: Divya
"""
def conditional():
x=100
y=100
if(x>y):
st="X is greater than Y"
elif(x==y):
st="X is same as Y"
else:
st="X is smaller than y"
print(st)
conditional() |
523e4460cc2696c6556cddc665a55a533562d8e5 | matamkiran/python2020 | /dictionary/diction_within_dictionary_ex.py | 440 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Sep 30 07:59:48 2021
@author: matam
"""
europe = { 'spain': { 'capital':'madrid', 'population':46.77 },
'france': { 'capital':'paris', 'population':66.03 },
'germany': { 'capital':'berlin', 'population':80.62 },
'norw... |
f13124f3c61c9a2eb91aab2a0b30445875f32cd3 | matamkiran/python2020 | /python_examples/length.py | 159 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Feb 9 11:39:21 2020
@author: 666292
"""
list=[1,2,3,45,4,5,2,3,15]
print(len(list))
for x in list:
|
80acc8293330350500120bed10a243483849e713 | matamkiran/python2020 | /numpy/numpy2_ex.py | 262 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 2 20:28:59 2021
@author: Divya
"""
import numpy as np
temp=np.array([29.3,39.5,29.8,9.2,9.8,6.7,9.8,10.9,78.6,29.8,30.5,31.6]).reshape(2,2,3)
print(temp) |
2acf6153ffee5b46504954ea22204254ff1c5ca9 | matamkiran/python2020 | /functions/function_multiplication.py | 298 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jan 31 11:26:26 2021
@author: Divya
"""
def func1(n,l):
for i in l:
print(n ," * ", i,"=",n*i)
number=int(input("Enter the number you wish to display multiplication of table :"))
b=[1,2,3,4,5,6,7,8,9,10]
func1(number,b)
|
dccd8564027f5f663c77e230ca21db59363bfbea | matamkiran/python2020 | /numpy/numpy_tile_example.py | 354 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 3 21:21:34 2021
@author: Divya
"""
import numpy as np
x = np.array([ 3.4])
y = np.tile(x,5)
print(y)
x = np.array([[1, 2], [3, 4]])
print(np.tile(x, 2))
"""
x = np.array([[1, 2], [3, 4]])
print(np.tile(x, (2, 1)))
x = np.array([[1, 2], [3, 4]... |
0d9a1412049102a546f8cf2a2a9415bf7bd5a38a | matamkiran/python2020 | /list/list_ex_intro.py | 569 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 25 08:33:46 2021
@author: Divya
List can hold mutiple value
List can have duplicate values
List is declared in square brackets
List maintains insertion
List supports slicing and index based operations
list supports negative indexing
"""
a=[10,20,30,40,... |
65c57e0f85345c411cda72def3047685909ae833 | matamkiran/python2020 | /numpy/numpy_pandas-3hours.py | 479 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 9 00:51:57 2021
@author: Divya
"""
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("climate_austin.csv")
# Create a plot with color='red'
df.plot(color='red')
# Add a title
plt.title('Temperature in Austin')
# Specify the x-axis ... |
a73ff8cb3079d4e7b3817eb5b3c35e4af3cc2664 | matamkiran/python2020 | /introduction_exercise/biggest_of_two_number.py | 115 | 3.71875 | 4 | a=100
b=2
#a==100 #equality
cond=a>b
print(cond)
if(cond):
print("a is big")
else:
print("b is big")
|
078c6fc2cc9dbe7a33ce9b5f67e308c9c4ed49ef | matamkiran/python2020 | /pandas/pandas_dataframe_plot_bar.py | 518 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 23 23:57:42 2021
@author: matam
"""
import pandas as pd
height = [5, 17.5, 40, 48, 52, 69, 88]
years_to_fully_grow = [2, 8, 70, 1.5, 25, 12, 28]
index = ['lemon', 'cotton', 'neem',
'hibscus', 'peepal', 'banyan', 'coconut']
df = pd.DataFra... |
5fdf362cdba8044abc6076da36e559e443513e68 | BigTailWolf/TuxMaze | /maze.py | 2,867 | 3.96875 | 4 | #!/usr/bin/env python3
'''
This maze generator is not guaranteed generate a valid maze.
All the validate is for a cell, if it's represents to connect to its
neighbor, the neighbor will represents to the connect to this cell as well
Data Representation:
For each cell, it will have a number range fro... |
8a86550dbfe046938d921d73efe06be95fa7aeda | HeatherKeaty/HangmanGame | /Hangman.py | 6,925 | 3.859375 | 4 | '''
Assignment: Pair Programming Project
Authors: Aura Rose Jensen-Curtis
Heather Keaty
Time spent on project: About 35 hours
Version 8 (Final)
Date: 11/27/2016
Honor Code: We pledge that this program represents our own program code.
We received help from no one in designing and debugging our code.
'''
import... |
0ed4e566263f4e65046a0a8901dd6e0a00a91a00 | 2501/slack_bot | /lisa_commands/commands.py | 28,552 | 3.53125 | 4 | """
handles parsing text and running the command specified from it
then gets the string to pass back to slack
"""
import random
import re
import json
import logging
import commands_helper
import request_helper as request
import collections
import emojify_constants
def message_text(slack_event):
"""
Gets text ... |
9bfeec1bcfe91f2b1512fecc57989e1184c085f3 | RubanenkoV/quarantine_Proga | /task8.6.py | 1,886 | 3.75 | 4 | #На еолимпе задача пройти не должна, ибо в ходе решения я использовал defaultdict, а я не думаю, что это предусмотрено в решении, которое ожтдаемо на еолимп.
from collections import defaultdict
n = int(input())
d = defaultdict(list)
arr1 = []
arr2 = []
for j in range(n):
x,y = input().split()
d[x].app... |
d3d6862921a1ff82589e9ffed56702d88b3354ce | flowerpaui/Python_course | /assignment_2.py | 779 | 3.890625 | 4 | def translate_numeral(number):
if type(number) == str: # check type of input
roman_numeral = number
# ======enter code below======
arabic_number = None
# ======enter code above======
print('{0} translated to {1}!'.format(roman_numeral, arabic_number)) # print the result
return arabic_number
else:
... |
b5f538cdf16ffcb3880119cecdf22e07997be11f | chibitobi/DataStructure | /Ch6/tree.py | 1,430 | 4.09375 | 4 |
#this will be done recursively
myTree = ['a', #root
['b', #left subtree start
['d', [], []],
['e', [], []] ], #left subtree end
['c', #right subtree start
['f', [], []],
[] ] #right subtree end
]
#notice how myTree[0] will be denoted as root
# how myTree[1] will be denoted as left subtree
# ho... |
0f20f16acef52695065f056f3072d2244759ee4a | Nick-Chawanvit/Beginner-Python | /Log_turtle.py | 5,155 | 3.859375 | 4 | Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import turtle
>>> tao = turtle.Turtle()
>>> tao.shape('dog')
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
... |
cd1c5922141ac074519815aaf8bcc6062147f9f1 | MotoShin/reinforcement-learning-tutorial | /policy/learning_method/base_learning_method.py | 1,130 | 3.5625 | 4 | from abc import ABCMeta, abstractmethod
class BaseLearningMethod(metaclass=ABCMeta):
"""
学習方法のinterfaceを記述するクラス
"""
@abstractmethod
def reset(self) -> None:
"""
policyをリセットする
:return: None
"""
pass
@abstractmethod
def update(self,
cu... |
3db7e4ae4a87f0c35771917ba6d8f2e72689ff2d | JLtheking/cpy5python | /number bases/ascii.py | 567 | 3.75 | 4 | # ascii.py
# ASCII decimal to character
#for i in range(65,123): # uppercase A to lowercase z
# print(chr(i)) # chr() returns ASCII character
# ASCII character to decimal
#print(ord('A'))
# Unicode hexadecimal to character
print(chr(0x5fb7))
# Unicode character to hexadecimal
print(hex(ord('德')))
# Dunman High ... |
e85c5ae1101d7e3e25ccd570231e3e04e5e32d74 | JLtheking/cpy5python | /practical03/q1_display_reverse.py | 899 | 4.3125 | 4 | # Filename: q1_display_reverse.py
# Author: Justin Leow
# Created: 19/2/2013
# Modified: 22/2/2013
# Description: Displays an integer in reverse order
##Input a positive integer: 5627631
##1367265
##Input a positive integer: nope
##Input is not an integer. Utilizing default value of 6593
##3956
##Input a positive inte... |
bf920db934db1952d9c741ce8e8335a47dae2d0f | JLtheking/cpy5python | /08_OOP/bankaccount.py | 2,339 | 4.3125 | 4 | #bankaccount.py
class Account():
'''Bank account class'''
def __init__(self,account_no,balance):
'''constructor method'''
#double underscore makes it a hidden private attribute
self.__account_no = account_no
self.__balance = balance
def get_account_no(self):
'''accessor method to retrieve account no'... |
d3711625531e60fd700c1fceb4f18dd5b6d8b17f | JLtheking/cpy5python | /promo/4.1.py | 1,371 | 3.5625 | 4 | import random
import datetime
##main
username = input("Enter username:")
timestamp = datetime.datetime.now()
timestamp = timestamp.strftime("%Y-%m-%d %H:%M:%S")
print("Hello " + username + "!")
print("The time now is " + timestamp)
with open("LEADERBOARD.DAT","r") as infile:
leaderArr = []
line = infile.readline(... |
8320a625a8762b3b207178bec9e6b0d11bc5681f | JLtheking/cpy5python | /number bases/numbases.py | 1,222 | 3.5625 | 4 | import math
def decToBin(quotient):
ans=""
while quotient > 1:
rem = quotient % 2
quotient = math.floor(quotient / 2)
ans = str(rem) + ans
ans = str(quotient) + ans
return ans
def decToOct(quotient):
ans=""
while quotient > 7:
rem = quotient % 8
quotient = math.floor(quotient / 8)
ans = str(rem) ... |
88ad0089cb824563e2838128570c2bb05796a292 | JLtheking/cpy5python | /HCI_PrelimP1_2013/Additional Materials/2.1.py | 193 | 3.953125 | 4 | def Factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * Factorial(n-1)
print("0!: " + str(Factorial(0)))
print("50!: " + str(Factorial(50)))
print("100!:" + str(Factorial(100))) |
f96b0f8b03be1c81f6b27b64c4692143129c0c70 | JLtheking/cpy5python | /practical01/q6_find_ascii_char.py | 790 | 4.09375 | 4 | # Filename: q6_find_ascii_char.py
# Author: Justin Leow
# Created: 24/1/2013
# Modified: 24/1/2013
# Description: receives an ASCII code (an integer between 0 and 127) and displays its character.
def newString(inputString):
tempInput = input([inputString + "; or 'quit' to quit program"])
if(tempInput=="quit"):... |
3dc654590655292543d1a1b5f132b9173c405cd6 | JLtheking/cpy5python | /promopractice/2.1.py | 510 | 3.859375 | 4 | Animal = []
Animal.append("SNAKE")
Animal.append("CAT")
Animal.append("LION")
Animal.append("WOLF")
Animal.append("TIGER")
Animal.append("GIRAFFE")
Animal.append("HORSE")
Animal.append("ZEBRA")
Animal.append("LIZARD")
Animal.append("BEAR")
Animal.append("CROCODILE")
Animal.append("AARDVARK")
Animal.append("ALLIGATOR")
... |
ecb2714ae5f1b4c4995b6bb370eb8581ed4bee8d | JLtheking/cpy5python | /HCI_PrelimP1_2013/Additional Materials/1.1.py | 427 | 3.625 | 4 | def DecimalToBinary(DecimalNumber):
ans = ""
while DecimalNumber > 0:
rem = DecimalNumber % 2
DecimalNumber = DecimalNumber // 2
ans += str(rem)
numzeros = 8 - len(ans)
realans = ""
for i in range(numzeros):
realans += '0'
for i in range(len(ans)):
realans += ans[len(ans) - i - 1]
print(rea... |
73b2fa58628caf0682ba2fbcca4d44c25662c460 | JLtheking/cpy5python | /practical01/q1_fahrenheit_to_celsius.py | 634 | 4.25 | 4 | # Filename: q1_fahrenheit_to_celsius.py
# Author: Justin Leow
# Created: 22/1/2013
# Modified: 22/1/2013
# Description: Program which converts an input of temperature in farenheit to an
# output in celcius
# main
while(True):
#get user input farenheit
fInput = input(["Input temperature in farenh... |
e86003625b7e00107d2799bb43d290574c7eddeb | SimHoZebs/Python-scripts | /Old scripts/Guess the number ver 1.py | 2,199 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 9 16:41:35 2019
@author: Zebs
"""
import random
num = random.randint(1, 100)
list1 = []
list1_counter = 0
str_detector = "abcdefghijklmnopqrstuvwxyz~!@#$%^&*()_+-=]}{[\|;:'\",<.>/? "
is_string = 0
guess = input("Guess a number from 1 to 100 until you get it right.\nYo... |
096d1575fc7c6354ec36ac1e1400975d20496bbe | davidfenomeno/520python | /div-mod.py | 1,077 | 3.578125 | 4 | #!/usr/bin/python
valor = float(input())
reais = int(valor)
centavos = int((valor - reais) * 100)
n100 = reais // 100
reais = reais - (n100 * 100)
n50 = reais // 50
reais = reais - (n50 * 50)
n20 = reais // 20
reais = reais - (n20 * 20)
n10 = reais // 10
reais = reais - (n10 * 10)
n5 = reais // 5
reais = reais - (n5 ... |
bc057fc2d2cfda88ff1572113c9b09308233d008 | gokhankozan/BBY162 | /uygulama04.py | 926 | 3.921875 | 4 | #Gökhan Kozan No:21763436
#1. soru
metin = "Açık bilim, araştırma çıktılarına ve süreçlerine herkesin serbestçe erişmesini, bunların ortak kullanımını, dağıtımını ve üretimini kolaylaştıran bilim uygulamasıdır."
print(metin[:20])
#2. soru
liste = ["Açık Bilim", "Açık Erişim", "Açık Lisans", "Açık Eğitim", "Açık ... |
1e53c2e3e7052d86c164fa4b58c85b266338f01f | KathMoreno/prog-101 | /Python/clases/arrays.py | 845 | 4.1875 | 4 | # Declare array
my_array = ["Luna de miel en familia", "Escuadrón suicida", "Maléfica"]
# Print a value from the array
# print(my_array[1])
# Print all the array
# print(my_array)
# Add item
# my_array.append("Nuestro video prohibido")
# print(my_array)
# Remove item
# my_array.remove("Nuestro video prohibido")
# prin... |
3b81ee6d0f5cb4ec5a49454c3b1ba7d782a41ade | 13jacole/5e_GM_Tools | /Music_Player/music_play.py | 2,142 | 3.546875 | 4 | #!/usr/bin/env python
#imports
import os
import sys
import argparse
import glob
import random as rando
from playsound import playsound
"""
music_play.py: Music Player
Usage: python music_play.py
"""
# meta information
__author__ = "Jakob Cole"
__maintainer__ = "Jakob Cole"
#arguments
pa = argparse.ArgumentP... |
59ca8364c4a7d359bc654aef38b18ee03866bab7 | CHAEIN/python_basic | /string_test.py | 1,369 | 3.765625 | 4 | """
문자열 테스트
"""
print(3**4)
print('hello')
print("hello")
print("""hello""")
print('''hello''')
print("he'llo")
print('he"llo')
print("he\"llo")
print("hello\nworld")
print("hello\nworld")
multiLine = """
Hello
World
1234
"""
print(multiLine)
"""
매우 특이하게도 파이썬에서는 주석을 변수에 담을 수 있고
출력 명령어 안에 주석이 들어가도 주석으로 인식하지 않고 문자열을 리... |
2f3a5a59aaadf7fe5441106565c9886b01867284 | Katsiarynka/Algorithms | /lengthOfLongestSubstring.py | 617 | 3.78125 | 4 |
def length_of_longest_substring(s: str) -> str:
longestSubstr = 0
for i in range(len(s)):
for j in range(i+1, len(s)+1):
if is_uniq_substr(s, i, j):
longestSubstr = max(longestSubstr, j-i)
else:
break
return longestSubstr
def is_uniq_substr(... |
aefee6f85630cf93b977675c094d9a8413fe0bfe | Stephla/pwp-capstones | /TomeRater_Capstone (for review)/TomeRater_StephanieW.py | 8,462 | 4.0625 | 4 | class User(object):
def __init__(self, name, email):
self.name = name
self.email = email
self.books = {}
#Returns email associated with user
def get_email(self):
return self.email
#Takes in new email and changes email accociated with user (and prints message saying emai... |
c2cd9a1721f7064da8de62b278d2cc1e4c70902e | lunaluxie/Q | /Q/qubit.py | 2,493 | 3.5625 | 4 | from numpy.random import choice
class Qubit:
"""
A simulated qubit.
"""
def __init__(self, alpha=None, beta=None, precision=2):
self.precision = precision
self.set_state(alpha, beta)
def __str__(self):
if self.alpha == None or self.beta == None:
return "QuBit: State not set"
return "QuBit: {}|0> {}|1>... |
a09378cc0dc9e7864989881cbfe105fa60584509 | EricWWright/Tkinter | /calculator.py | 8,859 | 3.78125 | 4 | from tkinter import *
class Application(Frame):
def __init__(self, master):
""" Initialize the frame. """
super(Application, self).__init__(master)
self.grid()
self.create_widgets()
self.displayText = ""
self.pos1 = ""
self.pos2 = ""
self.total = ""
... |
a30ee966b0757c1e3cfb27f8c2c139b07f7af319 | evgenblaghodir/pyproject | /Ln4_loops.py | 163 | 3.671875 | 4 |
for i in range(-10,10, 2):
print(" "+str(i))
print("***")
if (i==0):
break
y=0
while True:
print(y)
y+=1
if(y==10):
break
|
022226471ed11ceea3fd2ee0e50899a78392ef08 | augustparkjy/algorithm | /Heap.py | 459 | 3.546875 | 4 | import heapq
heap=[]
heapq.heappush(heap, 4)
heapq.heappush(heap, 1)
heapq.heappush(heap, 7)
heapq.heappush(heap, 3)
print(heap)
#push > O(logN)
print(heapq.heappop(heap))
print(heap)
print(heapq.heappop(heap))
print(heap)
print(heap[0])
heap2 = [4,1,7,3,8,5]
heapq.heapify(heap)
print(heap)
#heapify > O(N)
nums = [4,... |
a310c88b7fc76fe3caaeee1c7776e3216aa9eeec | water-lilies/Python_basics | /lotto/lottoNum.py | 464 | 3.625 | 4 | def lottoNum():
lottoNum = []
while True:
# 탈출조건 : 번호 6개인지 확인
if len(lottoNum) >= 6:
break
else:
# 로또번호 생성
data = random.randint(1, 46)
# 로또번호가 리스트에 있는지 없는지 확인
if data not in lottoNum:
lottoNum.append(data)
r... |
4113a76f3b6d32b376c4fea97c539bf848d29e35 | water-lilies/Python_basics | /day8_5_1.py | 2,021 | 3.578125 | 4 | # 입력받은 데이타를 데이타베이스에 삽입
# sqlite 임포트
import sqlite3
# 데이타베이스 연결
conn = sqlite3.connect('data/addrDb.db')
# 작업변수(cursor) 생성
cursor = conn.cursor()
# ------ 테이블 생성
# 테이블 sql
cursor.execute('''
CREATE TABLE IF NOT EXISTS addr1 (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
... |
75e84cf947d9b0dad392be633cd900846d94ece7 | rohanraval/interview-prep-2017 | /CTCI3_StacksQueues/stackMin.py | 1,662 | 3.984375 | 4 | '''
Stack Min: How would you design a stack which, in addition to push and pop, has a function min
which returns the minimum element? Push, pop and min should all operate in 0(1) time.
IDEAS:
1. Keep a separate variable, minElement, in the stack class
However, this will not work, because it will make pop not con... |
44c9330f9b576bcca4ae1d74992f009d584cc6b4 | rohanraval/interview-prep-2017 | /CTCI4_TreesGraphs/minimalTree.py | 674 | 3.796875 | 4 | '''
Minimal Tree: Given a sorted (increasing order) array with unique integer elements, write an algorithm
to create a binary search tree with minimal height.
SOLUTION:
1. Recursive - make a minimal subtree from left and right of array, recursively
PROCESS:
1. Insert into the tree the middle element of the array.
2. ... |
e1dec2dc25f50d1f46ae855b6427f6a4a32e7915 | levelvlevel/think | /test.py | 323 | 3.8125 | 4 | def sum(number_one,number_two):
number_one_int =convert_integer(number_one)
number_two_int=convert_integer(number_two)
result=number_one_int+number_two_int
return result
def convert_integer(number_string):
converted_integer=int(number_string)
return converted_integer
answer=sum("1","2")
#git ... |
26dcf69b77bf164a189baab8747d53bb138e9e30 | tomtomseddon/W205-SeddonREPO | /exercise_2/finalresults.py | 1,576 | 3.984375 | 4 | # Script to get the final results from the database created by the stream
# processing topology.
#
# If no words passed as arguments on the command line, will return all words in the stream
# sorted alphabetically
#
# If a word is passed as an argument, it will only return the number of occurences of that word
#
# Assu... |
b97c0f39065b14ca4668ec4db1ada5d4c6fe640d | wang-nihao/p-y | /printclock.py | 5,720 | 3.625 | 4 | from turtle import *
from datetime import *
import time
def Frame(radius): #建立时钟外框
reset()
home()#将位置和方向恢复至初始状态
penup()
right(30)
pensize(2)
i=0
while i<60:
fd(radius)
color("red")
pendown()
if i%5==0:
fd(10)
... |
bbcd58c87ea0fbc8479ac182e434715e079b37de | NaguBianchi/Workspace | /Integrando_conocimientos/Integracion.py | 1,834 | 4.3125 | 4 | """
Una librería de la ciudad de Carlos Paz requiere de un programa que permita
cargar los montos de todas las ventas realizadas en el mes. Para ello el programa
debe permitir guardar ese valor en una lista.
Se debe generar un menú que permita realizar las siguientes operaciones:
Agregar el monto de una venta.
Mostrar... |
0d706a2589c7ca196ad3a134938a9feda2aeeb70 | NaguBianchi/Workspace | /Integrando_conocimientos/Funciones_para_venta.py | 1,640 | 4.0625 | 4 | """
Agregar el monto de una venta.
Mostrar todos los datos en la lista.
Mostrar la venta más baja.
Mostrar la ganancia total (Suma de todas las ventas).
Calcular el promedio de Ventas.
"""
def imprimir_lista(lista):
for item in lista:
print(item)
print("El listado de ventas es: ")
i = 1
for ven... |
cd4121bd09406dad559630f0d16a91eba83fd4fe | NaguBianchi/Workspace | /Estructuras/Clase2_Funciones.py | 1,303 | 4.25 | 4 | """
Parametros o Argumentos
Los Parametros son posicionales y requeridos
Para que los parametros no sean obligatorios se define un parametro por default
Ej:def user_info(nombre, edad, ciudad = "Cordoba"):
En pocas palabras, son valores que se reciben en una funcion a traves de los parentesis
"""
# def user_info(nombre... |
9cea736703811452386005411f09dfd044a7d430 | NaguBianchi/Workspace | /Estructuras/Clase4_Diccionarios.py | 1,464 | 4.0625 | 4 | """
Diccionarios:
El contenido esta formado por una key y su valor que es clave valor ej: key=apellido valor=bianchi
son mutables osea se pueden modificar
Pueden mantener un orden de entrada(como se fueron creando)
Su sintaxis es entre llaves que contienen una key y son separados por coma
"""
anios = {... |
1ecdcf1d4398ce0d46d11e36dc456fd34bf8942c | anderson-dan-w/artificial-intelligence | /ai/genetic_algorithm.py | 1,382 | 3.953125 | 4 | #!/usr/bin/env python3
## python modules
import random
def hillclimb_basic(attempt, goal):
original = attempt
idx, nsteps = 0, 1
while calculate_distance(attempt, goal) > 0:
while attempt[idx] == goal[idx]:
idx += 1
nudge_up = DOMAIN
## Let's take a generic example, ... |
69f16ecc1827aeedb4271b8eee9727a8e44a8586 | anderson-dan-w/artificial-intelligence | /ai/percepdelta.py | 1,831 | 3.5625 | 4 | #!/usr/bin/env python3
import math
def f(xvec, wvec):
""" Sigmoid activations function: multiply each x_i*w_i, sum them, then
plug that in to the typical sigmoid function."""
s = sum(x*w for x,w in zip(xvec, wvec))
return 1/(1+math.e**(-1 * s))
def delta(xvec, wvec, desired):
""" Calculate de... |
7700ee3af00b085ac3eb1f1f9b4641c3853807e4 | Yanhenning/python | /phone-number/phone_number.py | 1,332 | 3.578125 | 4 | import re
pattern = r'(\.|\+|\-|\(|\))|\s+'
invalid_pattern = r'[A-z]|\@|\,|\+'
# (NXX)-NXX-XXXX
class PhoneNumber:
def __init__(self, number):
cleaned_number = re.sub(pattern, '', number)
has_international_code = len(cleaned_number) == 11
self.international_code = int(cleaned_number[0])... |
d4e5a84d2d25438d70af43e156a3479ed6e8ee47 | Yanhenning/python | /isbn-verifier/isbn_verifier.py | 492 | 3.640625 | 4 | def is_valid(isbn):
isbn = isbn.replace('-', '')
if len(isbn) != 10 or not isbn:
return False
verifiers = range(1, 11)[::-1]
sum_values = 0
for index, digit in enumerate(isbn):
check_digit = index == len(isbn) - 1
if digit == 'X' and check_digit:
digit = 10
... |
d070f1fba69318e4ce4f07dbf97e5b40aeda6994 | Pandinosaurus/TinyEKF | /python/tinyekf/__init__.py | 3,271 | 3.5 | 4 | '''
Extended Kalman Filter in Python
Copyright (C) 2016 Simon D. Levy
MIT License
'''
import numpy as np
class EKF(object):
'''
A simple class for the Extended Kalman Filter, based on the tutorial in
http://home.wlu.edu/~levys/kalman_tutorial.
'''
def __init__(self, n, m, P=1, Q=1, R=1):
... |
dab6ce9e8d679524b36f3652c29524ea100cc432 | P-v-R/pyhton-OO-practice | /serial.py | 809 | 3.9375 | 4 | class SerialGenerator:
"""Machine to create unique incrementing serial numbers.
>>> serial = SerialGenerator(start=100)
>>> serial.generate()
100
>>> serial.generate()
101
>>> serial.generate()
102
>>> serial.reset()
>>> serial.generate()
100
"""
def _... |
af47a62770895f3239b6a0505b1cce9509a903ad | mmutiso/digital-factory | /darts.py | 773 | 4.28125 | 4 | import math
def square(val):
return math.pow(val,2)
def score(x, y):
'''
Give a score given X and Y co-ordinates
Rules
X range -10,10
Y range -10, 10
The problem is finding the radius of the circle created by a given point x,y
then compare if the point is inside the circle using pythag... |
10832c420c2f0ee4e57977a9723c8758818ca3c2 | Latrazil/projetCorrecteurQCM | /Correcteur QCM - Copie/projetCorrecteur.py | 5,179 | 3.5 | 4 | lAlan = ['Alan','A','D','Z','C','C','B','Z','D']
lsolution = ['solution','A','A','C','C','C','B','C','D']
def points(reponse,solution):
if reponse==solution:
return 3
elif reponse!=solution:
if reponse=='Z':
return 0
else:
retu... |
4518d243e64e4e8990ad375820ff890d23789b9c | Anirban2528/Ultimate450 | /#11.py | 175 | 3.75 | 4 | #To find duplicate in array of n+1 integers
class Num:
def dup(self,nums):
for x in nums:
if nums.count(x)>1:
print(x)
break
a=[1,3,4,2,2]
o= Num()
o.dup(a) |
1bffc81c128edaacd369a0315abc48afc0a2e92a | E-menu/Raspberry_python_app | /functions/weatherApi.py | 830 | 3.6875 | 4 | # Import module for GUI weather
import requests, json
# end
# Variables to remember API key , city name and page URL
API_KEY = "8b7c4545e3874014261a301b43f9d144"
BASE_URL = "http://api.openweathermap.org/data/2.5/weather?"
CITY_NAME ="Wrocław"
COMPLETE_URL = BASE_URL + "appid=" + API_KEY + "&q=" + CITY_NAME
# end
# F... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.