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 |
|---|---|---|---|---|---|---|
b0c5661ed5f43f691ddd05e4ff8f2d641604ad87 | Justinyu1618/python-bee | /medium/10.py | 337 | 3.96875 | 4 | ''' Q10: Given an input string x, return a string with all the spaces removed without using replace().
>>> f('Hello World')
'HelloWorld'
>>> f(' ')
''
>>> f('test123')
'test123'
>>> f(' Lorem ipsum dolor sit aMet ')
'LoremipsumdolorsitaMet'
'''
def f(x):
pass
if __name__ == '__main__':
import doctest
... |
9635638d1a2c986bb8e9c91d62fd27ff9f5942d1 | jos3s/Linguagens | /Python/LT/matriz.py | 635 | 3.5625 | 4 | mat=[[0,0,0],[0,0,0],[0,0,0]]
pares=tcoluna=smaior=0
for i in range(0,3):
for j in range (0,3):
mat[i][j]=int(input(f'Digite um valor para posição [{i}, {j}]: '))
for i in range(0,3):
tcoluna+=mat[i][2]
if mat[1][i]>smaior:
smaior=mat[1][i]
for j in range (0,3):
pri... |
107f2dcc30b42e79a01f2d9105d81ac89aec1feb | jos3s/Linguagens | /Python/LT/pesos.py | 704 | 3.671875 | 4 | temp=[]
princ=[]
maior=menor=0
while True:
temp.append(str(input('Nome: ')))
temp.append(int(input('Peso: ')))
if len(princ)==0:
maior=menor=temp[1]
else:
if temp[1]>maior:
maior=temp[1]
if temp[1]<menor:
menor=temp[1]
princ.append(temp[:])
temp.cl... |
f53d472407a38e02ab633cc01b19802012ff0abb | jos3s/Linguagens | /Python/Aleatórios/loja.py | 558 | 3.640625 | 4 | total=prodmil=prodbarato=cont=0
menorpreco=''
while True:
prod=input('Nome do produto: ')
preco=int(input('Preço do produto: '))
total+=preco
cont+=1
esc=input('Quer continuar? S/N ').strip().upper()[0]
if preco>1000:
prodmil+=1
if cont==1 or preco<prodbarato:
prodbarato=prec... |
3c7cc627a1eb6409ba261e4230cb9e6b00632eff | jos3s/Linguagens | /Python/LT/lista.py | 652 | 3.59375 | 4 | lista=[]
menor=maior=0
for c in range(0,5):
lista.append(int(input(f'Digite um valor para a posição {c}:')))
if c==0:
maior=menor=lista[c]
else:
if lista[c] > maior:
maior=lista[c]
if lista[c] <menor:
menor=lista[c]
print(f'Valores {lista}')
print(f'Maior va... |
c64dd87f42abc1d7e897f7a2d9940519727bea3a | jos3s/Linguagens | /Python/LT/ordenacao.py | 316 | 3.96875 | 4 | lista = []
while True:
num=int(input('Digite um valor: '))
if num not in lista:
lista.append(num)
print("Adicionado na lista")
else:
print('Valor duplicado')
esc=str(input('Quer continuar: '))
if esc in 'Nn':
break
lista.sort()
print(f'Você adicionou: {lista}')
|
1bd4c6145ee3d9c887e0a551a750296ed4ac3e25 | jos3s/Linguagens | /Python/Matemática/basesnumericas.py | 444 | 4.09375 | 4 | num=int(input('Digite o numero:'))
print('Escolha a base:\n 1 - Binário \n 2 - Octal \n 3 - Hexadecimal')
esc=int(input('Digite a opção escolhida: '))
if esc==1:
print('{} covertido para binario é {}' .format(num, bin(num)[2:]))
elif esc==2:
print('{} covertido para binario é {}' .format(num, oct(num)[2:]))
el... |
b309b260c5c8a79d558405e896bca93ae077fdb2 | S1riyS/-2020 | /крестик-нолик.py | 3,134 | 3.609375 | 4 | import pygame
n = int(input("Введите ширину поля - "))
cross = 0
zero = 0
WIDTH = HEIGHT =600 # ширина и высота игрового окна
FPS = 60 # частота кадров в секунду
BLACK = (20, 20, 20)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
pygame.init()
screen = pygame.displa... |
db0d5151e3c6bb463c719520cd83b5e9eb814e3e | turicas/MMD | /scripts/Aula3_SerieTemporal.py | 3,614 | 3.90625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Mestrado em Modelagem Matematica da Informacao
Master Program - Mathematical Modeling of Information
Disciplina: Modelagem e Mineracao de Dados
Course: Data Mining and Modeling
Professor: Renato Rocha Souza
Topic: Two Variables Graphs - Temporal Series (class #3)
Inf... |
69ee3482568a83e15e02ff70ec9485d6623806f6 | selcukakarin/python_code_samples | /advencedLevelFunc/decorators.py | 1,037 | 3.671875 | 4 | import time
def zamanHesapla(func):
def wrapper(sayilar):
baslama=time.time()
sonuc=func(sayilar)
bitis=time.time()
print(func.__name__+" "+str(bitis-baslama)+" saniye sürdü.")
return sonuc
return wrapper
@zamanHesapla # zamanHesapla decorator'ımı... |
1c324c4312b408ce11c230897eb0a797db32be94 | selcukakarin/python_code_samples | /builtInFunctions/zip.py | 475 | 3.96875 | 4 | liste1=[1,2,3,4,5]
liste2=[6,7,8,9,10,11]
liste3=["Python","Php","Java","C#"]
i=0
sonuc=list()
while(i<len(liste1) and i<len(liste2)):
sonuc.append((liste1[i],liste2[i]))
i+=1
print(sonuc)
print(list(zip(liste1,liste2, liste3)))
for i,j,k in zip(liste1,liste2,liste3):
print(i,j,k)
sozluk1={"... |
52c39cdd21a7ef38db32542673da167bb563f921 | selcukakarin/python_code_samples | /ArmstrongNumber.py | 264 | 3.8125 | 4 | sayi=input("sayı gir : ")
toplam=0
basamak=len(sayi)
sayi=int(sayi)
tempsayi=sayi
while(tempsayi>0):
toplam+=((tempsayi%10)**basamak)
tempsayi//=10
if(toplam==sayi):
print("bu sayı armstrong")
else:
print("bu sayı armstrong değil") |
5276e76a122b440112fa2ff024d96f165b57bbef | selcukakarin/python_code_samples | /kumanda.py | 3,110 | 3.65625 | 4 | import random
import msvcrt
class Kumanda():
def __init__(self,tvDurum="Kapalı",tvSes=0,kanalListesi=["Trt"],kanal="Trt"):
print("Kumanda Oluşturuluyor...")
self.tvSes=tvSes
self.tvDurum=tvDurum
self.kanalListesi=kanalListesi
self.kanal=kanal
def sesiAzaltA... |
cf7fd805061a8b86262e149a6c0a5ffda3274449 | selcukakarin/python_code_samples | /builtInFunctions/filter.py | 327 | 3.546875 | 4 | print(list(filter(lambda x:x%2==0,[1,23,34,546,6576,2])))
def asalMi(x):
i=2
if(x==1):
return False
elif(x==2):
return True
else:
while(i<x):
if(x%i==0):
return False
i+=1
return True
print(list(filter(asalMi,range(1,... |
f74b9fcff6d21c2f8256ae3e0bb2072a2df17c64 | AnatkhQ/python-Sorting-Algorithm | /堆排序/topk实现.py | 1,432 | 3.578125 | 4 | # -*- coding: utf-8 -*-
# __author__ = "Anatkh"
# date: 2018/12/9
""""""
"""小根堆sift"""
def sift(li, low, high):
i = low # i最开始指向根节点
j = 2 * i + 1 # j开始指向左孩子
tmp = li[low] # 把堆顶保存起来,以便向下调整
while j <= high: # 只要j位置有数,即小于或等于最后一个元素
if j + 1 <= high and li[j + 1] < li[j]: # 如果有右孩子且右孩子<左孩子
... |
0882121549e88e62da542687b607b48e00d022b0 | AnatkhQ/python-Sorting-Algorithm | /算法进阶/动态规划/从斐波那契数列看动态规划.py | 812 | 3.6875 | 4 | # -*- coding: utf-8 -*-
# __author__ = "Anatkh"
# date: 2018/12/13
""""""
"""
斐波那契数列列:
练习:使用递归和非递归的方法来求解斐波那契数列的第n项
F n = F n−1 + F n−2
"""
# 子问题的重复计算
def fibnacci(n):
"""
递归法
:param n:
:return:
"""
if n == 1 or n == 2:
return 1
else:
return fibnacci(n-1) + fibnacci(n-2)
... |
10d0eca5228cab92662e45593811880c57856fb6 | willianscsilva/xml_to_csv | /src/file.py | 2,034 | 3.6875 | 4 | import sys,os,codecs
class File:
"""
MODES:
r: read only;
rb: read only in binary format;
r+: read and write, pointer beginning of the file;
rb+: read and write binary format;
w: write only, overwrite file if exists;
wb: write only in binary format;
w+: write and read, overwrite file if exists;
wb+: ... |
aa7e8a427c1e512cec82610e12140254ea59fb70 | Ekiz/adventofcode2019 | /readfile.py | 415 | 3.734375 | 4 | import sys
import os
def calculate_fuel(weight: int) -> int:
if (weight < 9):
return 0
else:
fuel = int(weight/3)-2
return fuel + calculate_fuel(fuel)
def main():
sum = 0
with open("input_day1.txt", 'r') as input:
for line in input:
sum += calcul... |
c1e5626f8c208d5bb9fa91e32a10700ef0119186 | tnat1031/viz_project | /website/dev_archive/bubbles_scratch/tweets_csv_to_json.py | 1,461 | 3.5 | 4 | ################################################################################
## tweets_csv_to_json.py
##
## Brad Taylor, March 2013
##
## Quick script to convert CSV data into JSON format,
## Each data point becomes it's own object entry
## This is the format expected to turn individual tweents into data bubbles
##... |
b796ac3c48368f1d2ed3d21382e06f7fc9f839b4 | binssa/Python_Study | /sentence.py | 606 | 3.625 | 4 | sentence = '문자열입니다.'
print(sentence)
sentence2 = "큰따옴푶문자열입니다"
print(sentence2)
sentence3 = """
여러줄의 문자열입니다,
이렇게 작성하고있어요.
"""
print(sentence3)
jumin = "990120-1234567"
print("성별 : " + jumin[7])
print("연 : " + jumin[:2]) # 0번째부터 2번째 직전까지
print("월 : " + jumin[2:4])
print("일 : " + jumin[4:6])
print("생년월일 : " + jumin[:6])... |
4698e65f6b47edcf78afa0b583ccc0bb873df5a3 | shouryaraj/Artificial_Intelligence | /uniformed_search_technique/uniform-cost-search.py | 1,787 | 4.21875 | 4 | """
Implementation of the uniform cost search, better version of the BFS.
Instead of expanding the shallowest node, uniform-cost search expands the node n with the lowest path cost
"""
from queue import PriorityQueue
# Graph function implementation
class Graph:
def __init__(self):
self.edges = {}
... |
8495cf32b9b6a08c871a42f5450e42ab9349779b | AdamRichey/Python | /Scoresandgrades.py | 512 | 4.03125 | 4 | import random
score =random.random()*100
def scoregrade(score):
if score>89 and score<100:
print "Score: " + str(score) + "; Your grade is A"
elif score>79 and score<90:
print "Score: " + str(score) + "; Your grade is B"
elif score>69 and score<80:
print "Score: " + str(score) + ";... |
fa2438b0be6d5ebfd218dd9915230a181fbd01cd | Improbus/DrexelCourseWork | /CS265/Lab5/sList.py | 819 | 4.09375 | 4 | #!/usr/bin/python
# given (singly-linked) lists like
# []
# [a, []]
# [1, [2, [3, []]]]
def init() :
return []
def isEmpty( L ) :
return len( L ) == 0
def value( L ) :
if isEmpty( L ) : return None
return L[0]
def rest( L ) :
if isEmpty( L ) : return None
return L[1]
def size( L ) :
if isEmpty( L ) : ... |
b9a9ff495b361f4bd09e201e4ed556954ca109d9 | SohelRaja/Experience_Vs_Salaray_Linear-Regression | /Intro.py | 452 | 3.546875 | 4 | from tkinter import *
def info(root):
info_f = Frame(root, height=100, width=800)
info_f.pack()
main_lbl=Label(info_f, text='(Experience VS Salary) Linear Regression and Predict Salary based on Experience', fg='blue', font=('Arial', -15, 'bold underline'))
main_lbl.place(x=110, y=25)
lb1=Label(info_... |
9f4a59b8593f0f4e707e3354b4a82e2fff0d4b56 | Sharkigamers/204ducks | /204ducks | 2,852 | 3.59375 | 4 | #!/usr/bin/env python3
##
## EPITECH PROJECT, 2020
## 204ducks
## File description:
## 204ducks
##
import sys
import math
import time
class Ducks():
def __init__(self, a):
self.a = a
def F(self, t):
return (self.a * math.exp(-t) + (4 - 3 * self.a) * math.exp(-2 * t) + (2 * self.a - 4) * math... |
2e5e44ba73492ca11a60fc193f088a191b7fd91f | akdutt/simple-programs | /193negative.py | 202 | 4.1875 | 4 | a=raw_input("Enter a no which you want to finf Negative , Positive or Zero. ")
if int(a)>0:
print ("No is Positive. ")
elif int(a)<0:
print("No is Negative. ")
else :
print ("No is Zero. ")
|
add00f5b3b7647c64b731aaa8b8ca26a1b311f39 | Pavithralakshmi/corekata | /12345.py | 136 | 3.609375 | 4 | num=int(input("enter limits"))
r=[]
for i in range(num):
a=int(input())
r.append(a)
for i in range(num):
print(r[i]," ",i)
|
d9c92cbd819418374239d8e0915c76926a994e13 | Pavithralakshmi/corekata | /poer.py | 207 | 4.125 | 4 | print(" power of input")
y=0
while y==0:
number1 = int(input('Enter First number : '))
number2 = int(input('Enter Second number : '))
o=number1**number2
print(o)
y=int(input("0 to continue"))
|
b659f52d5076f569bbc4fcb254feb7ad3c7e934b | Pavithralakshmi/corekata | /god.py | 104 | 3.59375 | 4 | n=int(input("enter:"))
m=int(input("enter:"))
if (n>0) and (m>0):
print(n*m)
else:
print("invalid")
|
4a7a71623021e0f8a0b1a648929883c0ccba436f | Pavithralakshmi/corekata | /strcmpincas.py | 109 | 3.9375 | 4 | a=input("enter string")
b=input("enter string")
if a.lower()==b.lower():
print("yes")
else:
print("no")
|
55684d2d4356d2a932665114ec4913f6dc610937 | Pavithralakshmi/corekata | /nad.py | 137 | 3.53125 | 4 | def pos(a,d,n):
s=0
i=0
while i<n:
s=s+a
a=a+d
i=i+1
return s
n=90
a=2.5
d=1.5
print(pos(a,d,n))
|
b20957c011a36b351927089aa62aed971cfc7dd3 | Pavithralakshmi/corekata | /rev_word.py | 193 | 3.859375 | 4 | def rev(word):
a = word.split(" ")
a=a[-1::-1]
output = ' '.join(a)
return output
if __name__ == "__main__":
word = raw_input("enter string: ");
print rev(word)
|
3a43c6af6974fbcbe2a5e141a5a83ead28d457d1 | Pavithralakshmi/corekata | /ascii.py | 60 | 3.6875 | 4 | y = 'A'
print("The ASCII value of '" + y + "' is",ord(y))
|
7c36a11e306e54eaa4b92ef78ae2e9accbbbc345 | Pavithralakshmi/corekata | /stringstrip.py | 98 | 3.75 | 4 | s=str(input("enter something"))
r=str(input("enter remove string"))
print(s)
print((s.strip(r)))
|
d770a4240fd48a1241225719c073293b638a6e36 | Pavithralakshmi/corekata | /3point.py | 274 | 3.640625 | 4 | a,b=map(int,input("Enter !st line").split(' '))
a1,b1=map(int,input("Enter 2nd line").split(' '))
a2,b2=map(int,input("Enter 3rd line").split(' '))
if (a==a1 and a1==a2) or(b==b1 and b1==b2) or (abs(a-a1)==abs(a1-a2) and abs(b-b1)==abs(b1-b2)):print("yes")
else:print("no")
|
3b6c21d628f9ccfc2c567698be15df66d6539cc9 | Pavithralakshmi/corekata | /pro2.py | 187 | 3.84375 | 4 | def printArray(u, n):
for i in range(0,n):
print ("%d"%( u[i]),end=" ")
u = [23, 610, 270, 11, 12, 6, 7]
n = len(u)
pancakeSort(u, n);
print ("Sorted Array ")
printArray(u,n)
|
9f2dc3d10ff33208dae2b0f9886da172f4bb579b | Pavithralakshmi/corekata | /idi.py | 223 | 3.703125 | 4 | from numpy import *
x = range(int(input("x")))
x = reshape(x,(4,4))
print(x)
n = int(input("enter row limits"))
m = int(input("enter col limits"))
a = [0] * n
for i in range(n):
a[i] = [0] * m
print(" ")
print(a)
|
22831bcd1ec68d0651c8a506994c2d5c96a68e16 | Pavithralakshmi/corekata | /soperation.py | 140 | 3.984375 | 4 | print(" operations")
a=int(input("enter a value:"))
b=int(input("enter b value:"))
c=int(input("enter c value:"))
print(" ans is:",(a*b)/c)
|
11c4528c8c4c1521b7009250f3b24e01415258ef | Pavithralakshmi/corekata | /temperature.py | 235 | 3.921875 | 4 | print("Temperature")
y=0
while y==0:
def Celsius_to_Kelvin(C):
return (C + 273.15)
C = int(input("enter celsius value"))
print("Temperature in Kelvin ( K ) = ", Celsius_to_Kelvin(C))
y=int(input("press 0 to continue"))
|
5f40dec210d36c3114c1d66a8c2c63371e93fa88 | Pavithralakshmi/corekata | /m7.py | 356 | 4.1875 | 4 | print("cheack the given input is mulitiple by 7");
y=0
while y==0:
num=int(input("enter ur first input"))
if num>1:
for i in range(1,num):
if num%7==0:
print (num,"this number is multiple by 7")
break
else:
print(num,"this number is not multiple by 7")
y=int(input("ë... |
4bc49f8619963df7992f24a653112c18745dc95a | Pavithralakshmi/corekata | /albha2.py | 280 | 3.65625 | 4 | print("count string albha order")
y=0
while y==0:
a=list(str(input("enter something")))
b=list(str(input("enter somthing")))
x=len(a)
c=0
i=0
j=0
while x>0:
c=c+(ord(b[j])-ord(a[i]))
i=i+1
j=j+1
x=x-1
print(c)
y=int(input("press 0 to continue"))
|
581c8b441de9dcafd76d98cfc6841f3b95bdf2c2 | Pavithralakshmi/corekata | /sec.py | 290 | 4.1875 | 4 | print("calculate amounts of seconds ")
days =int(input("Inputdays: ")) * 3600* 24
hours = int(input("Input hours: ")) * 3600
minutes = int(input("Input minutes: ")) * 60
seconds = int(input("Input seconds: "))
time = days + hours + minutes + seconds
print("The amounts of seconds ", time)
|
3fb0a0302735e7ef383b738400f4d53d2c2b013a | Pavithralakshmi/corekata | /posi1.py | 119 | 3.59375 | 4 | n=int(input("enter limit for a"))
a=[]
for i in range(n):
b=int(input("nter number:"))
a.append(b)
print(a[1])
|
6fc5779fcbb4a3c1978ca1f3acbeed182b390f1b | Pavithralakshmi/corekata | /yyyyy.py | 539 | 3.96875 | 4 | def separate_string(sentence):
l = list(sentence)
list_even = list()
list_odd = list()
index = 0
for letter in l:
if index % 2 != 0:
list_even.append(letter)
else:
list_odd.append(letter)
index += 1
string_even = "".join(list_even)
... |
32a1fc6fadaf1de753ac79e3574cfa05727a3340 | Pavithralakshmi/corekata | /checkcount.py | 232 | 4.03125 | 4 | a=str(input("Enter string:"))
c1=0
c2=0
for i in a:
if(i.isnumeric()):
c1=c1+1
elif(i.isupper()):
c2=c2+1
print("The number of numeric characters is:")
print(c1)
print("The number of uppercase characters is:")
print(c2)
|
079cfd9a75d31cbe281a3da6183574c9bc98ef03 | Pavithralakshmi/corekata | /array.py | 200 | 3.65625 | 4 | n=int(raw_input("Enter number:"))
a=int(raw_input("enter sum value"))
ll=[]
s=0
for i in range(0,n):
l=int(raw_input("enter values"))
ll.append(l)
for i in range(0,a):
s+=int(ll)
print(s)
|
958f714b9c0a7978e870bdeb1ea710eaffeaade9 | Pavithralakshmi/corekata | /tit.py | 95 | 3.53125 | 4 | a=str(input("ener anything"))
b=a.title()
print(b)
if a==b:
print("yes")
else:
print("no")
|
ee4ec532be449250fce89f8700e1e06df35d081e | Pavithralakshmi/corekata | /somin2.py | 182 | 3.828125 | 4 | a=int(input("enter number a:"))
b=int(input("enter number b:"))
l=[]
for i in range(a):
c=int(input("enter number c:"))
l.append(c)
for i in range(b-1):
c=min(l)
print(min(l))
|
3a97d7ae50be1c315f5b2d863d56c749c36ca989 | Pavithralakshmi/corekata | /commonsort.py | 173 | 3.734375 | 4 | n=int(input("enter a num1"))
l1=[]
l=[]
for i in range(n):
a=int(input())
l.append(a)
for i in range(n):
b=int(input())
l1.append(b)
s=set(l)
s1=set(l1)
print(s&s1)
|
ec3be27b9be9cb3fc1ec7de022c3cc787a196261 | sabarishkumaran/ComputerVisionBasics | /1.load_display_save/load_display_save_1.py | 458 | 3.625 | 4 | # import the necessary packages
import cv2
# load the image and show some basic information on it
image = cv2.imread( "new.jpg")
print ("width: %d pixels" % (image.shape[1]))
print ("height: %d pixels" % (image.shape[0]))
print ("channels: %d" % (image.shape[2]))
# show the image and wait for a keypress
cv2.imshow("... |
5e8064cd02449c45bc584d7728616dea69c8c186 | tantalum7/pyStorageBackend | /pyStorageBackend/file_lock.py | 3,285 | 3.515625 | 4 |
# Library imports
import os
import uuid
# Exceptions
class FileLockException(Exception):
pass
class FileLock(object):
def __init__(self, file_path: str, uuid_string: str=None):
"""
Simple file locking primitive. Works be creating a .lock version of the file it's locking, and stores a uniqu... |
1d974c8ad38f71f86a9f1c3102d7cfccdc8f004c | faisalmoinuddin99/python | /python/py3ExerciseFiles/py3ExerciseFiles/Chapter04/decoDemo.py | 1,068 | 3.6875 | 4 | #!/usr/bin/python3
#Exercise files by IgneusTech.COM
class Harley():
def __init__(self, **kwargs):
self.features = kwargs
def bigEngine(self):
print("Harley got a big Engine", self._cc)
def loudSound(self):
print("Potato sound is really cool", self._cc)
de... |
886e48bc59c4e8c424270e8491c16569ed458dd8 | faisalmoinuddin99/python | /python/chapter1/complexType.py | 879 | 4.15625 | 4 | def __main__():
tuple = (2,5,6)
#tuples are fixed
print(tuple)
#List
list = [4,1,9,3,2,0,45]
list.sort()
print(list)
#Dictionary
dict1 = {'one':1,'two':2}
print(dict1)
dict2 = dict([('one',1),('two',2)])
print(dict2)
dict3 = dict(one=1,two=2)
p... |
d6b8d1272ed2768ba2fce5962d2cc9fa263635ea | faisalmoinuddin99/python | /python/py3ExerciseFiles/py3ExerciseFiles/Chapter03/dateTime.py | 406 | 3.671875 | 4 | #!/usr/bin/python3
from datetime import date
#Exercise files by IgneusTech.COM
def main():
print("Hello")
currentDate = date.today()
print(currentDate)
print("day is ", currentDate.day)
print("Month is ", currentDate.month)
print("Year is ", currentDate.year)
print("Weekday is ",... |
81910dc935017f01db13689c13a266337a734f12 | faisalmoinuddin99/python | /python/py3ExerciseFiles/py3ExerciseFiles/Chapter03/listAndTuples.py | 382 | 3.96875 | 4 | #!/usr/bin/python3
#Exercise files by IgneusTech.COM
def main():
print("Hello")
tupy = 1,2,3,4,5
print(tupy)
singleTupy = (1,)
print(type(singleTupy))
tupo = tuple(range(20)) #Fixed
listo = list(range(21,41)) #change this
print(2 in tupo)
listo.appen... |
bd8fc4d2e90f81a44e83acd21a26e08ece2c7275 | Exodus111/Infinite-Adventure | /Test/testbreak.py | 130 | 4.03125 | 4 | thelist = [1, 2, 3, "something", 5]
for x in thelist:
if x == "something":
print x
break
else:
print x
|
b7505421064a111f1b8194951d41fe7645bfc4d9 | absonggit/devops | /note/Python/py_exercises/exercise - 石头剪子布.md | 1,067 | 3.796875 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# descirption:石头剪子布小游戏.
import random
while True:
s = int(random.uniform(1,3))
if s == 1:
ind = "石头"
if s == 2:
ind = "剪子"
if s == 3:
ind = "布"
m = raw_input("输入“石头”“剪子”“布”玩游戏、或者“q”退出游戏:")
blist = ["石头","剪子","布"]
if ( m n... |
18a8f0a3f3c25d243c8fe56700a0ddcad70bee1f | cr12345/main | /exm55.py | 74 | 3.59375 | 4 |
n=int(raw_input())
sum=0
for i in range(1,n+1):
sum=sum+i
print(sum)
|
0c60f7c05a0a04f05802152709e331f0ee0090dd | AmbassadeursCourageuxDeLaMontagePourpre/Hash2018 | /model.py | 1,922 | 3.5 | 4 | """
Fonction qui permet de parser
l'entrée et renvoie la data
"""
def distance(x1, y1, x2, y2):
return abs(x1 - x2) + abs(y1 - y2)
class Ride:
def __init__(self, id, start_y, start_x, end_y, end_x, earliest_start, latest_finish):
self.id = id
self.start_x = start_x
self.start_y = start_y
self.end_... |
c2112a870408a7a0b0b42f8d2daa3efa536d0065 | beLemoth/pythonTpl | /les1.py | 722 | 3.9375 | 4 | questions = {
'Какой язык я изучаю':'python',
'Как называется тип данных представляющий собой неизменяемый список':'tuple',
'Как называется тип данных представляющий собой изменяемый список':'list',
'Функция определения типа данных':'type',
'Тип данных строка':'str'
};
rightAnswer = 0;
for question... |
8531d7c6f9ac57387f35eaf850154051338e6fd6 | aocory/techcommit | /kadai7.py | 231 | 3.71875 | 4 | print("数字を入力してください")
nn=input()
n=int(nn)
def check(n):
for p in range(2, n):
if n % p == 0:
print(str(n) + '素数ではありません')
return
print(str(n) + 'は素数です')
check(n)
|
af021d19255be73eef0697649cea3ac249705acc | sdeepx/marks_parcentage_calculator | /Marks_calculator.py | 437 | 4.03125 | 4 | def parcent(marks, maxmarks):
parcentage = (marks / maxmarks) * 100
return parcentage
def main():
maxmarks = float(input("Enter you maximun marks : "))
assert maxmarks >= 0 and maxmarks <= 500
marks = float(input("Enter your marks : "))
assert marks >= 0 and marks <= maxmarks
parcentage =... |
fee5de4fafdac5eb3ee9751d98c1c5e5144f9ce8 | slavco86/Python-practice | /Comma Code.py | 455 | 3.921875 | 4 | def convert(atr):
newList = ''
for i in atr:
if atr.index(i) < len(atr)-1:
newList += str(i) + ', '
else:
newList += 'and ' + str(i)
return newList
words = []
while True:
print('Please enter word number ' + str(len(words)+1) + '(or enter nothing to stop):')
wo... |
9e350bf9c3c6abf3c14a1c7f69682e42cbe7cff9 | franklinchou/csci-ga-1170 | /week2/binary_search_r.py | 493 | 3.796875 | 4 | # Recursive bin search
def bin_search_r(arr, left, right, target):
m = left + (right - left) // 2
if right - left <= 1 and arr[m] != target:
return
else:
if arr[m] > target:
bin_search_r(arr, left, m, target)
elif arr[m] < target:
bin_search_r(arr, m + 1, r... |
50bbf5ce8b2c76d5fac6d6265cb0423cbee7d1ab | NickWang23/api_test | /basic_knowledge.py | 5,754 | 3.515625 | 4 | # !/usr/bin/env python
# -*-coding: utf-8-*-
# @ProjectName : api_test
# @FileName : basic_knowledge.py
# @Time : 2019/3/28 14:39
# @Author : Nick
# @description : python语言的基础知识回顾
"""
在Pycharm中自动添加时间日期作者等信息:
https://blog.csdn.net/u010105243/article/details/76154251
question1: utf-8 如何转换为GBK的编码:
Python2中的字符串进行字符编码转... |
ce22e7ecf59fea48b66faefe0cbfea7875838499 | thanhtoan1742/ganh | /src/game.py | 1,636 | 3.5 | 4 | import time
from board import *
from random_player import move as random_move_maker_1
from random_player import move_2 as random_move_maker_2
class game:
TIME_LIMIT = 3
def __init__(self, board=board(), first_move_maker=random_move_maker_1, second_move_maker=random_move_maker_2):
self.board = board
... |
883493771f8af79eaf384aa77bcb4db1343481ab | MenNianShi/leetcode148 | /133. 克隆图.py | 1,462 | 3.796875 | 4 | # 克隆一张无向图,图中的每个节点包含一个 label (标签)和一个 neighbors (邻接点)列表 。
#
# OJ的无向图序列化:
#
# 节点被唯一标记。
#
# 我们用 # 作为每个节点的分隔符,用 , 作为节点标签和邻接点的分隔符。
#
# 例如,序列化无向图 {0,1,2#1,2#2,2}。
#
# 该图总共有三个节点, 被两个分隔符 # 分为三部分。
#
# 第一个节点的标签为 0,存在从节点 0 到节点 1 和节点 2 的两条边。
# 第二个节点的标签为 1,存在从节点 1 到节点 2 的一条边。
# 第三个节点的标签为 2,存在从节点 2 到节点 2 (本身) 的一条边,从而形成自环。
# 我们将图形可视化... |
ae7656985c85cf67420491c353a2a07b3601cb23 | MenNianShi/leetcode148 | /链表/19. 删除链表的倒数第N个节点.py | 1,766 | 3.703125 | 4 | # 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。
#
# 示例:
#
# 给定一个链表: 1->2->3->4->5, 和 n = 2.
#
# 当删除了倒数第二个节点后,链表变为 1->2->3->5.
# 说明:
#
# 给定的 n 保证是有效的。
#
# 进阶:
#
# 你能尝试使用一趟扫描实现吗? 构建双指针p1与p2,p1先走n步,然后一同运动,当p1指向表尾,p2指向的next即是倒数第N个节点,删除即可。
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
... |
2e420bd5f7f0015eb4f013e6c2e5c369257f8f04 | MenNianShi/leetcode148 | /6. Z字形变换.py | 1,151 | 4 | 4 | # 将字符串 "PAYPALISHIRING" 以Z字形排列成给定的行数:
#
# P A H N
# A P L S I I G
# Y I R
# 之后从左往右,逐行读取字符:"PAHNAPLSIIGYIR"
#
# 实现一个将字符串进行指定行数变换的函数:
#
# string convert(string s, int numRows);
# 示例 1:
#
# 输入: s = "PAYPALISHIRING", numRows = 3
# 输出: "PAHNAPLSIIGYIR"
# 示例 2:
#
# 输入: s = "PAYPALISHIRING", numRows = 4
# 输出: "PINAL... |
264047bea1e1c4e45c4e3f014a069be5da985a9a | MenNianShi/leetcode148 | /9.回文数.py | 830 | 3.9375 | 4 | #
# 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。
#
# 示例 1:
#
# 输入: 121
# 输出: true
# 示例 2:
#
# 输入: -121
# 输出: false
# 解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。
# 示例 3:
#
# 输入: 10
# 输出: false
# 解释: 从右向左读, 为 01 。因此它不是一个回文数。、
#算出x的倒置数a,比较a是否和x相等就行了
class Solution:
def isPalindrome(self, x):
"""
:t... |
16e93128c59bc5f62a1daf7f346bee7ac2f5e5da | MenNianShi/leetcode148 | /链表/24. 两两交换链表中的节点.py | 1,292 | 3.984375 | 4 |
# 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。
#
# 示例:
#
# 给定 1->2->3->4, 你应该返回 2->1->4->3.
# 说明:
#
# 你的算法只能使用常数的额外空间。
# 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def swapPairs(se... |
377a3ba38c34e1a5ca90ed948aecb80526be8a1b | MenNianShi/leetcode148 | /动态规划/62.不同路径.py | 1,543 | 3.71875 | 4 | # 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。
#
# 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。
#
# 问总共有多少条不同的路径?
# 这是一道典型的动态规划问题,使用一个二维数组ans记忆到达每一点可行的走法总数。
# 首先将左边界点和上边界点初始化为1,因为机器人起始与(0,0),左边界点和上边界点的走法只有1种。接下来的每一点(x,y),
# 可以由(x-1,y)向右走或是(x,y-1)向下走来到达,因此在(x,y)这一点可到达的方法有ans[x-1][y]+ans[x][y-1]种,到达终点的方法则是ans最后一个点的数... |
d4d69efed9ca15cb5047ea3234125e65d587f10b | MenNianShi/leetcode148 | /二叉树/105. 从前序与中序遍历序列构造二叉树.py | 1,896 | 3.734375 | 4 | # 根据一棵树的前序遍历与中序遍历构造二叉树。
#
# 注意:
# 你可以假设树中没有重复的元素。
#
# 例如,给出
#
# 前序遍历 preorder = [3,9,20,15,7]
# 中序遍历 inorder = [9,3,15,20,7]
# 返回如下的二叉树:
#
# 3
# / \
# 9 20
# / \
# 15 7
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:... |
53465ee16798a7c532a04dd5300a1f430209ddf1 | MenNianShi/leetcode148 | /DFS/22. 括号生成.py | 1,470 | 3.875 | 4 | # 给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。
#
# 例如,给出 n = 3,生成结果为:
#
# [
# "((()))",
# "(()())",
# "(())()",
# "()(())",
# "()()()"
# ]
# 思路:合法的情况是,任意一时刻,左(“(”)括号数要大于等于右(")")括号数。关键在于题中只给了括号的对数,没有形象的左右括号字符,如何在脑海中转过弯去解题。故,在某次的调用中,
#
# 1)left大于right(left和right分别表示剩余左右括号的个数),即,临时变量中右括号的数大于左括号的数,则说明出现了“)(”,这是非... |
74df2c0f4ea09108114b6206c03004d40256aeb4 | MenNianShi/leetcode148 | /78. 子集.py | 678 | 3.96875 | 4 | # 给定一组不含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集)。
#
# 说明:解集不能包含重复的子集。
#
# 示例:
#
# 输入: nums = [1,2,3]
# 输出:
# [
# [3],
# [1],
# [2],
# [1,2,3],
# [1,3],
# [2,3],
# [1,2],
# []
# ]
import itertools
class Solution(object):
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[L... |
dcc4bf1291f5f54a20c442561d2de0a60fe46171 | bilodid123/tasksPy | /exercises/05_basic_scripts/task_5_2.py | 1,390 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Задание 5.2
Запросить у пользователя ввод IP-сети в формате: 10.1.1.0/24
Затем вывести информацию о сети и маске в таком формате:
Network:
10 1 1 0
00001010 00000001 00000001 00000000
Mask:
/24
255 255 255 0
11111111 11111111 11111111 000000... |
bf45e440c1a92a1a01d82d385ae1a81934c4f206 | bopopescu/Learn2Mine-Main | /rps/backup_bots/Bot.py | 549 | 3.59375 | 4 | #Bot
import random
if input =="":
numRock = numPaper = numScissors = 0
numRock = input.count("R")
numPaper = input.count("P")
numScissors = input.count("S")
if numRock > numPaper and numRock > numScissors:
output = "P"
if numPaper > numScissors:
output = "S"
else:
output = "R"
if numRock==numPaper and numRock==n... |
5d3ab295d70ab1bb8ce6aa5c080b98b9150f1805 | ramya-kiran/Wumpus-world | /q1.py | 3,465 | 3.671875 | 4 | #This program implements A star algorithm to find the shortest path(if one available)
# between two locations with x,y co-ordinates with Euclidean Distance computing the heutistics.
# name : Ramya Rao
# python verison: 2.7.12
# e-mail address: ramrao@umail.iu.edu
import numpy as np
import heapq
import yaml
import s... |
da849e60a9415fcab68301964185eec25d87a179 | ExerciseAndrew/Algorithms | /python/Stack.py | 1,271 | 4.25 | 4 | ### Implementation of a stack using python list
class Stack:
def __init__(self, items):
#creates empty stack
self._theItems = list()
def isEmpty(self)
#returns True if stack is empty
return len(self) == 0
def __len__(self):
#returns number of items in... |
efe342b45129d3743c350b964eb8861991a7579c | apockill/genbu | /fleet/math_utils.py | 3,453 | 4 | 4 | from math import atan2, degrees, cos, sin, radians
from typing import Sequence
import numpy as np
from fleet.direction import Direction
NEIGHBOR_COORDS = np.array(
[[1, 0, 0], [0, 1, 0], [0, 0, 1], [-1, 0, 0], [0, -1, 0],
[0, 0, -1]])
"""All possible directions a turtle could go relative to a block"""
VECT... |
eea7f7d0ba7898a1710816682b1aa4fad7ca2731 | Surfsol/Intro-Python-I | /src/12_scopes.py | 1,019 | 4.375 | 4 | # Experiment with scopes in Python.
# Good reading: https://www.programiz.com/python-programming/global-local-nonlocal-variables
# When you use a variable in a function, it's local in scope to the function.
x = 12
def change_x():
x = 99
change_x()
x = 99
# This prints 12. What do we have to modify in chang... |
5e17b8ff7f2c0fc3972d7e1ae07999ffc66a0846 | lastworden/datascience | /Udemy/my_udemy_notes/Lec010 Array Transposition .py | 1,204 | 3.640625 | 4 |
# coding: utf-8
# In[2]:
import numpy as np
# In[2]:
arr =np.arange(50).reshape((10,5))
# In[3]:
arr
# In[16]:
tarr = arr[:,1]
tarr
# In[18]:
tarr.shape
# In[19]:
tarr = arr.T
# In[20]:
tarr
# Even Tanspose is not a deep copy.
# In[21]:
tarr[0,0] =100
tarr
# In[22]:
arr
# In[25]:
arr1 = n... |
1d9bab0962207dc25e1cad9f660e1957e489ecc6 | pisuduo/Numerical-Optimization | /Function optimization/scant.py | 1,220 | 3.8125 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 21 10:05:59 2017
@author: maziyang
"""
import numpy as np
import math as m
import pylab as pl
import matplotlib.pyplot as plt
import scipy as sp
### secant method
def secant(f,x0,x1,tol,maxit):
n=1
while n<=maxit:
x2=x1-f(x1)*(x1-x... |
c7a62ba2fc57cbad6557e93ccef254bba7bb6f5c | 2021202025/Coding_Problems | /Binary_Search.py | 500 | 3.6875 | 4 | lis = [1,2,3,4,5,6,7,8,9]
mid = len(lis)//2
element = 8
flag = False
begin = 0
end = len(lis)
for i in range(begin, end):
mid = (begin + end)//2
if mid >= len(lis):
break
if lis[mid] == element:
flag = True
print("Iteration " + str(i) + " " + str(lis[mid]))
break
... |
3e244cc3058f4ac56c6f588861cbcedd3b4af3cb | 2021202025/Coding_Problems | /Maximal_Number.py | 190 | 3.59375 | 4 | siz = int(input())
strings = input()
new_string = ""
nos = list(int(s) for s in strings)
for i in range(0,siz):
new_string += str(max(nos))
nos.remove(max(nos))
print(new_string) |
609f758927e1418796543ffde2c9dc366c38bc59 | MuhammadEhtisham60/dev-code2 | /string.py | 723 | 4.1875 | 4 |
"""
print('Hello')
print("Hello")
a="Hello World"
print(a)
"""
#string are array
"""
a="Hello_World"
print(a[9])
"""
#b="hello,world"
#print(b[-5:-3])
#c="Hello, shami"
#print(len(c))
#print(c.strip())
#print(c.lower())
#print(c.upper())
#print(c.replace("shami","world"))
#print(c.split(","))
"""
txt="The rain i... |
06f40ec37dade1e225c0082acec7a95e7933de46 | MuhammadEhtisham60/dev-code2 | /inheritance.py | 918 | 4.09375 | 4 | """
class person:
def __init__(self,fname,lname):
self.firstname=fname
self.lastname=lname
def printname(self):
print(self.firstname, self.lastname)
class student(person):
pass
x = student("mike", "pomp")
x.printname()
"""
"""
class person:
def __init__(self,fname,lname):
self.firstnam... |
74dbfe6060ab0e641dfd900a2d541c7c655f7287 | timof1308/CsvToJson | /JsonFile.py | 1,315 | 3.75 | 4 | #!/usr/bin/python
# Author= Timo Fischer
import os
import re
import json
from File import File
class JsonFile(File):
"""
JSON File Class
"""
def __init__(self, file):
"""
JsonFile class constructor
:param file:
"""
super().__init__(file)
self.file_name... |
1fd3133bcfb8d1af0085ac05a0a44ce3a96bcd9f | HEMANT8712/python_practice | /FileInputOutput.py | 2,707 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 28 00:57:58 2017
@author: Administrator
"""
"""BAsic Exmaple"""
my_list = [i ** 2 for i in range(1, 11)]
# Generates a list of squares of the numbers 1 - 10
f = open("output.txt", "w")
for item in my_list:
f.write(str(item) + "\n")
f.write("Data to be written")
f.clos... |
127f9d1bbe2f7a652b94881018457ab5a7e89e4d | kubenet/pyLearn | /stepik course/stepik_3_basic_set.py | 2,312 | 3.9375 | 4 | #
# Множества set
#
s = set() # создание пустого множества
obj =['apple', 'orange', 'beer','weesky']
basket={'apple','apple','apple','orange','flower','raspberry','cherry', 'popatos', 'tomato'}
print(basket)
if 'orange' in basket: # проверка вхождения элемента в множество
print('Orange in the basket')
else:
pri... |
b5ba2cd7ba1bcbf6fafd10fe80164e76a23b5322 | kubenet/pyLearn | /stepik course/stepik_2_6_2.py | 1,024 | 3.6875 | 4 | # 2.6 Задачи по материалам недели
# 6 из 11 шагов пройдено
# 0 из 10 баллов получено
# Напишите программу, которая выводит часть последовательности 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 ... (число повторяется столько раз, чему равно). На вход программе передаётся неотрицательное целое число n — столько элементов последователь... |
0c1c34d1335ceb7d5e5b751e1f6f9ad41a15256d | benja956/Python-based | /game.py | 1,573 | 3.6875 | 4 | #体育比赛竞技分析
import time
from random import random
def printinfo():
print("这个程序模拟两个选手A,B的某种比赛")
print("程序运行需要输入AB的能力值(0.01~0.99)和比赛次数")
def getinputs():
NA = eval(input("请输入选手A的能力值:"))
NB = eval(input("请输入选手B的能力值:"))
N = eval(input("请输入模拟次数:"))
return NA,NB,N
def printsummary(winsA,winsB):... |
f3dcf8266caef2de5420252a857db757756cc0f2 | benja956/Python-based | /koch.py | 942 | 3.640625 | 4 | #v1
"""
import turtle
def koch(size,n):
if n == 0:
turtle.fd(size)
else:
for angle in [0,60,-120,60]:
turtle.left(angle)
koch(size/3,n-1)
def main():
turtle.speed(8)
turtle.pencolor("blue")
turtle.penup()
turtle.fd(-200)
turtle.pendow... |
c26f13a77e5cd6a0486487fead935ec055bc159d | benja956/Python-based | /计算1.py | 67 | 3.828125 | 4 | #计算1
x = ((3**4+(5*6**7))/8)**0.5
print("x={:.3f}".format(x))
|
03eedbac613fdf5284146126caaf7c2b627f9297 | garyliton/algo-review | /product_of_array_except_self.py | 574 | 3.53125 | 4 | class Solution:
def productExceptSelf(self, nums):
res = [nums[0]]
product = 1
for i in range(1, len(nums)):
res.append(nums[i] * res[i-1])
for i in range(len(nums) - 1, -1, -1):
if i == len(nums) - 1:
res[-1] = res[-2]
produc... |
f54f6e32e318c6881d71eda07bb09a894ac06c62 | garyliton/algo-review | /first_non_repeating_character.py | 269 | 3.59375 | 4 | def firstNotRepeatingCharacter(s):
hash_map = {}
for char in s:
if char in hash_map:
hash_map[char] += 1
else:
hash_map[char] = 1
for char in s:
if hash_map[char] == 1:
return char
return "_" |
be3a4dce1410d65475da6f405010219fe4b48539 | garyliton/algo-review | /maximum_subarray.py | 174 | 3.625 | 4 | def maxSubArray(nums):
msf = nums[0]
mf = nums[0]
for num in nums[1:]:
msf = max(num, msf + num)
if msf > mf:
mf = msf
return mf |
20861fd9173ca2877c9a06ebedd872ddac866e6e | garyliton/algo-review | /count_primes.py | 470 | 3.71875 | 4 | class Solution:
def countPrimes(self, n: int):
primes = [True for i in range(n)]
i = 2
while i * i < n:
if primes[i]:
j = i
while i * j < n:
primes[i * j] = False
j += 1
i += 1
count = 0
... |
3780c11bc67199df3b3c6c80c00d8190e5ad5132 | garyliton/algo-review | /word_search_2.py | 1,990 | 3.921875 | 4 | class Node:
def __init__(self):
self.children = {}
self.is_word = False
self.word = None
class Trie:
def __init__(self):
self.root = Node()
def insert(self, word):
node = self.root
for char in word:
if char in node.children:
nod... |
39ef92a8318c750bb5fa1abba7e0e62076c5721e | CodeFandomWithNyla/GuessAnumber2playersGame | /Guess_the_number_2_players.py | 1,383 | 4.09375 | 4 | import random
# baari function randomly selects a number and ask that to guess from player
def baari(x):
com = random.choice(range(a,b))
print(f"\nPLAYER {x} Turn :\n")
player = 0
i = 0
while player != com:
player = int(input(f"Enter a number between {a} and {b} :\t"))
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.