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 |
|---|---|---|---|---|---|---|
be6f057cea8e9dd113cdba16556d94e3f8a08144 | dipalira/LeetCode | /String/541.py | 445 | 3.53125 | 4 | s = "abcdefg"
k = 2
def reverseStr( s, k):
"""
:type s: str
:type k: int
:rtype: str
"""
run = len(s)//(2*k)
start = 0
print(run)
s = list(s)
for i in range(0,run):
s[start:start + k] = reversed(s[start:start + k])
start += 2*k
if len(s[start:]) <k:
s[start:]... |
44b8843279e8b4b8ae962fa6c1a6c4b81111c243 | dipalira/LeetCode | /String/657.py | 337 | 3.703125 | 4 | moves = "UD"
def judgeCircle(moves):
"""
:type moves: str
:rtype: bool
"""
dic = {"D": [0,-1],"U":[0,1],"L": [-1,0],"R":[1,0]}
x,y = 0,0
for move in moves:
step = dic[move]
x+= step[0]
y+= step[1]
if x == 0 and y == 0:
return True
else:
return False
print(ju... |
343ee055ff68588d94dfb2622fa088550a9828a4 | dipalira/LeetCode | /String/345.py | 513 | 3.6875 | 4 | s = "leetcode"
def reverseString(s):
"""
:type s: str
:rtype: str
"""
start = 0
end = len(s) - 1
s = list(s)
vowels = set(list("aeiou"))
while (start < end):
if (s[start] in "aeiou") and (s[end] in "aeiou" ):
s[start], s[end] = s[end] ,s[start]
start +... |
089b0ef5844d670e717f593a80e294bf4acae456 | dipalira/LeetCode | /Arrays/53.py | 550 | 3.96875 | 4 | def maxSubArray( nums):
"""
:type nums: List[int]
:rtype: int
"""
### All negative and postive array
if all(num < 0 for num in nums):
return max(nums)
elif all(num > 0 for num in nums):
return sum(nums)
else:
curr_sum,max_sum = nums[0],nums[0]
for arr in nums[1:]:
... |
aa6adc6e7b9e3c165e9bb8f6e07c5e8ced0a8313 | dipalira/LeetCode | /Arrays/Flip.py | 172 | 3.734375 | 4 | x = [[1,1,0],[1,0,1],[0,0,0]]
output = []
for ele in x:
t = []
for e in reversed(ele):
if e == 1:
t.append(0)
else:
t.append(1)
output.append(t)
print(output)
|
daf62555433e2d4fcd82423f7585ec0abdb4a8fb | yamlfullsan/cursopython | /condicional.py | 226 | 3.84375 | 4 | print("Programa de evaluación")
nota_alumno=input("Introduce la nota: ")
def evaluacion(nota):
valoracion="aprobado"
if nota<5:
valoracion="suspenso"
return valoracion
print(evaluacion(int(nota_alumno)))
|
036f0569b83ac5ace50d1bcb0139130149165f83 | yamlfullsan/cursopython | /ifelse.py | 267 | 3.828125 | 4 | #Verificacion de acceso.
print("verificación de acceso")
edad_usuario=int(input("Introduce tu edad: "))
if edad_usuario<18:
print("No puede pasar")
elif edad_usuario>100:
print("Edad incorrecta")
else:
print("Puedes pasar")
print("Programa finalizado.") |
8ca1e88e9fe85afda7fc6ec7b341db932914a246 | sagarkumarpatel936/Singlestone_Python_dev | /src/app.py | 4,663 | 3.71875 | 4 | """
Imports required for the program
================================
read_parquet => Function to read the content of ".parquet" file into a dataframe.
read_csv => Function to read the content of ".csv" file into a dataframe.
sys => Module required to access command line arguments, which would contain path to fil... |
e8f35deacbb17f5da377637761b4b6b55366b8fc | suganyaarjunan/1 | /12.py | 63 | 3.578125 | 4 | rs=input()
if rs==rs[::-1]:
print("yes")
else:
print("no")
|
14364c64ce1bf7499d741412948f2c0f3c75026a | NivedithaCV/numpy | /cs.py | 275 | 3.515625 | 4 | #import module
import numpy as np
import matplotlib.pyplot as plt
from numpy import random
#seed(1)
#generate random points
data1 = random.rand(1000)
data2 = random.rand(1000)
#giving slope
m=4
#relation
y=m*data1+data2
#plot
plt.scatter(data1,y)
plt.show()
|
aba34c394cd1bae28a1b87a56485916392c32e68 | IDarkgenesis/LP-FIB | /Python/P84591.py | 1,011 | 3.59375 | 4 | def absValue(x):
if x < 0:
res= x*-1
return res
else:
return x
def power(x,p):
res= x
if p == 0:
return 1
for d in range(1,p):
res = res * x
return res
def isPrime(x):
if x < 2:
return False
for d in range(2, x//2 +1):
if x % d ==... |
c305f54649744ab4b07d0cc23e5bc11be5e8394f | MilaKarmilaSolisa/pgame | /pgame16105/code62.py | 573 | 3.796875 | 4 | # Pemrograman Game Praktikum 6
# latihan code 6.2 : Perulangan (Loop) while
batas='*'*30
# Contoh 1
x = 0
while (x < 5): # jika x lebih kecil dari 5 maka ulangi
# x = x + 1
x += 1 # x + 1
print(" Praktikum 6 no.", x)
print(batas)
# Contoh 2
# kombinasi while, if dan break
a = 0
while a < 6:
print(" no a == ", a)... |
51eb0d8dfbe9bc2853a032c6576610b82ae9a678 | MilaKarmilaSolisa/pgame | /pgame16105/code63.py | 439 | 3.875 | 4 | # Pemrograman Game Praktikum 6
# latihan code 6.3 : Perulangan (Loop) while
batas='*'*30
# Contoh 4
# Penggunaan while dan else
c = 1
while c < 6:
print("C == ",c)
c += 1
else:
print("batas c < 6")
print(batas)
# Contoh 5
# Penggunaan while dan list
buah = ["Apel", "Melon", "Durian"]
print("Buah 1: ",buah)
while ... |
cecd3ab890083eb3ad054ee2ea29f08467451f31 | CMSgov/beneficiary-fhir-data | /ops/ccs-ops-misc/synthetic-data/scripts/test_synthetic_file.py | 1,536 | 3.53125 | 4 | import sys
def validate_file(filename):
'''Validates synthea rif csv files and ensures that the file is valid for loading
into the pipeline. This is primarily designed to check synthea files for minor
errors post-generation. Validations can be added here as needed.
'''
passed = True
with ... |
c14c990b65850ebd213fad5b2e59a70f33279511 | Gra4evIN/Homework_SF_FPW_19 | /cats_1.py | 491 | 3.671875 | 4 | class Cat:
def __init__(self, name, gender, age):
self.name = name
self.gender = gender
self.age = age
def get_name(self):
return self.name
def get_gender(self):
return self.gender
def get_age(self):
return self.age
cat_1 = Cat("Baro... |
cab3db095da327698c912168ad9c67b0febd4fcc | kloonsicle/manor_final_project | /manor.py | 38,015 | 3.796875 | 4 | # Miranda LaBounty
# 9 May 2016
# Adventure game: MANOR HOUSE
# Explore the manor house to find you hamster Mr. Tibbles.
# Search rooms and its contents to find your hamster.
# Ask the house's inhabitants for advice or help when you come across them.
# VARIABLES
#dictionary of variables, by end of game all should ... |
9a80cb55d2c198e71a46455787f8cff7cdc619ad | martdev1963/my-Python-Code | /graphs.py | 601 | 3.75 | 4 | # making a basic bokeh line graph...
# importing Bokeh...
from bokeh.plotting import figure
from bokeh.io import output_file, show
# prepare some data...
# lists must have same length in order to plot them in Bokeh...cuz bokeh pairs them together...eg; x[1] and y[6] etc...
x=[1,2,3,4,5]
y=[6,7,8,9,10]
#... |
d66f9928e0d7d17bfc20686066e0b7cd6905a3d1 | Shubham255/Python-Practice-Programs | /calculator.py | 1,743 | 3.84375 | 4 | from operator import pow, truediv, mul, add, sub
operators = {
'+': add,
'-': sub,
'*': mul,
'/': truediv
}
def calculate(s):
if s.isdigit():
return float(s)
for c in operators.keys():
left, operator, right = s.partition(c)
if operator in operators:
... |
4d2b457feee30dbf6ca34f4dbdb83b1244d3d7fa | OpenRuhr/ris-scraper-allris | /pyallris/utils.py | 410 | 3.5 | 4 |
import pytz
import datetime
from pytz import timezone
utc = pytz.utc
tzinfo = timezone('Europe/Berlin')
def parse_date(s, tzinfo = utc):
"""parse dates like 20121219T160000Z"""
year = int(s[0:4])
month = int(s[4:6])
day = int(s[6:8])
hour = int(s[9:11])
minute = int(s[11:13])
second = int(... |
73d4dbc12fed8bc83ac68f19a31a729283c9a05f | cascam07/csf | /hw2.py | 2,244 | 4.34375 | 4 | # Name: ... Cameron Casey
# Evergreen Login: ... cascam07
# Computer Science Foundations
# Programming as a Way of Life
# Homework 2
# You may do your work by editing this file, or by typing code at the
# command line and copying it into the appropriate part of this file when
# you are done. When you are done, runnin... |
df7929c86f59a742e74aac1be7313eda4bf08ca2 | cascam07/csf | /recent_dates.py | 1,947 | 3.53125 | 4 | import time
def earlier_date(date1, date2):
"""
Given two da
tes as strings (formatted like "Oct 06 2012"), returns True if
date1 is after date2.
"""
return (time.strptime(date1, "%b %d %Y") < time.strptime(date2, "%b %d %Y"))
def most_recent_poll_row(poll_rows, pollster, state):
"""
G... |
a22be2f04db234ea046559e0081d9bfcacb9a7a6 | eastskim48/CS231n_assignments | /assignment1/cs231n/classifiers/softmax.py | 3,375 | 3.75 | 4 | import numpy as np
from random import shuffle
from past.builtins import xrange
from math import log
def softmax_loss_naive(W, X, y, reg):
"""
Softmax loss function, naive implementation (with loops)
Inputs have dimension D, there are C classes, and we operate on minibatches
of N examples.
Inputs:
- W: A ... |
95f01dcbb6e0bb6df64fc4816a3ff16abeb5c239 | sarathsankar3690/Djangopython | /functionalprogramming/excepti.py | 635 | 3.765625 | 4 | employees=[
{"names":"varun","desig":"develop","salary":40000,"join":2000,"resign":2008},
{"names":"ram","desig":"develop","salary":30000,"join":1989,"resign":1995},
{"names":"raju","desig":"qa","salary":28000,"join":2004,"resign":2010},
{"names":"ravi","desig":"qa","salary":32000,"join":2005,"resign":2... |
541f07016267b2865071d8bd5496a18ca01b360b | sarathsankar3690/Djangopython | /oops/person.py | 330 | 3.765625 | 4 | class Person:
def __init__(self,age,name):
self.age=age
self.name=name
P1=Person(16,"ajay")
P2=Person(42,"varun")
P3=Person(78,"Harrish")
lst=[]
lst.append(P1)
lst.append(P2)
lst.append(P3)
high=[]
for i in lst:
high.append(i.age)
m=max(high)
for i in lst:
if m==i.age:
print(i.name,i... |
24147732de634fcb19cc21fa852a811975c9e5f1 | sarathsankar3690/Djangopython | /pythoncollections/dictionaryprob/employeees.py | 532 | 3.921875 | 4 | employees={
1000:{"eid":1000,"ename":"ram","desig":"developer","salary":30000},
1001:{"eid":1001,"ename":"sreerag","desig":"tester","salary":20000},
1002:{"eid":1002,"ename":"amit","desig":"trainee","salary":15000}
}
eid=int(input("Enter the eid: "))
property= input("Enter the property: ")
if eid in employe... |
b7732ad98509484af69970e8d898a4fd862b8d05 | sarathsankar3690/Djangopython | /pythoncollections/set/setprgrm1.py | 155 | 3.703125 | 4 | lst={10,20,20,20,30,30}
st=set(lst)
print(st)
# st={10,20,20,30,"hello",30,40}
# st2={100,200}
# st.update(st2)
# print(st)
# for num in st:
# # print(num) |
1386618e22bfa6299cdd7299239f3b7e34433acf | sarathsankar3690/Djangopython | /Flow controls/Looping/sum of cubes.py | 129 | 3.859375 | 4 | n=int(input("Enter the digits: "))
digits=0
sum=0
while (n!=0):
digits=n%10
sum=sum+(digits**3)
n=n//10
print(sum)
|
953c6e324f34f83ad2ad79a3ae9457dedfa80a4b | sarathsankar3690/Djangopython | /pythoncollections/listPrograms/list/nestedlist.py | 808 | 4.03125 | 4 | employees=[
[100,"Jack","developer",25000],
[101,"john","developer",18000],
[103,"jinu","tester",28000],
[104,"dinu","manager",30000]
]
# for employee in employees:
# print(employee[1])
# for job in employees:
# if job[2]=="developer":
# print(job)
# total=0
# for salary in employees:
#... |
b41aa3ecebb05e6bb26a61880a170c027b29aff2 | sarathsankar3690/Djangopython | /Language fundamentals/trial.py | 118 | 3.921875 | 4 | num1=int(input("Enter the first number"))
num2=int(input("Enter the second number"))
sum=num1+num2
print("sum is",sum) |
3a17090e0f306201b2394165aee6c1ff77c99d1d | sarathsankar3690/Djangopython | /pythoncollections/filesprgrms/wordss.py | 233 | 3.5625 | 4 | f=open("words","r")
lst=[]
dict={}
for w in f:
words=w.rstrip("/n").split(" ")
for wordss in words:
lst.append(wordss)
# for wordss in lst:
# print(wordss)
# wrdset+=w.rstrip("/n").split(" ")
# print(wrdset) |
8a5eeb0db7fee0660f8e10bb8f7789afbf14d0db | sha9127/PythonPragrams | /4.PalindromeNumber.py | 239 | 3.96875 | 4 | n=int(input('Enter Number to Reverse :'))
temp=n;
rev=0
while(temp!=0):
rem=temp%10
rev=rev*10+rem
temp=temp//10
print('Revesesd no is :',rev)
if rev==n:
print('No is Palindrome')
else:
print('No is not Palindrome')
|
fc03323078bf279a2ae4dd91180d3ac52ee69829 | sha9127/PythonPragrams | /6.TableOfAnyNumber.py | 97 | 3.765625 | 4 | n=int(input('Enter Number to Print Table :'))
for i in range(1,11,1):
print(n,'*',i,'=',i*n) |
074bc469defc143ca897431c693b01a93c897f2f | skinitimski/euler | /euler/problem1.py | 369 | 3.796875 | 4 | def multiples(factor, limit):
i = 1
while i * factor < limit:
yield i * factor
i += 1
def sum_of_multiples(limit):
deduped = set(multiples(3, limit)) | set(multiples(5, limit))
return sum(deduped)
def show():
print(sum_of_multiples(10))
print(sum_of_multiples(1000))
d... |
efc99599451c614057fa3a281a58926587d6dad3 | skinitimski/euler | /euler/problem6.py | 361 | 3.8125 | 4 | from math import pow
def sum_of_squares(n):
return sum([x * x for x in range(1, n + 1)])
def square_of_sum(n):
return int(pow(sum(range(1, n + 1)), 2))
def difference(n):
return square_of_sum(n) - sum_of_squares(n)
def show():
for i in range(10, 101, 10):
print(i, difference(i))
d... |
106e9420c27de71c83e0a1ff4304509ad3651ee5 | rowanlupton/aoc-2018 | /d1_1.py | 476 | 3.578125 | 4 | from typing import Iterable
def process_frequency_changes(
changes: Iterable[str],
initial_value: int = 0
) -> int:
value = initial_value
for change in changes:
if change[0] == '-':
value = value - int(change[1:])
else:
value = value + int(change[1:])
return... |
05a7f4876f529004d0d345392a0a56b87a3eacb7 | Skp80/mle-tech-interviews | /data-structure-challenges/leetcode/371. Sum of Two Integers.py | 1,145 | 4.0625 | 4 | """
Given two integers a and b, return the sum of the two integers
without using the operators + and -.
Example 1:
Input: a = 1, b = 2
Output: 3
Example 2:
Input: a = 2, b = 3
Output: 5
Constraints:
-1000 <= a, b <= 1000
Learnings:
- Almost got it right the xor with and trick with shifting,
I just missed ... |
5a72ce6107839317fb4c3ab167ab3768b0a32225 | Skp80/mle-tech-interviews | /data-structure-challenges/leetcode/1249. Minimum Remove to Make Valid Parentheses.py | 3,248 | 4 | 4 | """
Given a string s of '(' , ')' and lowercase English characters.
Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions )
so that the resulting parentheses string is valid and return any valid string.
Formally, a parentheses string is valid if and only if:
It is the empty ... |
9083333e1c23ba14e63284f8bb625fc351395a28 | Skp80/mle-tech-interviews | /data-structure-challenges/leetcode/463. Island Perimeter.py | 2,893 | 3.90625 | 4 | """
In an alien language, surprisingly they also use english lowercase letters,
but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.
Given a sequence of words written in the alien language, and the order of the alphabet,
return true if and only if the given words are s... |
8bbd6935cc49c5280a79327c61d90ffb2ef5889c | Skp80/mle-tech-interviews | /data-structure-challenges/leetcode/543. Diameter of Binary Tree.py | 1,658 | 4.25 | 4 | """
Given the root of a binary tree, return the length of the diameter of the tree.
The diameter of a binary tree is the length of the longest path between any two nodes in a tree.
This path may or may not pass through the root.
The length of a path between two nodes is represented by the number of edges between ... |
44a4ad07283ccbb8202cf2bbd407646fdcf52b6b | Skp80/mle-tech-interviews | /data-structure-challenges/leetcode/171. Excel Sheet Column Number.py | 853 | 4 | 4 | """
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
Example 1:
Input: "A"
Output: 1
Example 2:
Input: "AB"
Output: 28
Example 3:
Input: "ZY"
Output: 701
Constraints:
1... |
47fcd5771ae2861c0e5b677d3518b84065d34c70 | wduan2/misc | /roller/roller.py | 2,577 | 3.625 | 4 | #!/usr/bin/env python3
from random import randint
class Roller:
def roll(self, expr):
"""
Evaluate a D&D dice expression.
TODO: support +/- expression, e.g. (3d2-1)d(5d6+7)
:param expr:
:return:
"""
left, right = self.__split(expr)
# Note: if th... |
2e17e4c875a14c7bbfbe7e7af027dd573ab56ade | DayongTong/MEAM517_Project_Git | /sync_project.py | 1,123 | 3.625 | 4 | """
Synchronize homework files (link to google drive's hw files; if hw files don't exist in google drive, download files from github)
"""
import os
from os import path
from shutil import copyfile
import urllib.request
from pathlib import Path
import re
def sync_project(files, from_master_branch=True):
if 'google.co... |
5bb2505051c52dd6ac74ab7650b0f7c7726545d2 | starFaby/cursoPython | /parte 1-10/bAsignacionValor.py | 455 | 3.8125 | 4 | numero = 10.56
print(numero);
print(type(numero));
cadena = 'hola fabian como estas';
print(cadena);
print(type(cadena));
cadena1 = 'hola fabian como estas "exelent"';
print(cadena1);
print(type(cadena1));
valor = False;
print(valor);
num1 = 10.56;
num2 = 12.52;
suma= num1 + num2;
print('La suma es: ',suma);
print(... |
9086e676e72f459b15df69d93859f939f4cb4a0f | starFaby/cursoPython | /parte 20 - 30/iConjuntos.py | 930 | 4.21875 | 4 | # Conjuntos
# Conjuntos nos muestra cunado existe un numero repetitivo ya no se mostarar lo quitara
print('Conjuntos nos muestra cunado existe un numero repetitivo ya no se mostarar lo quitara')
conjunto = set()
conjunto = {1,2,3,4,5,1}
conjunto.add(4)
conjunto.add(6)
print(conjunto)
# Para quitar del conjunto
print('... |
8c4faf96ce42b6183328eb538e836d64c9747a67 | starFaby/cursoPython | /parte 20 - 30/gListasAvanzada.py | 2,153 | 4.09375 | 4 | listA = ['a','b','c','d']
print(len(listA))
print(listA)
# agregar un objeto mas
print('aumentamos uno mas')
listB = ['a','b','c','d']
listB.append('e')
print(listB);
#agregamos un item como string
print('agregamos uno que tiene string')
listaC = ['a','b']
listaC.append('c')
listaC.append('faby')
print(listaC)
#agregam... |
497d905fe654fcb5dbee91028a4bbea079e6a90e | belinabelortaja/python_fundamentals | /basic_functions_II.py | 1,010 | 3.65625 | 4 | #1
def countdown(myList):
myNexList = []
for x in range(myList, 0, -1):
myNexList.append(x)
return myNexList
print(countdown(7))
#2
def prRet(a,b):
print(a)
return b
print(prRet(1,4))
#3
def firstPlusLength(myList):
sum=0
for sum in range (0,len(myList),1):
... |
800061eca1e7e1c2443be83f54799002f22eb5b2 | CornPrincess/Automate-the-Boring-Stuff-with-Python | /code/Chapter2/test.py | 695 | 3.921875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun May 5 20:01:37 2019
@author: zhoutianbin
"""
#total = 0
#for num in range(101):
# total += num
#print(total)
#for i in range(0, 10, 2):
# print(i)
#for i in range(5, -1, -1):
# print(i)
#def spam():
# eggs = 31337
#
#spam()
#print(eggs)... |
48d6d09db68abb04e8745dd18deadf47527a005d | drbuche/python-design-patterns | /Structural/Facade/Facade.py | 1,924 | 3.703125 | 4 | class Estalajadeiro:
def __init__(self):
print("-------------------------------------------------------")
print("Estalajadeiro: Vou verificar se temos tudo, um segundo.")
print("-------------------------------------------------------")
def trabalhando(self):
self.Camareira = Ca... |
4ab01da115dfb71ebb94ca56e06f4f07d202731a | JokusPokus/pcb_shop | /src/price/calculate_board_price.py | 351 | 3.8125 | 4 | from random import randint
class BoardPriceCalculator:
"""A class that calculates a price for a given board configuration."""
@staticmethod
def calculate_price(board_attributes: dict) -> float:
"""Returns the current price for a given board configuration."""
toy_price = randint(200, 1000) ... |
5fc69400df7d0d720f89d57d813d77f85d0123f8 | zkr-origin-data-dpt/ODtools | /ODtools/excel_tools.py | 1,195 | 3.515625 | 4 | import xlrd
import xlwt
def read_excel(filename: str = None, sheet: str = "Sheet1", read_by_row: bool = False):
"""
read excel
:param filename: excel name
:param sheet: excel table
:param read_by_row: read by row or read by column
:return:
"""
assert filename, "No such file or director... |
e0a5161ce9b3d175ae8eca9a1c718c5a9a6e06c3 | roshanshilpakar/CommonPythonpgms | /massDensityVolume.py | 507 | 4.03125 | 4 | mdv = input("Choose one to calculate(m,d,v) : ")
if mdv == 'm' or 'M':
d = float(input("Please enter Density: "))
v = float(input("Please enter Volume: "))
result = d*v #This is for mass
elif mdv == 'd' or 'D':
m = float(input("Please enter Mass: "))
v = float(input("Please enter Volumn: "))
re... |
1e9eeee77f9d915b714b105cc4a16bb5b1e0d7f2 | mickaelthebox/cathy-machine-learning | /ML-youtube/v4.py | 235 | 3.796875 | 4 | def fibonaci(n):
a = 0
b = 1
while a < n:
print (a)
a, b = b, a+b
# return list
fi = []
def fiboo(n):
c = 0
d = 1
while c < n:
fi.append(c)
c,d = d, c+d
print (fi)
fiboo(10) |
94dac0f39afe43b041948e20de43453efe89b1b8 | mbd9441/FloodFill | /flood.py | 5,212 | 3.671875 | 4 | import random
import copy
class FloodFill:
colors=["red", "blue", "green", "yellow", "purple", "orange"]
colorvals=['r','b','g','y','p','o']
board = []
lastboard = []
size = 0
boardString = ''
lastcolor = ''
maxturn = 1
turn = 0
replay = False
game = True
def __init__(s... |
f0881f9ec77a982825071ed8106c4900278ac1a5 | vuthysreang/python_bootcamp | /sreangvuthy17/week01/ex/17_str_last.py | 625 | 4.40625 | 4 | """ Description : You will write a program that ask for one string as and return the last character.
If no argument is passed, display “Empty”
Requirements : ● Program must be named : 17_str_last.py and saved into week01/ex folder
Hint : ❖ print function
❖ string ind... |
b09cbe34ac66a41d58ab047f0dfbb6024c9a105e | vuthysreang/python_bootcamp | /Documents/week03/sreangvuthy17/week03/ex/45_auto_folder.py | 2,173 | 4.46875 | 4 | """
Description : You will create a program that take a list of string as argument, that represents folders names.
Then, for each, you will create a folder with the corresponding name.
Before create anything, you will check that the folders doesn’t already exists.
... |
201dac84630f55ffceb24392cd58051b66e60495 | vuthysreang/python_bootcamp | /sreangvuthy17/week01/ex/08_random.py | 465 | 4.28125 | 4 | """ Description : You will write a program that take display a random number between 1 and 100
Requirements : ● Program must be named : 08_random.py and saved into week01/ex folder
Hint : ❖ print function
❖ random
"""
# import random library
import random
# print random output between ... |
421e2d5f4300102b66651efd180d3dbd6bf66a82 | vuthysreang/python_bootcamp | /sreangvuthy17/week01/ex/06_odd_even.py | 1,491 | 4.46875 | 4 | """ Description : You will write a program that take will ask for a number in parameter and display “<number> is EVEN” or “number is ODD”.
If the number is not an integer, you will have to display “<input> is not a valid number.”.
If you enter “exit” or “EX... |
926c19499256827be9c6f281257082f307432908 | vuthysreang/python_bootcamp | /Documents/week03/sreangvuthy17/week03/ex/59_regex_html.py | 1,235 | 4.1875 | 4 | """
Description : You will create a function that take a string in parameter and remove every HTML content ( everything between ‘<’ and ‘>’ ) You will return the new formatted string.
You need to do it using REGEX only.
EXAMPLE :
regex_html("<html lang = 'pl' >... |
a287483a91fa92fd183f524039b0255d4ea11f7d | vuthysreang/python_bootcamp | /sreangvuthy17/week02/ex/35_current_time.py | 1,079 | 4.3125 | 4 | """
Description : You will write a function that return the current time with the following format: hh:mm:ss The return value must be a string.
Requirements : ● Program must be named : 35_current_time.py and saved into week02/ex folder
Hint : ❖ function
❖ datetime
Output :
... |
afe3f0b634798f0476ccd2a5bfce3113b8511925 | vuthysreang/python_bootcamp | /sreangvuthy17/week01/projects/03_tax.py | 1,523 | 3.875 | 4 | """
PROJECT 03: Tax Caculation
"""
# declaration the variable
program = True
running = True
# check loop condition
while running == True:
# user input number of amount
amount = input("Please enter your amount:\n>> ")
# check the condition
if amount.isdigit() == False or int(amount) < 0:
# p... |
0613d7beaa42dfe4acbccbcd93a154f788ba7c6f | vuthysreang/python_bootcamp | /sreangvuthy17/week03/ex/41_current_path.py | 577 | 4.15625 | 4 | """
Description : You will write a function that print the current path of your program folder, then you will return it as a string.
Requirements : ● Program name : 41_current_path.py
● Function name : current_path
● Directory : week03/ex folder
Hint : ❖ ... |
d8948deaeedfeaacaed947a20d81923ffd48f093 | vuthysreang/python_bootcamp | /sreangvuthy17/week01/ex/01_welcome.py | 309 | 3.8125 | 4 | """ Description : You will write a program that display “Welcome to Kirirom!”.
Requirements : ● Program must be named : 01_welcome.py and saved into week01/ex folder
Hint : ❖ print function
"""
# use print function to print or to show the output
print("Welcome to Kirirom!")
|
4b342ac196cfdd19c1b26b5770653cfe4170977f | DarriMT/improved-meme | /format.py | 183 | 3.984375 | 4 | a = [ 5 , 1 ,4,3,1]
str1 = ""
for element in a:
temp = str(element)
str1+= temp
print(str1)
temp = "| "
for chr in str1:
temp+= chr + " | "
print(temp)
|
ecbe228e92d28ab0423e5c98e637c170bfedba2f | inffille/test01 | /display.py | 948 | 4.03125 | 4 | import number
import operation
import tkinter as tk
class Display:
def __init__(self):
self.root = tk.Tk()
self.lbl = tk.Label(self.root, text = "Insert Numbers")
self.lbl.grid(row = 0, column = 0)
self.entry = tk.Entry(self.root)
self.entry.grid(row = 0, column = 1)
def run(self):
self.root.bind('<Butt... |
66cdad3fb6965b8b48dfb8981729129c75c9f17c | cnlong/everyday_python | /02_day_coupon/随机激活码升级版2.py | 1,008 | 3.59375 | 4 | import random
import string
class Coupon(object):
def __init__(self, num, length, file):
self.num = num
self.length = length
self.file = file
def coupon_store(self):
data = ''
count = 1
for i in range(self.num):
# coupon的内容每次循环需要清空,不然会被下次调用
... |
5bcf6047d4aad5fdf63ed6e6dfbf398b2d94ca1e | cnlong/everyday_python | /02_day_coupon/test2.py | 435 | 3.75 | 4 | import string
# 打印所有的小写字母
print(string.ascii_lowercase)
# 打印所有的大写字母
print(string.ascii_uppercase)
# 打印所有的大小写字母
print(string.ascii_letters)
# 打印0-9的数字
print(string.digits)
# 打印所有的特殊字符
print(string.punctuation)
# 打印空字符
print(string.whitespace)
# 打印所有的字符
print(string.printable)
# 打印0-7的所有数字
print(string.octdigits) |
e9833f4c8361a22d5e76e394fb79fcdbd617d268 | cnlong/everyday_python | /02_day_coupon/test1.py | 1,004 | 4 | 4 | import random
# 随机生成0到1范围之间的一个随机数
print("随机数1:", random.random())
# 在指定范围内生成随机数
print("随机数2:", random.uniform(2, 6))
# 在指定范围内生成随机整数
print("随机数3:", random.randint(6, 8))
# 在指定范围中,按指定基数递增生成的数据集合中随机获得一个数,三个参数,前两个为上下限,第三个为递增增量
print("随机数4:", random.randrange(1, 10, 2))
# 从序列中获取一个随机元素
print("随机元素1:" , random.choice("www.xi... |
a04637baf45409e28191f5a622a344bc0e56f137 | cnlong/everyday_python | /24_Devops/Sec_5/5.1/test_file.py | 442 | 3.984375 | 4 | """
实例:将文本中的所有单词的首字母大写
"""
with open('data.txt') as inf, open('out.txt', 'w') as outf:
# for line in inf:
# outf.write(" ".join([word.capitalize() for word in line.split()]))
# 需添加换行符,不然新添的字符连接在一起
# outf.write('\n')
for line in inf:
# print默认自带换行
print(*[word.capitalize() f... |
1d744c54b9913e12f3c89332931e564e2b6805ab | cnlong/everyday_python | /19_chat-room/asyncio/test4.py | 909 | 3.984375 | 4 | """
协程嵌套
"""
import asyncio
import time
def now():
return time.time()
async def do_some_work(x):
print("Waiting:",x)
await asyncio.sleep(x)
# time.sleep(x)
return "Done after {}s".format(x)
async def main():
cor1 = do_some_work(1)
cor2 = do_some_work(2)
cor3 = do_some_work(4)
... |
00fe563bafd7659957bebe621439c9ffcb409e5c | pietergmail/school | /1ejaar(2018-2019)/2e semester/scriptalen/ExamJanuary 2019/exercises/finalize.py | 1,048 | 3.578125 | 4 | import zipfile
import sys
import os
problem_names = [
'collapse-empty-lines',
'cyclic-list',
'find-keys',
'remove-duplicates',
'successors',
'zip-contains'
]
for expected_directory in problem_names:
expected_file = "{}/student.py".format(expected_directory)
if not os.path.isdir(exp... |
b871698ef37869b24c88fde90905251f1c57fc84 | pietergmail/school | /1ejaar(2018-2019)/2e semester/scriptalen/examen-scripting/hash/student.py | 1,573 | 3.90625 | 4 | import hashlib
def hash_file(filename):
with open(filename, 'r') as file:
data = file.readlines()
ret = ""
for line in data:
line = line.replace('\n', '')
hs = hashlib.sha256(line.encode('ASCII')).hexdigest()[:10]
ret += hs+"\n"
with open(filen... |
78550745897b99e2446174734c79d197079cdc7b | cl522/pokerpy | /Objects/table.py | 2,107 | 3.5 | 4 | """=================================================================================================
// POKERPY :
// Python code for automated poker learning and playing.
// https://github.com/ajw278/pokerpy.git
// Contact : ajwinter@ast.cam.ac.uk
// Contributors : Andrew Winter, Pablo Lemos Portela, Cameron Lemon... |
0d41e4c1f4bcec804d4733f9d0ba63604df50dd1 | Rup-Royofficial/Codechef_solutions | /Smallest Number of Notes.py | 472 | 3.734375 | 4 | if __name__ == '__main__':
currencies = [100, 50, 10, 5, 2, 1]
for i in range(int(input())):
exchange_currency = int(input())
notes = 0
for currency in currencies:
rem = exchange_currency % currency
div = int(exchange_currency / currency)
if di... |
e555d535b1174619f04cf8ccd2c3654c8e276a68 | Rodolfodq/SharringBooksBot | /menu/import_json.py | 1,214 | 3.5 | 4 | import os
import json
from re import escape
from cadastro_livro import novos_livros_json
import urllib.request, urllib.error
def json_import_livros_arquivo(user):
os.system("cls")
path_json = input("Informe o caminho completo do arquivo Json: ")
try:
with open(path_json, "r", encoding="utf-8") as j... |
33c0225595aa8329c0a6ad8f2f09cda36be25076 | regasj2018/Hwspring2018 | /Hw6/p1.py | 468 | 3.84375 | 4 | type = raw_input("If you would like to enter an entire game enter 1, if you would like to enter in a game every turn enter in 2")
if(type == "1"):
score = map(int, raw_input("Enter your score frame by frame seperated by a comma").split(","))
print(str(sum(score)))
if(type == "2"):
frame = 0
frame = frame + 1
... |
4b4d315da5d552a3400b62cbeb1cadfab694cda5 | azlaanmsamad/MultiAgentDQRNForDifferentTrafficDemands | /aienvs/FactoryFloor/Map.py | 5,315 | 3.59375 | 4 | from random import Random
import random
from numpy import array, ndarray
import copy
class Map():
"""
Contains a static (immutable) discrete square map
Each position in the map can have various values,
eg a free space or a wall.
This map is like a paper map of the environment,
so without movi... |
627017f467c70ecbbccedbb417f80dc26c4e8b2e | YuanKQ/leetcode | /out/production/leetcode/Stack/binary-tree-traversal/binary-tree-inorder-traversal.py | 1,445 | 4.0625 | 4 | #-*- coding: utf-8 -*-
"""
*****************************************
@Time : 2018/2/11 18:27
@Author : Yuan Kaiqi
@Site :
@File : binary-tree-inorder-traversal.py
@Software: PyCharm
@Desctiption:
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tr... |
334a2196cbfb16f73bd5a754b3b9ee4238011a90 | YuanKQ/leetcode | /out/production/leetcode/Linkedlist/partition-list/partition-list.py | 3,142 | 3.9375 | 4 | #-*- coding: utf-8 -*-
"""
*****************************************
@Time : 2018/2/7 22:00
@Author : Yuan Kaiqi
@Site :
@File : partition-list.py
@Software: PyCharm
@Desctiption:
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal t... |
db376adaf8613aa0e8b5a4640de1d5707a6e67fc | YuanKQ/leetcode | /out/production/leetcode/Linkedlist/Linked_List_Cycle/linked_list_cycle.py | 1,557 | 3.96875 | 4 | #-*- coding: utf-8 -*-
"""
*****************************************
@Time : 2018/2/5 14:04
@Author : Yuan Kaiqi
@Site :
@File : linked_list_cycle.py
@Software: PyCharm
@Desctiption:
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra spa... |
8a91b0fe44f0f59f2e557a924e8946147fa5c804 | powellb/seapy | /seapy/qserver.py | 2,886 | 3.6875 | 4 | #!/usr/bin/env python
"""
This module will execute any number of tasks using a queue of the
specified number of threads.
Define a list of qserver.task objects and then tell the server to
execute the list with a given number of threads.
**Examples**
>>> tasks = (qserver.os_task("list files","ls -1"),
>>... |
8b3aa7b0684c1533560c6a589dc8986d378e5268 | pritusingh/pritu | /list.py | 406 | 3.78125 | 4 | >>> list=[1,2,3,4,5,6]
>>> def myfunc(n):
print(n)
>>> myfunc(list)
[1, 2, 3, 4, 5, 6]
>>> list
[1, 2, 3, 4, 5, 6]
>>> t=1,2,3,4,6
>>> t=1,2,3,4,6
>>> t
(1, 2, 3, 4, 6)
>>> EMP={'Name':'ABC','AGE':23}
>>> EMP
{'Name': 'ABC', 'AGE': 23}
>>>list(range(10))
[0,1,2,3,4,5,6,7,8,9]
print(list(range(10)))
[0,1,2,3,4,5,6,7,8,... |
3cdfa0170ed1f6f4b72f33b60161f96f0f357df2 | ICDT-Official/Python3-Programs | /09. reverse printing in a same line.py | 82 | 3.90625 | 4 | n=int(input("enter the value: "))
for i in range(n,0,-1):
print(i,end=' ')
|
d05ad3e8acfeadfa772ea787ca99256d731084f9 | carchi8py/deep-learning | /week3/bag_of_words.py | 299 | 3.875 | 4 | from collections import Counter
def bag_of_words(text):
"""
By doing doing it this way vs a dictionary we keep the order of the words
which is important.
"""
return Counter(text.split())
test_text = 'the quick brown fox jumps over the lazy dog'
print(bag_of_words(test_text))
|
e7716c76092eddf57e5a9b9002cc340b0b5ac970 | sekR4/java-programming | /03_arrays-lists-data/notes.py | 239 | 3.9375 | 4 | def reverse(s):
# NOTE: reversing strings in python can be done easier
# here I am just playing through the java loop example
ret = ""
for k in range(len(s)):
ret = s[k] + ret
return ret
print(reverse("fun"))
|
33f54917bf7dbc4054342392b97ef7fb353193ff | etaliorum/learning-tasks | /word-dict-count/count-word.py | 1,234 | 3.703125 | 4 | # Когда Антон прочитал «Войну и мир», ему стало интересно, сколько слов и в каком количестве используется в этой книге.
# Помогите Антону написать упрощённую версию такой программы, которая сможет подсчитать слова, разделённые пробелом и
# вывести получившуюся статистику.
# Программа должна считывать одну строку со ста... |
d9486febfb4845da453c3a2398a42afa9c5e4548 | rupendra-p/Projects | /while loop.py | 48 | 3.5 | 4 | n=1
a=1
while n<5:
a=a*n
n=n+1
print(a)
|
2eaa1200b990bfbe6abeefc5edb362b95278df56 | rupendra-p/Projects | /WhileLoop.py | 79 | 3.890625 | 4 | z=" "
for i in range(5):
x=input("Enter your number")
z = z+x
print(z) |
0f0588c331a6fcdec6ef5ffabf4ceb904bd48279 | rupendra-p/Projects | /For loop Break.py | 75 | 3.53125 | 4 | for i in range (5):
print(i)
if i == 2:
break
i = i + 1 |
195bbc1afa3a7bb882720b35e2040b2148802345 | benjamin-chavez/Rest-APIs-with-Flask-and-Python---Udemy-CourseWork | /Section 3: Your first REST API/3.59 - Creating our application endpoints/app.py | 2,196 | 3.5 | 4 | from flask import Flask, jsonify, request, render_template
app = Flask(__name__)
# List of Dictionaries
stores = [
{
'name': 'My Wonderful Store',
'items': [
{
'name': 'My Item',
'price': 15.99
}
]
}
]
@app.route('/home')
def ho... |
aa27c29c3a7884b708bcb5490e6698ad96ec275b | Wright2533/cti110 | /P2HW1_CelsiusConverter(Resubmit)_ShawnWright.py | 374 | 4.28125 | 4 | # Celsius Fahrenheit Converter
# 9/10/18
# CTI-110 P2HW1 - Celsius Fahrenheit Converter
# Shawn Wright
#
#temperature in celcius c= celcius
c = float(input('Enter temperature in celsius: '))
#convert farenheit F = Fahrenheit FE = 9/5c
FE = c* 1.8
F = FE + 32
#show the conerted temperature in Fare... |
ea671944c359485417e928f7f5e6c3503740016e | jlevy44/LearningScripts | /Program 3/firstCGI.py | 240 | 3.515625 | 4 | #!/usr/local/bin/python
print "Content-Type: text/html"
print "<html>"
print "<head><title>Hello!</title></head>"
print "<body>"
print "<p> It Works!!! </p>"
for i in range(5):
print "<h1>Hello World"
print "</body>"
print "</html>"
|
e7a6f782b9804a0aa14e7b17e57322c1d6020178 | YatharthAndharia/003_YatharthAndharia | /lab1.py | 2,017 | 3.546875 | 4 | """import nltk # Python library for NLP
from nltk.corpus import twitter_samples # sample Twitter dataset from NLTK
import matplotlib.pyplot as plt # library for visualization
import random"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from google.colab import drive
drive.mount('/content/driv... |
7a417ec6554a9319172e0e6c681daef9c65a2f4a | mongolio/PRNE_practice | /Tkinter_fun.py | 410 | 3.625 | 4 | import Tkinter as tk
def printNum(num):
""""""
print "You pressed the %s button" % num
parent = tk.Tk()
frame = tk.Frame(parent)
frame.pack()
btn22 = tk.Button(frame,
text="22", command=lambda: printNum(22))
btn22.pack(side=tk.LEFT)
btn44 = tk.Button(frame,
... |
0334029c17b20ea70d0ca8d39cebf1e79b017780 | Akpandita/Competitive-Coding | /Codechef/Practice/TRISQ.py | 223 | 3.5 | 4 | x=int(input())
for i in range(x):
sum1=0
p=0
j=0
t=int(input())
while j>=0:
p=(t-2)/2
sum1+=j
j, d = divmod(p, 1)
t-=2
if sum1<0:
sum1=0
print(int(sum1))
|
0e34f8afd00a2a88de4cb184a47b2042a1234b43 | anversa-pro/ejerciciosPython | /operadores.py | 371 | 3.53125 | 4 | #!usr/bin/python
# -*- coding: utf-8 -*-
primer_numero = 10
segundo_numero = 5
suma = primer_numero + segundo_numero
resta = primer_numero - segundo_numero
multiplicacion = primer_numero * segundo_numero
division = primer_numero / segundo_numero
potencia = primer_numero ** segundo_numero
print(suma)
print(resta)
pr... |
2a188890d815ae102e0904feac671f456cd9e59a | anversa-pro/ejerciciosPython | /ahorcado.py | 2,262 | 3.875 | 4 | import random
IMAGES = ['''
+---+
| |
|
|
|
|
========''', '''
+---+
| |
O |
|
|
|
========''', '''
+---+
| |
O |
| |
|
|
========''', '''
+---+
| |
O |
/|... |
a075edb4de5ac8b34032dd82dee03978fbf0b6ac | anversa-pro/ejerciciosPython | /excepciones.py | 1,665 | 4.21875 | 4 | #usr/bin/python
# -*- coding: utf -*-
print(""" Lo que hace try es ejecutar un bloque de sentencias en un “entorno controlado”, para que el error generado (si se da) no detenga el programa, sino que se retorne de modo que pueda manejarse.
Por ejemplo, el clasico error de la division por 0 hara que el programa falle ... |
22b278bdc150f38ccc1c2e22e74a1cc5b35d1dd4 | MagnusFlieger/PythonControl | /Python_Control/GUI.py | 6,112 | 4 | 4 | """
This module provides all functions necessary for displaying the GUI
control window
"""
import pygame
# Color constants
BLACK = ( 0, 0, 0)
WHITE = ( 255, 255, 255)
GRAY = ( 128, 128, 128)
LI_GRAY = ( 204, 204, 224)
DA_GRAY = ( 77, 77, 77)
BLUE = ( 0, 0, 255)
GREEN = ( 0, 255... |
8c2ba5c14067998a832a58d83c89ddefac1c9a20 | harrietfiagbor/python-programs | /message-analyser.py | 268 | 3.796875 | 4 | # code for finding letters in messages and finding the length
# author: Harriet Fiagbor 5/1/21 10:20pm
message = input("Hey give me a message: ")
any(k in message for k in 'aeiou')
print("I found a vowel")
length = len(message)
print(" The message whole length is", length) |
6ce4cba7850602fa586fa1de69a3e9332ee12435 | thomaslo411/CodeExperiments | /First Test/daytwo.py | 457 | 3.890625 | 4 | #Review
print('Hello World')
string = "this is a string"
the = 15
flt = 3.0
print(the)
#New Stuff
print(type(flt))
lst = [1, 3, 5, "string", 3.0]
print(lst[3])
#for loop
for legallegends in lst:
print(legallegends)
for watch in range(11):
print(watch)
lst_two = [3, 4, 5, 6]
scores = [66, 76, 89, 92, 34]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.