blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
131530af44fcb51323fb3114d842a542c1e37efb | RobertoCruzF/Intensivo-Nivelacion | /20082019/000721.py | 277 | 3.859375 | 4 |
# se define la funcio , la cual retorna el valor de la suma de las variables del input
def function3(x,y):
return x+y
# se define la variable la cual evaula la funcion con las varibles input "1" y "2"
e=function3(1,2)
# imprime en consola el valor de la variable
print e |
cfe2a3f0f1816470572a80e7714de07eb44d1361 | RobertoCruzF/Intensivo-Nivelacion | /27082019/000346.py | 144 | 3.546875 | 4 | import numpy as np
# crea lista y luego la trasforma a array
a_list=[1,2,3,4,5,6,7]
z=np.array([a_list])
print z
# formato de z
print type(z) |
172b15d2299b9bc7a72ea969a0799fc155529665 | RobertoCruzF/Intensivo-Nivelacion | /30082019/001007.py | 677 | 3.546875 | 4 | from matplotlib import pyplot as plt
# defino dos listas
ages_x = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
dev_y = [38496, 42000, 46752, 49320, 53200,
56000, 62316, 64928, 67317, 68748, 73752]
plt.plot(ages_x,dev_y)# GRAFICO LAS DOS LISTAS DEFINIDAS ANTERIORMENTE
py_dev_y = [45372, 48876, 53850, 5728... |
34a75744fdc846dbeb8c5629aa53bd106d97543e | RobertoCruzF/Intensivo-Nivelacion | /19082019/001110.py | 375 | 4.21875 | 4 | c=3
d=4
# Imprime en consola "c is less than d" en caso de que c es menor a d
# en caso contrario imprime "c is NOT less than d" y "I don't think c is less than d"
# ademas cada vez que se corre el codigo imprime "outside the if block"
if c<d:
print "c is less than d"
else:
print "c is NOT less than d"
print "I don... |
2c8530978ee3df971503a739479c1fff27b816e8 | ynossiul/python | /tienda.py | 229 | 3.859375 | 4 | print("Escribe los siguientes valores solicitados")
nombre1=input("Ingrese el Nombre del primer producto")
precio=int(input("Ingresa el primer precio"))
print(f"El nombre del producto es {nombre1} y el precio es {precio} pesos")
|
804040b91e0eae85e85bc32f2db2958dd5f981e4 | 2-X/slackmojify | /slackmojify.py | 4,843 | 3.90625 | 4 | import sys
import pyperclip
from text_mappings import big_letter_templates
def is_slackmoji(some_text):
"""Determines if some text is a slackmoji (i.e. starts and ends with `:`).
Args:
some_text (str): The text to check.
Returns:
bool: Whether or not the given text is a sla... |
7cc7aaac9ea5b94efb8c450f97068e5a30cf21aa | q1234001/teach-python | /day1/base1_dim.py | 423 | 4.03125 | 4 | #數值與字串類型
inta = 1
stra = '1'
intb = 2
strb = '2'
name = "Shawn"
print("inta = 1\nstra = '1'\nintb = 2\nstrb = '2'")
ex1 = "數值相加:inta + intb = {ans}"
print(ex1.format(ans = inta + intb))
print("字串相加:stra + strb = "+ stra + strb)
print("數值跟字串相加(字串轉型):inta + int(stra) =", str(inta +int(stra)))
print('name = "Shaw... |
ba0535ffcb2ea45d184181279e2e11d4f98a0ef2 | SengunGoat/Ch.04_Conditionals | /4.3_Quiz_Master.py | 2,585 | 4.03125 | 4 | '''
QUIZ MASTER PROJECT
-------------------
The criteria for the project are on the website. Make sure you test this quiz with
two of your student colleagues before you run it by your instructor.
'''
points=0
score=0
print("A.Black Air Forces")
print("B.Jordan 1's")
print("C.Vans")
print("D.Crocs")
print("E.Barefoot"... |
ccf351dd50462e4752950f0b0825e8f9a51a93df | weixue139/MH8811-G1901790D | /06/genPassword.py | 1,405 | 4.125 | 4 | #06 Homework H1 module by Wei Xue
#Module to generate a strong password of length n (n>=4):
#import necessary modules:
import string
import random
#Function to generate a strong password of length n (n>=4):
def genPassword(n):
#define variables to contain the groups of symbols:
#lowercase letters:
let_low... |
f6223e79fc5ecbc17e70ded7bd29ad095e39357e | phoshell/python-challenge | /PyPoll/main.py | 1,804 | 3.984375 | 4 | import csv
csvpath = 'election_data.csv'
total_votes = 0
candidate_dict = {}
candidate_list = []
percent_vote = []
# For instance, key: "row[2], or candidate name", value: "number of votes"
with open(csvpath, newline='') as csvfile:
# CSV reader specifies delimiter and variable that holds contents
csvreader... |
d46d07b84a78e45f58091ebf4074fcebf3a2084b | msgabor/Python3 | /014_import_namespace_module(class).py | 776 | 3.5625 | 4 | import math
from math import sin, cos
print(sin(4))
print(cos(3))
print("............................................")
import FirstClass
FirstClass.call_function_from_another_file() # calling function from another file --> namespace = another class/module
print(FirstClass.color)
print(FirstClass.names)
... |
c0253db2f3d933c51b224ead6b994858867ef1bc | msgabor/Python3 | /021_string_manipulation.py | 3,746 | 4.03125 | 4 | string1 = 'This dog is "awesome"!'
print("Quotes:", string1)
print("......................................................................................")
string2 = "My girlfriend is Ivett and she is 30 years old."
print("Original string literal:", string2)
string3 = string2.replace("Ivett", "Kitty"). replace("3... |
b9ff0a2398cc4791431dce955cb9dc4d4b18d6e5 | msgabor/Python3 | /002_operators.py | 416 | 4.375 | 4 | # assignment
# + * / - // ** %
# comparison or relational operators
# < > <= >= != ==
# logical
# || && !
# Bitwise operator >> shifting
num1 = 5
num2 = 11
# arithmetical operators
print(num1 + num2)
print(num2 - num1)
print(num1 * num2)
print(num1 / num2)
print(num2 // num1)
print(num1 ** num2)
print(num2 % num1)... |
bd45966bdedc5b1fa00a1d0c0282bd7cfc53d605 | atur94/codefights_interviewPractice | /commonCharacterCount2.py | 215 | 3.6875 | 4 | def commonCharacterCount(s1, s2):
commons = 0
for letter in set(s1):
commons += min(s1.count(letter),s2.count(letter))
return commons
s1 = "aabcc"
s2 = "adcaa"
print(commonCharacterCount(s1,s2)) |
7c3ae1cd18f793ff3a99b5399effdaaed74b9270 | troj4n/LeetCode | /14.Longest_common_prefix.py | 1,544 | 3.671875 | 4 | ################################### Solution 1 (Word by Word matching) ########################################
class Solution:
def commonPrefix(self,str1,str2):
result=""
n1=len(str1)
n2=len(str2)
i=0
j=0
while i<n1 and j<n2:
if str1[i]!=str2[j]:
... |
46ff61087b3fccf3f9924676f78c27b901a4a948 | alexei/Py-Codette | /Py3_GUI/tutorial/tutorial4.py | 2,107 | 3.90625 | 4 | """
Dialogs in PyQt4
Dialog windows
- an indispensable part of most modern GUI applications.
- dialog = conversation between two or more persons.
In a computer application a dialog = window used to "talk" to the application.
A dialog is used to input/modify data, change the application settings... |
6af78cbfb34260116a0ea3b8ec301be6c020674f | SchulerHunter/CMPSC-465 | /insertionSort/sort.py | 495 | 3.828125 | 4 | def sort(sortArray):
swaps = 0
for i in range(1, len(sortArray)):
k = i
while k > 0 and sortArray[k] < sortArray[k-1]:
sortArray[k], sortArray[k-1] = sortArray[k-1], sortArray[k]
swaps += 1
k -= 1
return (swaps, sortArray)
with open(input("Provide file pa... |
c92a9faf1241630d7a135b031082a9009a8bb715 | SchulerHunter/CMPSC-465 | /mergeSorted/mergeSorted.py | 885 | 3.5 | 4 | def mergeSorted(arrA, arrB):
outArr = []
i, j= 0, 0
while i < len(arrA) and j < len(arrB):
if arrA[i] < arrB[j]:
outArr.append(arrA[i])
i += 1
else:
outArr.append(arrB[j])
j += 1
while i < len(arrA):
outArr.append(arrA[i])
i... |
8e776e93a34ec8e9bde2658c42b9267e9bc7df29 | m-g-shahriar/python | /date_time.py | 234 | 3.796875 | 4 | import datetime
time=datetime.datetime.now()
print("Current Date and time 24 hour")
#for 24 hour
print(time.strftime("%Y-%m-%d %H:%M:%S"))
#for 12 hour
print("\n")
print("12 hour")
print(time.strftime("%Y-%m-%d %I:%M:%S")) |
f4a5d74217a1e7bd01cb7584a2cf4eb5c3ad299e | m-g-shahriar/python | /ui/ui.py | 3,911 | 4.0625 | 4 | from tkinter import Tk, Entry, Button, INSERT, PhotoImage,Label
import speech_recognition as sr # use google speech recognition program
from gtts import gTTS # use google text-to-speech program
from pygame import mixer # use the mixer to play computer's speech
from tkinter import Tk, Message
import time
import... |
23fed4aceba3ad484c7259f1a09f77de8d308110 | burakoguz/leetcode_questions | /q845_longest_mountain_in_array.py | 3,653 | 3.6875 | 4 | class Solution(object):
def findFirstMountain(self, B):
mountain_length = 0
mountain_last = 0
increase_detected = False
decrease_detected = False
len_B = len(B)
for i in range(len_B-1):
mountain_last = i
# print "B[i] = {} and B[i+1] = {}".... |
32ee6630f79fed9d58dc8283b49eacce8d462c4a | burakoguz/leetcode_questions | /14q_longest_common_prefix.py | 1,540 | 3.65625 | 4 | class Solution(object):
def longestCommonPrefix(self, strs):
"""
:type strs: List[str]
:rtype: str
"""
longest_common_pre = ""
min_len = 2 ** 31
nr_of_strs = len(strs)
if (nr_of_strs == 0):
longest_common_pre
elif (nr_of_strs == 1)... |
9bac24a3900ef1bf75628d77457b8eefa13867de | jithinvijayan007/InKoop-Problem | /InKoop.py | 2,718 | 3.765625 | 4 | class Student(object):
def __init__(self, name):
self.name = name
self.costs = []
self.ratings = []
self.highestcost = 0
self.cheapestcost = 0
self.highestrating = 0
self.cheapestrating = 0
def __repr__(self):
return '<' + self.name + ', ' \
... |
b46503ee8cd28db42e6717225fddde38f9b5b789 | Leaf-Off-The-Old-Tree/Python-Tutorial- | /review.py | 115,091 | 3.984375 | 4 | # =========================================================================
# LEARNING PYTHON
# =========================================================================
# Keys:
# (EX:)- example
# (op)-output
# =========================================================================
# ... |
b690134635a2309abe1a275bcbd1292d89f43deb | shrestha-pranav/leetcode | /1027_longest_arithmetic sequence.py | 1,388 | 3.75 | 4 | # Longest Arithmetic Sequence
# https://leetcode.com/problems/longest-arithmetic-sequence/
from typing import *
from collections import Counter
class Solution:
def backtrack(self, start, index, diff):
# print(start, index, diff)
maxlen = 1
next_element = start + diff
... |
ca783dfab3baed9ecb2fca15e88a06383f0cd403 | msgerasyov/algs | /hash_table.py | 2,446 | 3.96875 | 4 | class HashTable(object):
"""
A class used to represent a Hash Table-based associative array.
...
Attributes
----------
max_size : int
Maximum size of the inner array
size : int
Current size of the inner array
elems : int
Current number of elements
... |
05b8bc20e7529d2b0f20cb244a3c5d767a7386da | TranBinhLuatUIT/Project--Writing-Functions-for-Product-Analysis | /main.py | 4,526 | 3.8125 | 4 | import pandas as pd
def categorize_nps(x):
""" Take a NPS rating and outputs whether it's a "promoter" , "passive", "detractor"
or invalid. Rating is 0 to 10
Args:
x(int) : NPS Rating
Returns:
string: The NPS Category or Invalid
"""
if x >= 0 and x <= 6:
re... |
026aea1681bb7ea6998d1c646f98c9b08be32033 | RishabhSablok/Wave-4 | /reverse_lookup_new.py | 1,025 | 3.9375 | 4 | def dictionary_creation():
number_of_elements = int(input("Input the number of dictionary elements: "))
dictionary = {}
for i in range(a):
hh = ("Input the name of the "+ str(i+1) + " key: ")
jj = ("Input the name of the " + str(i+1) + " value: ")
key = input(hh)
value = inpu... |
10e28ee3e3504b5c69b932f4dcf3ee2252b25244 | guillaumejounel/CodeWars | /Python/rgb.py | 514 | 3.625 | 4 | #rgb to hex conversion
def limit(nb, mini=0, maxi=255):
return max(min(maxi, nb), mini)
def rgb(r, g, b):
return "{:02X}{:02X}{:02X}".format(limit(r), limit(g), limit(b))
#best solution:
def rgb(r, g, b):
round = lambda x: min(255, max(x, 0))
return ("{:02X}" * 3).format(round(r), round(g), round(b)... |
65d85afefc9b78cfdc9b3a876d666a3ef7234178 | nachoaz/HackerRank_Python | /src/Basic_Data_Types/list_comprehensions.py | 895 | 4 | 4 | # list_comprehensions.py
"""
https://hackerrank.com/challenges/list-comprehensions
You're given three integers, (x, y, z) representing the dimensions of a cuboid
along with an integer n. You have to print a list of all possible coordinates
given by (i, j, k) on a 3D grid where the sum of i + j + k is not equal to n.
... |
95f53250de33190a8226eda06931596904e2ad7a | nachoaz/HackerRank_Python | /src/Introduction/if_else.py | 919 | 4.34375 | 4 | # if_else.py
"""
https://www.hackerrank.com/challenges/py-if-else
Given an integer, n, peform the following conditional actions:
* if n is odd, print Weird
* if n is even and in the inclusive range of 2 to 5, print Not Weird
* if n is even and in the inclusive range of 6 to 20, print Weird
* if n is ev... |
1cc3e8e52e6dd316e26b2cee8c82e92d9f96ff67 | nachoaz/HackerRank_Python | /src/Sets/union_operation.py | 294 | 3.515625 | 4 | # union_operation.py
"""
https://www.hackerrank.com/challenges/py-set-union
"""
def main():
_ = int(input())
nset = set(map(int, input().split()))
_ = int(input())
bset = set(map(int, input().split()))
print(len(nset.union(bset)))
if __name__ == '__main__':
main()
|
67f606197f839634ac1ce5e3cfc95ff06653bbcf | hero1682/Innovaccer-2 | /code.py | 1,644 | 3.765625 | 4 | # Innovaccer
# file I/O
import csv
last_names = []
genders = []
dobs = []
first_names = []
n = 0
with open('C:\\Users\\Nikhil\\Downloads\\Deduplication Problem - Sample Dataset.csv','r') as csv_file:
# here write the location of the data file(here it is Deduplication Problem - Sample Dataset.csv)
csv_reader = csv.... |
9a7b1de4e7df9505a93d848b2ffaf1644cb1e80c | abhinavbandaru/Machine-Learning-Assignments | /NeuralNetwork.py | 2,993 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 01:49:17 2020
@author: LENOVO
"""
import numpy as np
import pandas as pd
from sklearn import model_selection
def sigmoid(x):
return 1/(1 + np.exp(-x))
def sigmoid_derivative(x):
return sigmoid(x)*(1-sigmoid(x))
class NeuralNetwork:
def __i... |
234318e912af2d7d01200913e47a9679828ed089 | sebasgoldberg/organizat | /planificacion/strategy/utils.py | 204 | 3.53125 | 4 | # coding=utf-8
def add_keys_to_dict(dictionary,keys):
if len(keys) == 0:
return
if not dictionary.has_key(keys[0]):
dictionary[keys[0]] = {}
add_keys_to_dict(dictionary[keys[0]],keys[1:])
|
6cac9fd5169519d4ee532db40702d95e0b9498e3 | jainkashish/MAS-PROJECT | /main.py | 1,392 | 3.796875 | 4 | import node
import characteristic_function
import coalition
import shapley
import time
if __name__ == "__main__":
n = int(input("Enter Number of Nodes:\n"))
nodes = [] # it stores the information about n nodes
start = time.time()
# list of Node class objects for all agents
for x in ra... |
69e71c695a53c3243e5e786f0a40ce627eace76b | steAz/Backgammon-with-AI-bots | /PythonApplication1/GameField.py | 1,301 | 3.953125 | 4 | '''
Created on 18 maj 2017
@author: Oskar/Kazan
'''
from enum import Enum
'enumeration for colors of checkers'
class Color(Enum):
RED = 0
BLACK = 1
class GameField:
'''
Class which represents game field. Each field contains some number(or zero) of checkers in
one of two colors (black or red)
... |
58d3faab933a79ecdb91f8992a12a5ca356d92d0 | htietze/capstone_lab8 | /bitcoin.py | 1,711 | 3.6875 | 4 | import requests
def main():
bitcoins = get_bitcoin_amount()
bitcoin_rate = get_current_BTC_rate()
# if it successfully returned a bitcoin rate, then it'll convert and print, otherwise alerts the user to an issue.
if bitcoin_rate:
converted = convert_BTC_to_USD(bitcoins, bitcoin_rate)
pr... |
02fcbdd9486bc1b9caf76fa24de1c4141dd8f4c6 | MeatStack/StarterLearningPython | /newcodes/answers/q57.py | 537 | 4.28125 | 4 | #!/usr/bin/env python
# coding=utf-8
def palindrome(word):
word_lst = [ i for i in word ]
word_lst.reverse()
new_word = "".join(word_lst)
if word == new_word:
return True
else:
return False
if __name__ == "__main__":
while True:
word = input("input a word:('q'-exit)")
... |
5fb66ae02be085b938c50c7e14208b2b7786f203 | MeatStack/StarterLearningPython | /newcodes/answers/q8.py | 199 | 3.84375 | 4 | #!/usr/bin/env python
# coding=utf-8
name = input("what is your name?")
age = input("how old are you?")
new_age = int(age) + 10
print("{0} will be {1} yeas old in ten yeas.".format(name, new_age))
|
7c5ef26c7d11e198a5bcce882fc63433033f4f47 | MeatStack/StarterLearningPython | /fib/fib02.py | 180 | 3.5 | 4 | #!/usr/bin/env python
# utf-8
from math import sqrt
def fib(n):
return ((1+sqrt(5))**n - (1-sqrt(5))**n)/(2**n*sqrt(5))
if __name__=="__main__":
f = fib(4)
print(f)
|
024eeae0fa0437c25bc11cb69e03ab3c1ae1a5a4 | MeatStack/StarterLearningPython | /newcodes/answers/q63.py | 842 | 3.9375 | 4 | #!/usr/bin/env python
# coding=utf-8
from datetime import date
class DateDiff:
def __init__(self, start, end):
self.start = start
self.end = end
def diff_days(self):
return (self.end - self.start).days
def diff_months(self):
delta_years = self.end.year - self.star... |
1c088fa5d1a66bbffc372735ef8ab507b29beaff | MeatStack/StarterLearningPython | /newcodes/answers/q12.py | 159 | 4.3125 | 4 | #!/usr/bin/env python
# coding=utf-8
word = input("please input a word:")
length_word = len(word)
print("the length of {0} is {1}".format(word, length_word))
|
877fc24a7fab0024afe70c8c3f7c1a8fbb8d91e7 | MeatStack/StarterLearningPython | /newcodes/answers/q34.py | 786 | 3.796875 | 4 | #!/usr/bin/env python
# coding=utf-8
def average(lst):
total = 0
for i in lst:
total = total + i
ave = total / len(lst)
return ave
def max_student(dct):
max = 0
for k,v in dct.items():
if v > max:
max = v
name = k
return (name, max)
if __name__ == "... |
0a24780b36086f00f1942db4c4d3b63b0610cc20 | raghu566/LearnPython | /RepetetingNumbers.py | 372 | 3.765625 | 4 | _author_='RaghuK'
while 1:
try:
x =raw_input("Please enter a number or non-number to exit:")
x = int(x)
n = 0
while x > n:
n = n + 1
y = 1
#print '\n'
while n >= y:
print n,
y = y + 1
print '\n' + '\n' + 'Booyah Momswy'
for i in range(1, x+1):
print str(i) * i
except:
break
... |
a4268fdf3ac31d3ec8c4a1b0418510c585d495af | sambhav228/HOSPITAL-MANAGEMENT | /CODE.py | 2,195 | 3.78125 | 4 | class CircularQueue():
def __init__(self, size): # initializing the class
self.size = size
self.queue = [None for i in range(size)]
self.front = self.rear = -1
def enqueue(self, data):
if ((self.rear + 1) % self.size == self.front):
print(" FILE IS FULL\n")
elif (self.front == -1):
self.front ... |
960409c7e3cfa46bc90545580914925f9a645120 | spettigrew/cs-tree-traversal | /src/build_tree.py | 2,865 | 4.03125 | 4 | """
You are given the values from a preorder and an inorder tree traversal. Write a
function that can take those inputs and output a binary tree.
*Note: assume that there will not be any duplicates in the tree.*
Example:
Inputs:
preorder = [5,7,22,13,9]
inorder = [7,5,13,22,9]
Output:
5
/ \
7 22
/ \
... |
485904525705445d9a5ddc4c1644ddd8f55a86dd | Safa002/e-olymp | /2807. Cubes-3.py | 105 | 3.515625 | 4 | n=int(input())
s=0
a=input()
for i in a:
s=s^ord(i)
if s==0:
print("Ok")
else:
print(chr(s))
|
fd53ad7f8bfba617284949a84af53adca6334b80 | Safa002/e-olymp | /1658. Factorial.py | 178 | 3.609375 | 4 | faktorial = 1
reqem = int(input())
while (0 <=reqem <= 20):
for i in range(1, reqem + 1):
faktorial = faktorial * i
print(faktorial)
break
|
35096e574f512a290a087428d2a4f405631ee300 | sshipra319/leetcode | /MergeArrays.py | 954 | 3.953125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Shipra
"""
num1 = [1, 2, 3, 0, 0, 0]
num2 = [2, 5, 6]
m = 3
n = 3
class Solution:
def mergeArray(self, num1, num2, m, n):
i, j = 0, 0
num3 = []
while i < m and j < n:
if num1[i] < num2[j]:
num3.append(num1[i])... |
9752583b9d73a1ecba02c5784c63ffe86ae233ee | sshipra319/leetcode | /ReverseString.py | 432 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 13 15:39:41 2020
@author: Shipra
"""
arr = ["h", "e", "l", "l", "o"]
class Solution:
def ReverseString(self, arr):
l = 0
r = len(arr) - 1
while l < r:
arr[l], arr[r] = arr[r], arr[l]
l += 1
... |
f7ac755815c6976af68ff7fa08a11acd1129ffbd | Martbov/gevpro-week3 | /json_filter.py | 871 | 3.5625 | 4 | #!usr/bin/python3.4
import sys
from collections import namedtuple
import json
def main(argv):
"""" Checks for same meaning of the word blood and die in languages"""
if len(argv) > 2:
print("Usage: python3.4 json-file", file=sys.stderr)
exit(-1)
else:
jsonFile = open(argv[1], 'r')
... |
7946049f0dc2b8bdcf922602e536eb11033562e6 | chang-xiao-ling/pytest | /unittest 框架/03-代码/hm_04_assert.py | 852 | 3.5625 | 4 | import unittest
from tools import login
class TestLogin(unittest.TestCase):
def test_username_password_ok(self):
"""正确的用户名和密码: admin, 123456, 登录成功"""
self.assertEqual('登录成功', login('admin', '123456'))
def test_username_error(self):
"""错误的用户名: root, 123456, 登录失败"""
self.assert... |
bdd60416bfcb15aea1c12063c22a65a9d0b23e74 | curama228/n1 | /main.py | 180 | 3.6875 | 4 | a=int(input('ведите число'))
d=int(input('ведите число'))
b=int(input('ведите число'))
p=a+d+b
if p<30:
print('no')
elif p>29:
print('yes') |
d4e54b1d7c9216cb2a07b8d2241d31034b43f08b | tranc99/pong-breakout | /pyg.py | 1,917 | 3.640625 | 4 | import pygame
SCREEN_SIZE = 800, 500
#OBJECTS
BRICK_WIDTH = 60
BRICK_HEIGHT = 15
PADDLE_WIDTH = 60
PADDLE_HEIGHT = 12
BALL_DIAMETER = 16
BALL_RADIUS = BALL_DIAMETER / 2
MAX_PADDLE_X = SCREEN_SIZE[0] - PADDLE_WIDTH
MAX_BALL_X = SCREEN_SIZE[0] - BALL_DIAMETER
MAX_BALL_Y = SCREEN_SIZE[1] - BALL_DIAMETER
PADDLE_Y = SC... |
d6f8133438028b4e6e5b098b2050777a48d13111 | CodeAnt100/OpenHacks-Hackathon | /TESTING 3.py | 219 | 3.859375 | 4 | string = "(CH3)2CHCH(CH3)CH2CH3"
print(string.index("CH2"))
string2 = "(CH3CH2CH3)"
print(string2[1:len(string2) - 1])
print(string[9:6])
array = ["bb", "ae", "jj", "zw", "ga", "ja"]
print(sorted(array))
|
dc278789e2689425fa05d346eb373642af2840ee | yomihiko/listen | /chapter13/lambda.py | 378 | 3.984375 | 4 | def mySort(string):
return string[-1]
myList = ['python', 'ovg', 'kivy', 'apple', 'zoo']
myList.sort(key=mySort)
print(myList)
myList = [('納豆', 78), ('おまめ', 200), ('コーラ', 120), ('ポテチ', 60)]
myList.sort(key=lambda tpl: tpl[1])
print(myList)
numbers = [1, 2, 3, 4, 5]
for i in map(lambda num: '{0}です'.format(num), ... |
bc23f887ceeef472321afb15c93299cec2f4a56a | yomihiko/listen | /chapter02/string2.py | 297 | 3.828125 | 4 | mystr = ''
print(mystr)
print(type(mystr))
mystr += 'ジャーヴィス'
mystr += 'かわいい'
print(mystr)
print(mystr * 10)
mystr = 'ジェーナス\tかわいい'
print(mystr)
my_str = 'Hello World'
str_len = len(my_str)
print(str_len)
print(len(''))
print(dir(my_str))
print(my_str.title)
|
aad4f1074e11f0c1de99682de61aefea24529c04 | daianarodrig20/PythonProyects | /DataStructure/Stack.py | 1,440 | 3.546875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from dataclasses import dataclass
from typing import Any
class Pila():
@dataclass
class _Node:
value = Any
siguiente = _Node
__slots__=[_inicio]
def __init__(self, iterable = None):
self._inicio = None
if iterable is not ... |
fddfb774c0a6df793f60e08aa63f5314936da86f | thakur24/python-webscrapping | /code.py | 1,012 | 3.6875 | 4 | #install requests & Beatuiful soup libraries beforing improting
# command - pip install requests
#pip install Beautifulsoup4
import requests
import bs4
url=input("enter the url")
#sending a http request to the server using get function
response=requests.get(url)
filename="source.html"
bs=bs4.BeautifulSoup(respon... |
c6084b5855a50764f61190fc762cf7cf338d7016 | xeophin/lede-foundations | /01-classwork/homework-01-manz.py | 3,409 | 4.375 | 4 | # Kaspar Manz
# 2018-05-21
# Homework 1
# When run from the command line, this file should
# 1. Prompt the user for their year of birth, and tell them (approximately):
def ask_for_year_of_birth():
yearOfBirth = input('What is your year of birth? ')
yearOfBirth = int(yearOfBirth)
if yearOfBirth > 2018:
ret... |
eb427f43edb76ccb40736a937a18dcf78b1ba731 | xeophin/lede-foundations | /intro.py | 210 | 3.625 | 4 | print("Hello World")
print("4" + str(4))
def test_function() -> bool:
"""
This is doing stuff
:rtype: bool
"""
return True
test = False
if test:
print('untrue')
else:
print(test_function())
|
28a9d4022ce4a709c93cef24c3e932da30ce8090 | CesarLema123/RIPS | /LAMMPSFramework/lib/PyScripts/inFiles.py | 2,291 | 3.65625 | 4 | from random import randint
class inFile:
"""
fileName: Name of the file to be written
readFile: Name of the template in.*** file to read
runTime: Desired runtime of the simulation in simulation units
timeStep: Desired timestep in simulation units
"""
def __init__(self,fileName = "CuNi",read... |
17701a7507a0d24a8c17c85639ff78dfb7378777 | SteamDiver/Sem4OOP | /Labs/att1/V2T6.py | 221 | 3.671875 | 4 | def read(file):
with open(str(file), 'r') as f:
lines = [int(line.strip()) for line in f]
return tuple(lines)
arr = read("input2.txt")
s = (n for n in arr if n==max(arr, key=arr.count))
print(max(s))
|
b983e159359cb94956cbbc6298185f0984c77c51 | mturke/PythonSearchingMethods | /searching.py | 909 | 3.734375 | 4 | class SequentialStringList:
def __init__(self):
self.list = []
def add(self, str):
self.list.append(str)
def find(self, str):
for i in self.list:
if i == str:
return i
return None
class BinaryStringList:
def __init__(self):
... |
f0a8325fd02f6e82d5dcc8359769a687a01f7588 | bradleymailbox/RockPaperLizardSpock | /RockPaperLizardSpock/codemodule.py | 1,625 | 3.984375 | 4 | import random
rockbeats = tuple((3, 4))
paperbeats = tuple((1,5 ))
scissorsbeats = tuple((2, 4))
lizardbeats = tuple((2,5))
spockbeats= tuple((1, 3))
def showMenu():
print("What do you choose - Enter a selection 1 to 5")
print("=========================================================")
print("1. Rock - 2... |
66d3377c60cd59ff1a56406858fd5dd7aca02fe5 | introcart/walking | /correlation.py | 804 | 3.71875 | 4 | """Pearson correlation from Hackbright Exercise."""
from math import sqrt
def pearson(pairs):
"""Return Pearson correlation for pairs.
Using a set of pairwise ratings, produces a Pearson similarity rating.
"""
series_1 = [float(pair[0]) for pair in pairs]
series_2 = [float(pair[1]) for pair in p... |
7a154a6168a4d65d3e2ec97c81cee5c103fd90ed | Funjando/Multiplication-table | /multiplication-table.py | 983 | 4.78125 | 5 | """
multiplication-table.py
Author: Funjando
Credit:
Assignment:
Write and submit a Python program that prints a multiplication table. The user
must be able to determine the width and height of the table before it is printed.
The final multiplication table should look like this:
Width of multiplication table: 10
H... |
5bc5d6ed84583140051012ab7781c695eae7c9e0 | Rasmussvebestad/INF200-2019-Exercises | /src/rasmus_svebestad_ex/ex04/myrand.py | 813 | 3.703125 | 4 | # -*- coding: utf-8 -*-
__author__ = 'Rasmus Svebestad'
__email__ = 'rasmus.svebestad@nmbu.no'
class LCGRand:
def __init__(self, seed):
self.a = 7 ** 5
self.m = 2 ** 31 - 1
self.r = [seed]
def rand(self):
self.r.append(self.a * self.r[-1] % self.m)
return self.r[-1]
... |
e1dde18ada9d2bd785b48f8d297f7672a2c033fc | jooker33/learning_tasks | /Копия task1_18 Vector Class.py | 441 | 4.0625 | 4 |
class vector():
def __init__(self,x_coord,y_coord):
self.x_coord=x_coord
self.y_coord=y_coord
def __add__(self,other):
return vector(self.x_coord + other.x_coord,self.y_coord+other.y_coord)
def __repr__(self):
return 'Vector({}, {})'.format(self.x_coord,self.y_coord)
vector_1=vector(1,3)
#Вывели значения... |
450e9d7c4e5143e58b9549bf128e3f835ce5e9b9 | Rodrigmav/Side-Projects | /StockPredictAI/StockPredictionGame.py | 6,527 | 4.09375 | 4 | import time
print ("Welcome to the Stock Prediction game")
time.sleep(1) # Delay for 1 second.
input("Please press enter to continue after each statement, including this one.")
print("")
print ("In this game, you will be given $10,000 to be spent on")
print ("a random stock of our choosing. The time at which yo... |
ef5ffea928030392b16e65fb302fee9f5e8a2e9e | wukaixingxp/CS321-AlphaZero-Project | /Gomoku Game/game1.py | 7,283 | 3.828125 | 4 | """
game1.py
This module represents the game of Connect 4.
@author Bryce Wiedenbeck
@author Anna Rafferty (adapted from original)
@author Kaixing Wu and James Yang (adapted from original)
"""
import numpy as np
HEIGHT = 15 # Height of the board
WIDTH = 15 # Width of the board
CONNECT = 5 # Number of items in a seq... |
0dd5fabfdbef36c22ac92f573912b7ec1d71b9cf | crakama/Python-Playground | /consonantReversal.py | 1,549 | 3.71875 | 4 |
"""
Given N strings, reverse and print each string such that the
positions of its vowels remain unchanged but all
its consonants are reversed
"""
N = "abcdefg"
v = "aeiuo"
# agfdecb
newString = []
def consonantReversal(N):
for i in N:
if i not in v:
newString.append(i)
... |
d934871101b5e0db92a6c67d1e435b1c378a915f | crakama/Python-Playground | /nestedLogig.py | 1,439 | 3.875 | 4 | """
Task
Your local library needs your help! Given the expected and actual return dates for a library book, create a program that calculates the fine(if any). The fee structure is as follows:
If the book is returned on or before the expected return date, no fine will be charged(i.e.: fine=0.
If the book is returned aft... |
d033f9adb10934511a7cf39fa2e230ec9de33da3 | crakama/Python-Playground | /maxdifference.py | 655 | 4.125 | 4 | """
Complete the Difference class by writing the following:
A class constructor that takes an array of integers as a parameter
and saves it to the instance variable.
A computeDifference method that finds the maximum absolute difference
between any numbers in and stores it in the instance variable
"""
class Di... |
547e7a46e55faf2a4d8710ad5a087a1ed271f50a | crakama/Python-Playground | /oddeven.py | 925 | 3.640625 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
class OddEvenIndex:
def oddevenIndexed(self,newString):
even = []
odd = []
for i in newString:
even = []
odd = []
for j in range(0, len(i)-1):
if j in i:
... |
b91378e3dabf688e77d7c072ee881a8491099c59 | kesarsatyam/Terribly-Tiny-Tales-Project | /Terribly Tiny Tales/src/app.py | 1,831 | 3.828125 | 4 | from flask import Flask,render_template,request
import urllib.request # urllib.request is a Python module for fetching URLs (Uniform Resource Locators)
app = Flask(__name__) # instance of a Flask class
dict = {}
url = "https://terriblytinytales.com/test.txt" # given url of txt file
file = urllib.request.urlopen(... |
f927551f85e348df96b32cf2348f085d0fb65769 | eobrie16/interviews | /web_scraping.py | 4,814 | 3.5 | 4 | #!/usr/bin/env python
#
# Web scraping
# ASNs (Autonomous System Numbers) are one of the building blocks of the
# Internet. This project is to create a mapping from each ASN in use to the
# company that owns it. For example, ASN 36375 is used by the University of
# Michigan - http://bgp.he.net/AS36375
#
# The site ht... |
fed3e3df3ee6983e80aa63a0944d1b7d30fbd990 | Rwilkins1/Codeup-Web-Exercises | /public/python/numbers.py | 105 | 3.65625 | 4 | var1 = 1
var2 = 10
var3 = 100
power = pow(var2, var3)
# square = sqrt(var3)
print power
# print square |
bf6f6645782a83923c67e5e2367c28b1bee71fe4 | adityavbhat/assignment9 | /Assignment9.py | 3,533 | 4.5 | 4 | '''Q1'''
'''Defining Circle class'''
class Circle():
def __init__(self, r):
self.radius = r
'''Initializing class with a Radius r'''
def getArea(self):
return self.radius ** 2 * 3.14
'''getArea() method to calculate Area'''
def getCircumference(self):
return 2 *... |
9b32d71c80ba1bcf91ae23c8ee7a6d57dd9c801b | augustelalande/HMM-text-correction | /sentence_generator.py | 1,474 | 3.765625 | 4 | from utils.data_parser import load_data
vocab, unigrams, bigrams, trigrams = load_data()
def gen_sentence():
"""Creates a randomly generated sentence according to some word distribution
Returns:
list: list of words representing the sentence
"""
start = 153
end = 152
# initialize the... |
469dbb5daa6c107953d03849087f16c82087320d | RonaldoLegrama99/Office_Solutions | /SalesByQuarter.py | 11,198 | 4.09375 | 4 |
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import sqlite3
import re
#Populates Sales By Quarter Sub Menu
#Allows users to enter input to see desired data insight
def SalesByQuarter():
xl = pd.ExcelFile("SalesData.xlsx")
SalesData = xl.parse("Orders")
# Decorating = "\n" + "*... |
4aa9cafddada93c4663392f45d7be05d873acf8a | dillondavis/Python-Text-Games | /bagels.py | 1,637 | 4 | 4 | import random
def getSecretNum(numDigits):
numbers = list(range(10))
random.shuffle(numbers)
secretNum = ""
for i in range(numDigits):
secretNum += str(numbers[i])
return secretNum
def getClues(guess, secretNum):
if (guess == secretNum):
return "You got it!"
clues = []
fo... |
a3e3612571d02e4999cb00bcc5691a5182dbb234 | anhaeh/pyescoba | /entities/player.py | 1,941 | 3.703125 | 4 | # coding=utf-8
"""
Abstract Class for human or IA player
"""
from entities.exceptions import ImplementationError
class Player(object):
def __init__(self, name, game):
self.name = name
self.game = game
self.hand = []
self.cards = []
self.escobas = []
self.points = ... |
22a868833ebed4c55c0902bf50900f6797e0ae15 | sramyar/algorithm-problems | /energy_interview.py | 839 | 4.125 | 4 | '''
So, in this interview question, I was asked to sort the
input based on frequency.
Example:
input <- [3,4,6,3,4,3,5]
output: [3,4,6,5]
'''
def dic_maker(l):
'''
input: list of numbers
output: a dictionary mapping key to frequency
loops through list and maps key to frequency
RETURNS dictionary
... |
11d562295810f5a63edf6bb05a7b7abe7a6fb28d | sramyar/algorithm-problems | /dlinkedlist.py | 1,874 | 3.6875 | 4 | '''
Implmentation of Doubly Linked List data structure
'''
class Node:
def __init__(self, val):
self.value = val
self.prev = None
self.next = None
class LinkedList:
def __init__(self):
self.n = 0
self.dummy = Node(None)
self.dummy.prev = self.dummy
... |
98328359f80842b27fb979e02f07f7126a469664 | sramyar/algorithm-problems | /search-rotated-sorted-array.py | 1,782 | 4 | 4 | '''
Suppose an array sorted in ascending order is rotated at some pivot unknown to
you beforehand.
(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
You are given a target value to search. If found in the array return its index,
otherwise return -1.
You may assume no duplicate exists in the array.
Your algorith... |
bc536fb24012436309ca9b7058728d9400dea6ef | sramyar/algorithm-problems | /pylink.py | 2,571 | 3.828125 | 4 | '''
You are given two NONEMPTY linked lists representing two non-negative integers.
The digits are stored in REVERSE ORDER and each of their nodes contain a single
digit. Add the two numbers and return it as a linked list.
Example:
Input: (2 -> 4 -> 3) + (5 -> 6-> 4)
Output: 7 -> 0 -> 8
'''
class node:
def __init_... |
cf50c7918858fbf80fe6ca0f42ee77ae0b155125 | sramyar/algorithm-problems | /roman-to-integer.py | 1,201 | 4.03125 | 4 | '''
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.
Example 1:
Input: "III"
Output: 3
Example 2:
Input: "IV"
Output: 4
Example 3:
Input: "IX"
Output: 9
Example 4:
Input: "LVIII"
Output: 58
Explanation: L = 50, V= 5, III = 3.
Example 5:
Input: "MCMXCI... |
611b955f56980f88171dc939b97f14765f295eaa | sramyar/algorithm-problems | /mergesort.py | 1,036 | 4.21875 | 4 | '''
Implementing the MergeSort algorithm
input >> [3,43,34,53,5]
output >> [3,5,34,43,53]
'''
def merge(l1,l2):
'''
input: sorted lists l1 and l2
output: one sorted list containing values in l1 and l2
'''
output = []
output_length = len(l1) + len(l2)
i = 0
while i < output_length:
... |
5a3f2a3ccfb14bd3f626a1e181e920f24cb40b41 | sramyar/algorithm-problems | /word-distance.py | 868 | 4.3125 | 4 | '''
Given a list of words and two words word1 and word2,
return the shortest distance between these two words in the list.
For example, Assume that words = ["practice", "makes", "perfect", "coding", "makes"].
Given word1 = "coding", word2 = "practice", return 3.
Given word1 = "makes", word2 = "coding", return 1.
... |
ae89cbf179697f9c8194fe8422d63c0dbe0fb604 | ArnarSnaer/TileTraveller | /TileTraveller1.py | 2,428 | 4.46875 | 4 | # Player starts in room 1.1 and needs to cross towards room 3.1 in a 3x3 maze with a few walls ahead
# In every room the choice of directions is prompted to the player and they will put the first letter
# to indicate their choice of direction.
# High and lower case letters are allowed but anything else will yield an er... |
c26aace52dc7ce33158f7d035b31ccf8905cbed8 | bmac2020/projeto_google | /algoritmo_google/core/iterativo.py | 4,600 | 3.703125 | 4 | #!/usr/bin/python3
class Constante:
"""
Essa classe cria a constante que será usada para encontrar o erro da solução iterativa.
Parâmetros:
- matriz_modificada : será usada para obter os valores pra gerar a constante.
- n_nodes : número de nós.
Funções:
- constante_C() : depoi... |
28028832eb0a94ba665af433fce43b3c8d05bb5c | lucilleshield24/My-Projects | /21 Game.py | 1,322 | 3.9375 | 4 | class Player:
def __init__(self, name):
self.name = name
def prompt(self, total):
self.number = int(input("{}, please choose 1, 2, or 3 to be added to the running total.".format(self.name)))
total = total + self.number
total = self.check2(self.number, total)
print(... |
a01445969e02876e209305686acf27425826f6c6 | aikiyy/AtCoder | /abc104/b.py | 201 | 3.75 | 4 | import string
s = input()
if s[0] == 'A' and s[2:-1].count('C') == 1 \
and len(set(s.replace('A', '').replace('C', '')) & set(string.ascii_uppercase)) == 0:
print('AC')
else:
print('WA')
|
6e34dfe372e0250e813d96379d5c6d854fa379aa | aikiyy/AtCoder | /arc067/c.py | 466 | 3.609375 | 4 | N = int(input())
def trial_division(n):
factor = []
for num in range(2, int(n**0.5)+1):
while n % num == 0:
n //= num
factor.append(num)
if not factor or n != 1:
factor.append(n)
return factor
d = {}
for i in range(2, N+1):
divisors = trial_division(i)
... |
e75134bb01c3229cc29d17765198a0e964225387 | alexander161198/homework | /technopark/task3_final_reducer.py | 1,379 | 3.6875 | 4 | #!/usr/bin/python
import sys
previous_key = None
city_name = ""
product_name = []
avg_price = []
min_price = []
for line in sys.stdin:
key, value = line.strip().split('\t')
value = value.split(':')
if key == previous_key:
if value[0] == 'cityname':
city_name = value[1]
else:... |
70d971b9a4bf0a436b7dfdf61fd542974a301e82 | ismaeldeprada/Python | /practica 6/practica 6-9.py | 931 | 4.03125 | 4 | """
#P6E9 - AUTOR: ISMAEL DE PRADA
Escribe un programa que te pida nombres de personas
y sus números de teléfono. Para terminar debe pulsar
“S” cuando te pida el nombre. El programa termina
escribiendo nombres y números de teléfono. Nota:
La lista en la que se guardan los nombres y números
de teléfono t... |
3ac59e0cead62bfc360b912d1dee956867af8185 | ismaeldeprada/Python | /practica 6/practica 6-12.py | 1,003 | 4.125 | 4 | """
#P6E12 - AUTOR: ISMAEL DE PRADA
Escribir un programa para jugar a adivinar un número
(el usuario piensa un número y el programa lo ha de adivinar)
. El programa empieza pidiendo entre qué números está el número
a adivinar y luego intenta adivinar de qué número se trata.
El usuario va diciendo si el número que... |
0c40806fc0eb7aa00975858d3e3fa1afd09e5279 | ismaeldeprada/Python | /practica5/practica 5-9.py | 434 | 3.921875 | 4 | """
#P5E9 - AUTOR: ISMAEL DE PRADA
Escribe un programa que pida la anchura y la altura de un rectángulo y lo dibuje de la siguiente manera:
Anchura del rectángulo: 5
Altura del rectángulo: 4
*****
* *
* *
*****
"""
anchura=int(input("Escibe la anchura del rectangulo "))
altura=int(input("Escribe la altura del rect... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.