blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
49d79801a7fd4d2c730a29783a72e3f015517d1d | awelsh615/fluffy-sharks | /robots.py | 442 | 4.1875 | 4 | # Do you like robots?
user_reply=input("Do you like robots? (Type Yes or No)")
# If yes, then hello!
if user_reply=="Yes":
print("Beep Boop!")
# If no, they don't like you either
elif user_reply=="No":
print("Well, robots don't like you either.")
# Easter egg - laser eyes - watch out
elif user_reply=="only on... |
cab59f878d127b420200ae0e58719aa58f61d13b | aojanzen/onlinegame | /server/game.py | 1,726 | 3.6875 | 4 | #!/usr/bin/env python3
"""
game.py
Contains the main game loop of the high/low web app, as well as functions to
support the main loop, except for the database access
Author: Dr. Andreas Janzen, janzen@gmx.net
Date: 2020-09-13
"""
import db_services
import random
import sys
def game_intro():
print("\n"*3 + "="... |
ea4382e8615bf09db475f9a7db975038c738569c | ozashu/AIZUONLINE | /ITP/fizubuzz.py | 253 | 3.8125 | 4 | def fizzbuzz(num):
if num % 3 == 0 & num % 5 == 0:
return "fizzbuzz"
elif num % 3 == 0:
return "fizz"
elif num % 5 == 0:
return "buzz"
else:
return int(num)
for i in range(1, 100):
print(fizzbuzz(i))
|
54ce8b1f627a0fe803070d4643a783f05e3edd35 | vkvasu25/leetcode | /codeacademy/merge_sort.py | 1,830 | 4.25 | 4 | """
Please implement the merge sort algorithm
thi called divide-and-conquer solution
it consists from two steps:
1. divide the elements of array to small peaces
2. merge those peaces together in the result array
"""
class Solution:
# Here we will call the merge() function which
# should do the real work of ... |
41673345ec4d5be85a0b3b0310204349649a3044 | hemreozdemir/8QueensProblem | /8Queens.py | 6,061 | 3.984375 | 4 | import random
import time
def randomRestart():
columnList = [0] * 8
for i in range(8):
columnList[i] = random.randint(1, 8)
return columnList
# shows queens position on the board
def printBoard(columnList):
for i in range(8, 0, -1):
for j in range(8):
if columnList[j] == i... |
8585c66ce1c0fb93c287379d43795b849543396d | tjameskim/SoftDesSp15 | /data_mining/mining.py | 2,852 | 3.828125 | 4 | """
This file will take data from google
Regarding famous soccer players, those listed
as the top 23 players last season, and run through
google results and news articles to recieve a count
of how many times each players name shows up when
something generic is searched like, "Soccer",
"European Football", "Ballon'do... |
4db65d09c1514adc7f1909e26aab11d488f40ef4 | jkinney23/youtubesidebarscraper | /filescrape.py | 2,155 | 3.578125 | 4 | '''
This code will scrape the sidebar recommended videos from a saved
youtube page. You will need to right click on the page you want to
scrape and choose "save as..." (take note of the full path name to
your file - you will need to enter it when you run the program).
The page is rendered via the Render Class from re... |
19c95dafe571c7ede1cb930552f3048e4ad8580c | malvikasharan/software_writing_skills_potsdam | /Python_sessions/session-2/solutions/bob_solution.py | 721 | 4.1875 | 4 | hello = "Hi Human, I am B.O.B. "
question1 = "What is your name? "
response1 = "Thats a lovely name! "
input(hello+question1)
print response1
answer_type = "Please answer in 'yes' of 'no'. "
question2 = "Can I help you? "
response2 = "I am a computer, not a human. "
goodbye = "Great. Goodbye! "
question3 = "Did you li... |
9cb355702bc06f05d12779d3213a69bbe4542b79 | SCRK16/ProjectEuler | /src/1-100/77.py | 889 | 3.734375 | 4 | from collections import defaultdict
def sieve(upper):
primes = set()
composites = set()
for i in range(2, upper):
if i not in composites:
primes.add(i)
t = 2
while t * i < upper:
composites.add(t * i)
t += 1
return primes
upper = 100
primes = sorted(sieve(upper))
primes_count =... |
0d608bff35d433f954a2821a0211f9823db901bc | mensa2mj/isat252 | /lab7.py | 734 | 4.03125 | 4 | """
Michael Mensah - Lab 7
"""
#3.1
i = 0
while i < 6:
if i !=3:
print(i)
i=i+1
#3.2
num = 1
result = 1
while num <= 5:
result = result * num
num = num+1
print(result)
#3.3
number = 1
ans = 0
while number <=5:
ans = ans + number
number = number+1
print(ans)
#3.4
variable = 3
prod... |
b3d2e4e86c196ef65084a22589ec926ba78c2277 | ribeiro-rodrigo-exemplos/curso-python | /fundamentos/lista.py | 754 | 4 | 4 | lista = []
print(type(lista))
dir(lista)
print(len(lista))
lista.append(1)
lista.append(5)
print(lista)
print(len(lista))
nova_lista = [1, 5, 'Ana', 'Bia']
print(nova_lista)
nova_lista.remove(5)
print(nova_lista)
nova_lista.reverse()
print(nova_lista)
lista = [1, 5, 'Rebeca', 'Guilherme', 3.1415]
print(lista.index('... |
99f634d14c0d769efdebddb7a828791b9c326051 | pietglas/a-2017 | /Labs/CS109 2017 Lab 7 Skewness and handle missingness.py | 8,061 | 3.609375 | 4 | import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression, LogisticRegressionCV, LinearRegression
from sklearn.preprocessing import StandardScaler, MinMaxScaler
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn.metrics import confusion_matrix, roc_curve,... |
124b908a276ef612e942f43dd2cd72600d78573f | uniqueness001/Learning_summary | /Python_learning/Python小程序实战/hehehe.py | 162 | 3.6875 | 4 | # -*- coding: utf-8 -*-
for i in range(1,10):
for j in range(1,10):
if(i>=j):
print( "%d*%d=%-2d" % (i, j, i * j),end =" ")
print("")
|
7e09b4c953c88e392f71147ded4137389490ab1e | kanuos/python-programs | /String Programs/RecursiveDeletion.py | 609 | 4.25 | 4 | # String slicing in Python to check if a string can become empty by recursive deletion
def recursive_deletion(string, sub_str):
for _ in range(len(string)):
if sub_str in string:
string = string.replace(sub_str, '')
else:
break
return len(string)
user_string = input('... |
868c7b79a3d6cf9590cf77fbabcec358e70714ac | fernandojsmelo/Python---Curso-Completo | /exercicio4_10.py | 645 | 3.765625 | 4 | consumo = float(input("Informe Consumo em kWh: "))
tipo = input("Informe Tipo [R=Residencial C=Comercial I=Industrial]: ")
if tipo == "R":
if consumo <= 500:
print("O Comuso e = R$%5.2f "%(consumo*0.40))
else:
print("O Comuso e = R$%5.2f "%(consumo*0.65))
elif tipo <= "C":
if consumo <= 1000... |
fc6e5231402be9a516eadd401f1257eb895ba4cc | ganhan999/ForLeetcode | /中等146. LRU 缓存机制.py | 4,516 | 3.609375 | 4 | """
运用你所掌握的数据结构,设计和实现一个 LRU (最近最少使用) 缓存机制 。
实现 LRUCache 类:
LRUCache(int capacity) 以正整数作为容量capacity 初始化 LRU 缓存
int get(int key) 如果关键字 key 存在于缓存中,则返回关键字的值,否则返回 -1 。
void put(int key, int value)如果关键字已经存在,则变更其数据值;如果关键字不存在,
则插入该组「关键字-值」。当缓存容量达到上限时,它应该在写入新数据之前删除最久未使用的数据值,从而为新的数据值留出空间。
进阶:你是否可以在O(1) 时间复杂度内完成这两种操作?
示例:
输入
... |
9b30c229303f97c554d350eb44f12a123a78c699 | GuXipeng/python-exercise | /ex5.4-set.py | 497 | 4 | 4 | #! /usr/bin/env python3
basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
print(basket)
print('orange' in basket)
a = set('abcrachmlra')
b = set('alacazm')
print("a:", a)
print("b:", b)
print("a - b", a - b) #letters in a but not in b
print("a | b", a | b) #letters in either a or b
print("a & b", a & b)... |
779e848f711b1dcbf4bd650ce0348542fb930251 | namntran/python3 | /02/2sample.py | 374 | 3.890625 | 4 | # alculate money
# hours rate bonus result
# 5 9 0 -> 45
# 7 12 2 -> 98
regularHours = int(input("hours: "))
bonusHour = int(input("bonus hours"))
baseRate = int(input("base rate: "))
bonusRate = int(input("bonus rate: "))
print(regularHour * baseRate + bonusHour *( baseRate + bonus... |
0151bde754dfa777d5d1f46e29d53d61a2701a5c | blake1991/Corn_Bread_Mafia_PythonMod5 | /DBAccess.py | 1,800 | 4.1875 | 4 | #!/usr/bin/env python3
"""
Database acess script. Contains functions for opening a connection
to a database and reading information from it.
USAGE: python3 DBAcess.py <dbname>
"""
import sys
import sqlite3
def open_db(dbname):
"""
Establishes a connection to the specified DB.
Args:
dbname -> stri... |
ae83849f48f2b24b78f29e7ac2dd4199c2f33e66 | emilyng/NYT_Best_Sellers | /webapp/nyt_webapp.py | 2,021 | 3.5625 | 4 | import pickle
import streamlit as st
import numpy as np
import pandas as pd
from predict import compile_data, make_prediction
from text_process import get_title_data, get_desc_data, prep_desc
# from sklearn.feature_extraction.text import TfidfVectorizer
# from sklearn.preprocessing import Normalizer
def str2bool(v):
... |
14691cedd14e83ca187965f57bc79651169110e3 | 124tranvita/inventwithpython_3rd | /tic-toc-toe.py | 5,889 | 4.09375 | 4 | import random
def draw_board(board):
#this function prints out the board that it was passed
#'board' is a list of ten strings representing the board (ignore the index 0)
print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
print('-----------')
print(' ' + board[4] + ' | ' + board[5] + ' | ' ... |
b19256c57da9e5ec48c5cee50a078f6b0e99af71 | m4d4rchy/1ADS-MP1-19 | /mingMang.py | 6,753 | 3.9375 | 4 | #!/usr/bin/python3.5
#################################################
# @Author: Yassine Benmessahel #
# @Date: 2018-11-25 15:11:10 #
# @Last Modified by: Yassine Benmessahel #
# @Last Modified time: 2018-12-08 12:26:13 #
#################################################
def newBoard(n):
board = [[0] * n f... |
243f8efd930350eaaf63465255c533dfc6e5e5bb | martinpeck/advent-of-code-2019 | /day1/day1.py | 938 | 3.8125 | 4 | from math import floor
def determine_fuel(mass):
fuel = floor(mass / 3) - 2
return fuel
def determine_fuel_for_fuel(mass):
total_fuel = 0
fuel = determine_fuel(mass)
while fuel > 0:
total_fuel += fuel
fuel = determine_fuel(fuel)
return total_fuel
def solve_part1():
fue... |
f3776538f19a8fc78a0c773eb4ea464f6341f7d0 | oirampb/juego-Python | /game.py | 1,669 | 4.09375 | 4 | import random
options = [["piedra", 1], ["esponja", 2], ["pistola", 3], ["lobo", 4], ["rayo", 5], ["arbol", 6], ["diablo", 7], ["humano", 8], ["dragon", 9], ["serpiente", 10], ["agua", 11], ["tijera", 12], ["aire", 13], ["fuego", 14], ["papel", 15]]
random_option = random.randint( 0, len(options)-1)
option_computer = ... |
989955ff0e4a1e7e4eccc14f71088824bdb396f0 | elifyagmurturan/cryptography | /caesarCiphers/rot13.py | 274 | 3.640625 | 4 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
str_in = input("Enter message, like HELLO: ")
shift = 13
n = len(str_in)
str_out = ""
for i in range(n):
c = str_in[i]
loc = alpha.find(c)
newloc = (loc + shift)%26
str_out += alpha[newloc]
print("Obfuscated version: ", str_out)
|
efd09dd2db99ebf7cd1a28d6b25eb2ac78eaf2eb | team-c-ie-programming-fundamentals/workgroup-three | /string_calculator/string_calculator.py | 322 | 3.859375 | 4 | #%%
test_string = " 2,3,4,0 "
def string_calculator(string):
result = ''.join(string.split())
if result == '':
return 0
else:
result = result.split(",")
result = [int(number) for number in result]
return (sum(result)... |
4843c8dde736c96f56f394c5b01fec0bc89e376b | wzz482436/1807-2 | /04day/05-del方法.py | 395 | 3.796875 | 4 | class Dog():
def __init__(self):
self.name = "二哈"
print("init")
def __str__(self):
return "我是str方法"
def __del__(self):
print("我del")#当一个对象没有任何引用指向它的时候会执行
dog = Dog()#执行init方法
print(dog)#执行str方法
dog1 = dog
print(id(dog))
print(id(dog1))
del dog
del dog1
print("哈哈")
... |
d4ffeefdf2ed45e135f14c1d1ec02a51f466a236 | Garyluoluoluo/Algorithm-learning- | /20.括号.py | 1,106 | 3.921875 | 4 | # 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。
#
# 有效字符串需满足:
#
# 左括号必须用相同类型的右括号闭合。
# 左括号必须以正确的顺序闭合。
# 注意空字符串可被认为是有效字符串。
#
# 示例 1:
#
# 输入: "()"
# 输出: true
# 示例 2:
#
# 输入: "()[]{}"
# 输出: true
# 示例 3:
#
# 输入: "(]"
# 输出: false
# 示例 4:
#
# 输入: "([)]"
# 输出: false
# 示例 5:
#
# 输入: "{[]}"
# 输出: true
#
# 来源:力扣(LeetCode)
# 链接:... |
d5c2d38f5625f9222aea3d0830de235eca3c2069 | Keitling/algorithms | /python/2048/Game/LiYue.py | 4,563 | 3.875 | 4 | """
Clone of 2048 game.
"""
import random
# Directions, DO NOT MODIFY
UP = 1
DOWN = 2
LEFT = 3
RIGHT = 4
# Offsets for computing tile indices in each direction.
# DO NOT MODIFY this dictionary.
OFFSETS = {UP: (1, 0),
DOWN: (-1, 0),
LEFT: (0, 1),
RIGHT: (0, -1)}
def merge(line):
... |
a2af517c5d80479bc104f739a00e9ad4709e9901 | nikrasiya/Backtracking-2 | /131_palindrome_partitioning.py | 1,411 | 3.765625 | 4 | from typing import List
class Solution:
def __init__(self):
self.result = []
def partition(self, s: str) -> List[List[str]]:
"""
https://leetcode.com/problems/palindrome-partitioning/
Time complexity - O(n * 2^n)
'n' is the length of the string.
... |
d3e4b62c0157306c4a9f38143e159503a2950bbe | greall2/-Python-Fundamentals-Problem-Sheet | /Problem9.py | 1,424 | 4.3125 | 4 | #Emerging Technologies
#Python Fundatmentals Problem Sheet
#Ríona Greally - G00325504
#9. Implement the square root function using Newton’s method.
#In this case, Newton’s method is to approximate sqrt(x) by picking a starting point z and then repeating:
# z_next = z - ((z*z-x)/(2*z))
#To begin with, just repeat that... |
a4c68344bf5d2b8f19710e069d6c6f22dc64caa4 | jorinvo/r | /ml/python/xor_net.py | 619 | 3.515625 | 4 | #!/usr/bin/env python3
import numpy as np
from neural_net import train_network, predict
def xor():
X = np.array([
[0, 0],
[1, 0],
[0, 1],
[1, 1]
])
y = np.array([
[0],
[1],
[1],
[0]
])
np.random.seed(1)
model = train_network(
... |
9cf3f9e3f5402252c40f74325bbac8844be4e4ed | Aniket2124/Python-Insight | /If_statement.py | 221 | 3.703125 | 4 | def isTwoValuesEqual(first_par, second_par, third_par):
if(first_par == second_par or second_par == third_par or first_par == third_par):
return True
return False
print(isTwoValuesEqual(7, int("5"), 6))
|
57dd0ee9a68c56bcad32b53160e44235fa20a3e0 | elizavetakrasova/homework_python | /hw4/Pr3.py | 327 | 3.671875 | 4 | string = 'AAAbnAAbb'
def f1(string):
string1 = string.lower()
small, long = 0,0
for i,j in zip(string,string1):
if i == j:
small +=1
else:
long +=1
if small == long:
return 0
elif small > long:
return -1
else:
return 1
print(f1(s... |
21d815d73341bd986bdc9095081ec66a6e324164 | leomessiah10/String_lists | /words_in_string.py | 256 | 4.0625 | 4 | print('This program counts the number in the sentence')
line = input('Enter the sentence\n:-')
count = 0
line_list = line.split()
for i in line_list:
#print(i)
count+=1
print(line_list)
print('There are {} words in the sentence'.format(count))
|
31d66f664a7ada188bb48c81b9d69ee41c44ca65 | GianlucaBortoli/enhanced-clustering | /src/ellipse.py | 914 | 3.59375 | 4 | # coding: utf-8
# Original author: @HYRY
# https://stackoverflow.com/questions/15445546/finding-intersection-points-of-two-ellipses-python#15446492
import numpy as np
from shapely.geometry.polygon import LinearRing
def ellipse_polyline(x0, y0, a, b, angle=0, n=100):
"""
a: horizzontal semi-axis (aka hrad... |
72389ea81845f305f20e8a65b21a08a1a887f99b | Kushal-Coder453/guessing-game | /guessing.py | 390 | 4.1875 | 4 | import random
number=random.randint(1, 9)
chances=0
while chances < 3:
guess=int(input("enter the number"))
if guess==number:
print ("YOU GUESSED IT RIGHT, CONGRATULATIONS")
break
elif guess < number:
print ("please guess a higher number")
else:
print ("please guess a lower number")
chances=cha... |
f4798f16e3a5aadbc1b9b4e83e20f6b842b61283 | 13323106900/1python-diyigeyue | /系统.py | 3,304 | 3.984375 | 4 | #输入密码
print("户口".center(30,"*"))
print("1:新增人口".center(30," "))
print("2:查找人口".center(30," "))
print("3:修改人口".center(30," "))
print("4:删除人口".center(30," "))
cards =[]#定义空列表
while True:
fun_number =int(input("请选择功能"))
if fun_number ==1:
print("新增")
flag=0#默认值 0代表不在里面
card={}#定义空字典
name = input("请输入名字... |
7625b7c90410855548519f83c9ebc0efabbfc034 | Brychlikov/matura_solutions | /2019/zad4.py | 1,102 | 3.703125 | 4 | from math import factorial
from math import log
def digit_factorial(x):
return sum(map(lambda d: factorial(int(d)), str(x)))
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def gcd_arr(a):
if len(a) == 1:
return a[0]
head, *tail = a
return gcd(head, gcd_arr(tail))
... |
81594e4994767481aea2a8788ec32c1d18e20baf | DJV23/DarthVeder | /Programming/Math.py | 327 | 3.890625 | 4 | #create a variable and store a value on it
x=10
print(x)
x=x//5
print(x)
#operator spacing
#have 1 space before and after operators
y = 5
z = x + y
print(z)
#average
wrong_average = 50 + 50 + 50 + 100 + 80 + 50 / 5
right_average = (50 + 50 + 50 + 100 + 80 + 50) / 5
print(wrong_average)
print(right_average)
#Math funct... |
828cfc2164728a579b05ab96a67f2a483e4559e8 | duanxuepeng11/Alive | /pythonDemo/Functions/函数的参数.py | 1,682 | 3.890625 | 4 | # """
# 位置参数
# """
# def powder(x):
# return x * x
#
# """
# 默认参数
# """
#
# def power(x,n=2):
# s = 1
# while n >0:
# n = n- 1
# s = s * s
# return s
# """
# 可变参数
# """
# def calc(numbers):
# sum = 0
# for n in numbers:
# sum = sum + n * n
# return sum
# print(calc([1... |
461f72ec461f5d5962b804adbbb3dd58ede8ca80 | leknarf/project_euler | /4 - palindromic numbers.py | 385 | 3.8125 | 4 | def products():
a, b = 100, 999
for ii in range(b, a, -1):
for jj in range(b, a, -1):
yield ii * jj
def is_palindrome(x):
s = str(x)
return s == ''.join(reversed(s))
def find_largest_palindrome():
return max(p for p in products() if is_palindrome(p))
... |
d808dbbf115ab703d1bd9912d1d2453da27fb798 | JeffLi1993/robot-mumu | /org/coder/math/matrix/matrix_exp.py | 916 | 4.0625 | 4 | # -*- coding: utf-8 -*-
# 导入 numpy 函数,以 np 开头
import numpy as np
if __name__ == '__main__':
mat1 = np.array([1, 3])
mat1 = np.mat(mat1) # 相当于 np.mat([1,3]), mat 函数将目标数据的类型转换为矩阵(matrix)
print mat1
# 1 行 2 列的矩阵(也称 1 * 2 矩阵)
# ==> [[1 3]]
print
mat2 = np.array([[1, 3], [3, 4]])
mat2 = ... |
5f5ccfa6c383e2e4bf80ffdd156ae63b0bfb707c | ekeyur/learnPython | /even.py | 125 | 3.8125 | 4 | nums = [8,5,3,7,12,2,53,5,7,13]
for i in xrange(0,len(nums)):
if (nums[i]%2 == 0):
print "%d is even." % nums[i]
|
cd8681e73aef6571393dc0942b9a8c4c0f34d4df | alvinsen/pycode | /leetcode/102_BinaryTreeLevelOrderTraversal.py | 2,590 | 4.21875 | 4 | #!/usr/bin/python
# -*- coding:utf-8 -*-
import time
"""
Given a binary tree, return the level order traversal of its nodes' values.
(ie, from left to right, level by level).
For example:
Given binary tree {3,9,20,#,#,15,7},
3
/ \
9 20
/ \
15 7
return its level order traversal as:
[
[3],
[9,20... |
9f94762a4a16e96fb04645e7128ed38b8784cfa6 | polaris27/python_projects | /project2-Hangman_game.py | 1,513 | 3.96875 | 4 | import random
l = ['python', 'java', 'kotlin', 'javascript']
b = random.choice(l)
length = len(b)
hyphen = "-" * (length)
print("H A N G M A N")
while True:
choice = input('Type "play" to play the game, "exit" to quit:')
if choice == "exit":
break
elif choice != "play":
continue
itr = 8... |
187a2707bd9bae03b7f28611885e60a47ea7c31c | sameersaini/hackerank | /Amazon/TreesGraph/checkPathSum.py | 952 | 3.921875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def checkPathSum(self, node, total, sum):
if not node.left and not node.right:
if (total + node.val) == sum:
... |
1f76b681ceb6b4346f4295277053156d523ba7df | daniel-m-campos/algorithms | /src/algorithms/quicksort.py | 1,307 | 3.53125 | 4 | def partition_first(array, left, right):
pivot = array[left]
i = left + 1
for j in range(left + 1, right + 1):
if array[j] < pivot:
array[i], array[j] = array[j], array[i]
i += 1
array[i - 1], array[left] = array[left], array[i - 1]
return i - 1
def partition_last(a... |
ec76db0a4ff1df1365dbcdfb3f687c4b40876fd7 | JTMachen/Sponsio-Computatum | /Website/.ipynb_checkpoints/Place_Bet-checkpoint.py | 4,456 | 3.546875 | 4 | # Import required libraries
from datetime import datetime
from path import Path
import pandas as pd
from bs4 import BeautifulSoup as soup
from urllib.request import Request, urlopen as Ureq
import json
import warnings
warnings.filterwarnings('ignore')
from IPython.display import clear_output
from Website import basebal... |
d1b6883e5d61ea3124fd1307d7f1710e480722e7 | RamananRavichandran/python | /python assignment 2.py | 3,832 | 3.859375 | 4 |
n=int(input("Enter the number of students"))
roll=[]
marks=[]
m=""
dict={}
for i in range(0,n):
r=input("Enter the roll number")
roll.append(r)
r1=input("Enter the student name")
r2=input("Enter the class name")
s=int(input("Enter the number of subjects"))
marks.append([])
for ... |
d883cb44fee876ae2e4f5b0f55e97bc504d8a03d | Clem-Pat/Space_Invaders_Game | /Space invaders/characters/projectile.py | 1,548 | 3.65625 | 4 | """projectile"""
from pygame import *
import pygame.gfxdraw
import random
import time
import os
projectile_path = os.path.dirname(os.path.abspath(__file__))
if projectile_path.endswith('characters'):
projectile_path = projectile_path[:-10]
class Projectile():
def __init__(self, x, y, nature):
... |
d214abd2309dc8d5e9bc3f16efddb9130ae10568 | miguelzeph/Python_Git | /2011/13_Visual_Python_Estudos/InverserForce.py | 3,062 | 3.921875 | 4 | from visual import *
#=============================================================
# This program visualizes the orbit of a particle of mass m in
# an atractive central force field = -alpha/r. The initial conditions
# are given by r=r0, r_dot=0 (i.e r0 is a turning point in r) and
# phi=0 phi_dot=k/r0*sqrt(alpha/... |
04ee880afc86c7b8b1510dcfb4f81dd91a19c3d3 | kondziu/gritty-scripts-of-death | /python/tabrot.py | 16,279 | 4 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Tabrot
#
# The script reads the array from standard input, applies the specified
# transformations and prints the new array to standard output. The
# transformations include rotating the array (90°, 180°, 270°, and 0°) or
# flipping it (horizontally, vertically, or b... |
82279939c7246d27d65daf2b456a65c53d929141 | mahbeg/us-states-game | /main.py | 1,298 | 3.984375 | 4 | from turtle import Turtle, Screen
import pandas
data = pandas.read_csv("50_states.csv")
name_of_state = data["state"]
screen = Screen()
screen.setup(800, 800)
screen.title("U.S States game")
image = "blank_states_img.gif"
screen.addshape(image)
turtle = Turtle(image)
moving_name = Turtle()
moving_name.penup... |
6ceac621dc7a785ddff99a43791584190dd5a054 | jakemuncada/slitherlink-squares | /src/puzzle/board.py | 7,255 | 3.6875 | 4 | """Board"""
from copy import deepcopy
from typing import Optional
from src.puzzle.board_tools import BoardTools
from src.puzzle.enums import BorderStatus, CardinalDirection, DiagonalDirection, OptInt
class Board:
"""
The game board.
"""
def __init__(self, rows: int, cols: int, cells: Optional[list[... |
9fcdc45b4834568b25253c8e27b87c2ba05d6aa9 | mirkaoJRC/POO1 | /Tarea.py | 1,332 | 3.875 | 4 | #Autor: Mirko Ramirez
#Primer EJemplo
class Mascota():
def __init__(self, tipo, nombre, edad, Genero_Del_animal, color, raza):
self.tipo = tipo
self.nombre = nombre
self.edad = edad
self.Genero_del_animal = Genero_Del_animal
self.color = color
self.raza = r... |
d2890e2ca6c648ddc7fcb14632f9325851c8a569 | himanshu2801/Geeksforgeeks | /Container With Most Water .py | 1,218 | 3.828125 | 4 | """
Given N non-negative integers a1,a2,....an where each represents a point at coordinate (i, ai). N vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i,0). Find two lines, which together with x-axis forms a container, such that it contains the most water.
Example 1:
Input:
N = 4
a[] ... |
181ea6bc93e0f206aea20645474cdec777148530 | agolikova/Rosalind-Bioinformatics-Solutions | /Code/LGIS_Longest Increasing Subsequence.py | 2,258 | 3.671875 | 4 | #Given: Positive integer n≤10000 followed by a permutation π of length n
#Return: Longest increasing subsequence of π, followed by a longest decreasing subsequence of π
#NB a subsequence of a permutation is a collection of elements of the permutation in the order that they appear, not necessarily contiguously
def... |
6d073fe20ab61c2763b5e2ae06b2e9656c92f4b0 | shubham2704/Competitive-Programming-Question-I-Solved | /IQ-Test.py | 866 | 4.59375 | 5 | ##Question##
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given numbers differs
from the others.
Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program
that among the given numbers finds one ... |
cd935c2dcf986e6d8192355555160f1b44f13f1a | ajm-kohaku/CITP110 | /Homework 3/MurphyAHW3.py | 2,693 | 4.0625 | 4 | #-------------------------------------------------------------------------------
#Program: Designing a Program From a Desciption - Salesman's Salery
#Programmer: Amber Murphy
#Date: 05/30/2013
#Abstract: This program will compute the amount telephone solicitors
# will be paid each w... |
f11524d94e0dd5412f0fe8c1b49485e7a793a773 | prachi-bindu/Leetcode | /BinArraySorting.py | 632 | 3.90625 | 4 | class BinArraySorting:
def __init__(self):
self.arr = []
def showArray(self):
print(self.arr)
def fillArray(self):
n = int( input("Enter the size of the array-") )
print("Enter the elements in the array-")
for i in range(n):
el... |
e1062a45937c362543190ff607bb280f1bd549ec | GowthamPrasad/py_thon | /Keywords/andornot.py | 322 | 4.125 | 4 | #Logical and, or, not
#and - both the condition should be true
exp=10
age=45
if(exp>=10 and age>=45):
print("Eligible to work")
else:
print("Not Eligible")
#or - any one condition should be true
x=10
print(x>5 or x<5)
#not - returns false if the value is true and vice versa
x="True"
print(not(x... |
33893f3cf0a22534e39cceadf743a0569d79f4d3 | jmseb3/bakjoon | /05. 1차원 배열/8958.py | 208 | 3.578125 | 4 | t = int(input())
for i in range(t):
score = 0
sum =0
a = input()
for b in a:
if b =="O":
score +=1
sum +=score
else:
score =0
print(sum) |
f8061929d4c22f4f710f21c118015a94319f5d4b | gus07ven/CCIPrac | /Arrays.py | 691 | 3.96875 | 4 | from array import *
numbers = array('i', [10, 20, 30, 40, 50])
def display(input_array):
for x in input_array:
print(x)
# Printing all elements
print("Printing all elements of array:")
display(numbers)
print("")
# Accessing elements
print("Accessing 10 and 30: ")
print(numbers[0])
print(numbers[2])
pr... |
12c0d8763cdf58460f39b5a313f9ebce624f18ef | AminHCE/goodUni | /stu.py | 1,949 | 3.5625 | 4 | import csv
import error
import listGenrator
def lp(user):
print(listGenrator.lessonList())
order = str(input(" Enter code: "))
words = order.split()
if words[0] == 'B' or words[0] == 'b':
return
row = [words[0], words[1], user, 'N/A']
# print(row)
with open('database.c... |
e7a7997b35b3a63e0b8932fa4fe48a01bc4a1713 | linitachi/LeetCode_Practice | /easy/119.杨辉三角-ii.py | 1,210 | 3.640625 | 4 | #
# @lc app=leetcode.cn id=119 lang=python3
#
# [119] 杨辉三角 II
#
# https://leetcode-cn.com/problems/pascals-triangle-ii/description/
#
# algorithms
# Easy (61.91%)
# Likes: 181
# Dislikes: 0
# Total Accepted: 71.2K
# Total Submissions: 115.1K
# Testcase Example: '3'
#
# 给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行。
#
#
#
# ... |
be84f3f91cf1779b2bca7f6fa9b5542dbb615912 | tomasmu/aoc2020 | /aoc08.py | 1,521 | 3.546875 | 4 | #input
import os
file = os.path.basename(__file__).replace('.py', '_input.txt')
input = open(file).read()
#format
array = input.splitlines()
#puzzle 1
instructions = [line.split() for line in array]
instructions = list(map(lambda op_arg: (op_arg[0], int(op_arg[1])), instructions))
def get_value_at_loop(instructions)... |
b97d001bc8fd49f865fdc6fe3480bae2944b443f | hannahsteingass/primitive | /GUI.py | 10,772 | 3.96875 | 4 | import tkinter.filedialog as filedialog
import tkinter.font as font
import tkinter as tk
import os
import utils as util
from tkinter import messagebox
from tkinter import *
from tkinter.ttk import *
from re import search
import PIL
from PIL import ImageTk as a
from PIL import Image
inputPath = ''# Global variable to s... |
21d119463fbcbe17f87dc6ab881f44c925744617 | asha2003/asmagar | /panda3.py | 307 | 3.796875 | 4 | import pandas as pd
ds1 = pd.Series([2, 4, 6, 8, 10])
ds2 = pd.Series([1, 3, 5, 7, 9])
ds = ds1 + ds2
print("Add two Series:")
print(ds)
print("Subtract two Series:")
ds = ds1 - ds2
print(ds)
print("Multiply two Series:")
ds = ds1 * ds2
print(ds)
print("Divide Series1 by Series2:")
ds = ds1 / ds2
print(ds) |
9b9953c45f62d73f5c7f34cfcd4c0478c6f38268 | vinidusso/jpm_sss | /models/Trade.py | 1,059 | 3.609375 | 4 |
import datetime
class Trade(object):
BUY = 'B'
SELL = 'S'
def __init__(self, quantity_of_shares, operation_type, price, timestamp = None):
self.quantity_of_shares = None
self.operation_type = None
self.timestamp = None
self.price = None
if (quantity_of_shares < 0):
raise Exception("Quan... |
ffcb51cc838b614f35e192f34a99f62a50626834 | changetocoding/PyLoreKelly | /Week4/Homework/Solution/first.py | 464 | 3.59375 | 4 |
def fib(fib_index):
n_minus_1 = 1
n_minus_2 = 0
if fib_index == 0:
return n_minus_2
elif fib_index == 1:
return n_minus_1
else:
index = 2
while index <= fib_index:
new_number = n_minus_1 + n_minus_2
# Update our variables aka the reset
... |
0117a4302c57c16eb2bc29fc4a6f9e92991fc4ed | kangshengxian/test | /test_thread.py | 470 | 3.6875 | 4 | import threading
import time
from threading import current_thread #引用获取线程名称函数
def myThread(arg1, arg2):
print(current_thread().getName(),'start') #获取线程名称
print('%s %s' %(arg1, arg2))
time.sleep(1)
print(current_thread().getName(),'stop')
for i in range(1,6,1):
t1 = threading.Thread(targe... |
de75e98661c3e43ec624f03ad5ea265a264627bf | philippebarrette4/WarGame | /src/Player.py | 912 | 3.890625 | 4 | class Player:
def __init__(self, name):
self.name = name
# New player has no cards
self.all_cards = []
def remove_one(self):
# Note we remove one card from the list of all_cards
# We state 0 to remove from the "top" of the deck
# We'll imagine index -1 as the bo... |
4bce68756fdf72b3675a0ace3d2a45b28ec278a1 | sriramv95/Python-Programming | /Regression.py | 3,400 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 25 09:22:55 2020
@author: Sriram
"""
# =============================================================================
# Regression
# =============================================================================
# Regression is used to predict target variables(... |
7387f542ae469a797d8a050508885f22bf20c88f | sauravsingh/python | /day2.py | 1,934 | 3.609375 | 4 | ###exception handing
try:
1/0
except:
print("Divide by zero error")
#--------------------------------------#
try:
1/0
except ZeroDivisionError as e:
print(e)
#------------------------------------#
try:
print(b)
except NameError as e:
print(e)
#---------------------------------------#
lst=[1,2,3,... |
3936b8e89d893c4d51e909ef05660b16d37d965a | tarek2ty/PY-Socket | /send_EOT.py | 1,256 | 3.515625 | 4 | import socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(("0.0.0.0", 8080))
server.listen(0)
print("waiting")
connect, add = server.accept()
print("connected")
def send_text(send_socket, text):
text+="\n"
data=text.encode()
send_socket.send(data)
# We created an EO... |
67cb411ca773d222cb51213727bcd486ede63771 | BPSB/OOGillespie | /oogillespie/_oogillespie.py | 6,795 | 3.5 | 4 | from abc import ABC, abstractmethod
import numpy as np
import random
from inspect import signature
from itertools import product
from functools import partial, update_wrapper
class GillespieUsageError(SyntaxError):
pass
class Event(object):
"""
Decorator that marks a method (of a subclass of Gillespie) as an event... |
ae1f493612002041ca3d95ba8df6a97f3cf7a10e | schwarzwaldsvd/PythonFundamentals | /12_dev/algorithms/join_elements_iterative.py | 320 | 3.859375 | 4 | """ Task: rewrite this function so that it uses a loop rather than recursion """
def joinElements(array, joinString):
resultSoFar = ''
for i in range(len(array)-1):
resultSoFar += array[i] + joinString
return resultSoFar + array[len(array)-1]
print(joinElements(['s','cr','t cod', ' :) :)'], 'e'))
|
e305a194631e4e5527c185a677008a24e22be6ac | Melmanco/INFO229 | /Tutorial_4_PyTest_TDD/ejercicio4/test_prime.py | 768 | 3.515625 | 4 | import pytest
# Test values from 0 to 19
TEST_VALUES = [False, False, True, True, False, True, False, True, False, False, False, True, False, True, False, False, False, True, False, True]
def is_prime(num):
# Prime numbers must be greater than 1
if num < 2:
return False
if num == 2:
... |
5ea87c2bc5e2f63a5f88b978e868f81cd3b60845 | maoeneas/funciones_python | /borrar.py | 206 | 3.625 | 4 | def contar (lista, num_a_contar):
contador=0
for i in range(len(lista)):
if lista[i] == num_a_contar:
contador +=1
return contador
lista
contar([1,5,6,8,7],3)
|
7d771b74c8a6dffd690caa51fa25c5caf4e9c9ef | mingweihe/leetcode | /_0211_Add_and_Search_Word_Data_structure_design.py | 1,254 | 4.03125 | 4 | class WordDictionary(object):
def __init__(self):
"""
Initialize your data structure here.
trie solution
implemented by dictionary
"""
self.root = dict()
def addWord(self, word):
"""
Adds a word into the data structure.
:type word... |
0e9142de63296561cbb2a3120a5d86ef5f9db0a8 | jcyw/MyNote | /python/520.py | 781 | 3.9375 | 4 | import turtle
# 设置窗口大小和背景颜色
turtle.setup(600, 600)
turtle.bgcolor('white')
# 绘制红色心形
heart = turtle.Turtle()
heart.hideturtle()
heart.speed(0)
heart.pencolor('#e74c3c')
heart.fillcolor('#f9a26c')
heart.begin_fill()
heart.left(45)
heart.forward(150)
for i in range(2):
heart.circle(60, 180)
heart.left(90)
he... |
d78af1ef56f01c053dc28d7d9ab5e65f9c350f10 | RoysMG/questionsnanswerss | /Untitled-2.py | 978 | 4.0625 | 4 | while True:
a=input("evet ya da hayır a bas")
if (a=="hayır"):
a=input("devam etmek istiyor musun?")
if (a=="hayır"):
break
else :
print("istediğim cevabı alamadım o yüzden en başa dönüyorsun")
elif(a=="evet"):
a=input("o zaman bu şeyin devamı... |
4439e284db29481704a42521cfae0d7bbf0192d8 | christophercrouzet/hienoi | /hienoi/dynamics.py | 12,420 | 3.5 | 4 | """Physics systems evolving over time."""
import itertools
import math
import sys
import numpy
import hienoi._common
import hienoi._numeric
from hienoi._common import UserData
from hienoi._dynamicarray import DynamicArray
from hienoi._kdtree import KDTree
from hienoi._nani import Bool, Number, READ_ONLY, PickableNan... |
efb8e60f4e0b9a88edadec656067847dba9a78d9 | rafaelvictor88/python3exercises | /ex068.py | 995 | 3.90625 | 4 | from random import randint
count_victory = 0 #contador de vitórias
while True:
player = int(input('Jogue um número: '))
computer = randint(0, 10)
total = player + computer
choice = ' '
while choice not in 'PI':
choice = str(input('Par ou Ímpar [P/I]: ')).strip().upper()[0]
p... |
73818e307eac41f02fea3166fa94414ab8bfea21 | Meaguileraa/algorithms | /pos-of-large-groups.py | 1,134 | 4.1875 | 4 |
# In a string s of lowercase letters, these letters form consecutive
# groups of the same character.
# For example, a string like s = "abbxxxxzyy" has the groups
# "a", "bb", "xxxx", "z", and "yy".
# A group is identified by an interval [start, end], where start and
# end denote the start and end indices (inclusi... |
720ada20aba6d6771d55a5c7b7806b6a761bcf58 | neochen2701/TQCPans | /程式語言 V2答案檔/Python/506.py | 382 | 3.640625 | 4 | number = int(input())
factor_list = []
for i in range(2, int(number / 2) + 1):
while number % i == 0:
number /= i
factor_list.append(i)
if len(factor_list) == 0:
print('-1')
exit()
factor_str = ''
for idx in range(len(factor_list)):
factor_str += str(factor_list[idx])
if idx != len... |
552e755eadfa41cd6411702315b29ee57db09912 | Uche-Clare/python-challenge-solutions | /Ekeopara_Praise/Phase 2/LIST/Day40 Tasks/Task2.py | 308 | 4.1875 | 4 | '''2. Write a Python program to print a specified list after removing the 0th, 4th and 5th elements.
Sample List : ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']
Expected Output : ['Green', 'White', 'Black'] '''
SampleList = ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']
print(SampleList[1:4]) |
90e055e33f320b74989f69f5a36e89a87bb5edbc | Thamizhselvan310/example | /countVowel.py | 245 | 3.640625 | 4 | s=input()
volcount=0
constant=0
vol=['a','e','i','o','u','A','E','I','O','U']
for i in range(len(s)):
if(s[i] in vol):
volcount+=1
else:
constant+=1
print("Vowels in string",volcount)
print("Constant in String",constant)
|
3b02ef2b0e2632a83a7a207f1607be0a0bf91336 | uma-c/CodingProblemSolving | /2-pointer/slow_fast/linked_list_cycle.py | 816 | 3.84375 | 4 | '''
Given a linked list, return the node where the cycle begins. If there is no cycle, return null
'''
import unittest
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def detectCycle(self, head: ListNode) -> ListNode:
... |
bb30f1d6efa622a60c16a98e9bf1acda641fb696 | inons14/tipCalc | /tip.py | 876 | 3.53125 | 4 | from tipcalc import waiter
import datetime
#calculate tip by time
file = open('log.txt','a')
date = str(datetime.datetime.now())
file.write("Date: %s : \n" %(date))
waiters = []
hour = 0.0
totalTip = 0.0
while True:
name = input("Enter Name: \n")
if(name!=""):
newWaiter = waiter(name,float(i... |
edcb78e781d6d252800e750af2fc0508cc863e5c | sw5cc/tencent-finance | /tencent_finance/unicode_converter.py | 497 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
def to_utf8_string(unicodestr):
utf8str = ''
start = 0
end = 0
pos = unicodestr.find('\\u')
while pos != -1:
end = pos
if start != end:
utf8str += unicodestr[start:end]
start = pos + 6
ch = unicodestr[pos + 2:... |
8871f99103a3ab895c55ee3ee47b83d9b3edd979 | goareum93/K-digital-training | /01_Python/16_fileIO/실습문제_단어카운트.py | 490 | 3.8125 | 4 | # 파일의 단어수 카운트
f = open('yesterday.txt', 'r')
yesterday = f.readlines()
f.close()
contents = ''
words = []
for line in yesterday:
line = line.split()
for w in line:
words.append(w.lower())
# 사용된 단어들만 추출하기 위해 세트로 변경
wordList = set(words)
wordList = list(wordList)
wordList.sort()
# 단어별 빈도 계산을 위한 딕셔너리 생... |
7fff00012e4b26c3057523b555fe331929798d4b | cfudala82/DC-Class-Sept-17 | /projects/week1/tip_calc.py | 539 | 3.75 | 4 | totalBillAmount = int(input('Total bill amount? '))
levelOfService = input('Level of service? ')
tip = 0
if levelOfService == 'good':
tip = .2
totalAmount = (totalBillAmount * tip) + totalBillAmount
elif levelOfService == 'fair':
tip = .15
totalAmount = (totalBillAmount * tip) + totalBillAmount
elif levelOfSer... |
04caa49d228678c227538c7936d015db42c5f08c | ratannsingh/pythonlike | /cat.py | 1,026 | 3.8125 | 4 | #!/usr/bin/python3
#Python 2.x program for Speech Recognition
import os
from gtts import gTTS
import speech_recognition as sr
#Sample rate is how often values are recorded
sample_rate = 48000
#Chunk is like a buffer. It stores 2048 samples (bytes of data)
#here.
#it is advisable to use powers of 2 such as 1024 or ... |
f6382588c79fe626b2a60663487119142443394e | PauloMorillo/holbertonschool-higher_level_programming | /0x02-python-import_modules/2-args.py | 430 | 3.921875 | 4 | #!/usr/bin/python3
if __name__ == "__main__":
import sys
argv = sys.argv
count = 0
argc = len(argv)
if argc > 1:
if argc == 2:
print("1 argument:")
else:
print(argc - 1, "arguments:")
count = count + 1
while count < argc:
print("{:d... |
566dd732ee4f1eb804051476dc5ddab17ea94d1b | ChoiYoungHa/Learn_Python | /Example2/use_Random.py | 445 | 3.625 | 4 | from random import randint, uniform
# 중복제거 난수 구하기
# numbers []
# number = randint(1, 10)
# if number not in numbers:
# numbers.append(number)
# print(number)
print(randint(1, 10))
print(uniform(1, 0))
i = 0
count = 0
while i < 50:
number = randint(1, 10)
if number == 10:
count = co... |
da680d48190172f9c44244d89e9b6efa924189c3 | SpringCheng/Python--practice | /day2/判断闰年.py | 331 | 3.828125 | 4 | """
闰年是能被4整数且不能被100整除或者能被400整除
-*- coding: UTF-8 -*-
@date: 2019/8/30 2:40
@name: 判断闰年.py
@author:Spring
"""
years = int(input('请输入年份:'))
if (years % 4 == 0 and years % 100 != 0) or (years % 400 == 0):
print('该年是闰年')
else:
print('该年是平年')
|
2df0d634c53e7c6fb298552b458e6f6d262cf225 | Klakmal/Single-register-machine | /machine.py | 2,150 | 4.0625 | 4 | #Implementation of Stack using python list
class Stack:
def __init__(self):
self.list=[]
def isEmpty(self):
return self.list==[]
def push(self,item):
self.list.append(item)
def pop(self):
return self.list.pop()
def peek(self):
return self.list[len(self.list)-1]
def size(self)... |
2ba07bd480ef37ad489b4c5f7947b78e5650ef18 | WUVsUQkP/data-structures-and-algorithms-in-python-solutions | /solutions/exercises/P/ch1/ex36/word_count | 429 | 4.375 | 4 | #!/usr/bin/env python3
# ch1_ex36_sc1
import re
def word_count(whitespace_deliminated_list):
counts = {}
words = map(lambda x: x.lower(), filter(lambda x: len(x) > 0, re.split(r"\s+", whitespace_deliminated_list)))
for word in words:
counts[word] = counts.get(word, 0) + 1
return counts
if __... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.