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 |
|---|---|---|---|---|---|---|
9e6d7da05d5d50a1d7199f1bcb92d2397fe257cc | rupal121/Conceptions | /script/shopping_list.py | 1,088 | 3.515625 | 4 | from . import assistant_gui
shopping_list = [ ]
def displayList():
assistant_gui.engine_speak("shopping list")
for i in shopping_list:
assistant_gui.engine_speak(i)
def addItem():
item = record_audio("enter the item you wish to add to the shopping list")
shopping_list.append(item)
assistant_gui.e... |
d18b43cfff4359996a1063dbffc82ed97c1dc1b5 | DocBrown85/FreeCodeCamp | /07-scientific-computing-with-python/time-calculator-project/time_calculator.py | 4,107 | 3.609375 | 4 | import math
class TimeAdder:
_DAYS_OF_WEEK = (
"sunday",
"monday",
"tuesday",
"wednesday",
"thrusday",
"friday",
"saturday",
)
_SECONDS_FOR_MINUTES = 60
_SECONDS_FOR_HOUR = _SECONDS_FOR_MINUTES * 60
_SECONDS_FOR_DAY = _SECONDS_FOR_HOUR * 24
... |
4c8932c4c20dd16594203316815b5c65a7255ac7 | aminabyaneh/ml-miscs | /statistical-learning/HW2_ML.py | 30,470 | 3.609375 | 4 |
# coding: utf-8
# # HW2_MachineLearning
# ## Aminmohammad Soleymani Abyaneh --------------------------------------------------------- 94100805
# ## 1. MLE for binomial distribution
# In this problem we must find the maximum likelihood estimation for binomial distribution and finde out whether it is biased or unbiase... |
4d2db9b41e64566ef06ce37e3576c736534cd413 | Tajiboev/python_assignments | /week-1/student_manager.py | 5,662 | 4.46875 | 4 | """
Your objective is to implement a class Student.
An object of this class records information about one student, such as name, student_id, and courses taken
with relative grades. It also allows to calculate the current GPA of the student.
"""
class Student:
# This datastore structure is a Python "dictionary" an... |
a4f91d14e7cace7d562eda06b93ab071b8dbc30e | Tajiboev/python_assignments | /week-3/dlist_manipulation.py | 4,475 | 4.46875 | 4 | """
Your task is to complete the implementation of the functions below, which do some kind of
manipulation of DOUBLY linked lists (that is, you need to use the DoublyLinkedList class defined in the p0 session)
Note the import of the Node class, this is needed if you need to create new nodes to insert into
a list
"""
... |
754b250fe4375a3ce60498bcb2dd052f8e1548f3 | sobil-dalal/Database-Analytical-Programming | /Slides/3_mapAndReduce.py | 251 | 3.96875 | 4 | # Return double of n
def addition(n):
return n + n
# We double all numbers using map()
numbers = (1, 2, 3, 4)
result = map(addition, numbers)
print(list(result))
# map function
squares = map(lambda a : a*a, [0,1,2,3,4])
print(list(squares))
|
7cb0efeacb836a70fa3f189d7458861e1cf16b22 | sobil-dalal/Database-Analytical-Programming | /Slides/13_regex.py | 324 | 3.5 | 4 | import re
def re_new(pattern, replace, string) :
print(re.sub(pattern, "{"+replace+"}", string))
print("\n")
s = "The zoo had wild dogs, bobcats, lions, and other wild cats"
re_new("cat", "dog", s)
def re_view(pattern, string) :
print(re.compile(pattern, re.M).sub("{\g<0>}", string.rstrip()))
re_view("o... |
955294c9cc1e68cc51da143e7f9be1d9cef2adfc | pjmartinn/IntroToIA | /TP1/utils.py | 1,310 | 4.03125 | 4 | import numpy as np
### The goal of this function is to create a canvas, which will be the vector used to train the classifier.
### As we want to predict a next move, we will create a canvas that is centered on the player, so that we can easily with the translation invariance.
def convert_input(player, maze, oppone... |
30a42419e12d36084aad30459448ccf8e986c568 | niharika210400/practice.python | /practice.py | 319 | 3.828125 | 4 | n=int(input())
def func(n):
for i in range(n):
for j in range(i):
print('*',end=' ')
print("\n")
func(n)
#Method-2
m=int(input())
def func(m):
print('pattern with',m,'lines')
num=m
while(num>0):
print((m+1-num)*'*')
num=num-1
func(m)
|
1965f9876ec9c6d75eaf9ccfe8173541c4e3843c | ZeeshannR/streamlit_app_pythonproject | /car_prediction_app.py | 3,231 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 22 13:11:43 2021
@author: DELL
"""
import streamlit as st
import pandas as pd
#import numpy as np
import seaborn as sns
#import plotly.express as px
#import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression,Lasso,Ridge
from sklearn.... |
85b09929f10b700a1133b9ad20e8a833999999e6 | hamodey/Python-fun | /py/Address book.py | 4,615 | 4.34375 | 4 |
def main(): # def makes it a menu so the user can chose what to do i.e "Quit" etc
print("*** Ahmed's AddressBook ***")
my_data = load("AhmedsAddressBook.csv")
if my_data == []:
print("No data found")
return
while 1:
print("1:search by surname\n2: search by month of bir... |
17c538ba27ab35c465575099b0553c1dc311efb6 | hamodey/Python-fun | /psuedo_python/B8-a_times_Ba-1.py | 100 | 3.53125 | 4 | def A(a):
if a == 0:
return 1
else:
return a * A(a-1)
a = 8
print(A(a))
|
4ffa251ec808b2bc56225b7ef3f50cf9747cde85 | hamodey/Python-fun | /psuedo_python/p.py | 110 | 3.796875 | 4 | def A(a,b):
if a < b:
return 0
else:
return A(a-b,b) +1
a = 27
b = 5
print(A(a,b))
|
c4831c3c9e1b13bdad08fc330d0d9b155ff50da0 | hamodey/Python-fun | /psuedo_python/Product_Between_AandB.py | 110 | 3.765625 | 4 | def A(a,b):
if a == 0:
return 0
else:
return A(a-1,b) + b
a = 6
b = 2
print(A(a,b))
|
d03f781fa0abd4eba8e475a0d3af241075227906 | leeminee/JumpToPython | /3장_예제실습.py | 3,504 | 3.703125 | 4 | print()
"""
[조건문 다음에 콜론(:)]
- if, while, for, def, class 문의 문장 끝에 콜론(:)이 항상 들어간다.
"""
"""
[파이썬에서 들여쓰기]
- : 다음 수행되어야 할 코드에 들여쓰기를 하지 않으면 오류발생
- 들여쓰기를 했지만 하나라도 너비가 다르다면 오류발생
- 들여쓰기(Tab)는 공백(Space) 4개와 동일하다. 어느것을 해도 상관은 없으나 2가지를 혼용해서 쓰지는 말자.
"""
print("[ex1]")
money = True
if money:
print("택시를")
print("타고")
... |
5fc71703fba3d7be429fa128215cb01ffa0f32c2 | AliPollock/Morar-group-repository | /calculator.py | 302 | 4.1875 | 4 | x=int(input("enter value for x: "))
y=int(input("enter value for y: "))
symbol = input("enter operator ('*', '+', '-', '/'): ")
if symbol == '*':
print(x*y)
elif symbol == '/':
print(x/y)
elif symbol == '+':
print(x+y)
elif symbol == '':
print(x-y)
else:
print("invalid operator")
|
fc551bda83861e5a5f921668fc08d3e98b76307e | c344081/learning_algorithm | /01/48_Rotate_Image.py | 1,544 | 4.3125 | 4 | '''
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Note:
You have to rotate the image in-place, which means you have to modify the input 2D matrix directly.
DO NOT allocate another 2D matrix and do the rotation.
Example 1:
Given input matrix =
[
[1,2,3],
[4,5... |
4398736f00f0d3be5708ead9c0e95af07822ad82 | c344081/learning_algorithm | /01/128.py | 1,121 | 4.0625 | 4 | '''
Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
For example,
Given [100, 4, 200, 1, 3, 2],
The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.
Your algorithm should run in O(n) complexity.
'''
class Solu... |
9be6e8264bd0b43d80dfe55216bd55b41d4301d3 | PuneetSoni4/sum-powerset | /sum_powerset_using_recursion.py | 1,526 | 4.09375 | 4 | class SUMPOWERSET(object):
""" Sum powerset class """
def __init__(self):
""" init method """
self.result_list = []
def custom_combinations_recursive(self, data_list):
""" To generate combinations of given data_list recursively """
# params
combinations_... |
ef6e0aa469407678c44713504b70e0387b1ff75e | etp19/movie-trailer | /media.py | 861 | 3.5 | 4 | import webbrowser
#This is the class Movie, it contain the
#funtions that allows save the information and play the trailer.
class Movies():
""" ... contain the functions that allows us to save the information
"""
def __init__(self, title, movie_storyline, poster_image_url, trailer_youtube):
"""... |
5305f5cc49c9ab95e39b652d649cdfdcb1fa6b3d | iamm3chanic/EVM | /semestr2/prg1py/pos2.py | 1,095 | 3.71875 | 4 | ############## задача 7: каких элементов больше: больших предыдущего или меньших предыдущего?
def main():
err, num = find('in.txt')
if err==0:
print("answer ", num)
elif err==1:
print("Can't open the file")
elif err==2:
print("Bad value")
elif err==3:
print("File is empty")
else:
print("Error")
########... |
afa6c9ca9cd088581dabd4385fb6ff8dc6fb5630 | HansLigtenberg/MasterThesis | /ReadData2.py | 6,094 | 3.5625 | 4 | """
ReadData.py
Purpose: Reads, transforms and saves data
Version:
1 Read data and select the correct value premium
2 Collect all data in one data frame
Date: 20210318
Author: Hans Ligtenberg
"""
### Imports
import numpy as np
import pandas as pd
#import matplotlib.pyplot as plt
#import scipy as sc
#Fu... |
48e41a67b90fa2b6b8d7a8d0a2cc34ed54bf9b57 | Mohitesh-Kumar/TestOrangeHRMDemoApp | /TestOrangeHRMDemoApp/AutomationFramework/Utilities/Utils.py | 2,146 | 3.78125 | 4 | import csv
class Utils:
#EnvVars is a class type of dictionary variable,storing env vars
#in Key-value pair
EnvVars={}
#classmethod is a static method which can be called without creating object of class
#To define classmethod we have to annotate method with @classmethod
@classmethod
... |
f1251d29d364dd65a74150dcdd1c7b4e5a906bbc | 009shanshukla/tkinter_tut_prog | /tkinter3.py | 433 | 4.125 | 4 | from tkinter import*
root = Tk()
######making lable #######
one = Label(root, text="one", bg="red", fg="white") #bg stands for background color
one.pack() #static label
two = Label(root, text="two", bg="green", fg="black")
two.pack(fill=X) #label that streches in x-dir
three = Label(root, t... |
9fa66d5933092b0493f14dd73347ee423fca7fc6 | 009shanshukla/tkinter_tut_prog | /tkinter6.py | 231 | 3.9375 | 4 | from tkinter import*
root = Tk()
def myname(event):
print("shantanu shukla")
####### binding function with GUI(widget) #####
button1 = Button(root, text="print name")
button1.bind("<Button-1>",myname)
button1.pack()
root.mainloop()
|
a6c62c5952041a21d6571fa21238ea63d548d15f | HARIDHARSHINI04/hd | /isogm.py | 109 | 3.921875 | 4 | f=input()
z=""
for a in f:
if a not in z:
z=z+a
if(f==z):
print("Yes")
else:
print("No")
|
deb62db2e9619465df4094ce9e3329cfd122d22c | HARIDHARSHINI04/hd | /alphadigit.py | 158 | 3.703125 | 4 | v=input()
p=False
h=False
for i in v:
if(i.isalpha()):
p=True
if(i.isdigit()):
h=True
if(p==True and h==True):
print("Yes")
else:
print("No")
|
72ca2771888ba390d2911619b0820fd9f4bea11f | HARIDHARSHINI04/hd | /factrs.py | 77 | 3.640625 | 4 | yz=int(input())
for f in range(1,yz+1):
if(yz%f==0):
print(f,end=" ")
|
a6ed8b586dea7b773facc5585e89e2e2b775458f | HARIDHARSHINI04/hd | /fac.py | 147 | 3.828125 | 4 | n=int(input())
fac=1
if(n<0):
print("does not exist")
elif(n==0):
print("1")
else:
for i in range(1,n+1):
fac=fac*i
print(fac)
|
545bebe07bcdb15db70b76a9b011e85f1c5bc8b6 | Guillermomartinez03/Tic_20_21 | /python/ejercico_10.py | 344 | 4.34375 | 4 | '''10.Realizar un programa que al recibir un numero entero muestre por pantalla
los 3 numeros anteriores y los 3 numeros siguientes al numero recibido'''
def ejercicio_10 ():
numero=input ("Escribe un numero entero:")
print (numero-1), (numero-2), (numero-3)
print (numero+1), (numero+2), (numero+3)
ejercic... |
aa7421a05b94b9084bf3ba53eb94b2f3abbc041d | ProMonkeyST/PythonSampleProject | /DBPostGis/Practice_Lesson/Assignment/Ex7.py | 142 | 4.28125 | 4 | import math
print 'Square Root Application'
num=float(raw_input('Enter Number: '))
root=math.sqrt(num)
print 'Root of %d is: %d' % (num,root) |
a0cacf93459d91aba4ee455f476eb72d32d867bf | astraWireshark/exo-2 | /exo_2_(1,2,3,4).py | 607 | 3.5625 | 4 | un_dico={'toto':3, 'titi':1, 'tutu':42}
un_dico['tata'] = 8
un_dico['titi'] += 1
print(un_dico, end = '\n')
def maj_dico_compte(dico, mot):
dico[mot] = dico.get(mot, 0)
#dico.get(mot,0) renvoie la valeur de mot s'il existe dans le dico ou l'ajoute comme clé puis lui affecte la valeur 0
for mots in dico:
... |
f293f45bce3fc872d0f82e02f9357f9987b5bc87 | mehedees/Python-Code-Test | /bongo_3.py | 1,021 | 3.921875 | 4 | from typing import List
class Node:
def __init__(self, value, parent):
self.value = value
self.parent = parent
def find_ancestor(node: Node, path: List):
if node.parent:
path.append(node.value)
return find_ancestor(node.parent, path)
else:
path.append(node.value)
... |
2c14e6395727ed53e9f67d3dc303576bbb8da76b | amberhappy/-offer | /2-替换空格.py | 522 | 3.71875 | 4 | #请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
class Solution:
def replaceSpace(self,a):
s = list(a)
length = len(s)
i = 0
while i<length:
if s[i] == ' ':
s[i] = '%20'
i += 1
return ''.j... |
9c61bb04a081a81098b037e6e66b8a2317f14872 | amberhappy/-offer | /49-把字符串转换成整数.py | 1,004 | 3.546875 | 4 | #将一个字符串转换成一个整数(实现Integer.valueOf(string)的功能,但是string不符合数字要求时返回0),
# 要求不能使用字符串转换整数的库函数。 数值为0或者字符串不是一个合法的数值则返回0
# 输入描述:
# 输入一个字符串,包括数字字母符号,可以为空
# 输出描述:
# 如果是合法的数值表达则返回该数字,否则返回0
class Solution:
def StrToInt(self,s):
if len(s)==0:
return 0
else:
if s[0]>"9" or s[0]... |
bc7968f1335f9e397f4ea61454024c095299e9f2 | amberhappy/-offer | /36-两个链表的公共节点.py | 573 | 3.734375 | 4 | #输入两个链表,找出它们的第一个公共结点
# -*- coding:utf-8 -*-
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def FindFirstCommonNode(self, head1, head2):
list1 =[]
list2 =[]
node1 = head1
node2 = head2
while node... |
4148ce0216ee864c7c3aec8207163a37a3b3ff1e | amberhappy/-offer | /65-矩形中的路径.py | 977 | 3.5 | 4 | #
class Solution:
def hasPath(self,matrix,rows,cols,path):
for i in range(rows):
for j in range(cols):
if matrix[i*cols+j]==path[0]:
if self.find(list(matrix),rows,cols,path[1:],i,j):
return True
return False
def fi... |
1529b4f28744f6b4c795b828263695548fffea48 | amberhappy/-offer | /13-调整数组顺序使奇数位于偶数前面.py | 663 | 3.703125 | 4 | #输入一个整数数组,实现一个函数来调整该数组中数字的顺序,
# 使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分,
# 并保证奇数和奇数,偶数和偶数之间的相对位置不变。
#思路:利用python中的双向队列
from collections import deque
class Solution:
def reOrderArray(self,array):
count = len(array)
result = deque()
for i in range(count):
if array[count-i-1]%2 ... |
f241bc99a89c2b5895bd96c73803ffc28c99aacb | amberhappy/-offer | /9-变态跳台阶.py | 569 | 3.53125 | 4 | #一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。
#跳1级,剩下n-1级,则剩下跳法是f(n-1)
#跳2级,剩下n-2级,则剩下跳法是f(n-2)
#所以f(n)=f(n-1)+f(n-2)+...+f(1)
#因为f(n-1)=f(n-2)+f(n-3)+...+f(1)
#所以f(n)=2*f(n-1)
class Solution:
def jumpFloorII(self,number):
if number<=0:
return 0
if number ==1:
... |
190ed822b9a78a3415282df127c15aec1a50333f | einian78/The-Complete-Python-3-Course-Beginner-to-Advanced-Udemy-Course | /Section 3 (Programming Basics)/4. Self-Defined Functions.py | 1,129 | 4.375 | 4 |
# Without Arguments:
def my_function(): # recommended style: snake case
print("This is my function!")
my_function() # This is my function
# With Arguments:
def my_function2(str1, str2):
print(str1, str2)
my_function2("Argument 1", "Argument 2") # Argument 1 Argument 2
my_function2("Hello", "World!") ... |
6f8af959758fad53d3a36b7da1fb1ea9aeca3777 | einian78/The-Complete-Python-3-Course-Beginner-to-Advanced-Udemy-Course | /Section 3 (Programming Basics)/3. Built-in Functions.py | 706 | 4.21875 | 4 | # print(): prints whatever inside
print("hi!") # hi!
# str(): Converts any type into a string
str(5) # 5
str(True) # True
# int(): Converts any type into a integer
int("5")
# float(): Converts any type into a float
float("5.6")
print(float(1)) # 1.0
# bool(): Converts any type into a boolean
bool("True")
# len... |
6cdebf3c73399a762dd50366d998f648efbd8afc | msheikomar/pythonsandbox | /Python/B06_T7_ConditionalsAndBooleans_is.py | 499 | 3.953125 | 4 | a = [1,2,3]
b = [1,2,3]
print(a == b) # This compare A and B are equal. Yes it is.
print(a is b) # This compare object A and object B using same memory location. No its is not.
print(id(a))
print(id(b))
# If you assign object B = object A then it prints True
print('-----------')
b = a
print( a is b) # Now it prints ... |
854f403587f1536e7445bfdb579597daca26f7ef | msheikomar/pythonsandbox | /Python/B08_T4_Functions_Pass_Argument.py | 588 | 4.0625 | 4 | # Here function argument is mandatory. If argument is missing python throws error
def hello_func(greetings):
return '{} Function.'.format(greetings)
print(hello_func('Hi'))
# Here in this function argument is not mandatory. Bcz we pass the default value
def hello_func_2(greetings,name = 'You'):
return '{},{}.... |
755f827054d4a42a60e66abb585cea571951ef62 | msheikomar/pythonsandbox | /Python/B04_T2_List_Method_5_pop.py | 280 | 4.0625 | 4 | # This method will remove last item from the list
courses = ['History', 'Math', 'Physics', 'COmpSys']
popped = courses.pop() # If you have a stack or queue keep popping of the items until your list is empty using for loop
print(popped) # To see the popped value
print(courses)
|
91945d3b7d3fd6939c0d44e0a08fb8a5e6627af5 | msheikomar/pythonsandbox | /Python/B05_T1_Dictionaries.py | 420 | 4.21875 | 4 | # Dict:
# Name is String, Age is Integer and courses is List
student = {'name':'John', 'age':25, 'courses':['Math', 'CompSys']}
# To get value by using key
print(student['name'])
# To get value by using key
print(student['courses'])
# If you look at the keys are currently being string. But actually it can be any i... |
8b393455be6e85cc3825b98fe857d7147c7c1806 | msheikomar/pythonsandbox | /Python/B04_T1_Lists_Tuples_Sets.py | 974 | 4.5 | 4 | # Lists and Tuples allows us to work with sequential data
# Sets are unordered collections of values with no duplicate
# List Example
courses = ['History', 'Math', 'Physics', 'ComSys'] # Create List with elements
print(courses) # To print lists
print(len(courses)) # To print length of list
print(courses[0]) # To a... |
743596cca60df61dffee48071b03659aef591f4c | IshratEpsi16/Digital_Electronic_Store | /tech_product.py | 849 | 3.90625 | 4 | class Tech:
#class variable
total_products = 0
discount = 0.5
#creating
def __init__(self,name,price,weight,color):
self.name = name
self.price = price
self.weight = weight
self.color = color
Tech.total_products = Tech.total_products + 1
#creating all the... |
8f68766320c6453ccbb2a8e35717f70d5777e90b | alamius/Chess.py | /Game.py | 7,961 | 3.53125 | 4 | #Game object for chess.py
from utils import Vector, color_to_str, std_size
#from Figure import std_figures
from random import randint
class Game(object):
def __init__(self, size=std_size, figures=None):
from Figure import std_figures
super(Game, self).__init__()
self.size = size
if(... |
ede03b508ae490fba31389c68aff15cc81212a9f | pavithraabhi/repo | /listnum.py | 116 | 3.671875 | 4 | lst=['1','2','3','4','5','6','7','8','9','10']
i=input()
if i in lst:
print("yes")
else:
print("no")
|
30a4d0a771600347cd4f36c85f7d463b31787c27 | pavithraabhi/repo | /vowelornot.py | 141 | 3.6875 | 4 | h=input()
l1=['a','e','i','o','u','A','E','I','O','U']
for i in h:
if(i in l1):
print("yes")
break
else:
print("no")
|
1a98500138d598a42f0fb2c7e825d1d4c655b7a4 | Purota/cp_algo | /sheet/junior/a/0008-boy_or_girl.py | 236 | 4.03125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def boy_or_girl(s):
s = set(s)
if len(s) % 2 == 0:
return "CHAT WITH HER!"
else:
return "IGNORE HIM!"
s = input()
ans = boy_or_girl(s)
print(ans)
|
595376926c0ced73afeafba4bd4ab92f69640ec9 | Purota/cp_algo | /sheet/junior/a/0020-die_roll.py | 349 | 3.515625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def die_roll(y, w):
num = 6 - max(y, w) + 1
denom = 6
if num % 2 == 0:
num //= 2
denom //= 2
if num % 3 == 0:
num //= 3
denom //= 3
return "{}/{}".format(num, denom)
y, w = map(int, input().split())
ans =... |
c5407469ac309fbe7da85a49b14d9dbc6fd7eb2b | Purota/cp_algo | /sheet/junior/a/0012-stones_on_the_table.py | 285 | 4 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def stones_on_the_table(s):
last = ''
count = 0
for c in s:
if c == last:
count += 1
last = c
return count
n = int(input())
s = input()
ans = stones_on_the_table(s)
print(ans)
|
409366b4173987192268c489685771d7d391d6ea | jonathanlurie/ControlCombo | /ControlComboClient/MappingItem.py | 1,663 | 3.59375 | 4 | # a mapping item is an association between four things:
# a LETTER is the row index,
# a FIGURE is the column index,
# a STATE is P for pressed or R for released,
# a ARGUMENT is the keyboard mapping key
import re
class MappingItem:
m_originalString = None
m_mapKey = None
m_mapArgument = None
m_isVa... |
d5c7efe1c7f1345be4b3fa2bdc3c1cb218c532e7 | riya1794/python-practice | /py/list functions.py | 815 | 4.25 | 4 | list1 = [1,2,3]
list2 = [4,5,6]
print list1+list2 #[1,2,3,4,5,6]
print list1*3 #[1,2,3,1,2,3,1,2,3]
print 3 in list1 #True
print 3 in list2 #False
print "length of the list : "
print len(list1)
list3 = [1,2,3]
print "comparsion of the 2 list : "
print cmp(list1,list2) # -1 as list1 is small... |
44a21b543c7d77931cc7705e7ddaddd8745f69cd | riya1794/python-practice | /py/first.py | 117 | 3.515625 | 4 | ht = (raw_input("enter "));
ht2 = input("enter 2 ");
#print "%s" %ht
print "%s" %ht2
print "%s" %ht
#print "%d" %ht2 |
55190bc38f2ccc3eab2289446b2ac0f69015502b | NageshGowdaC/Exception-Handling | /CustomException.py | 546 | 3.734375 | 4 | class AgeInSufficientException(Exception):
def __init__(self,msg):
print('constructor is called')
print(msg)
def check(age):
if age<18:
raise AgeInSufficientException('You\'re age is insufficient')
else:
print('Welcome to Registration')
print('exited')
... |
2cc3a2d290d21561db64557a9f290eb3a9c404de | wajihanasim110/AI_python_assignments | /assesment2.py | 837 | 4.09375 | 4 | #To extract list of 1000 numbers and determine the minimum, maximum and mean value of the same
#Print List of 1000 random Numbers#
a=[]
import random
for m in range(1001):
a.append(random.randint(1,1001))
b=a[0]
print("The list of random numbers is:")
print(a)
#Print Minimum Value from the list#
x=0
... |
99e6722cd04ca68d3834c1daee59d2eefc2100cf | current1990/playground | /stanford_algorithm_mooc/count_inversions.py | 1,712 | 3.609375 | 4 | def read_input(filename):
with open(filename) as f:
arr = f.readlines()
arr = [int(x) for x in arr]
return arr
def merge_and_count_split_inversions(left, right):
left_remains = len(left)
right_remains = len(right)
split_inversions = 0
left_idx = 0
right_idx = 0
output... |
53ac4735006d21b7be2eeae9176e57c3e1488435 | dleblond312/IEEEXtreme_WorkingAsIntended | /2012/AB_Danny.py | 1,288 | 3.546875 | 4 | """import math
import sys
input = sys.stdin.readline()
x1 = int(input.split(',')[0].split('.')[1])
y1 = int(input.split(',')[0].split('.')[0])
x2 = int(input.split(',')[1].split('.')[1])
y2 = int(input.split(',')[1].split('.')[0])
dX = int(x1 - x2)
dY = int(y1 - y2)
distance = abs(dX) + abs(dY) + int(math.ceil(abs(f... |
87b4698780336f8a0edf68db8b2d759c6d2c8114 | dleblond312/IEEEXtreme_WorkingAsIntended | /2012/AC_Rob.py | 14,398 | 3.8125 | 4 | class Orientation(object):
UP=0
LEFT=1
FRONT=2
RIGHT=3
BACK=4
DOWN=5
class Piece(object):
def __init__(self, faces):
self.faces = faces
self.orientation = Orientation.FRONT
self.orientation2 = Orientation.UP
def GetOrientation(self):
return self.orient... |
1f4e5a883083c58f58f269a132c3cff4a7cfe09b | sandeshwani/hackerrank-python | /basic-data-types/list-comprehensions/solution.py | 2,695 | 4.09375 | 4 | """
https://www.hackerrank.com/challenges/list-comprehensions/problem
You are given two integers x and y . You need to find out the ordered pairs ( i , j ) , such that ( i + j ) is not equal to n and print them in lexicographic order.( 0 <= i <= x ) and ( 0 <= j <= y) This is the code if we dont use list comprehensions... |
d4f2ceff37d2b801cbb554d13f4c3c8b4c6982c7 | alewang/Projects | /python/numbers/next-prime.py | 324 | 3.765625 | 4 | #!/usr/bin/env python
import primes
primeList = [];
index = 0;
keepGoing = True;
while keepGoing:
inp = raw_input("Enter q to quit: ");
if inp == 'q':
keepGoing = False;
else:
if index == len(primeList):
primes.genPrimes(primeList);
print primeList[index];
index += 1;
print "Program complete. Exiting.... |
a978869d254b97350e2171340dc4a98d47c9e5a1 | Yanivgrbr/googlehashcode | /src/Pizza.py | 3,213 | 3.578125 | 4 | def add_slice(pizza, pslice):
#Todo: time consuming - must be more efficient
# Memory copy
layout = [row[:] for row in pizza.layout]
new_pizza = Pizza(pizza.num_of_rows, pizza.num_of_cols, pizza.min_ingredients, pizza.max_cells_per_slice, layout)
# new_pizza = copy.deepcopy(pizza)
# Add slices... |
de9f24a9ba6b29ba367074aa85fd933315dff116 | FR4NKESTI3N/project_euler | /1-10/04.py | 340 | 3.546875 | 4 | def is_palindrome(n):
flag=1
string = str(n)
length = len(string)
for i in range((length/2)):
if string[i] != string[length-1-i]:
flag=0
return flag
largest = 9009
for i in range(101,999):
for j in range(i,999):
n=i*j
if is_palindrome(n) and largest<n:
largest = n
I=i
J=j
print largest,I,J,is... |
51fbe399e6e79ad4caed3d5ca5e9c804bb6d2355 | yashodharIITHyd/geeksForGeeks | /dynamicProgramming/knapsack_01.py | 804 | 3.546875 | 4 | weights = [10,20,30]
values =[60, 100, 120]
amount = 50
class knapsack:
def __init__(self,weights,values,amount):
self.weights = weights
self.values = values
self.n = len(weights)
self.amount = amount#sum(weights)
self.mat=[[0 for _ in range(self.amount+1)] for _ in range(sel... |
78ee56c207e602c58825f6161b63b0a03682992d | yashodharIITHyd/geeksForGeeks | /dynamicProgramming/palindromePartitioning.py | 1,515 | 3.890625 | 4 | s="ababbbabbababa"
#s="aaa"
class palindromePartition:
def __init__(self,s):
self.s=s
self.n = len(s)
self.boolPalindrome = [[0 for _ in range(self.n)] for _ in range(self.n)]
self.palindromeMatrix=[['!' for _ in range(self.n)] for _ in range(self.n)]
for i in range(self.n):... |
688dbfca4de181e9e75e47eba31bee390c42c20c | Ntokozo-J/Team7 | /.github/workflows/function3.py | 163 | 3.578125 | 4 | def date_parser(dates):
for date in dates:
date = dates[:10] # the date from the datetime string is only made up of 9 characters
return date
|
1b3c4efbf1fc7eb5ba6e10fc1712df013fb06dd4 | Ryan171717/PickleChat | /PickleChatAccountHandling.py | 4,578 | 3.59375 | 4 | import socket, random
class User:
def __init__(self, username, password, ip, *kwargs):
self.password = password
self.username = username
self.ip = ip
if kwargs:
for part in kwargs:
self.message = part
else:
self.message = self.assignMe... |
707f70b17759d503b0f34f05c7d2b1dac10d8b86 | crazymalady/Python-Exercises | /ielect_Meeting5/w5_lab1e_DivisibleBy.py | 718 | 3.96875 | 4 | """
Given a list iterate it and display numbers which are
divisible by 10 and if you find number greater than 200
stop the loop iteration
list1 = [120, 15, 32, 42, 55, 75, 122, 132, 150, 180, 200]
created by: Lacaste, Jennifer - 2020.10.23"""
def f_divisibBy10():
sList = [120, 15, 32, 42, 55, 75, 122, 132, 150, ... |
22f540a39beef855d2c62af63eabba62b545d3f5 | crazymalady/Python-Exercises | /ielect_Meeting5/w5_lab2g_isAndisNotOperators.py | 339 | 3.828125 | 4 | """
by: Lacaste, Jennifer - 2020.10.23"""
def display():
smallest = 100
print('Before', smallest)
list = [9, 41, 12, 3, 15, 74]
for the_num in list:
if smallest is None:
print('Smallest is None:', smallest)
elif smallest is not None:
print('Not None:', smallest)
... |
306823cd754b5bea6bd0bc1f43a7b948e0da299e | crazymalady/Python-Exercises | /ielect_Meeting8/w9_lab1c_AppendingtoFile.py | 419 | 3.734375 | 4 | #Lab3 Write a python program that will append the file (dogs_breeds.txt)Put your name on it.
def display():
readFile()
def readFile():
# Append-adds at last
dfile = open("dog_breeds.txt", "a")
dfile.write("Jennifer Lacaste \n")
dfile.close()
dfile = open("dog_breeds.txt", "r")
#output the... |
34ea076a6ad9c001740abed4a5410d844158d321 | crazymalady/Python-Exercises | /ielect_Meeting10/w10_lab1c_Add1After7000.py | 300 | 3.71875 | 4 | def display():
try:
# 3. Create a python program that will add item 1 after 7000 in the following Python List
list1 = [100, 220,[300, 400,[5000, 7000],500],30, 40]
list1[2][2].append("1")
print(list1)
except:
print("Something went wrong")
display()
|
6ca0abefdbfa3185e579f4e604ece0b4713099ea | crazymalady/Python-Exercises | /ielect_Meeting6_ExamPractice/w6_ePrac1_ComputeGrossPay.py | 402 | 4.0625 | 4 | # Write a program to prompt the user for hours and rate per hour
# to compute gross pay.
# Lacaste, Jennifer
def calcGross( hrs, rate ):
gross = hrs * rate
print('Gross Pay: ', gross)
return gross
def display():
try:
hours = int(input('Hours: '))
rate = float(input('Rate: '))
c... |
b88612af7e0bfe8c0dbc3f3778a6856469dbb5f6 | crazymalady/Python-Exercises | /ielect_Meeting7/w8_e2b_Center.py | 173 | 3.703125 | 4 | def putCenter( word ):
mid = word.center(10) # center(padding)
print('Word is Center:', mid)
def display():
word = input('Word:')
putCenter(word)
display() |
c6e4fa1d487e0c922865c44fa8042aad78cf6a96 | crazymalady/Python-Exercises | /ielect_Meeting10/w10_e1fBC_ListOperations_Delete Elements.py | 508 | 4.40625 | 4 | def display():
try:
# We can change the values of elements in a List. Lets take an example to understand this.
# list of nos.
list = [1,2,3,4,5,6]
# Deleting 2nd element
#del list[1]
# Deleting elements from 3rd to 4th
#del list[2:4]
#print(list)
... |
aa94e7f43062f870b0cf6648a6cd3fddf104404d | Tiasa/StyleRecognitioninMusic | /GlobalGrammars/plot_svc.py | 6,327 | 3.65625 | 4 | """
==================================================
Plot different SVM classifiers in the iris dataset
==================================================
Comparison of different linear SVM classifiers on a 2D projection of the iris
dataset. We only consider the first 2 features of this dataset:
- Sepal length
- Se... |
547a8708244d19a6bb99bcd84e08cb67a94b63d1 | DaehanHong/Algorithmic-Thinking-Part-1- | /Algorithmic Thinking (Part 1)/Week 2/project_1.py | 2,093 | 3.96875 | 4 | # -*- coding: utf-8 -*-
"""
Project 1 - Degree distributions for graphs
"""
EX_GRAPH0 = {
0: set([1,2]),
1: set(),
2: set()
}
EX_GRAPH1 = {
0: set([1,4,5]),
1: set([2,6]),
2: set([3]),
3: set([0]),
4: set([1]),
5: set([2]),
6: set()
}
EX_GRAPH2 = {
... |
1c7af195c07d639fd1cebdf6e80226b43d5fe8ba | DavichoSs/calculadora | /calculadora.py | 1,814 | 3.703125 | 4 | # -*- coding: utf-8 -*-
from Tkinter import*
import tkMessageBox
def Suma():
n1=float(txt1.get())
n2=float(txt2.get())
suma=n1+n2
tkMessageBox.showinfo("Mensaje","La suma es: %.2f"%suma)
txt1.delete(0,20)
txt2.delete(0,20)
def Resta():
n1=float(txt1.get())
n2=float(txt2.get())
resta=n1-n2
... |
8611827759d143d19523ca3d2f47d5507546ed15 | aromig/advent2019 | /day10.py | 1,751 | 3.640625 | 4 | import math
import file
raw = file.readLines('inputs/day10.txt')
def find_asteroids():
for y, line in enumerate(raw):
for x, a in enumerate(line):
if a == '#':
yield (x, y)
def get_angle(start, end):
angle = math.atan2(end[0] - start[0], start[1] - end[1]) * 180 / math.pi
... |
5fa942cb659bf118cc2641d8efd9e84d123cea48 | jason91403/bot_DC | /tools.py | 2,178 | 3.734375 | 4 | import collections
import math
class Tools(object):
def __init__(self):
pass
@staticmethod
def get_distance(x_position, y_position):
return math.sqrt(math.pow((x_position[0] - y_position[0]), 2) + math.pow((x_position[1] - y_position[1]), 2))
@staticmethod
def record_map_to_loca... |
b170f898c8214d9cb8f01a36fc50dee48ce1cf16 | AlejandroL12/Act_11 | /assignments/00HelloWorld/src/Q4.py | 168 | 3.828125 | 4 | def main():
#escribe tu código abajo de esta línea
x=8
y=6
while (y<=x):
x+=1
y+=2
print(x,y)
if __name__=='__main__':
main()
|
8ce577bf72dd19b0d06c6109c798b119addac492 | mpavlovic/pywo-zadaci | /zadaci/my/mpavlovi2/iterator_protocol.py | 949 | 3.875 | 4 | __author__ = 'Milan'
list = [1, 2, 3]
for x in list:
print(x)
string = "123"
for char in string:
print(char)
mySet = set(list)
for element in mySet:
print(element)
dict = {'a': 1, 'b': 2}
for key in dict:
print(key)
# pazi
for key, value in dict.items():
print(key, value)
# pazi
l = [1, 6, 9... |
d63aa167926b91a246b0219af06e6ffec803a944 | SahityaRoy/get-your-PR-accepted | /Sorting/Python/Insertion_Sort.py | 532 | 4.21875 | 4 | # Python program to implement Insertion Sort
def insertion_sort(arr):
# Traverse through 1 to len(arr)
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
while j >= 0 and key < arr[j]:
arr[j + 1] = arr[j]
j = j - 1
arr[j + 1] = key
# Driver function
if... |
e9e99fae26f38d36362a21d2732423e3628578b3 | Calluml24/Python-work | /Python work/Assignment 1 & 3/First attempt.py | 2,844 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 26 17:30:58 2017
@author: Callum
"""
#Open up the London Undergroud file - create this as some sort of data?
#Create a Class that constructs a node map of the stations?
#A class that runs the algorithm for calcuating the shortest path?
#added class that runs th... |
bfba58ea2189cc2bd23f9f00339c0d2a5a8766b8 | bukandu1/code-challenge-practice | /leet_code/is_balanced_bst.py | 1,019 | 3.953125 | 4 | # Given a binary tree, write a function to determine whether the tree is balanced
class Node():
def __init__(self, value):
self.value = value
self.right = None
self.left = None
class Solution:
def isBalanced(self, node):
def helperBalancedHeight(node):
if not node... |
50fef9d4ca5f0aa1bbe9fbd4a64397d580077d5b | bukandu1/code-challenge-practice | /leet_code/find_nth_node_from_end_LL.py | 1,147 | 3.90625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
# Runtime: 32 ms, faster than 97.12% of Python3 online submissions for Remove Nth Node From End of List.
# Memory Usage: 13.8 MB, less than 6.06 % of Python3 online submissions for Remo... |
85c7670673eb7b446541612480d0b7f29a644d74 | bukandu1/code-challenge-practice | /advant_of_code/2019/day_01_fuel_mass.py | 1,314 | 3.953125 | 4 | import unittest
class Solution:
textfile = "day_01_fuel_mass.txt"
def fuel_mass(self, textfile):
file = open(textfile, 'r')
sum = 0
for line in file:
sum += int(line) // 3 - 2
print(sum)
file.close()
return sum
def deplete_fuel(self, textfile)... |
d0fa4bceed75e8f31367d690e1981763bd0783d5 | bukandu1/code-challenge-practice | /leet_code/binary_tree_level_order_traversal.py | 1,322 | 3.890625 | 4 | # 102. Binary Tree Level Order Traversal
# Runtime: 28 ms, faster than 91.77 % of Python3 online submissions
# for Binary Tree Level Order Traversal.
# Memory Usage: 13 MB, less than 100.00 % of Python3 online
# submissions for Binary Tree Level Order Traversal.
# Definition for a binary tree node.
# class TreeNode... |
0485b546cf3a12c4dd66d7d6b2c0278ffa7e9059 | bukandu1/code-challenge-practice | /leet_code/reverse_string_iii.py | 723 | 3.765625 | 4 | class Solution:
def reverseWords(self, s: str) -> str:
# "" -> ""
# "a" -> "a"
# "at today" -> "ta yadot"
"""
split the string at the spaces
[Let's, take, LeetCode, contest]
loop list and reverse each index
return joined list
"""
... |
5043578a392ecd035f2521c6baa3dd40b6689acf | bukandu1/code-challenge-practice | /leet_code/verifiying_an_alien_dictionary.py | 1,625 | 3.640625 | 4 | class Solution:
def isAlienSorted(self, words: List[str], order: str) -> bool:
"""
guaruntee that
test cases:
- all word in order, different first letters
- words not in order, diff 1st letters
- some words start with same letter
- no words
... |
5a846badcfe6d76b973c0e94c85bd7af05f269b7 | MaungSan/python-tutorials | /22 While Loop in Python.py | 365 | 3.796875 | 4 | # i = 1
#
# while i<=5:
# print("Telusko")
# i=i+1
# i = 5
#
# while i>=1:
# print("Telusko")
# i=i-1
# i = 5
#
# while i>=1:
# print("Telusko" , i)
# i=i-1
i = 1
while i <= 5:
print("Telusko ", end="")
j = 1
while j <= 4:
print("Rocks ", end="")
... |
51bce67bcedd274b114586d2777d4f131dc39714 | JiaYuanK/Mastermind-Game | /Mastermind Project.py | 6,506 | 3.96875 | 4 | #imports random module
import random
#Explanation of Mastermind game
def explanation():
print("==========================================================================")
print("In Mastermind, you (the player) will be tasked to guess 4 correct colours")
print("in a correct sequence which is generat... |
7cbfee938932f8c114ef68b1a57cd8554eae2d80 | RobotGyal/Generating-Fractals-with-Recursion | /recursion/recursion.pyde | 293 | 3.828125 | 4 | # FRACTAL TREE
# KOSH CURVE
# CANTOR SET
# MANDELBROT SET
def setup():
print("The recursive factorial is: ", factorial(4))
def draw():
pass
def factorial(n):
""" Calls itself to provide recursion """
if n == 1:
return 1
else:
return n * (factorial(n-1))
|
39187f501a57f03f679eb793028e9acc6e95c115 | laxte/coursework | /adventofcode/day3/day3c.py | 1,145 | 4.03125 | 4 | unique_locations = []
santa_location = [0,0]
robo_location = [0,0]
start_location = [0,0]
even = True
def isNotVisited(location, unique_s):
try:
next(obj for obj in unique_s if (obj[0] == location[0] and obj[1] == location[1]))
return False
except StopIteration:
return True
def updateLocation(locat... |
929a2192d8f4c69493c3b825872e6319fe743ebf | sajeelk/TicTacToe | /human.py | 536 | 3.84375 | 4 | class Human():
def __init__(self, piece):
self.piece = piece
def check_move(self, board, move):
if(move[0] > 2 or move[0] < 0 or move[1] > 2 or move[1] < 0):
return False
elif(board[move[0]][move[1]] != " "):
return False
return True
def get_move(self, board):
row = int(input("enter row: "))
col = ... |
7f49a565e6e06dbc3a6855d6ec350a580b5c8a24 | tian5017/ModelData | /test02.py | 623 | 3.859375 | 4 | # 二分查找法
def binary_search(list, item):
low = 0
high = len(list) - 1
i = 0
while low <= high:
i += 1
mid = (low + high) // 2
guess = list[mid]
if guess == item:
return mid, i
if guess > item:
high = mid - 1
else:
low = m... |
0d7caf495d8f528a3a64f2170c8a8cae37ea603b | SACHSTech/basic-practice-BrightonZhang1 | /oz_to_ml.py | 206 | 3.75 | 4 | recipe_ounces = float(input("Enter the amount of fluid in ounces: "))
servings = float(input("Enter the number of people to serve: "))
print("You will need", (recipe_ounces*29.5735) * (servings/4), "ml")
|
44b3cf57b75d8f9533950ac7df15c9580ae6fdfe | pradeepkris/PythonScribbles | /Decorators.py | 936 | 4 | 4 |
def Multiply_by_2(main_class):
def wrapper_func(*args, **kwargs):
x = main_class(*args, **kwargs)
return "Result = " + str(x * 2)
return wrapper_func
@Multiply_by_2
def Add_Hundred(x):
return (x + 100)
@Multiply_by_2
def Div_Four(y):
return (y / 4)
print Add_Hundred(20)
print Div_Fo... |
fcfa19c0ac46a527b33a507277a0a30e740968fc | RuaYiii/RuaYiii | /naturl_numpy.py | 1,653 | 3.765625 | 4 | import numpy as np
def natural_relu(x): #x 是一个numpy 2d 向量
'''线性整流函数(Rectified Linear Unit, ReLU)
又称修正线性单元,是一种人工神经网络中常用的**激活函数**(activation function)
通常指代以斜坡函数及其变种为代表的非线性函数。'''
assert len(x.shape)==2
x=x.copy()
for i in range(x.shape[0]):
for j in range(x.shape[1]):
x[i,j]=max... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.