blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
73a3570d4e133d5a84848e0bd99fba4f4b5d4bbf | SATAY-LL/LaanLab-SATAY-DataAnalysis | /python_transposonmapping/python_modules/chromosome_and_gene_positions.py | 6,569 | 3.65625 | 4 | '''This module includes three functions, 'chromosome_position', 'chromosomename_roman_to_arabic' and 'gene_position'.
Except for 'chromosomename_roman_to_arabic', the functions require an input with the full path to the file 'Saccharomyces_cerevisiae.R64-1-1.99.gff3' (which can be downloaded from https://www.ensembl.or... |
2127d5578f680cf952d71afb4fc12684648ef3fb | SimonCK666/C_Project | /CA_20_SpecialInfo/max_Common_Divisor.py | 529 | 3.875 | 4 | #
# max_Common_Divisor.py
# @author bulbasaur
# @description
# @created 2020-07-29T19:15:50.411Z+08:00
# @last-modified 2020-07-29T19:19:46.775Z+08:00
#
# Define a func
def fun(x, y):
# get min
if x > y:
smaller = y
else:
smaller = x
for i in range(1, smaller + 1):
if((x %... |
b9274e759685c79c83518ece5113e447ffc69b72 | FernandaRodriguez/Tarea_03 | /horas.py | 788 | 3.90625 | 4 | #encoding:UTF-8
#Ma Fernanda Rodriguez Hrdz
#escribir un programam que calcule el pago normal y el pago extra de un trabajador
def pagoNormal(normal,pago):
pagoNormal = normal * pago
return pagoNormal
def pagoExtra(extra,pago):
# aplicando el 50% mas
pagoHorasExtra = (pago * .5) + pago
pagoExtra ... |
d61c923be247454e02e67f60bf6cf8532cad8066 | Akash006/Apy_snipets | /flush_magic.py | 477 | 3.90625 | 4 | import sys
import time
print(f'{"="*10} Output without Flush {"="*10}')
# It will take 10 sec to print the output as print
# takes the data into buffer and then when the buffer gets
# full it prints the data.
for i in range(10):
print(i, end=' ')
time.sleep(1)
print("\n")
print(f'{"="*10} Output with Flush ... |
91cdbbd96fde95172b805d12ef657b4a33c79295 | MrHunterBoi/EVERYTHING | /2ndLab.py | 826 | 3.953125 | 4 | while True:
print('''1. Calculate quantity of letters in word
2. Make words in alphabetical order
3. Make word reversed
4. Exit''')
choice = input("Please choose something: ")
if choice == "1":
word = input("Enter some text for calculation: ")
a='abcdefghijklmnopqrstuvwxyz'
for i in range(len(a)):
... |
8cea6e7cd06065baff44920544272d5364455b3f | FlorentinPopescu/Self_Paced-Online | /students/terrance_jones/lesson9/mailroom9.py | 4,472 | 3.78125 | 4 | """
Mailroom9.py
Written by Terrance Jones
Assignment for lesson 9 UW Selfpaced Online course
"""
class Donor:
"""Creates a donor with name and and empty dontation list """
def __init__(self, name, donation):
self.name = name
self.donations = [donation]
@property
def number_donations(s... |
d6e74ef2cfb98c0910324cb301f322fc40e73817 | weixiaoshuo/python_project | /threadprogram/thread_one.py | 780 | 3.859375 | 4 | # python多线程编程,使用threading标准库
import threading
from time import sleep, ctime
loops=[4, 2]
def loop(nloop, nsec):
print('start loop ' + str(nloop)+' at '+ ctime())
sleep(nsec)
print('loop ' + str(nloop)+ ' done at '+ctime())
def main():
print(' starting at : '+ctime())
threads = [];
nloops =... |
b05f7f039b76e82b1955b57480088f3453713be6 | DICFACT/LogicCalc | /core/utils/vec.py | 443 | 3.890625 | 4 | """работа с векторами"""
def mul(vec: tuple, val: float):
"""Умножает каждую координату вектора на указанное значение"""
return tuple(map(lambda x: x * val, vec))
def imul(vec: tuple, val: float):
"""Умножает каждую координату вектора на указанное значение"""
return tuple(map(lambda x: int(x * val),... |
ff920b609d1103aa0add351a7e1fa2a180678d8f | NiumXp/Algoritmos-e-Estruturas-de-Dados | /src/python/quick_sort.py | 930 | 4.34375 | 4 | """ Implementaçao do algoritmo quick sort """
def swap(a_list, pos1, pos2):
""" Troca a posição de dois itens em uma lista """
temp = a_list[pos1]
a_list[pos1] = a_list[pos2]
a_list[pos2] = temp
def partition(a_list, start, end):
""" Divide uma lista """
pivot = a_list[start]
while True:... |
792dea1392e702331e32903a33567e1a954ba736 | NiumXp/Algoritmos-e-Estruturas-de-Dados | /src/python/busca_binaria.py | 962 | 4.0625 | 4 | """ Implementação do algoritmo de busca binária com recursão """
def busca_binaria(valor, vetor, esquerda, direita):
"""
Implementação de um algoritmo de busca binária com recursão.
Argumentos:
valor: Any. Valor a ser buscado na lista
vetor: list. lista ordenada na qual o valor será buscado
e... |
1a56c5287a08682dc4c2f711957c7d4fab9b2a3a | NiumXp/Algoritmos-e-Estruturas-de-Dados | /src/python/fatorial_recursiva.py | 414 | 4.03125 | 4 | """ Algoritmo de fatorial implementado com recursão """
def fatorial_recursivo(numero):
"""
Implementação de um algoritmo de fatorial com recursão.
Argumentos:
numero: int. o número do qual deseja-se obter o fatorial.
Retorna o resultado da operação.
"""
if numero == 1:
retur... |
42ce477183ff2efaeda2969db61cc0d44e3c6695 | NiumXp/Algoritmos-e-Estruturas-de-Dados | /src/python/busca_em_grafo.py | 2,880 | 3.75 | 4 | # Grafos - Algoritmos de BFS e DFS em Python
# Bruno Dantas de Paiva - 2021
# https://github.com/DantasB
from collections import deque
class Grafo():
"""Define um grafo utilizando matriz de adjacências.
Args:
arestas (list): uma lista de listas onde o indice é o
... |
e3013614a4dab8e0a4c11dadd94ee584fb6529cb | NiumXp/Algoritmos-e-Estruturas-de-Dados | /src/python/exponenciacao.py | 458 | 4.03125 | 4 | """ Algoritmo de exponenciação """
def exponenciacao(base, expoente):
"""
Implementação de um algoritmo de exponenciação.
Argumentos:
base: int. Base da operação
expoente: int. Expoente da operação.
Retorna o resultado da operação de exponenciação
"""
result = base
for _ ... |
64a18a6ea20a447482bbbb69110f4534bbe7d7f9 | anshul0708/MLMI_Exercises | /05_exercise/myKmeans.py | 6,781 | 4.0625 | 4 | """
% K-Means Implementation
% This is the outline of your first excercise in Machine Learning for
% Medical Application (MLMI) practical course
% --------------------------------------------------------------------------------------------
% Author
% Shadi Albarqouni, PhD Candidate @ CAMP-TUM.
... |
6f8853dc2f37295b8d3da7ffdcce523045a412e3 | sinanli1994/CP1404_A2 | /itemlist.py | 7,531 | 3.515625 | 4 | from kivy.app import App # Import relevant kivy function
from kivy.lang import Builder
from kivy.uix.button import Button
from item import Item
import operator # import the operator
import csv # import the csv file
class Itemlist(App):
def build(self): # Create the main widget for Kivy program
self.fi... |
168847f4391b0fd3f838ff6eb61fae6132b8226b | BarryZM/Python-AI | /BasicLibs/learnMatplotlib/scatter-demo1.py | 408 | 3.6875 | 4 | # -*- coding: utf-8 -*-
'''
Created by hushiwei on 2018/6/6
Desc :
'''
import numpy as np
import matplotlib.pyplot as plt
# 产生测试数据
x = np.arange(-10, 10)
y=list(map(lambda l:l*l,x))
print(x)
print(y)
print('~'*100)
fig=plt.figure()
ax=fig.add_subplot(111)
ax.set_title('Scatter plot demo1')
plt.xlabel('X')
... |
82755fcc26c05cd20d0923b3c26071cc8ba2febc | BarryZM/Python-AI | /BasicLibs/learnOthers/python-functions-useful.py | 279 | 3.515625 | 4 | # -*- coding: utf-8 -*-
'''
Created by hushiwei on 2018/5/28
Desc :
'''
def buy(x):
return x!='2'
arr=['1','2','3','4']
i = filter(buy, arr)
for l in i:
print(l)
print(type(l))
re=map(float,filter(buy, arr))
for l in re:
print(l)
print(type(l)) |
335c81aafe1ce5f80dee55c6983f5d418f51785c | BarryZM/Python-AI | /BasicLibs/learnMatplotlib/scatter-demo2.py | 461 | 3.5625 | 4 | # -*- coding: utf-8 -*-
'''
Created by hushiwei on 2018/6/6
Desc :
'''
import numpy as np
import matplotlib.pyplot as plt
# 产生测试数据
x = np.arange(-10, 10)
y = list(map(lambda l: l * l, x))
print(x)
print(y)
print('~' * 100)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('Scatter plot demo1')
plt.... |
dfd3716d9649d22c58564e6d3b58060ecf133574 | BarryZM/Python-AI | /MachineLearning/KMeans/case07.py | 1,202 | 3.59375 | 4 | # -*- coding: utf-8 -*-
'''
Created by hushiwei on 2018/10/24
Desc :
Note :
'''
import matplotlib.pyplot as plot
import pandas as panda
# opening datafile
datafile = panda.read_csv('./datas/Customers.csv')
X = datafile.iloc[:, [3, 4]].values
# applying K-Means to datafile
from sklearn.cluster import... |
4613abaed83fc1d5bf47bb8dfef5edd30c8be110 | pro-gramiz/hpj | /Car problem.py | 557 | 3.828125 | 4 | #ans
a=list(input())
while(len(a)>1):
x=0
for i in a:
x+=int(i)
a=list(str(x))
print('Valid' if a[0]=='1' or a[0]=='3' else 'Invalid')
#que
Balaji deva bought a new car and prefers certain registration numbers based on the following condition: The summation of the digits until he gets a number b... |
08f63a7bd6b9bee7ab28a75044a3e7a88a20d7be | pro-gramiz/hpj | /Frequency of digits.py | 403 | 3.75 | 4 | #ans
a=list(input())
b=list(set(a))
b.sort()
for i in b:
print(i+':'+str(a.count(i)))
#que
Problem
Submissions
Leaderboard
Discussions
Write a program to compute the frequency of digits in a given number
Input Format
Input contains integer
Constraints
1<=n<=100000
Output Format
... |
bd31686625d6d4fa7296c771a9b39892a74ed739 | pro-gramiz/hpj | /Prison Security Protocol.py | 2,303 | 3.90625 | 4 | #question
There is a highly secure prison which holds most dangerous criminals in the world. On 2nd November 2019 the prison officials received a warning that there was an attack planned on the prison to free the criminals. So, the prison officials planned a quick evacuation plan. They planned to shift all the criminal... |
1e4c4d62984b46e94fc59a4fc896ea0ef6cad1b9 | DMalonas/python-tasks-g | /Exercises/Ex1.py | 1,125 | 4.0625 | 4 | def fibonacci(n):
if n < 0:
print("Incorrect input")
# First Fibonacci number is 0
elif n == 0:
return 0
# Second Fibonacci number is 1
elif n == 1:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
def test_prime(n):
print(str(n) + ":\n")
if n =... |
f6b1fc4b2314408438b49674f49412a68e2d818a | Charlotteec/euler-problems | /Python/euler_006.py | 356 | 3.59375 | 4 |
def sumOfSquares(num):
squares = []
for i in range(num+1):
squares.append(i*i)
return sum(squares)
def squareOfSums(num):
numbers = []
for i in range(num+1):
numbers.append(i)
nsum = sum(numbers)
return nsum*nsum
print(sumOfSquares(100))
print(squareOfSums(100))
print(s... |
3fafab6e66adbdc8f566ee17ace4da2cc01beb29 | scottyungit/lufei_python | /第二模块/第一张作业/增删改查程序.py | 4,804 | 3.703125 | 4 | #-*- coding: utf-8 -*-
import os
def select():
"""查询语句1:find name,age from staff_table where age >= 22
2: find * from staff_table where dept = IT
3:find * from staff_table where enroll_date like 2013"""
sql=input("输入查询语句: ")
sql_list=sql.strip().split()
staff_table_var_list = ["s... |
ef3975103010c44213d289b635070f1c2cf6d810 | scottyungit/lufei_python | /第二模块/函数/生成器.py | 1,118 | 4.0625 | 4 | #coding=utf-8
#列表生成式和生成器的区别 ,列表生成器已经将每个元素生成,占用了内存。生成器是在调用的时候才会生成元素。
#在函数中写上yield 当执行函数时,遇到yield就会中止在此,下次next()时,再次继续执行。
#有yield的函数 就会变成一个生成器。
#两种方法写一个生成器:
#1.类似列表生成式的方法,把[]变成了()
a=(x*x for x in range(10))
print(a)
print(next(a))
print(next(a))
print(next(a))
#2.函数的方法
def fib(max):
n,a,b=0,0,1 #同时赋予三个变量的值
whi... |
0fde34bea884212df3b0f5a26d58ba550fddc52a | scottyungit/lufei_python | /第一模块:python基础/unit2-dict-list-fileopen/二进制_字符编码.py | 783 | 3.625 | 4 | # -*- coding: utf-8 -*-
#bin():把十进制数字转为二进制格式
# print(bin(342))
#ascii 美国信息交换标准表(实现文字(包括数字)与计算机能识别的的十进制数相关联)
#作图工具 : 文字 十进制 二进制
#bit 比特
#1byte=8bit=1B 百特 计算机的最小存储单位
# python2和python3字符编码
# python2默认使用ascii ,你写一个文件(中间有中文)叫 hello.py.现在执行python hello.py。就会报错,看不懂中文
# python默认使用utf-8,就不会有问题
# 要想python2支持中文,在py文件的开头写入: ... |
e154cb8bf2f670caf48f1a8f61b9cc3ad441fee2 | scottyungit/lufei_python | /第一模块:python基础/unit1-python-basic/用户认证登录作业/作业.py | 301 | 3.96875 | 4 | # encoding: utf-8
real_username = 'scott1'
real_password = 'password1'
i=1
while i <= 3:
username = input("what's you username:")
password = input("what's your password:")
if username == real_username and password == real_password :
print('welcome',username)
exit()
i+=1
|
2c21891d5fb9ccb7a78538b14091f833f2196fd3 | scottyungit/lufei_python | /第二模块/常用模块介绍/json模块.py | 819 | 3.5625 | 4 | #-*- coding: utf-8 -*-
import json
# data={
# "roles":[
# {"roles":'monster',"type":"pig","life":50},
# {"roles":"hero","type":"关羽","life":"80"}
# ]
#
# #使用json.dump()将dict存到文件中,json.dump()需要跟一个文件对象,所以需要下面这几句打开文件的操作。f就是一个文件对象
# f=open("test.json","w")
# json.dump(data,f) ##json 可以dump好几次,但最好不要... |
daefabcbd0d37f69c26d67b046796a2af06a5503 | scottyungit/lufei_python | /第三模块-面向对象/类继承.py | 1,206 | 4.03125 | 4 | # -*- coding:utf-8 -*-
class ParentClass:
pass
class SubClass(ParentClass):
camp = "personal"
pass
# 打印出子类继承哪个类
print(SubClass.__bases__)
# 总结: 在继承属性时,先找对象自己 -->Class -->ParentClass,
# 多继承
#print(SubClass.mro()) # 默认有个mro方法,可以帮你统计出继承的顺序
#到底是怎么一个原理呢?
#python2中的多继承
#经典类:没有继承object类 深度优先
#新式类:继承objec... |
8565867c55d6e0464f1a672f57bffb946111f37a | scottyungit/lufei_python | /test.py | 1,092 | 4 | 4 | # # # name1='scott'
# # # name2='scott'
# # # print (name1) if name1 is name2 else print("different")
# # #
# # #
# # # i=0
# # # while i<=3:
# # # user=input("what's you username:")
# # # password=input("what's your password:")
# # #
# # # if (user=='seven'or user=='alex') and password=='123':
# # # ... |
0d88b33746c1a40f58054cd45825a6ac8587f06e | scottyungit/lufei_python | /第三模块-面向对象/封装的意义.py | 2,610 | 4.1875 | 4 | # 封装数据属性: 明确区分内外
# 装函数属性:隔离复杂度,藏一些不重要的函数方法,加上__
# class People():
# def __init__(self, name, age):
# self.__name = name
# self.__age = age
#
# # 通过定义此方法,让对象间接访问了隐藏属性
# def tell_info(self):
# print("Name:%s Age:%s" %(self.__name,self.__age))
#
# # 通过定义此方法,防止对象在外部随便修改属性,通过函数可以加一些判断... |
ef9132867f0e10c5c43dea888dcbd67c08e56f73 | JianliZh429/opencv-learning | /lesson_openface/_3D_points.py | 508 | 3.734375 | 4 | import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def draw_3d_points(_3d_points):
fig = plt.figure()
# ax = fig.add_subplot(111, projection='3d')
ax = Axes3D(fig)
for x, y, z in _3d_points:
print(x, y, z)
ax.scatter(x, y, z)
ax.set_xlabel('X Label')
ax.se... |
4c64458517ce79ceeb6e4e619b2916ba9107e312 | david2999999/Python | /Archive/PDF/File_And_Directory/Operating-on-Directories.py | 1,091 | 4.125 | 4 | import os
import shutil
# Creating an empty directory is even easier than creating a file. Just call os.mkdir . The parent directory
# must exist, however. The following will raise an exception if the parent directory C:\photos\zoo does
# not exist
os.mkdir("C:\\photos\\zoo\\snakes")
# You can create the parent dire... |
9bdf3e3f9c208fdae61c43de68951e2328676900 | david2999999/Python | /Archive/PDF/Function/Function-Within-Function.py | 2,976 | 4.84375 | 5 | # Defining a function within another function looks exactly like defining it at the top level. The only
# difference is that it is indented at the same level as the other code in the function in which it ’ s contained.
# You may decide that a particular function ’ s work is too much to define in one place and want to ... |
43d417f04d7711fb69d6b7f63003573d2da64480 | david2999999/Python | /Archive/PDF/Loops/Break.py | 1,112 | 4.5 | 4 | # Infinite loops can be exited by using the break statement.
def main():
age = 0
while True:
how_old = input("Enter your age: ")
if how_old == "no":
print("Don't be ashamed of your age!")
break
num = int(how_old)
age = age + num
print("Your age ... |
b71b6af7e44abcc929de7b0d7286b30219c6efcb | david2999999/Python | /Archive/PDF/Sequences/Pop-From-List.py | 1,290 | 4.375 | 4 | def main():
# You need to tell pop which element it is acting on. If you tell it to work on element 0, it will pop the
# first item in its list, passing pop a parameter of 1 will tell it to use the item at position 1 (the second
# element in the list), and so on. The element pop acts on is the same number t... |
47810ae05723bd2b94d087b7db4324c1b5b13e7f | david2999999/Python | /Complete Python BootCamp - Udemy/Section 5 - Statements/Useful Operators/useful-operators.py | 974 | 4 | 4 | my_list = [1, 2, 3]
for num in range(0, 11, 2):
print(num)
print(list(range(0, 11, 2)))
index_count = 0
for letter in 'abcde':
print('At index {} the letter is {}'.format(index_count, letter))
index_count += 1
word = 'abcdef'
for index, letter in enumerate(word):
print(f'{index} {letter}')
my_list1 ... |
942bde9e30c0212ce843b1ee748a5ebd46b15cb7 | david2999999/Python | /Complete Python BootCamp - Udemy/Section 6 - Methods and Functions/Lambda Expressions/map.py | 353 | 3.8125 | 4 | def square(num):
return num ** 2
my_nums = [1, 2, 3, 4, 5]
for item in map(square, my_nums):
print(item)
new_list = list(map(square, my_nums))
print(new_list)
def splicer(my_string):
if len(my_string) % 2 == 0:
return 'EVEN'
else:
return my_string[0]
names = ['Andy', 'Eve', 'Sally']... |
a8645d73b830114b2d7a69a1bd1fc635aaa65a76 | david2999999/Python | /Complete Python BootCamp - Udemy/Section 6 - Methods and Functions/Exercise/Level 2 Problems/problem-1.py | 336 | 3.84375 | 4 | # Given a list of ints, return True if the array contains a 3 next to a 3 somewhere
def has_33(nums):
for i in range(0, len(nums) - 1):
if nums[i] == 3 and nums[i + 1] == 3:
return True
return False
# print(has_33([1, 3, 1, 3]))
# print(has_33([1, 3, 3, 3]))
# print(has_33([3, 3, 1, 3]))
pr... |
fdc15c0000c2138485dd096c4948b8515b174bba | david2999999/Python | /Archive/PDF/Objects/Fridge.py | 3,919 | 3.984375 | 4 | def main():
class Fridge:
def __init__(self, items={}):
if type(items) != type({}):
raise TypeError("Fridge requires a dictionary but was given %s" % type(items))
self.items = items
return
def __add_multi(self, food_name, quantity):
if... |
4681c4d95410d36948ac301c6df2e7752f1898b2 | david2999999/Python | /Archive/PDF/Sequences/List.py | 1,503 | 4.625 | 5 | def main():
breakfast = ["coffee", "tea", "toast", "egg"]
count = 0
print("Today's breakfast is %s" % (breakfast[count]))
count = 1
print("Today's breakfast is %s" % (breakfast[count]))
count = 2
print("Today's breakfast is %s" % (breakfast[count]))
count = 3
print("Today's break... |
0f89b2dbe677aa888685d352d09467b7c280c5a0 | david2999999/Python | /Archive/PDF/Objects/Interface-Method.py | 1,675 | 4.25 | 4 | def main():
class Fridge:
def __init__(self, items={}):
if type(items) != type({}):
raise TypeError("Fridge requires a dictionary but was given %s" % type(items))
self.items = items
return
def __add_multi(self, food_name, quantity):
if... |
57bd3416101252d3a2168a0e5a40f027a2298ddf | david2999999/Python | /Archive/PDF/Basic/Basic-Math.py | 1,787 | 4.21875 | 4 | # Simple math looks about how you ’ d expect it to look. In addition to + and – , multiplication is
# performed by the asterisk, *, and division is performed by the forward slash, /.
def main():
print(5 + 300)
print(399 + 3020 + 1 + 3456)
print(300 - 59994 + 20)
print(4023 - 22.46)
print(2000403030... |
3df117bbde8102c47c461ce4abe7c684672a8885 | david2999999/Python | /Archive/PDF/Decision/If.py | 1,978 | 4.40625 | 4 | def main():
# Python has a very simple way of letting you make decisions. The reserved word for decision making is
# if , and it is followed by a test for the truth of a condition, and the test is ended with a colon, so you ’ ll
# see it referred to here as if ... : . It can be used with anything that evalu... |
20cfb0ff9712fdf3219f747264764691210e5d55 | madhusudansatapathy/python | /input.py | 135 | 4 | 4 | num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
add = num1+num2
print("Addition: ", add)
|
0a0ef4144afbc114fedc4bf761c12d157697325d | madhusudansatapathy/python | /variables.py | 4,714 | 4 | 4 | """
Python variables:
Basic Data types:
Numbers: int, float
String: str
Boolean: bool
Types of variables:
1. Local variable: The variable declared inside the function and also the variable declare as function argument is local var.
2. Global variable: The variable declared outside the function
Function... |
50d2016ee66038463af92291ac82b3e84ef75cfd | Dyksonn/Exercicios-Uri | /1036.py | 347 | 3.5625 | 4 | import math
linha1 = input().split(" ")
A,B,C = linha1
A = float(A)
B = float(B)
C = float(C)
delta = B * B - 4 * A * C
if delta < 0 or A == 0:
print('Impossivel calcular')
else:
R1 = (-B + math.sqrt(delta)) / (2 * A)
R2 = (-B - math.sqrt(delta)) / (2 * A)
print('R1 = %0.5f' %(R1))
prin... |
95674afa147e46e78fd11369bb7524a356f95d74 | Dyksonn/Exercicios-Uri | /1071.py | 119 | 3.640625 | 4 | a = int(input())
b = int(input())
s = 0
for num in range((b + 1), a):
if (num % 2):
s += num
print(s) |
ae333d1b58ebc14b108b5f5fb9dfcd7545f0f731 | Dyksonn/Exercicios-Uri | /1133.py | 145 | 3.953125 | 4 | a = int(input())
b = int(input())
if(a > b):
a, b = b, a
for num in range(a + 1, b):
if(num % 5 == 2) or (num % 5 == 3):
print(num) |
a7d59796b9e1dc3c86ecd88b75f7296ee9958c25 | Dyksonn/Exercicios-Uri | /1043.py | 278 | 3.65625 | 4 | valor = input().split(" ")
a = float(valor[0])
b = float(valor[1])
c = float(valor[2])
if (a < b + c) and (b < a + c) and (c < a + b):
perimetro = a + b + c
print('Perimetro = %.1f' %perimetro)
else:
area = ((a + b)* c) / 2
print('Area = %.1f' %area) |
4765638839c81b6264253eea095bb4e9b155577d | gurby123/Python | /pythonAsync/thread/thread2.py | 1,191 | 4.15625 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
####################################################################################
# Python thread
# thread.start_new_thread ( function, args[, kwargs] )
####################################################################################
import threading
import time
exitFl... |
3d0b7b5c019077e873b5aa0c45e0946d5769fb2f | gurby123/Python | /fin101/fin103.py | 14,703 | 3.875 | 4 | import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt
############################################
# Used to generate an index array
dates = pd.date_range('20130101', periods=5)
np.random.seed(12345)
x = pd.DataFrame(np.random.rand(5, 2), index=dates, columns=('A', 'B'))
... |
abd04e00b437557cb5ddaf39c2b5785a157869c1 | gurby123/Python | /pythonPractice/python_class.py | 3,354 | 4.03125 | 4 | #!/usr/local/bin/python
# -*- coding: UTF-8 -*-
class MyClass:
"""A simple example class"""
i = 12345
__update = "update" # private copy of original update() method
def __init__(self):
print("No no, __init__")
def f(self):
print("Hello World!")
print(MyClass.i)
try:
MyClass.f()
except:
print("Except... |
63a4877aacaba6d95ec065b8898fb092f82f958b | gurby123/Python | /pythonAsync/thread/thread.py | 2,031 | 4.0625 | 4 | import time
####################################################################################
# Python thread
# thread.start_new_thread ( function, args[, kwargs] )
####################################################################################
from threading import Thread
class myThread (Thread): #继承父类thre... |
58a26ff7090a40adb873d81cfece4dfbb318f19b | aaronbush/aoc-2020 | /d12/part2.py | 3,290 | 3.59375 | 4 | import sys
from typing import Tuple
def inc(o, v): return o+v
def dec(o, v): return o-v
def nop(o, v): return o
def update_location(location: Tuple[int, int], amount: int, x_fun=nop, y_fun=nop) -> Tuple[int, int]:
new_point = (x_fun(location[0], amount), y_fun(location[1], amount))
if len(location) > 2:
... |
3f8806ff9c083c44a5dabe22f71a156163fa1991 | bijaykahar/Types-of-Regression | /Multiple Linear Regression/Multiple Linear Regression.py | 1,174 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 21 02:28:38 2020
@author: Kahar's
"""
#Multiple Linear Regression
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Companies.csv')
#print(dataset.columns)... |
ca90d8fb7cc7a35530501f9c4ec1e47f9cab8888 | rahlk/coding-practice | /strings/string_compare_with_backspaces.py | 2,162 | 4.1875 | 4 | """
Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.
Example 1:
Input: S = "ab#c", T = "ad#c"
Output: true
Explanation: Both S and T become "ac".
Example 2:
Input: S = "ab##", T = "c#d#"
Output: true
Explanation: Both S and T become "".
E... |
e394cca30c90d5875b852777897e2fec50d5641c | GG-kun/com139-class | /sim_combat/army/army_deploy.py | 450 | 3.6875 | 4 | from enum import Enum
class ArmyDeploy(Enum):
"""An enumeration of the types of army deployments"""
UNDEFINED = 0, 'UNDEFINED type. will do Random distribution'
HORIZONTAL = 1, 'Horizontal.'
VERTICAL = 2, 'Vertical.'
UP_DIAGONAL = 3, 'Upper Diagonal.'
DOWN_DIAGONAL = 4, 'Down Diagonal.'
RA... |
7bda264417a371efbe6b9e76a4cc4b7816d10e1f | spno77/OOP-python | /3.classmethods_staticmethods.py | 1,186 | 3.8125 | 4 | #classmethods and staticmethods
class Employee:
num_of_emps = 0
raise_ammount = 1.04
def __init__(self,first,last,pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + last + '@company.com'
Employee.num_of_emps += 1
def fullname(self):
return '{} {}'.format(self.first,s... |
7b1b54c2dc5a01f74e9adf5a445ef3f8251e10e5 | shivaverma97/minion-game | /minion_game.py | 1,581 | 3.546875 | 4 | # WORKS FOR ALL
vowels = ['A','E','I','O','U']
def minion_game(string):
strt_scr = 0
kvn_scr = 0
for i in range(len(string)):
if string[i] in vowels:
kvn_scr += len(string)-i
else:
strt_scr += len(string)-i
if strt_scr>kvn_scr:
print(f'Stuart {strt_scr... |
047c790aa836bbcb5831808f2ed8ee2534cca67d | Unick-q/Virus | /person.py | 682 | 3.5625 | 4 | import random
class Person:
id = 0 # Initial population
def __init__(self):
Person.id += 1 # Name of the person.
self.id = Person.id
# Epidemic state
self.suceptible = 0 #int(round(random.uniform(0, 1), 0)) # 0 means without disease, 1 means infected
self.exposed ... |
73a6dfc023fa3e89a1e7190ebd2c99939137924e | Jose-Juan29/Mineriaproyecto | /NuevoMineria.py | 2,183 | 3.703125 | 4 | import numpy as np
from sklearn import datasets, linear_model
import matplotlib.pyplot as plt
from scipy import stats
diabetes = datasets.load_diabetes()
print(diabetes)
# 7) MODELOS LINEALES
#Verifico la informacion contenida en el dataset
print("\n\nInformacion en el dataset:")
print(diabetes.keys())
... |
17153a9681e363d5a4873c86aaf0a82f750d9c5f | Blak3Nick/MachineLearning | /venv/DecisionTree/DecisionTree.py | 1,544 | 3.53125 | 4 | #Decision Tree
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Position_Salaries.csv')
X = dataset.iloc[:, 1:2].values
y = dataset.iloc[:, 2:3].values
# Feature Scaling
# from sklearn.preprocessing import StandardScaler
#... |
d552d48442d2fec0e369060ef91bac3b57c28147 | GodaProjects/python-basic-playground | /goda_functions.py | 1,033 | 4.40625 | 4 | # functions
# function 1 - simple
def function1(num1, num2):
return num1*num2
print(function1(3, 5))
# Function 2 - with data type and returns two values
def function2(num: int, string: str):
return num, string
print(function2(1, "Goda"))
# function 3 - with initial values
def function3(num: int = 1... |
c2a9ffd663feaaf3e9ffaaf06ea02178b684d9b9 | GodaProjects/python-basic-playground | /goda_dictionary.py | 475 | 4.25 | 4 |
# Dictionary or key value pairs
friends = {
"Goda": "Chellam",
"Tanu": "Kutty"
}
print(friends)
friends1 = dict([
("Goda", "Chellam"),
("Tanu", "Kutty")
])
print(friends1)
print(friends1["Goda"])
print(friends1.items())
del friends1["Tanu"]
print(friends1.items())
friends1.pop("Goda")
print(friends1.i... |
9dc4036d54d54d41077b83f2d3cb7e2a0fe2abaa | Akarsh2121/PP-LAB-Week-9-Programs | /main.py | 536 | 3.90625 | 4 | class students:
count = 0
def __init__(self, name):
self.name = name
self.marks = []
students.count = students.count + 1
def enterMarks(self):
for i in range(3):
m = int(input("Enter the marks of %s in %d subject: "%(self.name, i+1)))
... |
d250540b9b783e6144b1cb6b8417f497570e06e5 | mperrigo89/PythonPracticePrograms | /advance.py | 278 | 4.46875 | 4 | #!/usr/bin/python
my_dict = {
"color": "blue",
"size": 3.5,
"make": "maxima"
}
print my_dict.items()
#prints all values in a dictionary
my_dict = {
"color": "blue",
"size": 3.5,
"make": "maxima"
}
for key in my_dict:
print key, my_dict[key]
|
d9df7bc32e1c2e07cf65d69ff4508efa16c80d89 | blufa/Pytho-basic | /pyton_jcc/dictionnaire.py | 964 | 4.21875 | 4 | #Definition d'un dictionnnaire vide
d1={}
d2=dict()
#Definition d'un dictionnnaire avec initialisaton de valeurs
d3={'nom':'Fall', 'prenom':'Moussa', 'classe':'DITI4'}
print(f"L'etudiant {d3['prenom']} {d3.get('nom')} est inscrit en {d3['classe']}")
#Insertion de données
#print(d2)
#d2 contient les notes
d2['pytho... |
ba498bc1ecc2a512d927897e6397d98df359b350 | tzxb018/CSCE440-Work | /CSCE440_hw1.py | 2,473 | 3.59375 | 4 | import math
def f(x):
# return 2 * x ** 3 - x ** 2 + 6 * x - math.e ** x + 2
# return 3 * x ** 4 + x ** 2 - 2
return 3 * x - 3 * x ** 2 + 2 * math.e ** x - 2
# return 2 * x - math.cos(x)
def g(x):
return (3 * x ** 2 - 2 * math.e ** x + 2)/3
# return math.sqrt((3*x + 2 * math.e ** x - 2)/3)
... |
061d73df0cbbd65d6c874cf6817644624fce925b | VaibhavD143/Coding | /Data structures/merge_sort.py | 635 | 3.75 | 4 | def merge(lst,l,r):
mid = (r-l)//2
lp = l
rp = mid+1
tlst=lst[l:r+1]
ind =l
while lp<=mid and rp<=r:
if tlst[lp]<tlst[rp]:
lst[ind] = tlst[lp]
lp+=1
else:
lst[ind]=lst[rp]
rp+=1
ind+=1
while lp<=mid:
lst[ind... |
2db2e7986db27cf97687f521d6b825e181236186 | VaibhavD143/Coding | /Data structures/graph_bfs.py | 552 | 3.59375 | 4 | from collections import deque
def bfs(graph,source):
visited = [0]*len(graph)
for i in range(len(graph)):
if not visited[i]:
dq = deque([i])
visited[i] = 1
while dq:
elem = deque.popleft(dq)
# print(elem)
for node in gr... |
37fe1ec8071469aa69ec7cfe87ff7fb545686577 | VaibhavD143/Coding | /ib_capture_regions_on_board.py | 3,117 | 3.59375 | 4 | class Solution:
def solve(self, A) -> None:
"""
Do not return anything, modify board in-place instead.
"""
if not A or not A[0]:
return A
# ss = []
# for i in [0,len(A)-1]:
# for j in range(len(A[0])):
# if A[i][j] == 'O':
# ... |
7b18160aaa962c87e4e1db4c67367cf573e935c4 | VaibhavD143/Coding | /gfg_inversion_of_array.py | 956 | 3.796875 | 4 | """
Find the no of occurance when i<j and a[i]>=a[j](Inversion)
aproach : increase count when merging in mergesort function
"""
count = 0
def merge(lst,l,r):
global count
mid =l+ (r-l)//2
lp = l
rp = mid+1
tlst=lst[l:r+1]
ind =l
while lp<=mid and rp<=r:
if tlst[lp-l]<tlst[rp-l]:
... |
50b95a0f8ca3cc0f857db3c946cc3fe7bb320672 | VaibhavD143/Coding | /ib_longest_valid_parentheses.py | 757 | 3.5625 | 4 | """Intution:
dp[i] = stores length of valid parentheses ending on ith index
if ith index is '(' => 0
')' => skip valid string length stored in dp[i-1] if match then add that string(i-ind+1)+string before that (if any,dp[ind-1])
$ to avoid out of index check"""
class Solution:
# @param A : string
... |
66e2bb71af508d27ce94ce064013eb5f466c0f3e | VaibhavD143/Coding | /leet_construct_binary_tree_from_preorder_and_inorder.py | 924 | 3.828125 | 4 | """
To understand base:
take example
[8,5,2,3,4,6,7,9]
[3,2,4,5,7,6,9,8]
[3,9,20,15,7]
[9,3,15,20,7]
"""
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def buildTre... |
498965103d62ce5e153d10e81dadf518a0b8b842 | VaibhavD143/Coding | /leet_add_two_numbers.py | 1,228 | 3.640625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
res = ListNode(0)
tres = res
carry = 0
while l1 and l2:
... |
2d1602b0d695520ae4d3d59eb4dbc2af366afc81 | VaibhavD143/Coding | /Data structures/trie.py | 814 | 3.765625 | 4 | class Trie():
def __init__(self):
self.ha={}
def push(self,word):
memo = self.ha
for i in word:
if i in memo:
memo=memo[i]
else:
memo[i]={}
memo=memo[i]
memo["end"]=True
def search(self,word... |
b8016f3bbfe0973b8379cf8100d3f499f6d3b46e | VaibhavD143/Coding | /Data structures/disjoint_set_union.py | 1,960 | 3.703125 | 4 | """
Disjoint Union algo with and without Union-by-rank
https://leetcode.com/articles/redundant-connection/
"""
def union(i1,i2):
p1 = find(i1)
p2 = find(i2)
if p1 == p2:
return
if rank[p1]>rank[p2]:
p1,p2 = p2,p1
parent[p1] = p2
rank[p2]+=1
def find(i1):
if parent... |
cb70307d59cd00bd6d2efa62c45179e6a1fa1043 | VaibhavD143/Coding | /ib_sum_root_to_leaf_number.py | 642 | 3.734375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
# @param A : root node of tree
# @return an integer
res=0
def sumNumbers(self, A):
... |
c97669d30e63c19b6ccc9e226ecbfe00936e325c | VaibhavD143/Coding | /Data structures/cycle_detection_dfs.py | 2,744 | 3.6875 | 4 | """
Working
"""
def isCyclicUtil( v, graph,visited, recStack):
visited[v] = True
recStack[v] = True
for neighbour in graph[v]:
if visited[neighbour] == False:
if isCyclicUtil(neighbour, graph, visited, recStack) == True:
return True
elif recStack[neighbour] =... |
7264972fd506b3930c3200d6cb3e948125368baa | VaibhavD143/Coding | /ib_ways_to_color_a3d_grid.py | 1,740 | 3.984375 | 4 | """
Intution:
1)
TLE:
check for each possible configuration of color tuple and if it is allowed then add to the result
2)
THere are two types of combinations:
1- (x,y,z) col3 : one col3 tuple generates new 11 col3 combinations, 5 col2 combination
2- (x,y,x) col2 : one col2 tuple generates new 10 col3 combinations, 7 co... |
edb80c1a61aede4df9ed228a050a98d7a81fa39e | VaibhavD143/Coding | /leet_most_Stones_remove_with_same_row_or_column.py | 1,452 | 3.5625 | 4 | """
Intution:
Find number of components in graph, each component will miss one point
DFS can be used to find #connected components
1 DUS : if point clash with any previous point on same column and/or same row then union then in single component
2 DUS : to avoid most checks and distiguish rows and columns, add 10000 to ... |
832d42236777bf5e2a1d867da266234c6d656e77 | VaibhavD143/Coding | /ib_number_of_ways_to_wear_hats.py | 1,738 | 3.546875 | 4 | """
https://www.geeksforgeeks.org/bitmasking-and-dynamic-programming-set-1-count-ways-to-assign-unique-cap-to-every-person/
"""
from collections import defaultdict
class Solution:
def numberWays(self, hats):
ha=defaultdict(list)
maxHat = 1
for pers,hatl in enumerate(hats):
for ha... |
46e42d6cba71d4705a121bddd14b8903587afe54 | VaibhavD143/Coding | /ib_single_number_2.py | 1,730 | 3.625 | 4 | """
Intution:
for any bit position it can occure for 3x+1 times,
if 0 doesn't matter
if 1 then it should stay 1
so,
When hits 1st time, keeping record in ones
when second time, keeping it in twos
and on 3rd time clearing it from them
so left ones is the answer
"""
import math
class Solution:
# @param A : tuple of ... |
fc6fdf4a1d426d6c37d427258f3c7ab292c1e8d6 | VaibhavD143/Coding | /Data structures/bst.py | 4,123 | 3.625 | 4 | """
Input:
tc = no of inputs
each line:
x y
where x = operation (i = insert, d = delete)
y = value
"""
class node():
"""docstring for node"""
def __init__(self):
self.left = None
self.right = None
self.val=None
self.ind=None
COUNT = [10]
def print2DUtil(root, space) :
# Base case... |
9304ee33c1d02c00607cf64ed3a4cb8af5a736a5 | VaibhavD143/Coding | /leet_number_of_subsequence_that_satisfy_the_given_sum_condition.py | 1,185 | 3.5 | 4 | """
Intution:
make pair (x,y) in sorted array such that sum of them will be lesser than target and every elements fall between them can be part of subsequence. So 2**diff
diff : # of elements between x and y
as x is max number such that x+y is lesser than target, all lesse than x can also form subsequence. so (2**ind)-... |
fae362a680c9b5ffc545bb052fc6971d077c17a9 | VaibhavD143/Coding | /ib_k_reverse_linked_list.py | 1,050 | 4.25 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param A : head node of linked list
# @param B : integer
# @return the head node in the linked list
def reverseList(self, A, B):
head = A
... |
fe99ce60bcac779388a7a1e2557c4457f8b8a07c | VaibhavD143/Coding | /gfg_k_largest_elems.py | 2,117 | 3.5 | 4 | #https://practice.geeksforgeeks.org/problems/k-largest-elements/0
import math
class max_heap:
def __init__(self):
self.lst = []
self.length = 0
def bottom_up_heapify(self,child):
# par = child
par = math.ceil(child/2)-1
while par >=0:
if self.lst[par] >= s... |
950f0af9abc7b673dc97003f9544ced4dccd9904 | VaibhavD143/Coding | /ib_largest_coprime_divisior.py | 599 | 3.703125 | 4 | """
Intution:
Greates divisior of A is A itself, now to make it co-prime with B, we remove common factors from it.
When there is no common factor left. It is the answer!
"""
class Solution:
# @param A : integer
# @param B : integer
# @return an integer
def cpFact(self, A, B):
def gcd(q1,q2)... |
dae3fa91fc5d1897ace7bc91109564a72bd0390f | gt005/Git_for_lessons | /date_autumn.py | 479 | 3.921875 | 4 | def date_autumn(dates):
autumn_dates = []
for i in dates:
clear_date = list(map(int, i.split('-')))
if 9 <= clear_date[0] <= 11:
autumn_dates.append(clear_date)
autumn_dates = sorted(autumn_dates)
return '-'.join(map(str, autumn_dates[-1]))
if __name__ == '__main__':
da... |
52234feb4d101aa5193c65ab4679b0415649a52a | MeyMas/rck_ppr_scssrs | /rps.py | 3,259 | 3.828125 | 4 | import random
moves = ['rock', 'paper', 'scissors']
class Player:
def __init__(self):
self.score = 0
self.my_move = None
self.their_move = None
def move(self):
return 'rock'
def learn(self, my_move, their_move):
pass
class RandomPlayer(Player):
... |
ce7a9c8d9577a494ee617037627e9ad94cfb35b4 | QuantVI/idleheroesflask | /tut_01_melvin_l/helloworld_flaskRESTFUL.py | 706 | 3.671875 | 4 | # uses flash restufl to make code easier to write, read, maintain
# https://www.youtube.com/watch?v=s_ht4AKnWZg
# Building a REST API using Python and Flask | Flask-RESTful
# by Melvin L
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class HelloWorld(Re... |
5d84bef00cfe7844f3d6e56d262608050e90ae41 | Igor1407/Lessons | /урок 1-3.py | 258 | 3.953125 | 4 | # задача 3 настроить доступ
a = int(input('Ваш возраст?'))
if a>=18:
print('Доступ разрешен')
else:
print('Извините, пользование данным ресурсом только с 18 лет') |
cd0a7e4d7a4978fb4c003fac45c0040285ff0b0d | arianacabral/Introduction-to-Python | /Atividade 1/Q7.py | 251 | 3.8125 | 4 | # Escreva um programa que leia quatro números e imprima a soma desses quatro números na tela
v = [float(input("Número 1:")),float(input("Número 2:")), float(input("Número 3:")), float(input("Número 4:"))]
print("A soma dos valores é:", sum(v))
|
8e1c7639c258270579229bd93a34811d1bc63164 | arianacabral/Introduction-to-Python | /Atividade 7/Q8.py | 339 | 4 | 4 | # Escreva uma função que recebe uma palavra e uma lista de palavras e retorne True se a palavra dada está contida na lista. Falso em outro caso
palavra = input("Informe a palavra para busca: ")
banco_de_palavras = [input("Informe a lista de palavras: ")]
if (palavra in banco_de_palavras):
print("TRUE")
else:
... |
3e2b602c31f7907990b2a4ca6c5360c9bde0e2a6 | arianacabral/Introduction-to-Python | /Atividade 7/Q1.py | 140 | 3.78125 | 4 | # Escreva um programa que crie uma lista com 3 números e informe esses números na tela sem repetição
numeros = [3,5,7]
print(numeros)
|
dde7cb47745f5db2a88231c188c80c12a8c0a464 | arianacabral/Introduction-to-Python | /Atividade 5/Q27.py | 204 | 3.703125 | 4 | #Escreva um programa que leia o nome do usuário e depois imprima 9 vezes o nome do lido.
n = 1
while n <= 300:
nm = str(n)
if( nm[-1] == "5" or nm[-1] == "9"):
print(nm)
n+= 1
|
908d7e9839b3487ba7ea091df2bad4f34c5ae3c1 | arianacabral/Introduction-to-Python | /Atividade 6/Q14.py | 290 | 3.953125 | 4 | # Escreva um programa que leia 10 números inteiros. Em seguida informe a quantidade de números 3 lidos
num3 = 0
for i in range(1,11):
num = int(input("{} - Informe um número: ".format(i)))
if(num == 3):
num3 += 1
print("A quantidade de números 3 é {}".format(num3))
|
dec209063c41b2dee69fcf92c8453ec14792df31 | arianacabral/Introduction-to-Python | /Atividade 2/Q1.py | 232 | 3.796875 | 4 | Notas = [float(input("Nota 1:")),float(input("Nota 2:"))]
if sum(Notas)/2 >= 7:
print("A média das notas é",sum(Notas)/2)
print("Aprovado!")
else:
print("A média das notas é",sum(Notas)/2)
print("Reprovado!")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.