blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
3a890831504035a62d26ce841f2aeaff5d41a37e | olivier555/Projet-MOPSI | /MainTDLOG.py | 1,620 | 3.5 | 4 | """Module principale permettant de lancer le programme"""
## Modules importes ##
import Menu
import Constant
import pygame
import sqlite3
## Main ##
GAME = sqlite3.connect("game.db")
CURSOR = GAME.cursor()
def main():
"""Lance le jeu et gere l'actualisation des scores dans le base de
don... |
fe0a1a16f3802ff846143353676dc6d99b6a1080 | pnandini/Backtracking-3 | /prob_73.py | 1,856 | 3.625 | 4 |
class Solution(object):
# n= None
# m= None
def exist(self, board, word):
"""
:type board: List[List[str]]
:type word: str
:rtype: bool
"""
n = len(board[0]) # columns
m = len(board) # rows
# visited array
visited_array ... |
e55e164cbb73ea1b6be992069f43798e8234b5e9 | praneetha28/repo | /cspp1-practisem3/m9/odd_tuples.py | 609 | 4.25 | 4 | "'#Exercise : Odd Tuples'"
#Write a python function oddTuples(aTup) that takes a some numbers in the tuple as input and returns a tuple in which contains odd index values in the input tuple
def oddTuples(aTup):
'''
aTup: a tuple
returns: tuple, every other element of aTup.
'''
tup=()
... |
3c4c0ceb3046e8d2696eed1ad2f49a7f0d34e4f4 | praneetha28/repo | /cspp1-practisem3/m6/p1/fizz_buzz.py | 308 | 3.859375 | 4 | "'#enter the output'"
N = int(input())
i = 1
for i in range(1, N+1):
if i == 1:
print(i)
for i in range(2, N+1):
if i%3 == 0 and i%5 == 0:
print('Fizz')
print('Buzz')
elif i%5 == 0:
print('Buzz')
elif i%3 == 0:
print('Fizz')
else:
print(i)
|
b12ac4403b7763f9b689d522d86351d7834849ee | praneetha28/repo | /cspp1-practisem3/compare_AB.py | 202 | 4 | 4 | varA = "hello"
varB = "hi"
if type(varA)==str or type(varB)==str:
print (" string involved")
elif varA>varB:
print (" bigger ")
elif varA==varB:
print ( "equal" )
else:
print(" smaller ")
|
2ca7cdf606d8bf4618a03cbea21a682b671e6c4d | praneetha28/repo | /cspp1-practisem3/m20/CodeCampMatrixOperations/matrix_operations.py | 2,440 | 3.953125 | 4 | '''program'''
def mult_matrix(mat_m1, mat_m2):
''' check if the matrix1 columns = matrix2 rows
mult the matrices and return the result matrix
print an error message if the matrix shapes are not valid for mult
and return None
error message should be "Error: Matrix shapes invalid for m... |
63c8b6c0988170ef99ed910fdbf904ffdff83c04 | praneetha28/repo | /cspp1-practisem3/m12/p1/p1/create_social_network.py | 1,223 | 4.0625 | 4 | '''
Assignment-1 Create Social Network
'''
def create_social_network(data):
'''
The data argument passed to the function is a string
It represents simple social network data
In this social network data there are people following other people
Here is an example social network da... |
1ae9800a508d38b739c3bf5317d67da74b0de362 | pavan-nadupuru/codeChefPractiseEasy | /CLEANUP.py | 492 | 3.65625 | 4 | for _ in range(int(input())):
totalDishes, compDishes = input().split()
completedDishes = list(map(int,input().split()))
chef, chefAssis,toAssis = [],[],False
for i in range(1,int(totalDishes)+1):
if(i not in completedDishes):
if(toAssis):
chefAssis.append(str(i))
... |
d1c07892592e0f7c0b5632babd1088db33531248 | andresgerz/python-course | /data-preprocessing.py | 1,393 | 3.625 | 4 | ### Data preprocessing ###
# I import the libraries
import pandas as pd
import numpy as np
url = "C:/Users/mellisos/Desktop/Programming/Python/python-course/train.csv"
df = pd.read_csv(url)
print(df.head())
print('######################################################')
print(df.tail())
# I save the data
route =... |
4829097f8bef2ce036fd0dfb9b9ccffe482ecefd | andresgerz/python-course | /pythoncurse.py | 55,851 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 6 22:18:47 2018
@author: mellisos
"""
#==============================================================================
# #funcion
# def suma(n1,n2)(
# n=n1+n2
# return(n)
# )
# print(suma(5,10))
#
##======================================================... |
6d895fb48c930fbda4f1565922c785930db084f9 | zhaishujie2/MachineLearningTest | /Enron/outliers/outlier_cleaner.py | 848 | 3.703125 | 4 | #!/usr/bin/python
import math
def outlierCleaner(predictions, ages, net_worths):
"""
Clean away the 10% of points that have the largest
residual errors (difference between the prediction
and the actual net worth).
Return a list of tuples named cleaned_data where
each tuple... |
680c85b838022d2aea6d01fee9b0d72bf85d4bdf | stju19/study | /python/mat.py | 2,433 | 3.875 | 4 | #!/usr/bin/python
'this module contains different functions of matrix'
class Matrix(object):
"""the class of matrix"""
def __init__(self, m=2, n=2, v=0):
if isinstance(m, (int, float)) and isinstance(n, (int, float)):
self.rowNum = m
self.colNum = n
self.mat = creat... |
de2ade8e0702827fef1599fead5772954dabdc94 | conornugent1/Table_tennis_analysis | /TT_analyser_2.py | 7,920 | 3.5625 | 4 | from tkinter import *
import sqlite3
TABLETENNIS_DB="TableTennis.db"
FOREIGN_KEYS_ON="PRAGMA foreign_keys = ON"
def query(sql,data):
with sqlite3.connect(TABLETENNIS_DB) as db:
cursor = db.cursor()
cursor.execute(FOREIGN_KEYS_ON)
cursor.execute(sql,data)
db.commit()
... |
fa1cc144e40951f5b937ddd8473959a18e2af9c9 | infinitecoding009/age-calculater-in-py | /Age.py | 251 | 3.96875 | 4 | user = int(input())
count = 0
for user in range(user, 2021):
count += 1
if count >= 1:
# Returns how old you are.
print("You are/almost %d years old. Keep Gracing😀" % (count))
else:
print("You have not been born 😅. Pray hard.😂")
|
3b89451e03d9ced6add245bc3e22a01d106ac9a7 | whuhenry/leetcode_solution | /929.独特的电子邮件地址.py | 626 | 3.53125 | 4 | #
# @lc app=leetcode.cn id=929 lang=python3
#
# [929] 独特的电子邮件地址
#
from typing import List
# @lc code=start
class Solution:
def numUniqueEmails(self, emails: List[str]) -> int:
result = set()
for email in emails:
name, host = email.split('@')
plus_loc = name.find('+')
... |
d53f6bacf8b957bc51a841f00ac029f3184fce90 | whuhenry/leetcode_solution | /剑指 Offer 68 - I. 二叉搜索树的最近公共祖先.py | 1,386 | 3.84375 | 4 | class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def lowestCommonAnces... |
8a0a22e2456f8d230c23730655a56c842a863cbb | whuhenry/leetcode_solution | /剑指 Offer 39. 数组中出现次数超过一半的数字.py | 496 | 3.59375 | 4 | from typing import List
class Solution:
def majorityElement(self, nums: List[int]) -> int:
cur = None
cur_count =0
for num in nums:
if not cur:
cur = num
cur_count = 1
elif cur == num:
cur_count += 1
else:
... |
3460a449c5e7bd224d2ffe35d93ac524c223cee4 | whuhenry/leetcode_solution | /872.叶子相似的树.py | 970 | 3.671875 | 4 | #
# @lc app=leetcode.cn id=872 lang=python3
#
# [872] 叶子相似的树
#
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=N... |
044077761e715d86fcc11a8fd27a65288c7581c7 | phambaotrung/Python | /2nodes.py | 13,046 | 3.5 | 4 | # Example of interaction with a BLE UART device using a UART service
# implementation.
# Author: Tony DiCola
import time
import Adafruit_BluefruitLE
from Adafruit_BluefruitLE.services import UART
# Get the BLE provider for the current platform.
ble = Adafruit_BluefruitLE.get_provider()
# Main function implements the... |
c0c72df0a1bbbf18dd7cbc9c0f94052e1f92738e | Adamus-Bogdan/Algorithm-Reduction | /crt.py | 4,237 | 3.75 | 4 | """
This file contains functions which are necessary to use Chinese Reminder Theorem
"""
from sage.all import *
from mapping import Mapping
def map2dict(mapping, is_imaginary, p=None):
"""
This function converts polynomial mapping F (defined as list of n polynomials) into dictionary.
The keys in this dict... |
7f6ac1064445a33b244b777dd7c81b0825387ad7 | maewart/tigis | /main.py | 1,249 | 3.71875 | 4 | #!/usr/bin/env python3
""" Main entry to fields and finds code
This is the main entry point to the fields and finds website python code.
This code creates an instance of the website passing in any parameters.
It then prints the output to screen.
It also catches any exceptions preventing the website to crash in the ev... |
3fc4693d0d1f34710e6e9bbed7c737b78a597e2f | FatemehRezapoor/LearnPythonTheHardWay | /LearnPythonTheHardWay/E32ForLoops.py | 1,408 | 4.53125 | 5 | # June 5, 2018
# Update: July 8th , 2020
# For loop and interation
# List: container of things that are organized in order
# Let's define a For Loop ( iterable is defined by range function)
# Method1: ITERABLE: RANGE
x = 1
for x in range(0, 2): # the range function always defines variable from the first to ... |
74638ae57bf4502ff487670deac95e86a2abc010 | FatemehRezapoor/LearnPythonTheHardWay | /LearnPythonTheHardWay/E25ModuleFirst.py | 1,598 | 3.984375 | 4 | # June 1, 2018
# E25PracticeSkills is actually a module that we created
# The functions are the methods of our module
# when you call this file in terminal, it acts as a module which includes multiple functions
# split is used to split the sentence. When you type split(), python looks for space for splitting
# B... |
0f18ed3500804c9ab1ec26047364252ce698f304 | FatemehRezapoor/LearnPythonTheHardWay | /LearnPythonTheHardWay/E23Exception.py | 1,528 | 3.84375 | 4 | # July, 8, 2020
# ERROR TRACKING
# CASE 1: In a normal situation, when error happens, the editor shows all the lines which are effected by the error and will not execute the code.
"""
def main1():
x=int ('foo')
print('Tadaaaa')
main1()
"""
# Error is : Traceback (most recent call last): File "D:/Re... |
738ec071cb6ba21571954ccfe8dab69cbb7a5325 | FatemehRezapoor/LearnPythonTheHardWay | /LearnPythonTheHardWay/E42Calender.py | 1,120 | 4.28125 | 4 | # July 2020
# Calender in Python
import calendar
# ** PLAIN TEXT CALENDER **
c=calendar.TextCalendar(calendar.SUNDAY) # This means the calender is starting from sunday
st=c.formatmonth(2020,7,0,0)
print(st)
cn=calendar.TextCalendar(calendar.MONDAY)
st=cn.formatmonth(2020,7,0,0)
print(st)
# ** HTML CALEN... |
91d9d30bba320319551a09fe6175a58156c9c1b8 | ForrestSurles/01_Challenge | /loan_analyzer.py | 11,038 | 4.15625 | 4 | # coding: utf-8
# import necessary libraries
import csv
from pathlib import Path
# BONUS: custom function for console output formatting
def line_break(repeats, space_location="none"):
if space_location == "before":
print(f"\n{'-' * repeats}")
elif space_location == "after":
print(f"{'-' * repea... |
86c752cb628d5416e6bb2b6a93fb8e07a977a77d | cseai/python-crash-course | /lecture-09/greet_users.py | 1,510 | 3.796875 | 4 | # Passing a List
def greet_users(names):
"""Print a simple greeting to each user in the list"""
for name in names:
msg = f"Hello, {name.title()}"
print(msg)
# usernames = ['belal', 'kabir', 'rafiq']
# greet_users(usernames)
# Modifying a List in a Function
# unprinted_designs = ['phone case',... |
e80397e0ea4a3b6aca5c3ad032b47d960e28cf99 | agamora/GeekHomework | /Lesson_7/task_1_l7.py | 1,276 | 4.15625 | 4 | # Отсортируйте по убыванию методом пузырька одномерный целочисленный
# массив, заданный случайными числами на промежутке [-100; 100). Выведите
# на экран исходный и отсортированный массивы.
# Примечания:
# ● алгоритм сортировки должен быть в виде функции, которая принимает на вход массив данных,
# ● постарайтесь сде... |
2c15d5847211577ed0f9f5c272df94458b27d19c | Muntaha-Islam0019/Hello-World | /Codes/22 - Sets.py | 313 | 3.90625 | 4 | # Set is auto-sorted & non-repeating data structure in Python, kinda like maps.
a_list = ['some', 'values', 'well', "let's", 'try', 'mixing', 19, 47, 1]
a_set = set(a_list)
print(a_set)
# Sets can be explicitly created. Values are gonna be autmatically sorted.
another_set = {3, 2, 4, 5, 1}
print(another_set)
|
495889073a71a61038209221bdb9d2a905f3e0ba | Muntaha-Islam0019/Hello-World | /Codes/05 - IfStatement.py | 454 | 4.09375 | 4 | # ----- If statement -----
hasMoney = False
isSmoker = False
hasGirlfriend = False
print("\nReply with Y or N.\n")
if input("Do you have much money? ") == "Y":
hasMoney = True
if input("Do you drink/smoke? ") == "Y":
isSmoker = True
if input("Do you have a girlfriend? ") == "Y":
hasGirlfriend = True
if (... |
d7b4f6e03e02c0dd231d9066524a619380cec9e0 | Muntaha-Islam0019/Hello-World | /Codes/02 - InputAndVariableConversion.py | 551 | 4.3125 | 4 | # ----- Taking input and Variable and Conversion -----
name = input("What's your name buddy? ")
print("Hello " + name + "! Welcome to this Repl.")
# Well, like all other languages, Python has variables.
# But, every input is been taken as a String.
# For instance ...
birthYear = input("Please enter your birth-year: ... |
c2db9991c13a32aaaae9f1ca0d1fb6354f372573 | Muntaha-Islam0019/Hello-World | /Codes/Challenges/Challenge_14.py | 393 | 3.875 | 4 | # Make a basic emote converter what converts some basic emotes like
# :) to 🙂.
emotes = {
":)": "🙂",
":(": "🙁",
":'(": "😥",
":3": "😅",
":p": "😛"
}
message = input("Enter with message: ")
message_Split = message.split(" ")
output_Message = ""
for word in message_Split:
output_Message +=... |
65c407cc9e2ef24c2718bb90a2b4d2144278bb15 | phanisai22/GCTC-Challenges | /06_smart_interviews_basic/Smart Interview Basics - Hackerrank/48 Vowels in a string.py | 127 | 3.71875 | 4 | s = input().lower()
v = 0
a = 0
for c in s:
if c not in "aeiou":
print("No")
break
else:
print("Yes") |
6e6cfc933ed8d3d3dbc2f5df22bc0cb110017994 | phanisai22/GCTC-Challenges | /06_smart_interviews_basic/CodeChef/Primality test.py | 279 | 3.71875 | 4 | import math
T = int(input())
for k in range(T):
n = int(input())
if n < 2:
print("no")
else:
for i in range(2, int(math.sqrt(n))):
if (n % i) == 0:
print("no")
break
else:
print("yes")
|
bfb86b87dc58d3566a5169e13c5bbe2e8d882909 | phanisai22/GCTC-Challenges | /04_neural_hack/00_max_sum.py | 750 | 3.78125 | 4 | def max_sum(input1, input2, input3):
row_sum = []
col_sum = []
s = 0
for i in range(input1):
j = i * input2
for _ in range(input2):
s += input3[j]
j += 1
row_sum.append(s)
s = 0
for i in range(input2):
for j in range(input1):
... |
4c75392f88bb213c5fbf55090df30992c0608403 | phanisai22/GCTC-Challenges | /06_smart_interviews_basic/Smart Interview Basics - Hackerrank/19 Compute fibonacci number.py | 106 | 3.65625 | 4 | n = int(input())
a, b = 1, 1
c = 1
for i in range(2, n):
c = a + b
a = b
b = c
print(c)
|
e4ea495a5c518c6391562933aa74777b38e9b98f | phanisai22/GCTC-Challenges | /06_smart_interviews_basic/Smart Interview Basics - Hackerrank/47 Print pyramid pattern.py | 197 | 3.640625 | 4 | n = int(input())
a = 0
for i in range(1, n + 1):
for j in range(1, (n - i)+1):
print(end=" ")
while a != (2*i - 1):
print("*" ,end="")
a += 1
a = 0
print()
|
3ecc2c4ca7b0038dd036ebebb6a3b2856fa23857 | hadanye/masanai | /if_and_or_test.py | 282 | 3.9375 | 4 | a = int(input("숫자를 입력하세요"))
b = int(input("숫자를 입력하세요"))
if(a%2==0)and(b%2==0):
print('두 수 모두 짝수입니다.')
elif(a%2==0)or(b%2==0):
print('두 수 중 하나 이상이 짝수입니다.')
else:
print("둘 다 홀수입니다") |
fe36f0f928eb27f7df1228c79c5e7afcadb88f8a | Cesferort/SIGE | /Actividad 3 (IF)/Actividad3_EJ3.py | 396 | 3.765625 | 4 | # -*- coding: utf-8 -*-
class Actividad3_EJ3:
def main(self):
self.funcion(-6)
self.funcion(1.23)
def funcion(self, x):
resultado = 0
if x < 0:
resultado = (x * x) - x
else:
resultado = (-x * x) + 3 * x
print("Función a calcular:\nf( " + s... |
d44963c8316ec772201ffb6ef61137a083b36d52 | Cesferort/SIGE | /EXTRA Ficheros/Extra_Ficheros.py | 2,256 | 3.65625 | 4 | # -*- coding: utf-8 -*-
class Extra_Ficheros:
def main(self):
# 1- Abrir el fichero y asignar a una variable
try:
fich = open("prueba.txt","a")
except:
print("No se ha podido abrir el archivo")
exit
# 2-Tratamiento información
print("\r\r\... |
421a39a3878845c46f84771d481a6d54647f678e | Taeheon-Lee/Backjoon_Online_Judge | /2577.py | 180 | 3.65625 | 4 | "Question 2577"
ANSWER = 1
for i in range(3):
tmp = int(input())
ANSWER = ANSWER * tmp
ANSWER = str(ANSWER)
for i in range(10):
i = str(i)
print(ANSWER.count(i))
|
b858e4af3884437ab40fed257a01a6c462eb63d0 | Taeheon-Lee/Backjoon_Online_Judge | /11729.py | 435 | 3.984375 | 4 | "Question 11729"
def hanoi(num, start, end, middle, tmp):
"function for moving process of Hanoi"
if num == 1:
tmp.append([start, end])
return tmp
hanoi(num - 1, start, middle, end, tmp)
tmp.append([start, end])
hanoi(num - 1, middle, end, start, tmp)
return tmp
N = int(input())... |
d02e7c138ca91976baaaf5cf2bc36b81628e971c | Taeheon-Lee/Backjoon_Online_Judge | /5904.py | 479 | 3.640625 | 4 | def moo(length, K, N):
middle = (length - (K + 3)) / 2 + 1
if N == middle:
print("m")
return
if middle < N <= middle + K + 2:
print("o")
return
if N < middle:
moo((length - (K + 3)) / 2, K - 1, N)
elif N > middle + K + 2:
moo(middle - 1, K - 1, N - (mi... |
046a48ef33a663ee4b01d0fca87ce11a596f0f89 | goga-nakagawa/leetcode | /python/hashtable_chaining.py | 1,248 | 3.84375 | 4 | class HashTable:
def __init__(self, size):
self.size = size
self.keys = [None] * size
self.data = [None] * size
def hash(self, key):
return key % self.size
def __setitem__(self, key, datum):
hashvalue = self.hash(key)
if self.keys[hashvalue] is None:
self.keys... |
306c77f729799aeb2b67fa12935d8feb592ea5fe | goga-nakagawa/leetcode | /python/5_LongestPalindromicSubstring.py | 872 | 3.96875 | 4 | """
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.
"""
class Solution(object):
def longestPalindrome(self, s):
"""
:type s: str
:rtype: str
"""
long... |
d1df56bb81ae0b28e13f96df3efec31bb52e2e6c | goga-nakagawa/leetcode | /python/151_ReverseWords.py | 711 | 4.09375 | 4 | """
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
"""
class Solution(object):
def reverseWords(self, s):
"""
:type s: a list of 1 length strings (List[str])
:rtype: nothing
"""
def reverse(start,... |
d7abfd97b3448b203036b27553eaab584ed8b7f8 | goga-nakagawa/leetcode | /python/3_LogestSubstringWithoutRepeatingChracters.py | 927 | 4.15625 | 4 | """
Given a string, find the length of the longest substring without repeating characters.
Examples:
Given "abcabcbb", the answer is "abc", which the length is 3.
Given "bbbbb", the answer is "b", with the length of 1.
Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substri... |
d53b5d3429a54bc891a70495e605b32f74b61296 | wwlee94/online-coding-tutor | /app/example/python/function.py | 303 | 3.546875 | 4 | # -*- coding:utf-8 -*-
# 함수 호출, 링크 전환 기본예제
def func(a,b,c):
return a+b+c
# 메인함수
if __name__ == '__main__':
result = func(10,20,30)
array = [100, 200, 300, 400]
x = array
z = func
func = array
print(result)
print(array)
print(z(1,2,3))
|
3f1784c4a02dfeee3e50b399be54ce667ec011f3 | SebastianoFazzino/Fundamentals-of-Computing-Specialization | /Introduction to Interactive Programming in Python - Part1/Keybord Input Events.py | 1,676 | 3.625 | 4 |
# Keyboard echo
import simpleguitk as simplegui
# initialize state
current_key = ' '
# event handlers
def keydown(key):
global current_key
current_key = chr(key)
def keyup(key):
global current_key
current_key = ' '
def draw(c):
# NOTE draw_text now throws an error on ... |
1cc3cb6e46fea517d0681fd83af0fd2ed9b42d6f | SebastianoFazzino/Fundamentals-of-Computing-Specialization | /Introduction to Interactive Programming in Python - Part1/Drawing on Canvas.py | 2,353 | 4.28125 | 4 | #Drawing on the canvas
#we start importing simpleguitk
import simpleguitk as simplegui
#we define a draw handler
def draw(canvas):
'''this function will be registered in the frame and it will draw
the string "Hello!" and a circle'''
#draw_text can take five arguments: the text itself, coordinates(as... |
a1129c2543d66e0012d2bfec0ba242b756902e2c | MOHIT51196/data-structure-cheatsheet | /DS_CHEATSHEET.py | 65,631 | 4.09375 | 4 | import sys
head="CHEAT SHEET"
#-------------------SPARSE MATRIX CODE-------------------
def sparsemat() :
prog='''
#include<stdio.h>
#include<conio.h>
void represent(int A[4][4], int m , int n)
{
int i,j;
printf("\n\t\n-----MATRIX REPESENTATION-------\n\n");
for(i=0;i<m;i++)
{
prin... |
a5df12a2beabfe9d4259b709ff5c1f2d46c33d12 | ArielOliveira/Students-Lessons | /Python/helloPython/helloworld.py | 1,773 | 4.03125 | 4 | # Turtle Race - Project1
import turtle
joe = turtle.Turtle()
joe.color("green")
joe.speed(12)
# Joe draws the Race Track
# Variables
turns = 90
straights = 300
small_forwards = 150
joe.forward(straights)
joe.left(turns)
joe.forward(small_forwards)
joe.left(turns)
joe.forward(straights)
joe.left(turns)
joe.forward(sma... |
07da1ce2748ffb70bb6304e21b69082f7f162056 | bhatvikrant/Game-Ping-Pong-Python3- | /pong.py | 3,545 | 3.671875 | 4 | import turtle
import os
window =turtle.Screen()
window.title("Ping Pong by Vikrant")
window.bgcolor("black")
window.setup( width=1080, height=720)
window.tracer(0)
# Drawing Boundaries
t = turtle.Pen()
def drawBoundary():
t.pencolor("white")
t.penup()
t.goto(400,300)
t.pendown()
t.left(180)
t.... |
fc73c48890375bc49d49ee96608a8295e84acf87 | cbgoodrich/Unit3 | /divisors.py | 247 | 4.125 | 4 | #Charlie Goodrich
#09/28/17
#divisors.py - asks the user to input a number, prints all of its divisors
number = int(input("Enter a number: "))
i = 1
while True:
if number%i == 0:
print(number/i)
elif i > number:
break
i +=1
|
4eeb5596e558ada7d6d29de17852ab814d93f624 | cbgoodrich/Unit3 | /fri13.py | 372 | 3.984375 | 4 | #Charlie Goodrich
#10/04/17
#fri13.py - gives you the next 10 friday the 13ths
from calendar import weekday
fri13Counter = 0
i = 0
k = 0
year = date.today().year
month = date.today().month
day = date.today().month
year = 2017
month = 10
day = 13
while fri13Counter < 10:
if weekday(year, month, day) == 5 and day =... |
31a2c293aa9f768867112a0458aa95aa2db24863 | blindij/python3_stl | /text/src/re_findall.py | 155 | 3.875 | 4 | import re
text = 'abxzzabxxxzzzz'
text2 = 'abbaaabbbbaaaa'
pattern = 'ab'
for match in re.findall(pattern,text):
print('Found {!r}'.format(match))
|
e7ca83a805f6901a7411abdc7c40f867eca5a014 | sahilkhose/Competitive-Programming | /HackerRank/Python/Language_proficiency/nested-list.py | 297 | 3.5625 | 4 | if __name__ == '__main__':
name = []
score = []
for _ in range(int(input())):
name.append(input())
score.append(float(input()))
min = sorted(list(set(score)))[1]
name = sorted([name[idx] for idx, sc in enumerate(score) if sc==min])
[print(n) for n in name] |
5791cd771a2130637c2fc2f4ae2424c340d2db8f | sahilkhose/Competitive-Programming | /HackerRank/Python/Language_proficiency/most-commons.py | 154 | 3.5 | 4 | from collections import Counter
chars = Counter(input()).items()
for char, freq in sorted(chars, key=lambda k: (-k[1], k[0]))[:3]:
print(char, freq) |
77354eacfa4aad9c386fcc4a810bbf57eca5aca7 | wanckit/pythontestprojects | /program_9.py | 142 | 3.625 | 4 | def tri_area(base, height):
area = (base*height)/2
return area
print tri_area(13,4)
print tri_area(23,4)
print tri_area(20,2)
|
172286448a3d61c2948ecabebffad364c3f7a126 | aarongo/python_operations | /day4/proson.py | 566 | 3.515625 | 4 | # _*_coding:utf-8_*_
# 定义人的类
class Proson(object):
def __init__(self, name, ages, sex, job, nationality):
self.name = name
self.ages = ages
self.sex = sex
self.job = job
self.nationality = nationality
# 定义方法
def info(self):
print ''' ----Proso... |
b0e7cddf455926396e689dd415955bf5bef2f80c | saniYaro/Hangman | /forth class(b)(hangman).py | 808 | 4.0625 | 4 | import time
fruits = 'orange'
name = input("what is your name user:")
print("Welcome " + name, "to the game of hangman")
time.sleep(2)
print("You have five turns to guess the name of the fruit " + name, "!")
time.sleep(3)
guess = " "
turns = 10
while turns > 0:
failed = 0
for i in fruits:
... |
2792e161ee177d3651a2b990e2d907854eba475a | AnaBenn/Practice | /Python/treehouse/functions.py | 3,420 | 4.03125 | 4 | def hows_the_parrot():
print("He's pining for the fjords!")
hows_the_parrot()
def lumberjack(name):
if name.lower() == 'anastasia':
print("Anastasia's a lumberjack and she's OK")
else:
print("{} sleeps all night and {} works all day!".format(name, name))
lumberjack("Turkey")
def lumberjack(name, pronoun... |
4ea8e8b1e915cbb482156dbd287f3c5a919208f0 | gouravtulsani/temp-data- | /python/queue.py | 686 | 3.9375 | 4 | class Queue:
def __init__(self):
self.items = []
self.lis=[]
def enqueue(self, item):
self.items.insert(0,item)
def dequeue(self):
return self.items.pop()
def findmiddle(self):
l=len(self.items)/2
if l%2==0:
l=l-1
for i in range(0,l):... |
f56655afb7c7cd25a38a9516f535ec11b53964b5 | gouravtulsani/temp-data- | /python/factorial.py | 165 | 3.609375 | 4 | factorial = 1
for i in range(1,41):
factorial = factorial*i
fac = 1
for i in range(1,21):
fac=fac*i
ans = factorial/(fac*fac)
print factorial
print fac
print ans |
a50207016d9a21b30debdc119bd609acb49e4f37 | PiotrWolinski/Python-Daily-Byte | /spot_the_difference.py | 443 | 3.5 | 4 | def spot(s: str, t: str) -> str:
letters = []
letters_set = set()
for i in s:
letters_set.add(i)
for i in t:
letters.append(i)
for i in t:
if i in letters_set:
letters.remove(i)
if len(letters):
return letters[0]
return ''
assert spot(... |
779cd7ba53717e7aa38378f2d1f29fd864604df8 | PiotrWolinski/Python-Daily-Byte | /valid_palindrome.py | 110 | 3.640625 | 4 | def valid_palindrome(string: str) -> bool:
return string == string[::-1]
print(valid_palindrome('level')) |
f59be0c085bb00d38a72f18b7f018ec5f8d0c923 | optima740/OOP-Designing-Python- | /My_AbstractQueue.py | 2,530 | 3.71875 | 4 | from abc import ABC, abstractmethod
class My_Queue(ABC):
@abstractmethod
def __init__(self):
# создается структура под нашу очередь
pass
# СТАТУСЫ:
CONST_ENQUEUE_NIL = 0 # enqueue() еще не вызывался
CONST_ENQUEUE_OK = 1 # выполнился корректно
CONST_DEQUEUE_NIL = 0 # dequeue... |
87626ec202dcb7b1cc1f7c229ed7a3ade0b77aba | uibcdf/MolSysMT | /coding/documentation_class.py | 1,443 | 3.515625 | 4 | class Patata():
"""The summary line for a class docstring should fit on one line.
If the class has public attributes, they may be documented here
in an ``Attributes`` section and follow the same formatting as a
function's ``Args`` section. Alternatively, attributes may be documented
inline with th... |
de7b70d963df86627aaa47be60bc41849db43fe2 | Raghurammandapally/cs | /cs540/HW3/3-nn.py | 745 | 3.53125 | 4 |
"""
class1
class2
class3
Training Set Points
(2, 2), (4, 4), (2, 4)
(6, 5), (5.4, 5.6), (3.6, 6.4)
(1.8, 8), (5.6, 8.2)
"""
class1 = [[2,2],[4,4],[2,4]]
class2 = [[6,5],[5.4,5.6],[3.6,6.4],[4.4,6]]
class3 = [[1.8,8],[5.6,8.2]]
train = [class1, class2, class3]
def dist(p1,p2):
return abs(p2[0]-p1[0])+abs(p2[1]-p1... |
bc38ab17c8661fc2ea104689f92e3b3186099944 | 121121lol/python-qs | /Sum.py | 96 | 3.671875 | 4 | a=float(input("Enter first no"))
b=float(input("Enter second no"))
print(f'The sum is {a+b} ') |
8516d0489146c1320cceb86d9ec4e1720bef26ea | 121121lol/python-qs | /31Calendar.py | 298 | 4.0625 | 4 | import calendar
print("Which type of calendar")
print("1 : Monthly")
print("2 : Yearly")
c=int(input())
if c==1:
a=int(input("Enter the month number "))
b=int(input("Enter the year"))
print(calendar.month(b,a))
elif c==2:
b=int(input("Enter the year"))
print(calendar.calendar(b))
|
0229cebc105526174880b7936e2888431f5e641e | 121121lol/python-qs | /MaxAmongThreeNos.py | 171 | 4 | 4 | a=float(input())
b=float(input())
c=float(input())
m=max(a,max(b,c))
if m==a:print(f"Max is a={a}")
elif m==b:print(f'MAx is b={b}')
elif m==c:print(f'MAx is c={c}') |
752a97c65b3736fb1a2550e63bc3dd3617b284d6 | 121121lol/python-qs | /KmtoMiles.py | 74 | 4.03125 | 4 | km=int(input("Enter distance in km"))
print(f'{km}km is {km*0.621}miles') |
c6f42eb03b34424261a5010b789bdd9eceb145f2 | 121121lol/python-qs | /29Calc.py | 440 | 3.90625 | 4 | while (True):
print("Enter Choice:")
print("0:Exit")
print("1:Add")
print("2:Subtract")
print("3:Multiply")
print("4:Divide")
c=int(input())
a=float(input("Enter first no"))
b=float(input("Enter second no"))
if c==0:break
elif c==1:
print(a+b)
elif c==2:
print(a-b)
elif c==3:... |
8369236bf2c22e3d2ebef9c61425158353f8d187 | astrid77/Hogwarts_Python_Practise | /python_practise2/homework2/TianshanTL.py | 1,752 | 3.875 | 4 | """
定义一个天山童姥类 ,类名为TongLao,属性有血量,武力值(通过传入的参数得到)。TongLao类里面有2个方法,
see_people方法,需要传入一个name参数,如果传入”WYZ”(无崖子),则打印,“师弟!!!!”,如果传入“李秋水”,打印“师弟是我的!”,
如果传入“丁春秋”,打印“叛徒!我杀了你”
fight_zms方法(天山折梅手),调用天山折梅手方法会将自己的武力值提升10倍,血量缩减2倍。需要传入敌人的hp,power,
进行一回合制对打,打完之后,比较双方血量。血多的一方获胜。
"""
import random
class TongLao:
def __init__(self, h... |
22d43d88cfef5391041df4105cb9514a566d509f | rushi2828/PythonPractise | /PythonExcersize.py | 900 | 3.859375 | 4 | from pip._vendor.distlib.compat import raw_input
"""
Question 1
Level 1
Question:
Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
between 2000 and 3200 (both included).
The numbers obtained should be printed in a comma-separated sequence on a single line.
"""
l =... |
2a70230156890bbf550341246b8df2d1ad37ee9c | marciofleitao/ifpi-ads-algoritmos20202 | /semana05/uri1045_tipo_triangulo.py | 673 | 3.9375 | 4 | def main():
num = input('Informe os números: ')
dados1 = num.split()
a = float(dados1[0])
b = float(dados1[1])
c = float(dados1[2])
if a >= (b + c):
print('NAO FORMA TRIANGULO')
elif (a ** 2) == (b ** 2 + c ** 2):
print('TRIANGULO RETANGULO')
elif (a *... |
5493c343155339ebf81fcd58f91b99e2664ed376 | marciofleitao/ifpi-ads-algoritmos20202 | /semana06_07/uri1101_seq_num_soma.py | 588 | 3.65625 | 4 |
def main():
soma = 0
zero = 0
while zero != 1:
num = input('Números: ')
numeros = num.split()
n1 = int(numeros[0])
n2 = int(numeros[1])
soma = 0
if n1 > n2:
naux = n1
n1 = n2
n2 = naux
if n1 <= 0 ... |
5fb37c9437db7c0a9076de924dda093ec35e5948 | marciofleitao/ifpi-ads-algoritmos20202 | /semana02/uri1011_esfera.py | 166 | 3.875 | 4 | def main():
raio = int(input('Digite o raio: '))
pi = 3.14159
c = 4/3
vol = c * pi * raio**3
print(f'VOLUME = {vol:.3f}')
main() |
1bf6a2f918f26bef0f28779cf9a2317a4c7504f7 | marciofleitao/ifpi-ads-algoritmos20202 | /semana02/uri1007_diferenca.py | 288 | 3.859375 | 4 | def main():
a = int(input('Digite o primeiro número: '))
b = int(input('Digite o segundo número: '))
c = int(input('Digite o terceiro número: '))
d = int(input('Digite o quarto número: '))
dif = (a*b)-(c*d)
print(f'DIFERENCA = {dif}')
main() |
86e8e20141fc7a5a8f95a18ea97efc01bc477617 | marciofleitao/ifpi-ads-algoritmos20202 | /semana05/uri1047_tempo_jogo_com_minutos.py | 1,238 | 3.5 | 4 | def main():
num = input('Informe os números: ')
dados1 = num.split()
hora_i = int(dados1[0])
min_i = int(dados1[1])
hora_f = int(dados1[2])
min_f = int(dados1[3])
if hora_i < hora_f:
hora = hora_f - hora_i
if min_i < min_f:
minuto = min_f - min_i
... |
6b169b69ea5140aea5e05b8753ab027c4d5d5399 | chandhan-j/python_basics | /if.py | 195 | 4.125 | 4 | age = int(input('enter your age '))
print(age)
if (age > 18):
print('you are older than a teenager')
elif (age > 12):
print('you are a teenager')
else:
print('you are a kid') |
d0968565caa9431b03a8c6bcd229e4d8a00d38d1 | Alexander-fix/lab8-python3 | /individual_2.py | 3,983 | 3.96875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Вариант: ((N^2+1)^2 mod 19) + 1 = 2
# Задание: Использовать словарь, содержащий следующие ключи: фамилия и
# инициалы; номер группы; успеваемость(список из пяти элементов). Написать
# программу, выполняющую следующие действия: ввод с клавиатуры данных в список,
#... |
1ec483fe4ddba4c598cd3b51820b3fef0c5e1826 | sojojo/PyPractice | /project_euler/problem_01.py | 272 | 3.6875 | 4 | #Problem 1
#http://projecteuler.net/problem=1
#Find the sum of all the multiples of 3 or 5 below 1000.
highest_number = 1000
multiple1 = 3
multiple2 = 5
sum = 0
i = 0
while i < highest_number:
if i % multiple1 == 0 or i % multiple2 == 0:
sum += i
i += 1
print sum |
a626f9fc0f054bd9757bad7c7b6b49ed5c814e2b | sojojo/PyPractice | /LearnPythonTheHardWay/PROJECT.py | 1,545 | 4.0625 | 4 | #Project - example 36
#make a text based adventure similar to example 35
#it's supposed to be a general solution, but it hasn't turned out too well yet
from sys import exit
#each scene that the character goes through is formatted the same way
def new_area(title, message, actions):
print "\n~~~~%s~~~~\n" % title
pri... |
f1b478c5779cd9644522e9db119e553f2430f4c3 | squeemishly/squeemishly | /stealThisVote4.py | 1,102 | 4.09375 | 4 | Clinton = 0
Trump = 0
ClintonTest = 0
need2Vote = True
def Vote():
global Clinton
global Trump
global ClintonTest
decision = input("Who do you vote for? A = Clinton; B = Trump\n").upper()
if decision == "A":
Clinton += 1
ClintonTest += 1
if ClintonTest... |
fefdd8e06aad03a78d8187a1a0252fef058e9723 | lizcarey13/cs61a | /practice/disc02.py | 579 | 4.34375 | 4 | """Create a recursive countdown function that takes
in an integer n and prints out a
countdown from n to 1.
"""
def countdown(n):
if n <= 0:
return
print(n)
countdown(n-1)
"""Have countdown count up
"""
def countup(n):
if n <= 0:
return
countup(n-1)
print(n)
"""Write a recursive function that sums the d... |
066b5751ad27f47df9ac0a6b437295094cec25fb | keepmyfavor/test | /奇偶數判斷.py | 342 | 3.6875 | 4 | # -*- coding:UTF-8 -*-
def oddandeven():
num = int(input("請輸入1~1000的整數:"))
if 0 < num <= 1000:
if num % 2 == 0:
print("%d 是一個偶數" % num)
else:
print("%d 是一個奇數" % num)
else:
print("%d 超過範圍" % num)
if __name__ == '__main__':
oddandeven()
|
c8ec393c6e5c9db9484ffdc6949d229fb4e102de | ChowDavid/pythonTutorial | /au/com/david/python/annotation/FunctionAnnotationDemo.py | 216 | 3.53125 | 4 | def f(ham:str , eggs:str = 'eggs') ->(str,str):
print('Annotations:',f.__annotations__)
print('Arguments:',ham,eggs)
return ham+' and '+eggs,'others output'
x ,y = f('spam')
print('x=',x)
print('y=',y)
|
4840c27833d4613ceadf7f1f11240d9d18175244 | tritone4/PycharmProjects | /train/PythonExercises/Basic Part-1.py | 700 | 4.65625 | 5 | '''
1. Write a Python program to print the following string in a specific format (see the output).
Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are" Output :
Twinkle, twinkle, littl... |
89a293e2d2ea5e270d0d566cf5f79535f8dedb1c | kpjfors/aoc2020 | /3/3_1.py | 521 | 3.703125 | 4 | def trees(slope, right, down):
i = 0
j = 0
count = 0
while i < len(slope):
if slope[i][j] == "#":
count += 1
j = (j + right) % len(slope[0])
i += down
return count
def main(inp):
slope = list(map(lambda x: list(x.strip()), inp))
product = 1
toboggans ... |
e41127886f83c486c0627f367e16832282fa8b02 | xpadro/algorithms | /algorithms/tests/easy/test_reverse_integer.py | 671 | 3.625 | 4 | from algorithms.easy.reverse_integer import Solution
def test_reverse_integer_positive():
solution = Solution()
assert solution.reverse(123) == 321, "Should be 321"
def test_reverse_integer_negative():
solution = Solution()
assert solution.reverse(-123) == -321, "Should be -321"
def test_reverse_inte... |
7d7252cf3c4a3485bf05b783b214d306d10e4acc | veigaran/MachineLearning | /5 Logictic regression/logistic regression.py | 6,039 | 3.625 | 4 | """
逻辑回归分类算法
"""
from numpy import *
import matplotlib.pyplot as plt
# 载入数据
def loadData(file_name):
"""
:param file_name:文件
:return: 返回数据矩阵、标签矩阵
"""
dataMat = []
labelMat = []
fr = open(file_name)
for line in fr.readlines():
lineArr = line.strip().split()
# 该数据集第一列、第二列... |
febbbe7b157c7543029551271521a2bd5b317975 | AnnexK/ds-fun-thingies | /data_structures/linked_list/single.py | 327 | 3.65625 | 4 | class SingleList:
def __init__(self, data):
self.data = data
self.next = None
def append(self, L):
self.next = L
def search(self, key):
cur = self
while cur is not None:
if cur.data == key:
break
cur = cur.next
ret... |
99f3c680969e0530f9d27f32f1449ad7a818192b | Alpha-1787/Zombie-Game | /zombie.py | 23,431 | 3.640625 | 4 | import sys
import os
import string
class Survivor:
"""The playable character in the game."""
def __init__(self):
"""initialize the playable character with default attributes"""
self.health_points = 100
self.melee_weapon = Item("Frying Pan")
self.ranged_weapon = ... |
52a3c709d871487042493187a17f7f8c3fb6edf2 | chenerous/gravitational-lensing | /Strong Gravitational Lenses.py | 14,973 | 3.6875 | 4 | #!/usr/bin/env python
# coding: utf-8
# ### Introduction to strong gravitational lensing
#
# In a strong gravitational lens systems, light from a distant source is bent by the intervening mass of a galaxy, resulting in multiple images of the source.
#
# 
#
# Here is a... |
0db596ce9f4f16fc207f4975fff20a03cce0426e | Chisdo/algorithm | /alg/chapter1/quick_select.py | 755 | 3.765625 | 4 | #!/usr/bin/env python3
from random import randint
def quick_select(k, arr):
# time: O(n)
# select the (k)th smallest number in (array)
if arr == [] or k > len(arr) or k == 0:
return []
else:
length = len(arr)
pivot = arr[randint(0,length-1)]
left = [x for x in arr if x <... |
d7d4f22460542666e24c35de85270cd1f7a4e887 | Chisdo/algorithm | /alg/chapter2/longest_path.py | 664 | 4.0625 | 4 | #!/usr/bin/env python3
def _longest_path(tree):
# O(n)
#return _longest_path(l) + _longest_path(root) + _longest_path(r)
if tree == []:
return 0, 0
depth_left, total_left = _longest_path(tree[0])
depth_right, total_right = _longest_path(tree[2])
return max(depth_left, depth_right)+1, ... |
d557b2d5fbfdaff89104d85e4973f6828a60045d | Anphet/FULL2020-1 | /EjerciciosTaller.py | 1,484 | 4.15625 | 4 | """
Programación.
Parcial 2.
Andres Forero.
"""
"""
While
Nos piden que escribamos una función que le pida al usuario
que ingrese un número positivo, Si el usuario ingresa cualquier
cosa que no sea lo pedido, se le debe informar de su error mediante
un mensaje y volverle a pedir el número.
Resuelva el problema usando:... |
82663a74edab5cb768c1d9dff9eafc86fb7431f0 | ExpressoJava/Data-Structures-Algorithms-Python | /Algorithms/bubbleSort.py | 1,119 | 4.34375 | 4 | """
Bubble Sort:
We start at the beginning of unsorted list and compare each element to its right hand
neigbhor. If the right hand neighbor/element is smaller gets shifted to the left.
The above is repeated until we passed through the entire collection/array/list
without performing a single swap/shift. With each pass... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.