blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
14de2d3ce67d4e89c45a3ac4427743931c852fc5 | saipavans/pythonrepo | /lab3/3Task9.py | 342 | 3.515625 | 4 | words_file_path = "../resources/words.txt"
fin = open(words_file_path)
words_exceeding_twenty_characters = 0
character_threshold = 20
for line in fin:
word = line.strip()
if len(word) > character_threshold:
words_exceeding_twenty_characters = words_exceeding_twenty_characters + 1
print(word)
print(words_exceedi... |
ead7c18a738ee6fec1ea6f4cb69805da4799b4b9 | VineethChandha/Cylinder | /TicTacToe_Game.py | 2,607 | 4.09375 | 4 | #PY.01.15 Project 8: Tic Tac Toe Game
#Description: It is a 2 player game where X and O are two persons symbols used to fill the board
# If one of the person fills the board in such a way his/her symbol forms a straight line or a
# daigonal he will be the winner
board = [" " for i in ... |
cdfad3f2a3b8d22c82c203195a5c03ec456111e6 | VineethChandha/Cylinder | /loops.py | 987 | 4.125 | 4 | # PY.01.10 introduction to the loops
for a in range(1,11): # a will be valuated from 1 to 10
print("Hi")
print(a)
even_numbers = [x for x in range(1,100) if x%2 == 0]
print(even_numbers)
odd_numbers = [x for x in range(1,100) if x%2 != 0]
print(odd_numbers)
words = ["ram","krishna","sai"]
answ... |
773b4f9062212086ea7f4444a5d26983219cc8bd | omnimarkn/python_crud_with_graph | /Menu.py | 933 | 3.71875 | 4 | class Menu:
def __init__(self):
self.menus = [
'Add Student',
'Store Grade on Existing Student' ,
'View Grade of Students for each Assesment',
'View Students with below Average Grade for each Assesment',
'View Report of Students Total Grade for the Semester',
'View Report of Students with below ... |
3c557554bffacdc1a07db0b6fce7ebad4495f210 | hectortv9/turtle-crossing-start | /car.py | 1,451 | 3.546875 | 4 | import random
from screen_box import ScreenBox
from turtle import Turtle
FILL_COLORS = ["cornflower blue", "lime green", "orchid", "bisque3", "DarkOliveGreen4", "turquoise3", "purple3"]
CAR_COLOR = "white"
CAR_SHAPE_NAME = "car"
CAR_SHAPE = ((3, -10), (3, -6), (10, -5), (10, 4), (3, 6), (3, 8), (1, 10), # trunk (top)... |
c61f81309de7e41b2bda16893872031a23632b1a | ferreiradh/URI-Online-Judge-Problems-Contests | /Iniciante/1010.py | 264 | 3.6875 | 4 | cod1, n1, valor1 = input().split(" ")
cod1 = int(cod1)
n1 = int(n1)
valor1 = float(valor1)
cod2, n2, valor2 = input().split(" ")
cod2 = int(cod2)
n2 = int(n2)
valor2 = float(valor2)
total = (n1 * valor1) + (n2 * valor2)
print(f'VALOR A PAGAR: R$ {total:.2f}') |
ef850216d86059027091cc350436313781320bc0 | lila-yilmaz/alistirmalar_I | /soru13.py | 205 | 3.65625 | 4 | for sayı1 in range(10,100):
s1 = str(sayı1)
for sayı2 in range(10,100):
s2 = str(sayı2)
if int( s1+s2 ) == ( int(sayı1) + int(sayı2) ) * 11:
print("sayı1=",sayı1,"\nsayı2=",sayı2)
|
c105707683771cfcd237d7ebf82e3c80a4591863 | lila-yilmaz/alistirmalar_I | /soru17.py | 485 | 3.921875 | 4 | sayı = input("Lütfen 3 veya 4 basamaklı bir sayı giriniz:")
if len(sayı) == 3:
if int(str(sayı)[0]) == int(str(sayı)[-1]):
print("Bu sayı palindromiktir!")
else:
print("Bu sayı palindromik değildir.")
elif len(sayı) == 4:
if int(str(sayı)[0]) == int(str(sayı)[-2]) and int(str(sayı... |
8b5aee4c6d58a3ec1fcc85ae5ca34b3cdc092178 | suvadipde/python | /databaseinsert.py | 732 | 3.734375 | 4 | import sqlite3
# establishing the connection
con = sqlite3.connect('TEST.db')
# preparing a cursor object
cursor = con.cursor()
# preparing sql statement
# rec = (456789, 'Frodo', 45, 'M', 100000.00)
records = [
(123456, 'John', 25, 'M', 50000.00),
(234651, 'Juli', 35, 'F', 75000.00),
(345121, 'Fred', 4... |
d31ae6d84acd8352773045a2ab46b21421db9442 | rajkonkret/python-szkolenie | /pi2_pong.py | 2,048 | 3.8125 | 4 | import turtle
def paddle(x,y):
paddle = turtle.Turtle()
paddle.speed(0)
paddle.shape("square")
paddle.color("white")
paddle.shapesize(stretch_wid=5,stretch_len=1)
paddle.penup()
paddle.goto(x,y)
return paddle
def ball(x,y):
circle = turtle.Turtle()
circle.shape("circle")
ci... |
7f5e17b47ddd4152186df642968e61752178fab9 | rajkonkret/python-szkolenie | /prime.py | 116 | 3.53125 | 4 | number = int (input('Podaj liczbe\n'))
p_n=True
if number%2==0:
print('parzysta')
else:
print('niepRZYSTA')
|
bd7374bbb746fc41fe349d7446f11a3eb4c954e9 | rajkonkret/python-szkolenie | /wt_3_12.py | 216 | 3.75 | 4 | def is_it_quibc(number_1):
return(round(pow(number,1.0/3.0),8) % 1 == 0)
try:
number = int(input('Podaj liczbę: '))
print('Jest sześcianem ?:', is_it_quibc(number))
except:
print('Incorrect value!') |
fb9e938d9d4e5335f4c7c21836bdf364527b7bac | rajkonkret/python-szkolenie | /pi_pong_maja.py | 2,305 | 3.8125 | 4 | import turtle
def create_window():
window = turtle.Screen()#ekran
window.title('Pong Akademia Kodu')#tytul
window.bgcolor('black')#kolor ekranu
window.setup(width=800,height=600)
window.tracer(0)#szybkosc odswiezania
return window
def create_paddle(x,y):
paddle = turtle.Turtle()#tworzy jeden... |
8adb0db493d91f2877df01a696fd936141a25146 | rajkonkret/python-szkolenie | /pon_3_ex5.py | 811 | 3.75 | 4 |
def multiply(x,y):
return x*y
def pitagoras(a,b,c):
if a<0 or b<0 or c<0 :
return False
array = [a,b,c]
array.sort()
#if array[0] *array[0]+array[1]*array[1]==array[2]*array[2] :
# return True
#else:
# return False
return array[0]*array[0] +array[1]*array[1] == arr... |
4ad9f27ff0639ad57543eecb1f22fb8353eb8cd4 | rajkonkret/python-szkolenie | /14.py | 230 | 3.796875 | 4 | word = input('Podaj wyraz \n')
if word == 'Akademia':
print('Podałeś poprawne hasło')
else:
print('nie')
try:
age = int(input('Podaj wiek\n'))
print('Twój wiek to: ', age)
except:
print('To nie jest wiek') |
96f4ff5df40c6d37b6cba08cc463fd1aeb27a0f1 | rajkonkret/python-szkolenie | /pon_3_ex11.py | 167 | 3.59375 | 4 | def number_of_divisors(n):
counter = 0
for i in range(1,n+1):
if n%i == 0:
counter+=1
return counter
print(number_of_divisors(9240))
|
d19fa849423670874a2b749adeb8b2dba700cd6d | rajkonkret/python-szkolenie | /pi_03_kaggle.py | 397 | 3.71875 | 4 | import pandas as pd
df = pd.read_csv('2019.csv')
print(df.head())
print(df.columns)
max_index = 0
min_index = 0
for index in df.index:
print(index)
if(df['Score'][index] > df['Score'][max_index]):
max_index = index
if(df['Score'][index] < df['Score'][min_index]):
min_index = index
print(df... |
edd61578d315cd37951ec334a4a6348d18f50f4e | IwanMitsak/Praktyka | /завдання5.2.py | 570 | 3.671875 | 4 | import math
import itertools
def f(x,k):
return pow(-1,k-1)*pow(x,k)
e=0.001
a=-0.9
b=1
k=0
i=0
print('X ','f(x)','f(x)набл','eps ','iteration')
for x in itertools.count(start=a,step=0.2):
if x>b:
print('break')
break
tmp=f(x,k)
result=tmp
if 1+x == 0:
... |
d1266c7789546ff1a2ee4a1239a9e20bf117dd50 | miseriae/python.practice | /codewars/unique_in_order.py | 387 | 4.0625 | 4 | '''
Implement the function unique_in_order which takes as argument a sequence and returns a list of items without
any elements with the same value next to each other and preserving the original order of elements.
'''
def unique_in_order(iterable):
list = []
for i in iterable:
if len(list) < 1 or not i... |
93621e9707c7d40cb107ff3636c3a19b02cbf9e9 | feitenglee/target_offer | /13_1_N皇后.py | 1,186 | 3.546875 | 4 | # 2019-08-28
# by lifieteng@live.com
# 二维矩阵上的回溯问题,leetcode-#51
# 题目描述:n 皇后问题研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。
# 输入输出:给定一个整数 n,返回所有不同的 n 皇后问题的解决方案。
# 示例:
# 输入: 4
# 输出: [
# [".Q..", // 解法 1
# "...Q",
# "Q...",
# "..Q."],
# ["..Q.", // 解法 2
# "Q...",
# "...Q",
# ".Q.."]
# ]
def NQueen(n):
""... |
5fa81f2a650b285b0328fd85049e61fb336325b2 | feitenglee/target_offer | /34_二叉树中和为某一值的路径.py | 2,020 | 3.578125 | 4 | #!/usr/bin/env python
'''
@Author: lifeiteng@live.com
@Github: https://github.com/feitenglee/target_offer
@Date: 2019-08-31 17:05:53
@LastEditTime: 2019-09-01 16:50:24
@Description:
@State: PYTHON35 PASS
'''
import sys
class TreeNode:
def __init__(self, data=None, left=None, right=None):
self.data = data... |
673a0b7e371aee727579c98eb803b65a553fe47e | feitenglee/target_offer | /55_二叉树的深度.py | 1,839 | 3.6875 | 4 | #!/usr/bin/env python
'''
@Author: lifeiteng@live.com
@Github: https://github.com/feitenglee/target_offer
@Date: 2019-09-05 20:56:57
@LastEditTime: 2019-09-06 09:32:44
@Description: 二叉树的深度, 判断是否是平衡二叉树
题目1:二叉树深度
思路1:深度是max(左子树,右子树)+1,递归解决
题目2:是否是平衡二叉树
思路:不太理解
@State: PYTHON35 PASS
'''
import sys
class TreeNode:
def... |
7d7de0be772aaed08737ed0612307dedf6ee0ac8 | feitenglee/target_offer | /A_二叉树遍历.py | 5,088 | 3.859375 | 4 | #!/usr/bin/env python
'''
@Author: lifeiteng@live.com
@Github: https://github.com/feitenglee/target_offer
@Date: 2019-08-29 22:04:54
@LastEditTime: 2019-09-23 13:10:46
@Description:
1、前序遍历
2、中序遍历
3、后序遍历
4、层序遍历
5、二叉树的右视图,层序遍历的变种
6、根据前序遍历和中序遍历重建二叉树
思路:队列中只存放下一层的所有节点,即pop出当前层的所有节点
@State: PYTHON35 PASS
'''
import sys
fro... |
09be272a07d69c34fac2832d7e484bed71947dd3 | feitenglee/target_offer | /54_二叉搜索树的第k大节点.py | 1,471 | 3.890625 | 4 | #!/usr/bin/env python
'''
@Author: lifeiteng@live.com
@Github: https://github.com/feitenglee/target_offer
@Date: 2019-09-05 20:41:15
@LastEditTime: 2019-09-05 20:54:16
@Description: 二叉树的中序遍历,是二叉树的升序
@State: PYTHON35 PASS
'''
import sys
class TreeNode:
def __init__(self, data=None, left=None, right=None):
se... |
790caf7e8da81001024549ecec550403d23c2ff1 | witoriamanuely/IA-2019.1 | /SearchingAlgorithms/BFS.py | 1,104 | 3.65625 | 4 | class BFS:
def __init__(self, grafo):
self.grafo = grafo
self.caminho = []
def imprimeCaminho(self):
print("Caminho achado utilizando BFS:")
for i in range(len(self.caminho)):
if i+1 == len(self.caminho):
print(self.caminho[i])
else:
... |
9fbc8187fe431f5322c4f1270562b810209cb77c | rustamovilyos/python_lessons | /py_lessons_for_github/my_game/game.py | 3,688 | 3.625 | 4 | import random #random ishlashi
b = 3 #joni
while True:
a = (random.randint (0,1)) #uyin sonlari random tanlash
print (a,'=') ... |
d9eb3425a954f55795c7be817c10923987c3f191 | rustamovilyos/python_lessons | /py_lessons_for_github/dars_3/if-else.py | 1,451 | 3.90625 | 4 | # """ if ni yozilish strukturasi"""
# x = True
# x = False
# if x:
# print('x true!')
# print('if ichidagi komanda')
# print('if dan tashqari komanda')
# """ <, >, <=, >=, == """
# y = 2
# if y < 4:
# print('y 4 dan kichkina')
# """ Misol №1 """
# x = int(input(' 5 bilan taqqoslash uchun son kiri... |
9136b04d39610962d6316eb077735b5dfb7c7bf7 | rustamovilyos/python_lessons | /py_lessons_for_github/dars_10/vaqt.py | 742 | 3.96875 | 4 | # import time
# x = 0
# while True:
# print(x)
# x = x + 1
# time.sleep(2)
##############################################
# import time
# print(time.strftime("%H:%M:%S"))
# print(time.strftime("%Y-%m-%d"))
# print(time.strftime("%D"))
#########################################
# import time
# x = 0
#... |
509e1fd051492bccb5ff9a2b9c92cbf39dc9e165 | rustamovilyos/python_lessons | /py_lessons_for_github/dars_3/Vazifa-6.py | 655 | 3.8125 | 4 | а = int(input('введите число для а: '))
б = int(input('введите число для б: '))
с = int(input('введите число для с: '))
д = int(input('введите число для д: '))
if (а+б)%4 == 0:
print("а + б")
else:
print("а + б:", False)
if (б+с)%4 == 0:
print("с + б")
else:
print("а + б:", False)
if (с+б+а)%4 == 0:
... |
d68124c47ce8939dc69bf08b6d38758b8c09dc3b | Teresa90/demo | /assisngment2.py | 805 | 4.09375 | 4 | import math
def introduction_message():
print("This program computers the roots")
print("of a second order equation:")
print()
print(" ax^2+bx+c=0 ")
print()
def input_and_solve():
a = eval(input ("please enter a: "))
b = eval(input ("please enter b: "))
c = eval(input ("please e... |
bb5ca3c05d0d46ab6ba63e7a75e3632bc91e1db7 | Artyom1803/course-2130 | /year_2021/python/hw2/legacy.py | 1,208 | 3.703125 | 4 | def t1(number):
"""
Поправьте код, чтобы возвращаемое значение было ближайшим сверху, кратным к 20
Пример: number=21 тогда нужно вернуть 40
Пример: -5 -> 0
"""
pass
def t2(string):
"""
На вход подается набор слов, разделенных пробелом, инвертируйте каждое слово.
Пример: `abc abc ab... |
f80085477c26ac983c627180dd14c432f64bc439 | cuchas/pythonlab | /my-first-script.py | 453 | 3.828125 | 4 | def welcome_message(name):
#Prints out a personalised welcome message
return "Welcome to this Python script, {}!".format(name)
def enjoy_yourself(name):
#prints how I'm happy to learn python
return "Long time you wanted to learn python, congratulations {}".format(name)
#Call the welcome message functi... |
4ca05ba21a3bcc47d07c19c414a48b9086754c3d | awanisazizan/awanis-kl-oct18 | /strToNum.py | 343 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 31 11:36:32 2018
@author: awanis.azizan
"""
deposit = input("How much would you like to deposit?")
freeToaster
if float(deposit) > 100:
freeToaster = True
else :
print("Enjoy your free mug!")
if freeToaster:
print("You get a free toaster!")
print(... |
daf4203e12c8e480fe1b6b0b9f1f3e63b2f292fa | awanisazizan/awanis-kl-oct18 | /birthday.py | 439 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 31 10:41:07 2018
@author: awanis.azizan
"""
import datetime
#birthday = input("What is your birthday? (dd/mm/yyyy)" )
#birthdate = datetime.datetime.strptime(birthday,"%d/%m/%Y").date()
#print("Your birth month is " +birthdate.strftime('%B'))
nextBirthday = datetime.d... |
30d48de72e6ebae96779f46a1eac87450af54187 | awanisazizan/awanis-kl-oct18 | /shipping.py | 302 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 31 11:20:04 2018
@author: awanis.azizan
"""
answer = input("Would you like express shipping?").lower()
if answer == "yes" :
print("That would add $10 to the fees")
print("Thank you!")
else :
print("Thank you for your purchase!") |
37475caf8afef1bfb9cf94754b6473c94bafbe39 | mogulseeker/sentiment-analysis | /20190922_Sentiment_analysis-assignment.py | 2,929 | 3.78125 | 4 |
#Import the relevant libraries
import pandas as pd
import matplotlib.pyplot as plt
#Import the baseline file and label the columns
df = pd.read_fwf('baseline.txt', delimiter=" ", names = ['Class', "Count"])
df
#remove the column header that we do not need
df = df.dropna()
df
# add a new column with the sentiment v... |
075aef3a38d29f02a62052d369e285788d0267f6 | LuizVinicius38/Semana-04---Aula-1---Parte-2 | /Atividade_Aula_4_2.2.py | 105 | 3.65625 | 4 | a = int(input(""))
b = int(input(""))
c = int(input(""))
resultado = (a + b + c)/3
print(resultado)
|
cc229e16ee78884dd3774fac7fd4bf64916e9960 | umpatel2618/Exercism | /isogram/isogram.py | 202 | 3.953125 | 4 | def is_isogram(string):
check=True
string=string.lower()
for i in string:
if i!=" " and i!="-" and string.count(i)>1:
check=False
break
return check
|
aaf7a5a0a5195ff1376ef2f0d6e6f84ffc273341 | XxdpavelxX/Python3 | /L3 Iteration in Python/decoder.py | 1,682 | 4.625 | 5 | """Create a Python3_Homework03 project and assign it to your Python3_Homework working set. In the
Python3_Homework03/src folder, create a file named decoder.py, which contains an iterator named alphabator.
When passed a list, simply return objects as-is unless they are integers between 1 and 26, in which case it
sho... |
0a78c83f9ef57d9b72a23fe657ed93c9761f3e3e | XxdpavelxX/Python3 | /L4 Basic Regular Expressions/find_regex.py | 1,719 | 4.3125 | 4 | """Here are your instructions:
Create a Python3_Homework04 project and assign it to your Python3_Homework working set. In the Python3_Homework04/src
folder, create a program named find_regex.py that takes the following text and finds the start and end positions of the
phrase, "Regular Expressions".
Text to use in ... |
1eff10714e2827822e302261df860ce54ce51a8b | seryeongi/learn_algorithm | /Code06-03.py | 2,048 | 3.765625 | 4 | ## 함수
def isStackFull():
global SIZE, stack, top
if top >= SIZE -1 :
return True
else:
return False
def isStackEmpty():
global SIZE, stack, top
if top <= -1 :
return True
else:
return False
def pop() :
global SIZE, stack, top
if (isStackEmpty()) :
... |
ccc8620d0ec8f4dd1fdf13800ce16db8efa218ff | BiancaHofman/python_practice | /ex37_return_and_lambda.py | 744 | 4.3125 | 4 | #1. Normal function that returns the result 36
#And this result is printed
def name():
a = 6
return a * 6
print(name())
#2. Normal function that only prints the result 36
def name():
a = 6
print(a * 6)
name()
#3. Anonymous function that returns the result 36
#And this result is printed
x =... |
fa489d07b01773a2018ed9c381198b045b4cb7d3 | gjreda/rosalind | /bioinformatics-stronghold/iprb.py | 1,864 | 3.921875 | 4 | """
Problem ID: IPRB
http://rosalind.info/problems/iprb/
Mendel's First Law
------------------
Given: Three positive integers k, m, and n, representing a population
containing k+m+n organisms: k individuals are homozygous dominant for
a factor, m are heterozygous, and n are homozygous recessive.
Return: The probabi... |
9dc01537d2a393584196037037261f946f31e8a6 | niranjana209/pro4.py | /30pro.py | 185 | 3.578125 | 4 | ani=(input())
cute=0
for i in range(0,len(ani)):
suro=(ani[:i]+ani[i+1:])
if(int(suro) % 8==0):
cute=1
break
if(cute==1):
print("yes")
else:
print("no")
|
d411b1259d7a7e4ea8d8f45a4bb0a213659aa275 | ermeydan-coder/jenkins-webhook-project | /hello-world.py | 141 | 3.8125 | 4 | fruits = ["christian", "joseph", "tyler", "kiwi", "azra"]
newlist = []
for x in fruits:
if "a" in x:
newlist.append(x)
print(newlist) |
2cf1813ba0c933c00afef4c26bec91ec7b1494ff | johnsbuck/MapGeneration | /Utilities/norm.py | 1,596 | 4.34375 | 4 | """N-Dimensional Norm
Defines the norm of 2 points in N dimensional space with different norms.
"""
import numpy as np
def norm(a, pow=2):
""" Lp Norm
Arguments:
a (numpy.ndarray): A numpy array of shape (2,). Defines a point in 2-D space.
pow (float): The norm used for distance (Default: 2... |
d6b657d761425a208e55bfc46ba19a29beb1f581 | zoleikha-mousavipak/zChallengeCodes | /Functionals/fib2.py | 180 | 3.890625 | 4 | def zfib(n):
if n <= 1:
return n
return zfib(n-1)+zfib(n-2)
if __name__ == "__main__":
inp = int(input("N: "))
for i in range(inp):
print(zfib(i)) |
f7f8c27059bf8b480fad7f7fdf1f1d9fde54f7b6 | zoleikha-mousavipak/zChallengeCodes | /Multiprocessing/multiprocessing_shareMemory.py | 670 | 3.765625 | 4 | import multiprocessing
def print_records(records):
for record in records:
print("Name: {0}\nScore: {1}\n".format(record[0], record[1]))
def insert_record(record, records):
records.append(record)
print("New Record Added!\n")
if __name__ == "__main__":
with multiprocessing.Manager() as manager:... |
e9b6b4b2513c832213ef99b37cf7cd2109ff520b | ggjj321/leetcode-heap-practice | /K-Closest-Points-to-Origin-q973.py | 1,176 | 3.5 | 4 | import heapq
class Solution(object):
def kClosest(self, points, k):
"""
:type points: List[List[int]]
:type k: int
:rtype: List[List[int]]
"""
def calcu(x,y):
return x ** 2 + y ** 2
heap = []
ans = []
for point in ... |
1040a092ef92aa80822e0cada2d5df026a95b1e2 | snahor/chicharron | /cracking-the-code-interview/02.06.py | 860 | 4.15625 | 4 | from linked_list import Node
def reverse(head):
'''
>>> head = Node(1)
>>> reverse(head)
1
>>> head = Node(1, Node(2, Node(3)))
>>> reverse(head)
3 -> 2 -> 1
>>> reverse(reverse(head))
1 -> 2 -> 3
'''
new_head = None
curr = head
while curr:
new_head = Node(c... |
d8d8e2c4775e02977eb21ee60d28ec4fb123982e | Manmohit10/data-analysis-with-python-summer-2021 | /part01-e04_multiplication_table/src/multiplication_table.py | 200 | 3.765625 | 4 | #!/usr/bin/env python3
def main():
for n in range(10):
for m in range(10):
print('{:>4}'.format((n+1)*(m+1)),end="")
print("")
if __name__ == "__main__":
main()
|
81a1ab2f702bd56d5379540bee0e14044661a958 | Manmohit10/data-analysis-with-python-summer-2021 | /part01-e07_areas_of_shapes/src/areas_of_shapes.py | 864 | 4.21875 | 4 | #!/usr/bin/env python3
import math
def main():
while True:
shape=input("Choose a shape (triangle, rectangle, circle):")
shape=str(shape)
if shape=="":
break
elif shape=='triangle':
base=float(input('Give base of the triangle:'))
height=float(inp... |
37e2ca6c89b45416dda7e6c747d8b044bb03e961 | Manmohit10/data-analysis-with-python-summer-2021 | /part03-e11_to_grayscale/src/to_grayscale.py | 892 | 3.6875 | 4 | #!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
def to_grayscale(image):
"""avg=np.array([0.2126,0.7152,0.0722 ]).reshape(1,3)
new=image*avg
new=new.sum(axis=2)"""
avg=[0.2126,0.7152,0.0722]
new=np.sum(image*avg, axis=2)
return new
def to_red(image):
m=[1,0,0]
... |
6a96a1e2cd5b6a185ee7a6f53f3e5b52a14c1d9e | Manmohit10/data-analysis-with-python-summer-2021 | /part02-e01_integers_in_brackets/src/integers_in_brackets.py | 287 | 3.875 | 4 | #!/usr/bin/env python3
import re
def integers_in_brackets(s):
result=re.findall(r'\[\s*([+-]?\d*)\s*\]', s)
return list(map(int,result))
def main():
s1="afd [128+] [47 ] [a34] [ +-43 ]tt [+12]xxx"
print(integers_in_brackets(s1))
if __name__ == "__main__":
main()
|
0c810db86362129156458844b2b9a52bc4ad4ddf | Manmohit10/data-analysis-with-python-summer-2021 | /part02-e10_extract_numbers/src/extract_numbers.py | 415 | 3.875 | 4 | #!/usr/bin/env python3
def extract_numbers(s):
word = s.split()
List=[]
for l in word:
try:
List.append(int(l))
except ValueError:
try:
List.append(float(l))
except ValueError:
continue
return List
def main():... |
e1fab846ea96a6245113afd7a963f59ad3b6fc13 | Bigoz005/Python | /Fib.py | 225 | 3.78125 | 4 | def fib(n):
if n == 1:
return 0
if n == 2:
return 1
if n == 3:
return 1
else:
w = fib(n - 1) + fib(n - 2)
return w
print(fib(8))
# 0 1 1 2 3 5 8 13 21
|
6e820c26645987a220a3953b3d0a234b3a54b41c | nizhan26/leetcode_python | /17. Letter Combinations of a Phone Number.py | 911 | 4.03125 | 4 | '''
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.
'''
class Solution(object):
def letterCombinations(self, dig... |
36ceba8ac7c9a36f5c785bff1e783bddc048643d | nizhan26/leetcode_python | /24. Swap Nodes in Pairs.py | 1,004 | 4.03125 | 4 | '''
Given a linked list, swap every two adjacent nodes and return its head.
Example:
Given 1->2->3->4, you should return the list as 2->1->4->3.
Note:
Your algorithm should use only constant extra space.
You may not modify the values in the list's nodes, only nodes itself may be changed.
'''
class ListNode(object)... |
44ab850db10f462c00deaeded7766d8a75e5df73 | janagterhuis/Zaagcalculator | /dropdown.py | 439 | 3.65625 | 4 | from tkinter import *
root = Tk()
root.title('Zaagcalculator')
# Drop Down Boxes
def show():
myLabel=Label(root, text=clicked.get()).pack()
options = [
"Multiplex",
"MDF",
"Spaanplaat",
"Plexiglas"
]
clicked = StringVar()
clicked.set(options[0])
drop = OptionMenu(root, clic... |
09119efc6094cd992e23ad5c81b041806cf0dcca | rcarroll/DPW | /Rodriguez_Julian_Madlib/main.py | 2,061 | 3.90625 | 4 |
#First Prompt
print "Well hello hail and harty traveler, Who may I ask your name?"
NAME= raw_input(" Full Name?:")
print "Ahhh so your name is "+NAME+ " ....I see."
#Second Prompt
CLASS= raw_input(" What Class are you?: _")
print "Ohh so you are a mighty, "+CLASS+", Very interesting..."
#Third Prompt
HOME= raw_inpu... |
758367a38be51f3900fe63887c0eaa03a5ae5fa9 | sayalighaisas/datastructures-algos | /palindrome.py | 234 | 4.09375 | 4 | def is_palindrome(string):
rev_string=string[::-1]
if string==rev_string:
return True
else:
return False
if __name__=="__main__":
str="radarrr"
if is_palindrome(str):
print("Is palindrome")
else:
print("Not palindrome")
|
4b37c423cd1c2c186689fb052204429a9452f9c1 | Davecupp/Pong | /Pong1.py | 5,377 | 3.671875 | 4 | # Made it to 17:10 in tutorial
# Link: https://youtu.be/XGf2GcyHPhc
import turtle
import tkinter as tk
import winsound
# Pulling splash page on main file, but then exiting. Can not get it to exit.
# Test turtle code. Turtle starts near center and goes as far as you put. 100 not far. Runs before pong game.
# turtle.s... |
a193a1b776334839238436d42a90dee05541e558 | flyxuxiaobai/AID2011 | /exercise02.py | 420 | 3.6875 | 4 | from threading import Thread, Lock
lock1 = Lock()
lock2 = Lock()
l = []
def value1():
for i in range(65, 91):
lock1.acquire()
print(chr(i))
lock2.release()
def value2():
for i in range(1, 53, 2):
lock2.acquire()
print(i)
print(i+1)
lock1.release()
t... |
42a2bdcd7c5f50a2889f7f12fc5e31377e19c036 | jakubczaplicki/projecteuler | /problem081.py | 1,413 | 3.625 | 4 | #!/usr/bin/env python
# pylint: disable=invalid-name
"""
In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right,
by only moving to the right and down, is indicated in bold red and is equal to 2427.
131 673 234 103 18
201 96 342 965 150
630 803 746 422 111
537 699 497 121 956
805 732 524... |
96cd3f07a60f4b8aae3ee63dcd25030f411b0bc1 | jakubczaplicki/projecteuler | /problem020.py | 698 | 3.546875 | 4 | #!/usr/bin/env python
# pylint: disable=invalid-name
"""
https://projecteuler.net/problem=20
"""
import math
from problembaseclass import ProblemBaseClass
class Problem20(ProblemBaseClass):
"""
@class Solution for Problem 20
@brief
"""
def __init__(self, n):
self.result = None
self... |
a83c79efaf48554e1ad4e863de45e38ed8ffdafa | jakubczaplicki/projecteuler | /problembaseclass.py | 1,938 | 3.53125 | 4 | #!/usr/bin/env python
"""Base class for the Project Euler problems in Python"""
##@file
#@ingroup
#
# @brief
# Base class for the Project Euler problems in Python
#
#
# @version $$
# @details
#
# @b Description
# This module implements a base class, that can be used
# for all project eurler solutions.
#
# @b Usage
# U... |
70b8698f195d78d197bd89b6ccf9eebf4f824f50 | yunchan312/data-structure | /LinkedStack.py | 504 | 3.625 | 4 | class Node:
def __init__(self, element):
self.link = None
self.data = element
class LinkedStack:
def __init__(self):
self.top = None
def isEmpty(self):
return self.top == None
def push(self, e):
newNode = Node(e)
newNode.link = self.top
self.top = ... |
c9db9a68499d75cb7f8acef452a0c5e45fa764d8 | qinacme/qinacme-interview | /lintcode/Python/PNov9_1.py | 679 | 3.71875 | 4 | #[-2,2,-3,4,-1,2,1,-5,3]
#greedy
def maxSubArray(nums):
if nums == None or len(nums)==0:
return 0
maxSum = nums[0]
curSum = maxSum
for i in nums[1:]:
if curSum<0:
curSum = i
else:
curSum = curSum+i
maxSum = max(maxSum, curSum)
return maxSum
#pr... |
1773b435b09579cef80f7850a2f9fb33d04c1200 | vdakinshin/learn1 | /infro.py | 219 | 3.921875 | 4 | user_info = {}
user_first_name = input('What is your first name?: ')
user_info['first_name'] = user_first_name
user_last_name = input('What is your last name?: ')
user_info['last_name'] = user_last_name
print(user_info) |
eb7afe093052c09e4b96b47b9a8176d2988d1d72 | Claudio9701/bingtiles | /bingtiles/bingtiles.py | 8,015 | 3.5 | 4 | import math
class TileSystem(object):
EARTH_RADIUS = 6378137
MIN_LATITUDE = -85.05112878
MAX_LATITUDE = 85.05112878
MIN_LONGITUDE = -180
MAX_LONGITUDE = 180
def clip(self, n, min_value, max_value):
"""
Clips a number to the specified minimum and maximum values.
Paramet... |
719484e3da2a99162a834431824ac42c356d7fad | SfietKonstantin/qfb | /tools/qfbtools.py | 830 | 3.546875 | 4 | def lowerCamelCase(name):
return name[0].lower() + name[1:]
def isPointer(name):
if name.strip()[-1:] == "*":
return True
else:
return False
def split(name):
return name.split("_")
def camelCase(splitted):
newSplitted = []
for splittedWord in splitted:
splittedWord = s... |
87b47edb3ac4c944e7498021311d29a683de4873 | mashanivas/python | /scripts/fl.py | 208 | 4.28125 | 4 | #!/usr/bin/python
#Function for powering
def raise_to_power(base_num, pow_num):
result = 1
for index in range(pow_num):
result = result * base_num
return result
print(raise_to_power(2, 3))
|
5cfe897e64a23dea12802535001062a6e4e0575a | Apthox/MindPuzzle | /Graphics/Board.py | 2,396 | 3.8125 | 4 | from Graphics.Graphics import *
class Board:
__x_pixels = -1
__y_pixels = -1
__vertical_boxes = -1
__horizontal_boxes = -1
__matrix__ = None
__win__ = None
def __construct_board(self):
self.__win__ = GraphWin('board', self.__x_pixels, self.__y_pixels)
self.__win__.setCo... |
620123a59f661877712972c9d9733b690d5ce3e4 | skphy/align | /align/_utils.py | 2,939 | 3.828125 | 4 | import numpy as np
from itertools import izip
def random_q():
"""
uniform random rotation in angle axis formulation
input: 3 uniformly distributed random numbers
uses the algorithm given in
K. Shoemake, Uniform random rotations, Graphics Gems III, pages 124-132. Academic, New York, 1992.
This ... |
f53e3d04b180ef7a9c362f00f5b1c8172fcacb38 | bazhenov23/GB_Home-Work | /Lesson3/Task 3.2.py | 619 | 3.921875 | 4 | def info():
name = input("Введите имя ")
surname = input("Введите фамилию ")
year = int(input("Введите год рождения "))
city = input("Введите город ")
email = input("Введите адрес электронной почты ")
telephone = input("Введите номер телефона ")
info_user = (
f"Пользователь {name} {s... |
bfc5e5ed666b7f18d2a7d152b153c08e373e0b62 | bazhenov23/GB_Home-Work | /Lesson3/Task 3.3.py | 345 | 4 | 4 | def my_func():
x = int(input("Первое число "))
y = int(input("Второе число "))
z = int(input("Третье число "))
if x >= z and y >= z:
result = x + y
elif y < x < z:
result = x + z
else:
result = y + z
return result
user_result = my_func()
print(user_result)
|
05238eaab83d31d097428f7b9c85bc0f947d805a | bazhenov23/GB_Home-Work | /Lesson1/Task 3.py | 144 | 3.671875 | 4 | n = int(input("Введите число от 0 до 9 "))
sum_n: int = (n + int(str(n) + str(n)) + int(str(n) + str(n) + str(n)))
print(sum_n)
|
d1c843f440e1d929e2be5f859fc003db18b92c8b | bazhenov23/GB_Home-Work | /Lesson1/Task 5.py | 678 | 4 | 4 | profit = float(input("Введите выручку компании "))
cost = float(input("Введите издержки компании "))
if profit > cost:
print(f"Компания работает с прибылью. Рентабельность выручки составила {profit / cost:.1f}%")
workers = int(input("Введите количество сотрудников "))
print(f"Прибыль в расчете на одного сто... |
cc6c58e549f132112a68038f4d71c8c582e63552 | moon-light-night/learn_python | /project.py | 577 | 4.3125 | 4 | #Дэбильный калькулятор
what = input ('Что делаем? (+, -, *, /)')
a = float(input ('Введи первое число: '))
b = float(input ('Введи второе число: '))
if what == '+':
c = a + b
print('Результат:' + str(c))
elif what == '-':
c = a - b
print('Результат:' + str(c))
elif what == '*':
c = a * b
print('... |
ea590d448e1961a26b862f5d0ec12bacb376d60d | Mingqianluo/A1805A | /A1807/05day/01-实例属性.py | 304 | 3.6875 | 4 | class Dog():
print('哈哈哈哈')
count = 10#类属性
def __init__(self,name):
self.name = name #实例属性
self.__age = 10
def getAge(self):
return self.__age
tom = Dog('Tom')
print(tom.name)
print(tom.getAge())
print(Dog.count)#通过类访问类方法
|
c11cfe2fdb52e858548532dd4a5b14474ab92d12 | Mingqianluo/A1805A | /A1807/02day/lx-gess.py | 404 | 3.640625 | 4 | import random
class Guess:
def guess(self):
a = random.randint(0,101)
while True:
u = int(input('请输入数字'))
if u > a:
print('猜大了')
elif u < a:
print('猜小了')
else:
print('猜对了')
... |
71f0a8c47e3a62c795d535570b6f3403d771667f | Mingqianluo/A1805A | /A1807/11day/04-..py | 129 | 4.03125 | 4 | list = [1,2,3,4,5,4,4]
list1 = []
for i in list:
if i not in list1:
list1.append(i)
print(list1)
#print(list(set()))
|
bf4e29367e523ef7306acc2620e1d253bc4c95b9 | kevinismantara/Stock-Predictor | /analyze_stocks.py | 5,150 | 3.515625 | 4 | import pandas as pd
import matplotlib.pyplot as plt
import datetime
import numpy as np
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
data = pd.read_csv('stock-data.csv', parse_dates=[0])
indexed = data.set_index(['Unnamed: 0'])... |
9de11c63bb0f64ac791be24c045d9ca4827d41f1 | Zorha/my-first-blog | /python_intro.py | 157 | 3.671875 | 4 | def hi (name):
if name == 'zoro':
print('hello my dear')
elif name == 'zola':
print('hello zola roronoa !! ')
else:
print('hi miss! ')
hi ("zola") |
3e3cf577d2b43618bbdbff52ca2ef06842964d64 | zjzjgxw/leetcode | /py/zigzagLevelOrder.py | 725 | 3.71875 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def zigzagLevelOrder(self, root):
if not root:
return []
ans, level = [], [root]
curD... |
346eb96f30b1e2af8210564c1b40456c50268ff6 | zjzjgxw/leetcode | /py/largestValues.py | 977 | 3.734375 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def largestValues(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
if... |
835e1ffe42ba987d0b0ed32f1ce215a4e8462e61 | zjzjgxw/leetcode | /py/swapPairs.py | 761 | 3.765625 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def swapPairs(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head is None or head.next i... |
89788d2a5a6109a880a4a4983a631d9674f517c6 | hackrole/leetcode_go | /avltree/avltree2.py | 2,261 | 3.71875 | 4 | # -*- coding: utf-8 -*-
class Node(object):
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.height = 0
class AVLTree(object):
def __init__(self):
self.root = None
def height(self, node):
if node is None:
return... |
214e549b2c0032870788edb8532ff84d635909ae | sanjelarun/eip_python | /practice_programs/stacks/parenthesis_check_my_way.py | 569 | 3.6875 | 4 | def check_valid_parenthesis(exp):
s_cnt = m_cnt = l_cnt = 0
for each_brac in exp:
if s_cnt < 0 or m_cnt < 0 or l_cnt < 0:
return False
if each_brac == '(':
s_cnt += 1
elif each_brac == ")":
s_cnt -= 1
elif each_brac == "{":
m_cnt +... |
9f52740f2da3b46278c7927b1f723b4064419472 | sanjelarun/eip_python | /practice_programs/stacks/RPN.py | 890 | 3.578125 | 4 | def RPN_evaluate(expression):
delimt = ","
operators = {'+': lambda x, y: x + y,
'-': lambda x, y: y - x,
'*': lambda x, y: x * y,
'/': lambda x, y: int(x / y)}
current_stack = []
cnt = 0
operator = ""
for token in expression.split(delimt):
... |
1508cfcdfc2e044d29c677e6587843d50bca6b34 | sanjelarun/eip_python | /practice_programs/arrays_1D/binary_add_cache_table.py | 1,284 | 3.609375 | 4 | ''' WAP which takee input two strings s and t of bits encoding binary numbers Bs and Bt, respectively
and returns a new string of bits represeting the number Bs + Bt '''
import time
def cache_table(a, b, c):
if a == '0' and b == '0' and c == '0':
return '0', '0'
elif a == '0' and b == '0' and c == '1'... |
aba50d2cd0d38f0b41aafe7f3998751f6a753e25 | sanjelarun/eip_python | /practice_programs/arrays_1D/multiply_two_arbitary_int.py | 1,522 | 4 | 4 | '''
WAP that takes two arrays_1D representing integers, and returns an integer representing their product
Example <1,2> and <2> returns <2,4>
'''
import time
# MY METHOD : Convert into single int and do multiplication
def multiply_two_list(A, B):
sign = -1 if A[0] < 0 or B[0] < 0 else 1
A[0], B[0] = abs(A[0])... |
048e068032ebe293e664c6c7a1481a658dbf42e6 | victoriapovolotsky/practice | /codeWithTests/MaxArea.py | 700 | 3.703125 | 4 | class MaxArea:
def max_area(self, height):
"""
:type height: List[int]
:rtype: int
"""
max_area = 0
length = len(height)
for i in range(length):
for j in range(length):
if i != j:
area = MaxArea.find_area(i, j, h... |
43dc57dfb14286a0a105fc36cc2ebda200341d26 | ureChanger/1day-1Algorithm | /2020.12.03 - 26/phoneBook.py | 480 | 3.609375 | 4 | def solution(phone_book):
#문제이해
#추상화: 뒤의 번호들과 비교
#계획하기: phone_book를 차례로 뒤에 위치한 원소들의 접두어들과 비교
answer = True
phone_book.sort()
for num in range(len(phone_book)):
phone_num = phone_book[num]
for nextNum in range(num+1, len(phone_book)):
if phone_num == phone_bo... |
e525f6530b818da101641d91a7efa2a01a91de62 | YangF0917/ML_Tutorials | /NumPy/Indexing.py | 1,383 | 4.0625 | 4 | import numpy as np
# Array Accessing
arr = np.array([1, 2, 3, 4, 5])
print(arr[0])
print(arr[4])
arr = np.array([[6, 3], [0, 2]])
# Subarray
print(repr(arr[0]))
# Accessing an element in an 1d array is identical to most other langs
# Sub-arrays
arr = np.array([1, 2, 3, 4, 5])
print(repr(arr[:]))
print(repr(arr[1:]))... |
e5e0ec01bced5b08bb77559ca40c82e9486f1f1b | YangF0917/ML_Tutorials | /NumPy/Filtering.py | 2,575 | 3.734375 | 4 | import numpy as np
# Filtering Data
arr = np.array([[0, 2, 3],
[1, 3, -6],
[-3, -2, 1]])
print(repr(arr == 3))
print(repr(arr > 0))
print(repr(arr != 1))
# Negated from the previous step
print(repr(~(arr != 1)))
# Will return a boolean array of whether each element meets the filter requ... |
affc33ba8100d8e4d2a42e6eb1c223fe018c4372 | semohy/Deu-programlama1 | /python-22022018.py | 1,479 | 3.609375 | 4 | def main():
state = input("ciro için 1 katma değer için 2 yaz : ")
state = int(state)
if(state == 1):
ciro()
elif(state ==2):
KatmaDegerciro()
def turnint(liste):
global createdDict
createdDict={}
for key, value in liste.items():
createdDict[key] ... |
8570e157445bcbb0d2ff72b5d3c62921d5e084fd | prahaladbelavadi/codecademy | /python/5.making-a-request.py | 1,129 | 4.40625 | 4 | # Making a Request
# You saw a request in the first exercise. Now it's time for you to make your own! (Don't worry, we'll help.)
#
# On line 1, we've imported urlopen from the urllib2 module, which is the Python way of bringing in additional functionality we'll need to make our HTTP request. A module is just a collecti... |
821eef207a015d9ffa9b47e6d161f0cd566822c2 | prahaladbelavadi/codecademy | /python/17.requests.py | 645 | 3.84375 | 4 | # Requests
# All right! Let's see if you can make that request to http://placekitten.com/ all on your lonesome.
#
# Instructions
# You need to do two things:
#
# On line 4, create a variable called website and set it equal to calling the urlopen method on "http://placekitten.com/" (no need for the "www"!)
# On line 5, ... |
901d7d94caefeb64b57c992199b377e0d4f29542 | INFO3401/problem-set-7-tala3849 | /parsers.py | 10,406 | 3.734375 | 4 | ################################################################################
# PART #1 #worked with Hannah and Marissa
################################################################################
import string
import csv
import os
from os import listdir
import json
def countWordsUnstructured(filename):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.