The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The information about the size of the dataset is not coherent.
Error code: UnexpectedError
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
55884a59514464a78f8002779532a7eb01b8331c | sudajzp/jzp-s-python | /FBNQ_py/Fib_circle.py | 854 | 3.84375 | 4 | #coding utf-8
'''
斐波那契数列-循环法
'''
def Fib_circle():
while True: # 去掉while循环,只用for循环
num_1 = 0
num_2 = 1
fib_array = [0] # 用于存储计算出的FB数列值
m = input('你想要查找的起始项:')
n = input('你想要查找的结束项:')
if m.isdigit() and n.isdigit(): # 在这个实现函数中,不要进行检验。每个函数只做一个事情
m = int(... |
bbdbe92fa64d8a4006a4a6f7ef2ffc862ffaadb2 | waffle-iron/osmaxx | /osmaxx/utils/directory_changer_helper.py | 1,710 | 3.609375 | 4 | import shutil
import os
class changed_dir: # pragma: nocover # noqa -> disable=N801
"""
Changes into a arbitrary directory, switching back to the directory after execution of the with statement.
directory:
the directory that should be changed into.
create_if_not_exists:
set this to ... |
dadbdd33b087e16ffcbb985b8b28e1e215f5fc53 | Sandro37/Introducao_ao_python-CURSO-Digital_Innovation-One | /aula02.py | 1,172 | 4.25 | 4 | #O que são variáveis e como manipulá-las através
# de operadores aritméticos e interação com o osuário
valorA = int(input("Entre com o primeiro valor: "))
valorB = int(input("Entre com o segundo valor: "))
soma = valorA + valorB
subtracao = valorA - valorB
multiplicacao = valorA * valorB
divisao = valorA / valorB
re... |
4f532cd9216766b1dfdb41705e9d643798d70225 | Sandro37/Introducao_ao_python-CURSO-Digital_Innovation-One | /aula05.py | 1,138 | 4.125 | 4 | #como organizar os dados em uma lista ou tupla
# e realizar operações com elas
lista = [12,20,1,3,5,7]
lista_animal = ['cachorro', 'gato', 'elefante']
# print(lista_animal[1])
soma = 0
for x in lista:
soma += x
print(soma)
print(sum(lista))
print(max(lista))
print(min(lista))
print(max(lista_animal))
print(m... |
425854801551920590427c26c97c6cc791ee7d43 | lxy1992/LeetCode | /Python/interview/找零问题.py | 799 | 3.671875 | 4 | # -*- coding: UTF-8 -*-
def coinChange(values, money, coinsUsed):
#values T[1:n]数组
#valuesCounts 钱币对应的种类数
#money 找出来的总钱数
#coinsUsed 对应于 前钱币总数i所使 的硬币数
for cents in range(1, money+1):
minCoins = cents
#从第 个开始到money的所有情况初始
for value in values:
if value <= cents:
temp... |
1da8f86df0eb1737339a4ffc51f9f37e6aaaba24 | bui-brian/FinalGradesPrediction-ML | /studentLRM.py | 1,620 | 3.625 | 4 | # Author: Brian Bui
# Date: May 1, 2021
# File: studentLRM.py - Student Performance Linear Regression Model
# Desc: predicting grades of a student by using a linear regression model
# importing all of the necessary ML packages
import numpy as np
import pandas as pd
import sklearn
from sklearn.linear_model import Line... |
5db0164f453ff465f1b12d6c90902573c4404578 | ritobanrc/cryptography-toolkit | /cryptography_toolkit/tests/test_encryption.py | 985 | 3.6875 | 4 | import unittest
from cryptography_toolkit import encrpytion as en
class EncryptionTest(unittest.TestCase):
def test_reverse_cipher(self):
self.assertEqual(en.reverse_cipher("Lorem ipsum dolor sit amet, consectetur adipiscing elit."),
".tile gnicsipida rutetcesnoc ,tema tis rolod m... |
f3a8fa37a1285908b5069546c484b7b5443b37f5 | ni26/MAPCP2019U | /Homework/3/fib.py | 533 | 3.984375 | 4 |
# coding: utf-8
# In[1]:
def fibo(n_int):
if n_int == 0:
return 0
if n_int == 1:
return 1
if n_int >= 2:
return (fibo(n_int-1)+fibo(n_int-2))
# In[4]:
def fib(n):
if isinstance(n,float):
print('The input argument {} is not a non-negative integer!'.format(n)... |
a3f1d3d28fb81c256fd37fd3f6da1ded15395248 | mhelal/COMM054 | /python/evennumberedexercise/Exercise03_12.py | 390 | 3.546875 | 4 | import turtle
length = eval(input("Enter the length of a star: "))
turtle.penup()
turtle.goto(0, length / 2)
turtle.pendown()
turtle.right(72)
turtle.forward(length)
turtle.right(144)
turtle.forward(length)
turtle.right(144)
turtle.forward(length)
turtle.right(144)
turtle.forward(l... |
92ead6f875e82d780d89a676e0c602737dafb509 | mhelal/COMM054 | /python/evennumberedexercise/Exercise03_06.py | 175 | 4.21875 | 4 | # Prompt the user to enter a degree in Celsius
code = eval(input("Enter an ASCII code: "))
# Display result
print("The character for ASCII code", code, "is", chr(code))
|
db0efc096311e8d2bd40a9f845af2a4ee2a38caf | mhelal/COMM054 | /python/evennumberedexercise/Exercise4_6.py | 525 | 4.3125 | 4 | # Prompt the user to enter weight in pounds
weight = eval(input("Enter weight in pounds: "))
# Prompt the user to enter height
feet = eval(input("Enter feet: "))
inches = eval(input("Enter inches: "))
height = feet * 12 + inches
# Compute BMI
bmi = weight * 0.45359237 / ((height * 0.0254) * (heigh... |
b53f694546230e659192bcc46194c791ff1c68a3 | IvoNet/StackOverflow | /src/main/python/005.py | 501 | 4.0625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def bubble_sort(seq):
changed = True
while changed:
changed = False
for i in range(len(seq) - 1):
if seq[i] > seq[i + 1]:
seq[i], seq[i + 1] = seq[i + 1], seq[i]
changed =... |
d808f1b2b598f8549208cbdfe36b635d2f12c6f8 | nsnoel/Fifth-Assignment-nsnoel | /medium_assign.py | 5,672 | 4.21875 | 4 | '''
Implement the following functions based on the question. Retain the name of the functions, and parameters as is in the question.
=================
1. compute_number_of_occurences(file_name) --> 50%
Read the file large_sample.txt, and create dictionary of words where the key is the word, and value is the numbe... |
0aa83c8b941db62f131b3a469d7c96f74e68e7df | jenny-jt/HW-Accounting-Scripts | /melon_info.py | 439 | 3.65625 | 4 | """Print out all the melons in our inventory."""
melon_info = {
'Honeydew': [True, 0.99],
'Crenshaw': [False, 2.00],
'Crane': [False, 2.50],
'Casaba': [False, 2.50],
'Cantaloupe': [False, 0.99]
}
def print_melon(melon_info):
"""Print each melon with corresponding attribute information."""
... |
7c5c01a3d83699a0b7813d8d486c6e24fdf7d213 | VinceBy/newone | /python/001-PythonCooked/第一章 数据结构与算法/14-dictcum.py | 538 | 4.09375 | 4 | prices = {
'ACME': 45.23,
'AAPL': 612.78,
'IBM': 205.55,
'HPQ': 37.20,
'FB': 10.75
}
#zip创建了一个迭代器,只能使用一次
min_price = min(zip(prices.values(), prices.keys()))
print("min_price:",min_price)
max_price = max(zip(prices.values(), prices.keys()))
print("max_price:",max_price)
print('=====================... |
41bbf42e97518fdcaf99fdb6e344d919e466c20e | VinceBy/newone | /python/3day/1.py | 189 | 3.640625 | 4 | #99乘法表
#记录乘法表的长度
i=9
j=1
n=1
while j<=i:
m=1
while m<=j:
n=j*m
print('%d*%d=%-2d'%(m,j,n),end=" ")
m=m+1
print('\n')
j=j+1
|
db1aaeb45d9bbc3493dd74a71d4a17bbaf145046 | VinceBy/newone | /python/04-python高级/01-线程/05-多线程的缺点.py | 480 | 3.703125 | 4 | from threading import Thread
import time
g_num = 0
def test1():
global g_num
for i in range(1000000):
g_num +=1
print("-----test1-----g_num=%d"%g_num)
def test2():
global g_num
for i in range(1000000):
g_num += 1
print("----test2----g_num=%d"%g_num)
p1 = Thread(target=test1)
p... |
a571691e818d6ab77a2397e4d23d9e929941f5dd | VinceBy/newone | /python/2 day/11.py | 83 | 3.734375 | 4 | i=0
while i<=100:
print("%d"%i,end="-")
i=i+1
if i==100:
print("\n")
|
959dc83e6aefc1ce5885b903a6124461f47fd60b | VinceBy/newone | /python/02-python高级-2/06-内建属性/02-内建函数.py | 1,269 | 3.515625 | 4 | from functools import reduce
print('='*30)
print('对map的操作')
#map(f,l1,l2)分别表示 f:函数 l1:操作数1 l2:操作数2
def f1(x,y):
return (x,y)
l1 = [0,1,2,3,4,5,6]
l2 = ['sun','M','T','W','T','F','S',]
l3 = map(f1,l1,l2)
print(list(l3))
print("="*30)
print("对filter的操作")
#filter(f,l) 分别表示 f:函数 True l:操作数
#过滤
a = filter(lambda x: x%2,[... |
eec99a1173918d15dcc2abde23d40d29c451b5fd | VinceBy/newone | /python/suanfa/13-quick-sort.py | 825 | 3.78125 | 4 | def quick_sort(alist,first,last):
if first>=last:
return
mid_value = alist[first]
low = first
high = last
while low < high:
#high的游标左移
while low < high and alist[high] >= mid_value:
high -= 1
alist[low] = alist[high]
#low 右移
while low < hi... |
b0a9cdc7356c886265143290404671c56a7d069a | VinceBy/newone | /python/1016/01-保护对象的属性.py | 595 | 3.5625 | 4 | class Person():
def __init__(self,name,age):
#只要属性名前面有两个下划线,那么就表示私有的属性
#所谓私有,不能在外部使用 对象名.属性名获取
#
#原来没有__的属性,默认是 公有
self.__name = name
self.__age = age
def setNewAge(self,newAge):
if newAge>0 and newAge<=100:
self.__age = newAge
def getAge(self):
return self.__age
def __test(self):
print('---... |
d2b672a5c8dfcacb09f474dc279991ed76ad9afc | VinceBy/newone | /python/01-python高级-1/02-私有化/03-test.py | 426 | 3.59375 | 4 | class Test(object):
def __init__(self):
self.__num = 100
def setNum(self,newNum):
print("----------setter-------")
self.__num = newNum
def getNum(self):
print('-----------getter------')
return self.__num
num = property(getNum,setNum)
t =Test()
#t.__num = 200
... |
b02653080a7a155f673e8bcd85171c44d13485e9 | VinceBy/newone | /python/001-PythonCooked/第一章 数据结构与算法/29-从字典中提取子集.py | 510 | 3.859375 | 4 |
prices = {
'ACME':45.23,
'AAPL':612.78,
'IBM':205.55,
'HPQ':37.20,
'FB':10.75
}
#make directonary of all prices
p1 = {key:value for key,value in prices.items() if value>200}
p1 = dict((key,value) for key,value in prices.items() if value>200)
print(p1)
#make a dictionary of tech stocks
tech_names ... |
cf1a30476f4384a36235c62bd8a4b83a4d3678b2 | VinceBy/newone | /python/1017/03-类方法.py | 739 | 3.890625 | 4 | class Test(object):
#类属性
num = 0
#实例属性
def __init__(self):
#实例属性
self.age = 1
def test(self):
print(self.age)
#类方法
#可以由类名直接调用类属性或更改类属性
#也可以由类的对象调用
@classmethod
def setNum(cls,newNum):
cls.num = newNum
#静态方法
#可以由类直接调用不需要参数也可以由对象调用... |
87d55680fd9999f2b7676dfce3a813750fd56977 | ethanfebs/Minesweeper | /Minesweeper_Playable.py | 2,511 | 3.890625 | 4 | import random
nearby_offsets = [(-1, 0), (0, 1), (1, 0), (0, -1),
(-1, -1), (-1, 1), (1, -1), (1, 1)]
def print_board(board):
"""
Prints board in 2D format
board - 2D list of mine locations
"""
d = len(board)
# print upper border
for i in range(d):
print("==", ... |
b098be5aec4d590c64ed78d96a60fa82031ed103 | FerGrant/ProyectoFinal | /ConvergenciaDivergencia/codigo.py | 475 | 3.71875 | 4 | import numpy as np
import matplotlib.pyplot as plt
def xnew(x):
return (2*x**2 + 3)/ 5
x0 = 0
x1 = 0
itera = 0
x0array = np.zeros(100)
x1array = np.zeros(100)
xexe= np.zeros(100)
for i in range (10):
x1 = xnew(x0)
xexe[i] = 1
x0array[i]= x0
x1array[i]= x1
if abs (x1 - x0) < 0.00000001:
... |
71a19ea2fdcbe4ee378e6859e127addf842acb16 | ashusaini1988/melbourne | /fibo.py | 333 | 3.984375 | 4 | def fibonacci(n):
'''
This is a fibonacci series function.
Comment
'''
a, b = 0, 1
while n > 0:
a, b = b, a+b
n -= 1
return a
#print fibonacci(1000)
assert fibonacci(0) == 0
assert fibonacci(1) == 1
assert fibonacci(2) == 1
assert fibonacci(3) == 2
assert fibonac... |
865e8db4c54b14cfa8f9a4bb332938d240f471ea | ashusaini1988/melbourne | /complex_if.py | 150 | 3.5 | 4 | import sys
a = int(sys.argv[1])
if (a<50) and (a>0):
print "Minor"
elif (a>=50) and (a <1000):
print "Major"
else:
print "severe"
|
e64b941a4dcd7ab11fb3c54aed574abe25959efd | TimKillingsworth/Codio-Assignments | /src/dictionaries/person_dict1.py | 239 | 4.0625 | 4 | #Here's the code for Ringo
person = {'first_name':'Ringo','last_name':'Starr'}
#Add the new entries
person['instrument'] = 'drums'
person['born'] = 1940
#Print the result
print(person['first_name'] + ' was born in ' + str(person['born'])) |
b37520ed33b2fef924c8ea17c96d34799b78cc37 | TimKillingsworth/Codio-Assignments | /src/dictionaries/person_with_school.py | 306 | 4.34375 | 4 | #Create dictionary with person information. Assign the dictionary to the variable person
person={'name':'Lisa', 'age':29}
#Print out the contents of person
print(person)
#Add the school which Lisa attends
person['school'] = 'SNHU'
#Print out the contents of person after adding the school
print(person) |
38a0c28141a41c88aa2d7210c96ffce37abe6e30 | TimKillingsworth/Codio-Assignments | /src/lists/max.py | 317 | 3.8125 | 4 |
# Get our numbers from the command line
import sys
numbers= sys.argv[1].split(',')
numbers= [int(i) for i in numbers]
# Your code goes here
index = 0
maxVal = 0
maxIndex = index
for index in range(0, len(numbers)):
if numbers[index] > maxVal:
maxVal = numbers[index]
maxIndex = index
print(maxIndex) |
d54f448967d127688cc7b4d37c2a9db11aeb5d60 | TimKillingsworth/Codio-Assignments | /src/functions/red.py | 221 | 3.734375 | 4 |
# Get our input from the command line
import sys
text= sys.argv[1]
# Write your code here
def isRed(str):
found = str.find('red')
if found >= 0:
return True
else:
return False
print(str(isRed(text)))
|
5dff174f4164bb5933de55efcf58c74152287e51 | TimKillingsworth/Codio-Assignments | /src/dictionaries/list_of_dictionary.py | 336 | 4.59375 | 5 | #Create a pre-populated list containing the informatin of three persons
persons=[{'name':'Lisa','age':29,'school':'SNHU'},
{'name': 'Jay', 'age': 25, 'school': 'SNHU'},
{'name': 'Doug', 'age': 27, 'school': 'SNHU'}]
#Print the person list
print(persons)
#Access the name of the first person
print(per... |
462acf5fc99890cc95f83ba89f716be60bb7e6fb | Joey238/python_laicode | /Laicode/binarysearch_recursion_2/bisearchtest.py | 5,569 | 4.09375 | 4 | """
Python standard library for binary search tree is bisection method,
which module named bisect
"""
import bisect
def binary_search_tree(sortedlist, target):
if not sortedlist:
return None
left = 0
right = len(sortedlist)-1
"""
1. 首先判断能不能进while loop, 如果只有一个元素在list里面, so, 我需要... |
061398644a97dd50567debc6204b049734d63fcd | Joey238/python_laicode | /Laicode/heap_graph_5/deque_demo.py | 376 | 4.0625 | 4 | from collections import deque
'''
deque:
- stacks and queues (double ended queue0
- thread-save, memory efficient appends and pops from either side of the deque O(1)
'''
queue = deque('Breadth-1st Search')
queue.append('algorithm')
queue.appendleft('hello')
for i in queue:
print(i)
print(f'size: {len(que... |
99bbfce8bd57964e1a177617ef1e3307e6ec3953 | SumitB-2094/My_Money_Bank | /part-1 mini project.py | 810 | 4.0625 | 4 | name=(input("Enter your name:"))
print("-------------------------------------------------------------------------------------------")
a=print("1-Add expense:")
b=print("2-Read expense report:")
c=print("3-Email expense report:")
ans=int(input("Enter your choice:"))
def database():
global database
global ans
... |
ba5f25636ecc3855c69a5e9a8c7548f3ea6f6e4a | Riicha/PythonChallenge | /PyBoss/Employee.py | 1,167 | 4.03125 | 4 | from datetime import datetime
class Employee:
"""Construct employee class and its members/operations"""
# constructor of employee class
def __init__(self,EmployeeId,Name,DOB,SSN,State):
"""Initialize the employee and return a new employee object. """
self.EmployeeId = EmployeeId
# Ne... |
04b3b24788c05906c147423474ec64bcb76a781e | LiamLead/get-initials | /initials.py | 98 | 4.09375 | 4 | name = str(input("Name: ")).title()
for n in name:
if n.isupper():
print(n, end=" ")
|
72dc04ca9c52407b1149442b0d32f377c5e28a12 | nidiodolfini/descubra-o-python | /Guanabara/desafio95.py | 1,211 | 3.6875 | 4 | jogador = dict()
jogadores = list()
gols = list()
while True:
jogador.clear()
jogador['nome'] = str(input('Nome do Jogador: '))
partidas = int(input(f'Quantas partidas {jogador["nome"]} jogou? '))
for i in range(0, partidas):
gols.append(int(input(f"Quantos gols na partida {i + 1}: ")))
... |
e7663c7fb9c123e506298ec2a308be41a5348cce | nidiodolfini/descubra-o-python | /URI/1010.py | 545 | 3.859375 | 4 | # a,w,e = input().split(" ") # pega 3 valores na mesma linha e atribui a variáveis
# # Converte o valor para os tipos necessários
# a = int(a)
# w = int(w)
# e = float(e)
lista = input().split(" ")
lista2 = input().split(" ")
codigo_peca = int(lista[0])
numero_de_peca = int(lista[1])
valor_pecas = float(lista[2])... |
0b0b1b9c830b91417b2c0e2095378548dee688f6 | nidiodolfini/descubra-o-python | /URI/1012.py | 392 | 3.734375 | 4 | dados = input().split(" ")
a = float(dados[0])
b = float(dados[1])
c = float(dados[2])
pi = 3.14159
triangulo = (a * c) / 2
circulo = (c ** 2) * pi
trapezio = (( a + b) * c) /2
quadrado = b * b
retangulo = a * b
print("TRIANGULO: %0.3f" %triangulo)
print("CIRCULO: %0.3f" %circulo)
print("TRAPEZIO: %0.3f" %trapezio)... |
354337fe40f7e1df55cb6c5e935499841b20a20d | nidiodolfini/descubra-o-python | /Guanabara/desafio89.py | 1,631 | 3.828125 | 4 | ficha = list()
while True:
nome = str(input('Nome: '))
nota1 = float(input('Nota 1: '))
nota2 = float(input('Nota 2: '))
media = (nota1 + nota2) / 2
ficha.append([nome, [nota1, nota2], media])
resp = str(input('Quer continuar? S/N: '))
if resp in 'Nn':
break
print('-='*30)
print(f'{"... |
855d056333d0d84f9a450399717f640238d9fe16 | nidiodolfini/descubra-o-python | /CS50/marioLess.py | 240 | 3.890625 | 4 | tamanho = 3
for i in range(tamanho):
for j in range(1,tamanho+1):
if j == tamanho - i:
for b in range(tamanho, j-1, -1):
print("#", end='')
break
print(" ", end='')
print() |
850a2be484f2de91195eadc731948930aaeb9acc | nidiodolfini/descubra-o-python | /Guanabara/desafio76.py | 359 | 3.53125 | 4 | listagem = ( 'Lapis', 1.75,
'Borracha', 2.00,
'Carderno', 20.25,
'Estojo', 9.99 )
print('-'* 40)
print(f'{"Listagem de Preços":^40}')
print('-'*40)
for pos in range(0, len(listagem)):
if pos % 2 == 0:
print(f'{listagem[pos]:.<30}', end='')
else:
print(f'R$... |
765c0c8fe31f4e036da13d40ae79199a85395466 | nidiodolfini/descubra-o-python | /URI/1035.py | 242 | 3.796875 | 4 | numeros = input().split(" ")
a = int(numeros[0])
b = int(numeros[1])
c = int(numeros[2])
d = int(numeros[3])
if ((a % 2 == 0) and (b > c) and (d > a) and ( c + d > a + b)):
print("Valores aceitos")
else:
print("Valores nao aceitos") |
f4f5f02467f01e945a826b16feffa495e89ee51f | nidiodolfini/descubra-o-python | /Guanabara/desafio86.py | 263 | 3.875 | 4 | lista = [[0,0,0], [0,0,0],[0,0,0]]
for l in range(0,3):
for c in range(0,3):
lista[l][c] = int(input(f'Digite um valor na posição: [{l},{c}] '))
for l in range(0,3):
for c in range(0,3):
print(f'[{lista[l][c]:^5}]', end='')
print()
|
bfadb9cad0df6a7f350498a4a4bf0ef05587d6c7 | nidiodolfini/descubra-o-python | /Guanabara/desafio102.py | 335 | 3.734375 | 4 | def fatorial(num=1, show=True):
if show:
fat = num
for i in range(1, num + 1):
if fat != 1:
print(f'{fat}', end=' x ')
else:
print(f'{fat}', end=' = ')
fat -= 1
for i in range(1, num):
num *= i
print(f'{num}')
fat... |
92695e87a783152773fc6fc09851190db2a6d1c7 | nidiodolfini/descubra-o-python | /Guanabara/desafio84.py | 800 | 3.75 | 4 | temp = []
dados = []
maior = menor = 0
while True:
temp.append(str(input('digite o nome: ')))
temp.append(int(input('Digite o peso: ')))
if len(dados) == 0:
maior = menor = temp[1]
else:
if temp[1] > maior:
maior = temp[1]
if temp[1] < menor:
menor = t... |
62e1b57f1ad0ba73813481a24ba2159fd3d5d714 | Eunsol-Lee/projectEulerPythonSolve | /p14 Longest Collatz sequence.py | 370 | 3.671875 | 4 | # Problem 14
# Longest Collatz sequence
#
# By Eunsol
num = {}
num[1] = 1
def seq(x):
if x in num:
return num[x]
if x % 2:
num[x] = seq(3 * x + 1) + 1
else:
num[x] = seq(x / 2) + 1
return num[x]
largest = 0
for i in range(1, 1000001):
if largest < seq(i):
largest =... |
1e758a4591812d3906e4cf6d95a20873f3769720 | jerryAnu/Detecting-Depression-from-Physiological-Features-on-the-basis-of-Neural-Networks-and-Genetic-Algorit | /nn.py | 16,179 | 4.125 | 4 | """
This file is used to detect levels of depression by using a neural network model.
This model is a three-layer network.
This model is not combined with the GIS technique or genetic algorithm.
"""
# import libraries
import pandas as pd
import torch
"""
Define a neural network
Here we build a neural network with... |
e076131a45b7aa04318f73ea7e9d163d1dbf1cf2 | Nireka74/gy-sbj | /excise/duixiang.py | 1,147 | 3.71875 | 4 | #类的封装
# class aaa():
#类变量
# pub_res = '公有变量'
# _pri_res = '私有变量'
# __pri_res = '私有变量2'
#类变量通过类直接调用,双下划线私有变量不能调用。单下划线私有变量能调用,不能修改。
# print(aaa.pub_res)
# print(aaa._pri_res)
# class aaa():
# 实例方法
# def pub_function(self):
# print('公有方法')
# def _pri_function(self):
# print('私有方法')... |
47f7f996f21d85e5b7613aa14c1a6d2752faaa82 | zaidjubapu/pythonjourney | /h5fileio.py | 1,969 | 4.15625 | 4 | # file io basic
'''f = open("zaid.txt","rt")
content=f.read(10) # it will read only first 10 character of file
print(content)
content=f.read(10) # it will read next 10 character of the file
print(content
f.close()
# must close the file in every program'''
'''f = open("zaid.txt","rt")
content=f.read() # it will read a... |
6a72313370336294491913d7eb3b50aaa6c81b65 | zaidjubapu/pythonjourney | /h22operatoroverloadingdunder.py | 970 | 3.9375 | 4 | class Employees:
no_of_l=8
def __init__(self,aname,asalary):
self.name=aname
self.salary=asalary
def printdetails(self):
return f"Namae is {self.name}. salary is {self.salary}"
@classmethod
def change_leaves(cls,newleaves):
cls.no_of_l=newleaves
def __add__(self, ... |
014987c11429d51e6d1462e3a6d0b7fb97b11822 | zaidjubapu/pythonjourney | /enumeratefunction.py | 592 | 4.59375 | 5 | '''enumerate functions: use for to easy the method of for loop the with enumerate method
we can find out index of the list
ex:
list=["a","b","c"]
for index,i in enumerate(list):
print(index,i)
'''
''' if ___name function :
print("and the name is ",__name__)# it will give main if it is written before
if __name__ =... |
50e523c196fc0df4be3ce6acab607f623119f4e1 | zaidjubapu/pythonjourney | /h23abstractbaseclassmethod.py | 634 | 4.21875 | 4 | # from abc import ABCMeta,abstractmethod
# class shape(metaclass=ABCMeta):
# or
from abc import ABC,abstractmethod
class shape(ABC):
@abstractmethod
def printarea(self):
return 0
class Rectangle(shape):
type= "Rectangle"
sides=4
def __init__(self):
self.length=6
self.b=7
... |
dfc07a2dd914fa785f5c9c581772f92637dea0a7 | zaidjubapu/pythonjourney | /h9recursion.py | 1,167 | 4.28125 | 4 | '''
recursive and iterative method;
factorial using iterative method:
# using iterative method
def factorialiterative(n):
fac=1
for i in range(n):
print(i)
fac=fac*(i+1)
return fac
# recusion method which mean callingthe function inside the function
def factorialrecursion(n):
if n==1:
... |
cb8b23c641448a238fd11bdfc9ea7b8116d8991e | zaidjubapu/pythonjourney | /exe7.py | 857 | 3.53125 | 4 | sentences=["python is python very good laguage","python python is python is cool","python is awesome","javascript is good"]
import time
# join=sentences[0].split()
# print(join)
inp=[x for x in (input("enter the word you want to search").split())]
searchmatch=[]
# dict1={}
c=time.time()
for search in inp:
a = 0
... |
b7544654e79a09747fc2ab42643cf265a7a77dc4 | zaidjubapu/pythonjourney | /rough.py | 1,135 | 3.625 | 4 | # # # a="hello"
# # # b="python"
# # # print(a,b,"fish",sep="zain",end="!")
# # # print(a,b,"zain",end="!")
# # a=["ima zaid","iam zuha"]
# # z=a.sort()
# # print(a)
# # import pyaudio
# b=open("zaid.txt",'r')
# for a in b:
# a=a.rstrip()
# print(a)
# import pyaudio1
#to tell you in wich your you will become 10... |
22773f2a2796ae9a493020885a6e3a987047e7f8 | Pegasus-01/hackerrank-python-works | /02-division in python.py | 454 | 4.125 | 4 | ##Task
##The provided code stub reads two integers, a and b, from STDIN.
##Add logic to print two lines. The first line should contain the result of integer division, a// b.
##The second line should contain the result of float division, a/ b.
##No rounding or formatting is necessary.
if __name__ == '__mai... |
6f31574f1e99ad506ecfdc4d1d74dc292f1083be | YuyangZhang/leetcode | /81.py | 1,089 | 3.515625 | 4 | class Solution:
# @param A, a list of integers
# @param target, an integer to be searched
# @return an integer
def search(self, A, target):
B=list(set(A))
return find(B,target,0,len(B)-1)
def find(A,target,start,end):
if A==[]:
return False
if start+1<len(A):
if... |
d8ef559f6a0a87acaa355bf458504cfa53afa5dd | YuyangZhang/leetcode | /153.py | 605 | 3.59375 | 4 | class Solution:
# @param A, a list of integers
# @param target, an integer to be searched
# @return an integer
def findMin(self, num):
return findPeak(num,0,len(num)-1)
def findPeak(A,start,end):
if A[start]<A[end] or start==end:
return A[start]
else:
if end-start==1:
... |
4bea0d3f0b98fe2b2749aa0a2587efb6d7bc1dcb | YuyangZhang/leetcode | /2.py | 935 | 3.59375 | 4 | class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
# @return a ListNode
def addTwoNumbers(self, l1, l2):
i1=1
i2=1
num1=0
num2=0
while True:
num1+=l1.val*i1
if l1.next==None:
... |
9a5fea44aa42331fafd6654f693ed6792fec0a12 | shudongW/python | /Exercise/Python48.py | 403 | 3.6875 | 4 | #-*- coding:UTF-8 -*-
#笨办法学编程py3---异常,扫描
def cover_number(s) :
try:
print("this function's value:", s)
return int(s)
except ValueError:
return None
'''
a = cover_number('python')
print(a)
b = cover_number(12305)
print(b)
'''
stuff = input("> ")
print("input value:",stuff)
words = stuff... |
e1988a2808048261146e27e94d513fc79053aaf9 | shudongW/python | /Exercise/Python21.py | 709 | 4.09375 | 4 | #-*- coding:UTF-8 -*-
#笨办法学编程py3---函数和变量
def add(a,b):
print("ADDING %d + %d " % (a,b))
return a + b
def substract(a,b):
print("SUBTRACT %d - %d " % (a, b))
return a - b
def multiply(a,b):
print("MULTIPLY %d * %d " % (a,b))
return a * b
def divide(a,b):
print("DEVIDE %d / %d" % (a,b))
... |
379509ed51eb7ac9484e7b9a5acbb537b4de7c5b | shudongW/python | /Exercise/Python09.py | 287 | 4 | 4 | # -*-coding: UTF-8 -*-
#笨办法学编程py3-输入
print("How old are you?",end="")
age = input()
print("How tall are you?",end="")
height = input()
print("How much do you weight?",end="")
weight = input()
print("So you're %r old,%r tall and %r heavry." %(age,height,weight))
|
139d9c55627188c10bc2304695fd3c66c700ceb2 | shudongW/python | /Exercise/Python40.py | 507 | 4.25 | 4 | #-*- coding:UTF-8 -*-
#笨办法学编程py3---字典
cities ={'CA':'San Francisco','MI':'Detroit','FL':'Jacksonville'}
cities['NY'] = 'New York'
cities['OR'] = 'Portland'
def find_city(themap, state) :
if state in themap:
return themap[state]
else:
return "Not found."
cities['_find'] = find_city
while Tru... |
fc89e815a53416d1e274bfe9e5eff307f69b3d37 | Jerkow/BNP_Datathon | /datathon_ai/interfaces/responses.py | 1,110 | 3.5 | 4 | from dataclasses import dataclass
from typing import List
@dataclass
class QuestionResponse:
"""
Interface that represents the response of one question.
"""
answer_id: int
question_id: int
justification: str = None
@dataclass
class FormCompanyResponse:
"""
Interface that represen... |
a0c6ea7a8f1310a36a81b72c6edf4214def0ae62 | BarunBlog/Python-Files | /14 Tuple.py | 468 | 4.375 | 4 | tpl = (1, 2, 3, "Hello", 3.5, [4,5,6,10])
print(type(tpl)," ",tpl,"\n")
print(tpl[5]," ",tpl[-3])
for i in tpl:
print(i, end=" ")
print("\n")
#converting tuple to list
li = list(tpl)
print(type(li),' ',li,"\n")
tpl2 = 1,2,3
print(type(tpl2)," ",tpl2)
a,b,c = tpl2
print(a," ",b," ",c)
t = (1)
print(type(t))
t1... |
eefb8356e729952c086e208211ef64f5831a0290 | BarunBlog/Python-Files | /17 Read & Write file.py | 222 | 3.640625 | 4 | fw = open('sample.txt','w') ##'w' for writing file
fw.write('Writing some stuff in my text file\n')
fw.write('Barun Bhattacharjee')
fw.close()
fr = open('sample.txt','r') ##'r' for reading file
text = fr.read()
print(text)
fr.close()
|
fee9b0aa24b959b9e61ce49bdd723327ec68981d | BarunBlog/Python-Files | /leap_year.py | 153 | 3.6875 | 4 |
def main():
n = int(input())
str = ''
for i in range(1,n+1):
str = str + f"{i}"
print(str)
if __name__=="__main__":
main()
|
5a4c0c930ea92260b88f0282297db9c9e5bffe3f | BarunBlog/Python-Files | /Learn Python3 the Hard Way by Zed Shaw/13_Function&Files_ex20.py | 1,236 | 4.21875 | 4 | from sys import argv
script, input_file = argv
def print_all(f):
print(f.read())
def rewind(f):
f.seek(0)
'''
fp.seek(offset, from_what)
where fp is the file pointer you're working with; offset means how many positions you will move; from_what defines your point of reference:
0: means your reference point is... |
b6fefcbd7ae15032f11a372c583c5b9d7b3199d9 | BarunBlog/Python-Files | /02 String operation.py | 993 | 4.21875 | 4 | str1 = "Barun "
str2 = "Hello "+"World"
print(str1+" "+str2)
'''
To insert characters that are illegal in a string, use an escape character.
An escape character is a backslash \ followed by the character you want to insert.
'''
str3 = 'I don\'t think so'
print(str3)
print('Source:D \Barun\Python files\first project.... |
37b61edb32bd793db26b3ec05d4013e0dec76765 | BarunBlog/Python-Files | /Python modules.py | 312 | 3.9375 | 4 | ## Modules: bunch of codes in pyhon library
import calendar ## importing calendar module
year = int(input('Enter a year number: '))
calendar.prcal(year) ## prcal() is a sub-module of calendar module
import math
fact = int(input('Enter a number: '))
print('The Factorial of ',fact,'is: ',math.factorial(fact))
|
fbdbdd1019c438c8cbcff0a8f5ece04701a5ccb4 | sklx2016/Salary-of-Adults | /AdultSalary.py | 1,628 | 3.53125 | 4 | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Loading the Data Set
data = pd.read_csv("train.csv")
null = data.isnull().sum() #To determine the the no. of NaN
# Imputing the NaN Values , other methods such as kNN, sklearn Imputer can also be used
#Educati... |
6f95262465fd4e871d264b3e21469cb6ca41083f | Sartaj-S/Portfolio | /Python/Guess The Word Game/GuessTheWord Game.py | 2,248 | 4.09375 | 4 | import random
def search(letter, word):
n=0
i=0
for x in word:
if letter==x:
n=i
i= i+1
#load words
word=[ 'apple', 'notebook', 'phone', 'monitor', 'coconut', 'burrito', 'convertible', 'mansion', 'unorthodox', 'hangman']
#get random word
i=(random.randint(0,9))
man=w... |
cc727eb2b7cbea8092a744aab971403dfde6b790 | AdamBucholc/SpaceX | /API_CSV.py | 906 | 3.75 | 4 | # Program that writes data from an API to a CSV file.
import requests
import csv
url = "https://api.spacexdata.com/v3/launches"
response = requests.get(url) # Data download.
with open("flights.csv", mode='w') as flights_file:
csv_w = csv.writer(flights_file)
csv_w.writerow([ #Save stri... |
adf3fb5c5918ebccec51fe5b9709cacf78dbf511 | mont-grunthal/titanic_kaggle | /Titanic_training.py | 8,227 | 3.546875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
#import required modules
import math
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import sklearn as sk
import scipy as sp
from sklearn.ensemble import RandomForestClassifier,RandomForestRegressor
from sklearn.experimental import enable_iterat... |
4c137f2f6e171fd84d296099ea98cf0333dba392 | TheCodingRecruiter/joblistinggenerator | /generatorlisting.py | 616 | 3.546875 | 4 | class Hiring:
def __init__(self, title, skills, location):
self.title = title
self.skills = skills
self.location = location
def listjob(self):
print('We have a current job opening for a ' + str(self.title) + ' who is skilled in ' + str(self.skills) + '. The position is ... |
5c5af8b01b167bcf1229a33b6fcd2e8b468322da | kenji-kk/algorithm_py | /list1-19.py | 237 | 3.78125 | 4 | #1から12までを8をスキップして繰り返す
#ダメなら例
for i in range(1,150):
if i == 8:
continue
print(i, end='')
print()
#良い例
for i in list(range(1, 8)) + list(range(9, 150)):
print(i, end=' ')
print()
|
08b2822f41f28adf122c2f069681edf81153cbe2 | DylanDu123/leetcode | /94.二叉树的中序遍历.py | 968 | 3.625 | 4 | #
# @lc app=leetcode.cn id=94 lang=python3
#
# [94] 二叉树的中序遍历
#
# @lc code=start
# Definition for a binary tree node.
import collections
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def inorderTraversal(self, root: TreeNode) ... |
8ed06dba5c6dac0ec030f4a000f274de68a6c2e7 | DylanDu123/leetcode | /48.旋转图像.py | 808 | 3.71875 | 4 | #
# @lc app=leetcode.cn id=48 lang=python3
#
# [48] 旋转图像
#
# @lc code=start
class Solution:
def rotate(self, matrix: [[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
size = len(matrix)
l = size - 1
for row in range(0, int(size/2)):
... |
ac705d9e1b145b8d47a927c79c0917f651da0101 | sanjayait/Python-Tkinter-Library | /Tkinter _Libarary/tic_tac_toe_game.py | 5,792 | 4.03125 | 4 | # Tutorial 17 Tic-Tac-Toe Game
from tkinter import *
root=Tk()
root.minsize(400,400)
root.resizable(0,0)
# Define function to change label of button
x=1
def show(b):
global x
x=x+1
if x%2 == 0:
if (b["text"]==""):
b["text"]="O"
else:
if (b["text"]==""):
... |
48406d347ca5ca5ec379bf78ed0280bab6f62569 | sanjayait/Python-Tkinter-Library | /Tkinter _Libarary/Label_widget.py | 388 | 4.03125 | 4 | # Tutorial 1 Label widget
from tkinter import *
# Create window object
root=Tk()
# Define size of window
root.minsize(600, 300)
# To fix size of window
root.resizable(0, 0)
# Create label in window using "Label" class
lbl=Label(root,text="Sanjay\nGoyal\nBhind",font=("Arial",15),bg='lightgreen',fg='black'... |
ed0c0537b5e48a9f86c70957a9b69f4fba67e35e | AnkitAvi11/100-Days-of-Code | /Strings/longest.py | 511 | 3.765625 | 4 |
def count_substring_length(string : str) -> int :
seen = dict()
last_index = 0
max_len = 0
for i in range(len(string)) :
if string[i] in seen :
last_index = max(last_index, seen[string[i]] + 1)
seen[string[i]] = i
max_len = max(max_len, i - last_index + 1)
... |
54515c6f31106af4e112942e09b8d08e9f5b370c | AnkitAvi11/100-Days-of-Code | /Day 11 to 20/Sort.py | 458 | 4.03125 | 4 | # List sorting in python
class Person(object) :
def __init__(self, name, age) :
self.name = name
self.age = age
def __str__(self) :
return "Name = {} and age = {}".format(self.name, self.age)
if __name__ == "__main__":
mylist = [
Person('Ankit', 22),
Person('... |
047dd0b26413c4e4130f551a9aec46fafafd753f | AnkitAvi11/100-Days-of-Code | /Strings/union.py | 973 | 4.1875 | 4 | # program to find the union of two sorted arrays
class Solution :
def find_union(self, arr1, arr2) :
i, j = 0, 0
while i < len(arr1) and j < len(arr2) :
if arr1[i] < arr2[j] :
print(arr1[i], end = " ")
i+=1
elif arr2[j] < arr1[i] :
... |
6e778eca7af31d0913539cda877f26d6ee5436c3 | AnkitAvi11/100-Days-of-Code | /Day 11 to 20/duplicateinarray.py | 462 | 4.0625 | 4 | # program to find the duplicate in an array of N+1 integers
def find_duplicate(arr : list) -> None :
slow = arr[0];fast = arr[0]
slow = arr[slow]
fast = arr[arr[fast]]
while slow != fast :
slow = arr[slow]
fast = arr[arr[fast]]
fast = arr[0]
while slow != fast :
... |
6c727ec6706b42ea057f264ff97d6f39b7481338 | AnkitAvi11/100-Days-of-Code | /Day 11 to 20/MoveAllnegative.py | 798 | 4.59375 | 5 | """
python program to move all the negative elements to one side of the array
-------------------------------------------------------------------------
In this, the sequence of the array does not matter.
Time complexity : O(n)
space complexity : O(1)
"""
# function to move negatives to the right of the array
def... |
8d431c5c7681b0a7298e20e69d916c106bfba8f9 | AnkitAvi11/100-Days-of-Code | /Strings/equalstring.py | 1,114 | 3.9375 | 4 | """
Equal Strings
-------------
You are given N strings, You have to make all the strings equal if possible.
Output : Print the minimum number of moves required to make all the strings equal or -1 if it is not possible to make them equal at all
"""
# function to get the minimum number of moves
def min_moves(arr : l... |
f035dfbeb10ccb98eb85ae9f7625666fbf31e409 | AnkitAvi11/100-Days-of-Code | /Day 11 to 20/Pangrams.py | 239 | 3.90625 | 4 |
def pangrams(string : str) :
string = string.upper()
alpha = [0]*26
for el in string :
if el.isalpha() : alpha[ord(el) - 65] += 1
return all(alpha)
if __name__ == "__main__":
print(pangrams("ankit")) |
b595a08c2935570d1d5fa83805f03119444ab3f7 | AnkitAvi11/100-Days-of-Code | /Strings/fakepassword.py | 909 | 3.84375 | 4 | def rotate_string(string : list, i : int, j : int) -> None :
while i <= j :
string[i], string[j] = string[j], string[i]
i+=1;j-=1
def main() :
t = int(input())
for _ in range(t) :
original_string = input()
fake_string = list(input())
temp = fake_string.copy()
... |
0ada57c61248ca2d1bc470a1d0dd6fd52b8da72e | AnkitAvi11/100-Days-of-Code | /Recursion/ass3.py | 361 | 3.875 | 4 | def decode_message(string) :
res = list()
for el in string :
next_char = chr(ord(el) - 3)
if ord(el) - 3 < 65 :
next_char = chr(ord(el) - 3 + 26)
res.append(next_char)
return res
if __name__ == '__main__' :
string = input()
res = decode_message(string)
... |
4986274f00f6a7686333e7cddb05dc0b1767e1b8 | siddharthkarnam/leetcode1992 | /151-200/200.py | 1,535 | 3.875 | 4 | '''
200. Number of Islands
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
Example 1:
Input:
11110
11010
11... |
4337472b441001cdb16b3774358b4653148a68e6 | C9Adrian/FaceNET | /facepic.py | 1,849 | 3.90625 | 4 | import curses
#-----------------
# Curses Variables
#-----------------
stdscr = curses.initscr() # Initiate the curses terminal
curses.start_color()
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_BLUE, curse... |
2745adacab5e9df7eee9e5b1b6dff266012519b4 | kollyQAQ/wx-robot | /learning/chart/main.py | 333 | 3.84375 | 4 | fig = dict({
"data": [{"type": "bar",
"x": [1, 2, 3],
"y": [1, 3, 2]}],
"layout": {"title": {"text": "A Figure Specified By Python Dictionary"}}
})
# To display the figure defined by this dict, use the low-level plotly.io.show function
import plotly.io as pio
# pio.show(fig)
print(... |
e4649cc9aea90f14b3a27effd33b8367bdeda2c3 | jackrosetti/ProjectEulerSolutions | /Python/prob17.py | 806 | 3.796875 | 4 | # If the numbers 1 to 5 are written out in words: one, two, three, four, five,
# then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
#
# If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
#
#
# NOTE: Do not count spaces or hyphens.
# For exampl... |
0354cd26dbab16b6c889222b491e5b3bba47b33c | kishoreramesh84/python-75-hackathon | /scopedemo.py | 187 | 3.625 | 4 | x=10
def fun1():
#"x=x+1"
print("x=x+1 this statement produces error as this function treats x as a local variable")
def fun2():
global x
x=x+1
print(x)
fun1()
fun2()
|
9f076e1b7465ff2d509b27296a2b963dd392a7f9 | kishoreramesh84/python-75-hackathon | /filepy2.py | 523 | 4.28125 | 4 | print("Reading operation from a file")
f2=open("newfile2.txt","w")
f2.write(" Hi! there\n")
f2.write("My python demo file\n")
f2.write("Thank u")
f2.close()
f3=open("newfile2.txt","r+")
print("Method 1:")
for l in f3: #Method 1 reading file using loops
print(l,end=" ")
f3.seek(0) #seek is used to place a pointer to... |
cf268b95b8fffc6af24f53bd1412ecf5cc72ca1a | kishoreramesh84/python-75-hackathon | /turtlerace.py | 888 | 3.90625 | 4 | import turtle
from turtle import *
from random import randint
wn=turtle.Screen()
wn.bgcolor("light yellow")
wn.title("Race")
turtle.pencolor("dark blue")
penup()
goto(-200,200)
write("RACE TRACK!!",align='center')
goto(-160,160)
for s in range(16):
write(s)
right(90)
forward(10)
pendown()
forward(15... |
6628b79efc3e8d60d67344ecb44be3e03c3217ce | Jemanuel27/URI | /URI_SALARIO_1008.py | 142 | 3.640625 | 4 | N = int(input())
H = int(input())
R = float(input())
salario = float(H * R)
print ("NUMBER = %d" %N)
print("SALARY = U$%.2f" %salario) |
End of preview.
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.