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 |
|---|---|---|---|---|---|---|
e353d6402c8056184fde7a747d54f5ee800770dc | LearningPythonBU/UriOnlineJudge | /1015.py | 170 | 3.703125 | 4 | x1,y1 = input().split()
x1 = float(x1)
y1 = float(y1)
x2,y2 = input().split()
x2 = float(x2)
y2 = float(y2)
dist = ((x2-x1)**2+(y2-y1)**2) ** 0.5
print("%0.4f" % dist)
|
ccba1cd38e26f8e0be4a7f2d5f0b06fe0fea73a0 | cirosantilli/bbc-microbit-cheat | /count_image.py | 485 | 3.703125 | 4 | """
Let's see if display image uses some more efficient hardware built-in than looping.
Same speed it seems.
"""
from microbit import *
def show_binary(i):
dig = 1
img = Image(5, 5)
for y in range(5):
for x in range(5):
if dig & i:
val = 9
else:
... |
5f7a0d3cba7faafc23c98f6d340a244d3fc951a5 | thesethtruth/windspeed-geo | /API.py | 3,767 | 3.734375 | 4 | import requests
import json
from datetime import datetime
import pandas as pd
import os.path
def get(lat, lon):
"""
Returns:
TMY as dataframe with information appended as class items.
Inputs:
Lattitude
Longtiude
---
Checks the latest api call (stored offline) to save the t... |
dcabaabbfd2906ca84b3a31faa05628ca0a9fa95 | tskiranmayee/Python | /4.Strings&Lists/list_loop.py | 204 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon May 17 10:40:28 2021
@author: tskir
"""
"""list loops"""
l=["Social","Science","Maths","English"]
for i in range(0,len(l)):
print(l[i])
|
e0bbc58ab9cb0a12e026e2879c929a8506622237 | tskiranmayee/Python | /1.Introduction/Ques4_Simple_Interest.py | 300 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 5 20:39:28 2021
@author: tskir
"""
"""Ques 4: Simple Interest """
p=float(input("Enter the Principle"))
r=float(input("Enter the rate"))
t=float(input("Enter the number of year"))
interest=((p*r*t)/100)
print("Simple Interest is:%0.2f"%interest)
|
985fb44fd9783d4870f2c60bbbe4263028b8909a | tskiranmayee/Python | /2.Conditional_Statements/Q1_Greatest_of_Three_Number.py | 484 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 6 20:02:38 2021
@author: tskir
"""
"""Ques 1:The Greatest Number Among the Given Three Number"""
a = int(input("Enter first number"))
b = int(input("Enter second number"))
c = int(input("Enter the third number"))
if(a>b):
if(a>c):
print("First number is grea... |
0c36d7c151066f4031938c4c71bf6a8a353c1e3e | tskiranmayee/Python | /1.Introduction/Ques3_Area_of_Triangle.py | 327 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 5 18:24:07 2021
@author: tskir
"""
"""Ques 3: Area of Triangle """
a=float(input("Enter the first side:"))
b=float(input("Enter the second side:"))
c=float(input("Enter the third side:"))
s=(a+b+c)/2
area=((s*(s-a)*(s-b)*(s-c))**0.5)
print("Area of Triangle:%3.2f" %are... |
17044fe456f5ab3ea5e6d5fdb9b3bdc4b736158c | tskiranmayee/Python | /3.Functions/FuncEx.py | 261 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri May 7 12:07:56 2021
@author: tskir
"""
"""Example : Add two numbers"""
def add(a,b):
c=a+b
return c
a=int(input("Enter first value:"))
b=int(input("Enter second value:"))
print("sum={}".format(add(a,b)))
|
9eec922629390ca6e5f59a0949e23e350f20d1d5 | tskiranmayee/Python | /2.Conditional_Statements/Q9_monthNumber_Name.py | 607 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri May 7 09:32:44 2021
@author: tskir
"""
"""Ques 9: Input month number and print number of days in that month.
lets consider yeap year for Feb """
a=31
b=30
c=28
d=29
m=str(input("Enter first 3 letter of month for number of days: "))
y=int(input("Enter year please: "))
if(m==... |
6fe21ddb4f394c71e778ded8318b7f6b8730578a | tskiranmayee/Python | /1.Introduction/Ques5_Gross_Pay.py | 281 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 5 20:51:49 2021
@author: tskir
"""
"""Ques 5:Gross pay( without considering overtime)"""
hours=float(input("Enter the number of hours:"))
wage=float(input("Enter the hourly wage:"))
gross=wage*hours
print("Gross pay:%0.2f" %gross) |
6811f8a6667506b20213934697e0b3207ace1520 | tskiranmayee/Python | /5. Set&Tuples&Dictionary/AccessingItems.py | 393 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue May 18 15:49:01 2021
@author: tskir
"""
""" Accessing Items in Dictionary """
dictEx={1:"a",2:"b",3:"c",4:"d"}
i=dictEx[1]
print("Value of the key 1 is: {}".format(i))
"""Another way of Accessing Items in Dictionary"""
j=dictEx.get(1)
print("Another way to get value for key... |
6fceca7dd08694d9bd1e8ffba7710e5ec1e3cc9f | TBarmak/ERS | /ers.py | 16,701 | 4.15625 | 4 | """
Author: Taylor Barmak
A GUI to play Egyptian Rat Screw against the computer
Rules of ERS: https://bicyclecards.com/how-to-play/egyptian-rat-screw/
To do:
- Improve the aesthetic
"""
# Imports
import random
from tkinter import *
from tkinter import ttk
# Global variables to represent the state of th... |
0af6bedee66312a51569e1e36a23d53d4b3ed2ac | adityak74/HackerrankSolutions | /ai-ml-corrreg1-numpy.py | 602 | 3.546875 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
import numpy as np
phy_scores = [15,12,8,8,7,7,7,6,5,3]
his_scores = [10,25,17,11,13,17,20,13,9,15]
phy_his = np.multiply(phy_scores,his_scores)
phy_sqr = np.power(phy_scores, 2)
his_sqr = np.power(his_scores, 2)
phy_his_sum = np.sum(phy_his)
phy_s... |
c2e88d79e03904bc41c849691d12962c9165c683 | Marlon-Poddalgoda/ICS3U-Assignment5-B-Python | /times_table.py | 1,287 | 4.1875 | 4 | #!/usr/bin/env python3
# Created by Marlon Poddalgoda
# Created on December 2020
# This program calculates the times table of a user input
import constants
def main():
# this function will calculate the times table of a user input
print("This program displays the multiplication table of a user input.")
... |
9eac191cea2b8d7ef7229c0955634d968d10e892 | wengmingcan/cp1404 | /A1.py | 4,160 | 3.875 | 4 |
"""
Name: weng mingcan
Date:23/08/2019
Brief program details :
Github:
"""
from operator import itemgetter
import csv
def main():
"""this is main function """
print("Travel Tracker 1.0 - by weng mingcan")
print("3 places loaded from places.csv")
#print("{} places loaded".format(len(p... |
2f26746a240230554c4179f837c14d3c0e7dfc7a | Pooryamn/CLRS_Algorithms | /CLRS Algorithms/Python/Sort Algorithms/Insertion Sort.py | 809 | 4.03125 | 4 | # Poorya Mohammadi Nasab
# April,2019
import os
def Insertion_Sort(Array=[],n=0):
# begin
for i in range(n):
key = Array[i]
j=i-1
while j>=0 and Array[j]>key:
Array[j+1] = Array[j]
j=j-1
Array[j+1] = key
return Array
# end
# main
Arr... |
9ee093e60476ae3b7cdbd26229c5b0e8260c00b9 | jakedaylong/SP_Online_PY210 | /students/ABirgenheier/lesson03/mailroom.py | 2,908 | 3.71875 | 4 | database = [
["Mike", 3, 200, 150, 50],
["Tony", 3, 150, 50, 250],
["Sarah", 3, 150, 150, 150]
]
def menu():
user_input = input(
"Please select from following options: (s) to select donar, (c) to create report, or (q) to quit program: ")
while user_input != 'q' or user_input != 'Q':
... |
13894d1d988e5ccd9ab6cfc7e0e2c86f012eb5c9 | akelshareif/fiscally | /application/auth/auth_forms.py | 2,771 | 3.53125 | 4 | """ Forms related to user registration and authentication """
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField
from wtforms.validators import InputRequired, Email, Optional, Length, Regexp
class RegisterForm(FlaskForm):
""" Registration form for new user """
first_name = String... |
e71ef8d8f63ab2189542e98eb081d976e6cda88b | akelshareif/fiscally | /application/pay/pay_helpers.py | 793 | 3.921875 | 4 | from decimal import Decimal
def calculate_gross_pay(pay_data):
""" Calculates the total gross pay including overtime pay """
rate = Decimal(pay_data['payRate']
) if pay_data['payRate'] != '' else Decimal(0.00)
hours_list = [hours for hours in pay_data['hours'] if hours != '']
over... |
fb976318bdc72e4137aa11b60af4d05b579fada8 | Oleg20502/infa_2020_oleg | /hypots/hypot4.py | 240 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 8 12:40:38 2020
@author: student
"""
import turtle
n = 1000
step = 1000/n
for i in range(n):
turtle.shape('turtle')
turtle.forward(step)
turtle.left(360/n)
|
b7ef4304df610e7fec38a89d4fcf6fa433ccb042 | jopham/gradient_boost | /gradient_boost.py | 3,279 | 3.71875 | 4 | '''
This project explores gradient boosting using CatBoost (based on a tutorial).
Data: Amazon Employee Access Challenge
'''
#######################
# IMPORT & DATA
#######################
#!pip install --user --upgrade catboost
import os
import pandas as pd
import numpy as np
np.set_printoptions(precision=4)
im... |
308bbf1bd20b6c9dd87aa21428c0a4733bfc9f9b | shaktixcool/python | /20.mergefiles.py | 535 | 3.609375 | 4 | read=''
def merge_file(read):
list = ["C:\\shakti\\python\\file1.txt","C:\\shakti\\python\\file2.txt","C:\\shakti\\python\\file3.txt"]
for i in list:
print(i)
openfile = open('%s' %i,'r')
openfile.seek(0)
read = openfile.readlines()
openfile.close()
print(re... |
ad64adbf23c2e35d56e2ab5468dc72e0ee7bce34 | shaktixcool/python | /9.conditionals.py | 139 | 4.15625 | 4 | a = int(input("Enter the value: "))
if a > 5:
print("value is %d" %a)
else:
print ("Enter value greater or equal to %d" %a)
|
0ca4479f78b160fb90fed8378ef717f8ac048233 | shaktixcool/python | /6.minutestohours.py | 361 | 4.09375 | 4 | # -*- coding: utf-8 -*-
def mTOh(minutes):
hours = int(minutes/60)
return hours
def sTOh(seconds):
hours1 = int(seconds/3600)
return hours1
minutes = int(input ("Enter Minutes: "))
seconds = int(input ("Enter Seconds: "))
print (("Conversion of %d to hours : " %minutes) mTOh())
print ("... |
62fb9d429b269174283f7ce361fbf4b03a088308 | PashaKim/Python-Function-Leap-year | /Leap-year.py | 264 | 4.1875 | 4 | print ("This function(is_year_leap(year)) specifies a leap year")
def is_year_leap (y):
if y%400==0:
print(y," is leap year")
elif y%4==0 and y%100!=0:
print(y," is leap year")
else:
print(y," is common year")
|
6f1ef5f64c87c937cf108479953c9308b4136fac | suman-v/Email-Tool-Flask | /excel_read_code.py | 1,110 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun May 16 22:41:44 2021
@author: User
"""
import os
import datetime
import namegenerator
import numpy as np
import pandas as pd
import openpyxl
def random_dates(start=None, end=None, n=1, unit='D', seed=None):
"""A function which produces random dates"""
if not seed: #... |
396b070c5282a5a6416aaa494ef2bebcb74e47e8 | ZhiquanW/Learning-Python-HackerRank | /Strings/String-Validators.py | 879 | 3.796875 | 4 | solution = 1
if solution == 1:
S = input()
print (any([char.isalnum() for char in S]))
print (any([char.isalpha() for char in S]))
print (any([char.isdigit() for char in S]))
print (any([char.islower() for char in S]))
print (any([char.isupper() for char in S]))
else:
if __name__ == '__main... |
7b82747250c94b831a18ffb056941303f13a36c5 | Gafera/processamentoInformacaoUfabc | /exer3L1.py | 250 | 3.984375 | 4 | def mcd(a, b):
resto = 0
while(b > 0):
d = b
b = a % b
a = d
return a
m = int(input("Primeiro número: "))
n = int(input("Segundo número:"))
print("O máximo divisor comum de ", m," e ", n," é ", mcd(m, n))
|
711870186a852ab4bd5a349fac1a2777351cfc5f | sakaul88/dd | /lib-python-orchutils/orchutils/ibmcloudmodels/resource.py | 1,093 | 3.5 | 4 | from orchutils.ibmcloudmodels.attribute import Attribute
class Resource(object):
def __init__(self, resource_json):
self.attributes = Attribute.parse_attributes(resource_json['attributes'])
@property
def attributes(self):
return self._attributes
@attributes.setter
def attributes(... |
ad841fe2c7b77c9f500e9a1962d9460b3dfc0425 | sweetmentor/try-python | /.~c9_invoke_74p4L.py | 2,562 | 4.3125 | 4 | # print('Hello World')
# print('Welcome To Python')
# response = input("what's your name? ")
# print('Hello' + response)
#
# print('please enter two numbers')
# a = int(input('enter number 1:'))
# b = int(input('enter number 2:'))
# print(a + b)
# num1 = int(input("Enter First Number: "))
# num2 = int(input("Enter S... |
441bcd1898049d595edbdc9a7461ff33771555f4 | seonhan427/python-study-unictre- | /2021.03.15/word.py | 295 | 3.8125 | 4 | # word = 'python'
# word[15]
word1 = input("첫 번째 단어를 입력해주세요: ")
word2 = input("두 번째 단어를 입력해주세요: ")
word3 = input("세 번째 단어를 입력해주세요: ")
# print(word1[0],word2[0],word3[0], sep="")
print(word1[0]+word2[0]+word3[0]) |
ffa0cf545a3e2300f3378c6800f6051f133e24f7 | seonhan427/python-study-unictre- | /2021.03.22/if_else2.py | 330 | 3.75 | 4 | num = int(input("정수를 입력하시오 : "))
A = num % 2
if A == 0 :
print("입력된 정수는 짝수입니다.")
else :
print("입력된 정수는 홀수입니다.")
# if num % 2 == 0 :
# print("입력된 정수는 짝수입니다.")
# else :
# print("입력된 정수는 홀수입니다.") |
36d6d8c927fbc31aaa8faf5e617caa7827734814 | seonhan427/python-study-unictre- | /python_practice/python_print_practice/exercise_7.py | 262 | 3.59375 | 4 | #python print practice 문제 7
width1, length1 = map(int,input("가로, 세로를 입력하시오 : ").split())
width2 = width1 + 5
length2 = length1*2
area = width2*length2
print("width =",width2)
print("length =",length2)
print("area =",area)
|
a349873d130049f3135b15a5291a23652eccf7da | seonhan427/python-study-unictre- | /python_practice/if_statement_practice/if_practice_7.py | 231 | 3.765625 | 4 | # if_statement_practice 문제 7
num1, num2, num3 = map(int,input("입력하시오 : ").split())
if num1 < num2 and num1 < num3:
print(num1)
elif num2 < num1 and num2 < num3:
print(num2)
else :
print(num3)
|
78df5f7523e536f0497f375d9d18fe02c52e8e06 | seonhan427/python-study-unictre- | /python_practice/python_print_practice/exercise_8.py | 309 | 3.890625 | 4 | #python print practice 문제 8
high, weight = map(int,input("민수의 키와 몸무게를 입력하시오 : ").split())
high1, weight1 = map(int,input("기영이의 키와 몸무게를 입력하시오 : ").split())
if high > high1 and weight > weight1:
print("true")
else:
print("false")
|
e2f5c68c53f78830245f1bd7d216cd251de49c0c | seonhan427/python-study-unictre- | /python_practice/loop_practice_2/loop_practice_2_6.py | 309 | 3.90625 | 4 | # practice loop 2 문제6
string = list(input("입력 문자열:"))
# print(string)
letter = input("찾고 싶은 문자:")
string.index(letter)
#enumerate 을 사용해서 여러개의 인덱스 값을 찾았습니다
output = [idx for idx, let in enumerate(string) if let == letter]
print(output) |
ff6b8c05b137e947a3580da484d15134ed6dfb4d | seonhan427/python-study-unictre- | /2021.03.29/for1.py | 665 | 3.9375 | 4 | for name in ["철수","영희","길동","유신"]:
print("안녕!"+name)
# print(x, end=" ") 여기서 end는 문장이 끝나고 행해질것을 의미
#나란히 띄어쓰기로 출력할때 사용
# range() 특정구간의 정수를 생성, 입력된 정수 이전까지 생성
# ex) range(10) 이면 9까지 생성
# range(start, stop) start 부터 (stop-1)까지의 정수 생성
# 역순으로 출력시 ex) range(10,0,-1)
#>>>>>> 10 9 8 7 6 ... 1
# range ([... |
1fd574997f2e82ac5a0da8489e8441e240e1430e | seonhan427/python-study-unictre- | /python_practice/loop_practice_1/loop_practice_1_3.py | 176 | 3.78125 | 4 | # practice loop 1 문제3
num = 0
while num != -1:
num = int(input("입력하시오: "))
if num % 3 == 0:
print(num//3)
else:
continue |
88a00a55774274724298e6641d778fc1ef0e77d7 | pavelgolikov/Python-Code | /Data_Structures/Linked_List_Circular.py | 1,978 | 4.15625 | 4 | """Circular Linked List."""
class _Node(object):
def __init__(self, item, next_=None):
self.item = item
self.next = next_
class CircularLinkedList:
"""
Circular collection of LinkedListNodes
=== Attributes ==
:param: back: the lastly appended node of this CircularLinkedList
... |
dbaa1a417e12832ee0865031534e3d04de7e6d04 | pavelgolikov/Python-Code | /Old/Guessing game.py | 808 | 4.15625 | 4 | import random
number = random.randint (1,20)
i=0
print ('I am thinking about a number between 1 and 20. Can you guess what it is?')
guess = int(input ()) #input is a string, need to convert it to int
while number != guess:
if number > guess:
i=i+1
print ('Your guess is too low. You used ... |
9d841232854343600926341d118f977d258536be | pavelgolikov/Python-Code | /Old/Dictionary practice.py | 1,576 | 4.1875 | 4 | """Some functions to practice with lists and dictionaries."""
def count_lists(list_):
"""Count the number of lists in a possibly nested list list_."""
if not isinstance(list_, list):
result = 0
else:
result = 1
for i in list_:
print(i)
result = re... |
7eb40898cbf1810efb5feb9fd35035345ceb057b | MarcoGlez/ProyectoFinal | /proyectoFinal.py | 18,099 | 3.5 | 4 | #Marco González Elizalde A01376527
#Proyecto Final de Introducción a la programación Semestre 2018-13
import pygame
from random import randint
"""Ya que decidi mover la respuesta del programa al click del boton del mouse derecho a solo cuando se está
en el estado de juego en que se muestra el boton (el menú o ... |
835049cb13e47b53b72f043b5e1b9ab2a90232d1 | Thanhche/CatalogAppR1 | /Correct.py | 1,917 | 3.734375 | 4 | def correct(s,correct_spelled):
words=s.strip().split()
output_str=""
for current_word in words:
if len(current_word)<=2 or (current_word in correct_spelled) :
output_str=output_str+" "+current_word
continue
min_mismatch=2
replacement_word=current_word... |
4a41ae0e9938a948a91408618cfb2d5b1a681285 | Surya0705/Awesome_Python_Filter | /Main.py | 930 | 3.96875 | 4 | import cv2 # Importing the OpenCV module.
from tkinter import filedialog # Importing the tkinter filedialog to let the User select Image File of their Choice.
a = filedialog.askopenfilename(title="Select Image") # Letting the User Choose the Image.
b = cv2.imread(a) # Making the OpenCV read that Image.
c = cv2.cvtColo... |
b4bee39744a6b0759a8ca12902ae8fea9daff5e5 | NHopewell/coding-practice-problems | /Algorithms/leetcode/arrays/monotonicArray.py | 1,335 | 3.828125 | 4 | import pytest
from typing import List
def is_monotonic_array(array: List[int]) -> bool:
pointer1 = 0
pointer2 = 1
total_greater_than_or_equal = 0
total_less_than_or_equal = 0
while pointer2 < (len(array)):
if array[pointer1] > array[pointer2]:
total... |
49e33d668ecb40438357080079933872478e81ec | NHopewell/coding-practice-problems | /Algorithms/codewars/strings/firstVaritionOnCaesarCipher.py | 1,642 | 3.796875 | 4 | """
https://www.codewars.com/kata/5508249a98b3234f420000fb/train/python
"""
from typing import List
def moving_shift(s: str, shift: int) -> List[str]:
"""
moving_shift("I should have known that you would have a perfect answer for me!!!", 1)
["J vltasl rlhr ", "zdfog odxr ypw", " atasl rlhr p ", "gwkzzyq ... |
bbb220800e64264d497be29ae5fb04fcdc817063 | NHopewell/coding-practice-problems | /OOP/leetcode-design/scoreBoard.py | 1,770 | 3.8125 | 4 | """
Design a LeaderBoard
---------------------
https://leetcode.com/problems/design-a-leaderboard/
"""
from typing import Tuple
class Player:
def __init__(self, id: int):
self.id = id
def __repr__(self):
return f"Player: {self.id}"
clas... |
c39625c38c69c65290ff0e4ea50d763f4d5f7ab6 | NHopewell/coding-practice-problems | /OOP/leetcode-design/throneInheritence.py | 2,224 | 3.734375 | 4 | """
throneInheritance.py
--------------------
https://leetcode.com/problems/throne-inheritance/
"""
import pytest
from collections import defaultdict
from typing import List
class ThroneInheritance:
def __init__(self, king: str):
self.king = king
self.order: List[str] = [king]
... |
cd98dc822cfc661054ba0d9036d4eb994826e36d | NHopewell/coding-practice-problems | /OOP/random/deckOfCards.py | 2,843 | 4.03125 | 4 | """
deckOfCards.py
==============
Simulate a deck of cards as a Python class
classes:
Card(symbol, suit):
properties:
instance:
str suit
str symbol
methods:
instance:
__repr__
... |
6390cc18aee6fe3327451c10adeca7ecc6fd50ba | NHopewell/coding-practice-problems | /OOP/leetcode-design/designTwitterV2.py | 5,585 | 3.890625 | 4 | """
Twitter.py
+++++++++
Design and implement a simplified version of twitter.
classes
-------
1) User:
properties:
instance:
str name
int id
str email
list following (other user ids)
list followers (other user id... |
e2c469b4650f8842d1eb8baaec16cf841a732728 | charan3/CompetitiveProgramming | /Week1/Day1/AppleStocks.py | 667 | 3.859375 | 4 | def getMax(arr):
if len(arr)<=1:
return False;
elif(len(arr)==2):
return arr[1]-arr[0]
else:
minimum=arr[0]
max_profit=arr[1]-arr[0]
for i in range(2,len(arr)):
minimum=min(minimum,arr[i-1])
max=arr[i]-minimum
if max>max_... |
0c0cf5a60d44e288e0ea11e41a6febb4e910f66d | starlightromero/Superhero-Dueler | /hero.py | 3,526 | 3.8125 | 4 | """Import Armor, Ability, and Weapon."""
from armor import Armor
from ability import Ability
from weapon import Weapon
class Hero:
"""Hero class."""
def __init__(self, name, starting_health=100):
"""Instance properties.
abilities: List
armors: List
name: String
starti... |
70634171e2dccf8d4ac06fcc193358bf84b170ab | JeraKrs/minimizing.interviews | /tools/test_utils.py | 2,476 | 3.796875 | 4 | # -*- coding: utf-8 -*-
import unittest
from utils import *
class TestUtilsFunc(unittest.TestCase):
def test_minusones(self):
"""Test method minusones(m)"""
self.assertEqual([], minusones(0),
"minusones is failed in m = 0")
self.assertEqual([], minusones(-1),
... |
c02602bf41a2b989716d8d0f953f6ff6c02cb5fe | ReGaBeh/PersonalRepo | /Projects/classes.py | 1,701 | 3.6875 | 4 | def dunderExamples():
class Employee:
raise_amt = 1.04
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.email = first + "." + last + "@email.com"
self.pay = pay
def __repr__(self):
return "... |
98f2e842b35040d99f6039858874e759f27433c8 | hangyu-feng/python-course | /course-contents/course-2/rectangle.py | 344 | 3.9375 | 4 |
class Rectangle:
def __init__(self, length, width):
self.length = length
self.width = width
def area(self):
return self.length * self.width
class Square(Rectangle):
def __init__(self, length):
self.length = length
self.width = length
a = Squa... |
431d8e088874db4324088088e4cdf2eec8e11588 | enrique95ae/Python | /Project 01/test013.py | 192 | 4.09375 | 4 | name = input("Enter your name: ")
last = input("Enter your last name: ")
message1 = "Hello %s %s!" % (name, last)
message2 = "Hello {} {}!".format(name, last)
print(message1)
print(message2) |
3e43132819bc8bae1eb277d76ca981b9827fcde4 | enrique95ae/Python | /Project 01/test007.py | 391 | 4.1875 | 4 | monday_temperatures = [9.1, 8.8, 7.5, 6.6, 8.9]
##printing the number of items in the list
print(len(monday_temperatures))
##printing the item with index 3
print(monday_temperatures[3])
##printing the items between index 1 and 4
print(monday_temperatures[1:4])
##printing all the items after index 1
print(monday_tem... |
69a2a0a46b12fd00ecbac3e217cc92152f5f3953 | TrojanPunk/web105 | /DSA2.py | 202 | 3.578125 | 4 | #Convert a queue to a list
from queue import Queue
que=Queue()
que.put(2)
que.put(20)
que.put(1)
que.put(12)
print("Initially:")
print(que.queue)
l=list(que.queue)
print("Finally: ")
print(l) |
1a542a3601c2677955ff4902395ad33881bd56a4 | Bolaxax/valhalla | /run_route_scripts/generate_tests/create_random_points_within_radius.py | 1,099 | 3.859375 | 4 | #!/usr/bin/env python
import sys
import math
import random
import json
### Enter a location in an urban area and then generate a set random locations nearby.
### Continue to use a similar process to generate a smaller number near surrounding urban areas
### until you get the number of locations you need. Next, these ... |
dc00d14fc068a8471de0042c4e9f806d237fa9cb | JetErorr/Python3 | /8.EvenMorePrints.py | 231 | 3.53125 | 4 | #8. Even More printing, with a formatter.!
formatter = "{}, {}, {} & {}"
var1 = "one"
var2 = "two"
var3 = "three"
print(formatter.format(var1,var2,var3,"Yellow"))
formatter2 = "{}-{}-{}"
print(formatter2.format(var2,var1,var2)) |
4e70b2be7d5caff62fa9da52303a372310fa3ae7 | BertilBraun/Brute-Force-Sudoku-Solver | /Sudoku Solver.py | 2,214 | 3.53125 | 4 | import copy
def solve(board):
if fillObv(board) == False:
return False
if complete(board):
return True
i, j = 0, 0
for y in range(9):
for x in range(9):
if board[y][x] == ".":
i, j = x, y
for p in getPos(bo... |
835bbc207ec0ffb49e6a0edcf82dc3aeb3b28504 | fbakalar/pythonTheHardWay | /exercises/ex26.py | 2,999 | 4.25 | 4 | #---------------------------------------------------------|
#
# Exercise 26
# Find and correct mistakes in someone else's
# code
#
# TODO: go back and review ex25
# compare to functions below
# make sure this can be run by importing ex25
#
#-----------------------------------------... |
1832a289dececef43f9f2e08eaf902bc5ced7016 | fbakalar/pythonTheHardWay | /exercises/ex22.py | 1,248 | 4.1875 | 4 | #####################################################
#
# Exercise 22 from Python The Hard Way
#
#
# C:\Users\berni\Documents\Source\pythonTheHardWay\exercises
#
#
# What do you know so far?
#
# TODO:
# add some write up for each of these
#
#####################################################
'''
thi... |
d7b1ad488bb0707b71005be3b5ff49cf8f60ca77 | CuteSmartTiger/basic_python | /operate set/set_define.py | 1,314 | 3.625 | 4 | # 可变集合:<class 'set'>
# 方法1
s1 = {1,2,3,4}
# 方法2:set(iterable)
s2 = set('adsakjf')
print(s2,type(s2)) #{'d', 'k', 'f', 'j', 'a', 's'}
s3 = set([1,2,3,4])
print(s3) #{1, 2, 3, 4}
s4 = set({'name':'liuhu','age':18})
print(s4) #... |
e4ed100d70d908c2595c614fe379b3cd94c3098a | CuteSmartTiger/basic_python | /operate_dict/dict_key_value_item.py | 652 | 4.0625 | 4 | dic = {'name':'liuhu','age':18,'e': 7,'a': 1, 'd': 4, 's': 5}
# 获取key
keys = dic.keys()
print(keys)
# dict_keys(['name', 'age', 'e', 'a', 'd', 's'])
# 获取value
values = dic.values()
print(values)
# dict_values(['liuhu', 18, 7, 1, 4, 5])
# 获取键值对 获取的是可迭代待对象,元素以元组的方式呈现
items = dic.items()
print(items)
# dict_items([('n... |
12e111ae64b379afe52f96f75054902e94ddcfdc | CuteSmartTiger/basic_python | /operate_dict/dict_delete.py | 734 | 3.890625 | 4 | dic = {'e': 7,'a': 1, 'd': 4, 's': 5}
# 1.del 若只有一个键值对,删除后字典就消失了
del dic['d']
print(dic)
# 2.clear
dic = {'e': 7,'a': 1, 'd': 4, 's': 5}
print(dic.clear()) #None
print(dic) #{} 返回一个空字典
# 3.pop
dic = {'e': 7,'a': 1, 'd': 4, 's': 5}
print(dic.pop('a','meiyou')) #1 返回的是所删除的键值对的值
print(dic.pop('h','me... |
341c4d37d569ecf816da3897e5b2118323e95c47 | CuteSmartTiger/basic_python | /operate_dict/define_dict.py | 679 | 3.640625 | 4 | # 定义字典的另外一种方法:
# 调用字典类或者实例的fromkeys方法
# 字典的键是不可变类型,理解字典的键必须唯一的理由,根据其存储原理与查找原理来决定的
r = [1,2,3,4]
d = 'adescf'
print(dict.fromkeys(r)) #{1: None, 2: None, 3: None, 4: None}
print(dict.fromkeys(d,5)) #{'a': 5, 'd': 5, 'e': 5, 's': 5, 'c': 5, 'f': 5}
# 批量修改键值对,后来者覆盖前面的
person = {'name':'liuhu','age':18}
dic = {'e': ... |
989f401a6c68ac3f2cf07f9e553210222eee8477 | CuteSmartTiger/basic_python | /operate_str/split_and_compare_version.py | 1,049 | 3.609375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/1/2 14:23
# @Author : liuhu
# @File : split_and_compare_version.py
# @Software: PyCharm
# @github :https://github.com/Max-Liuhu
# old_version= '3.4.3.0105'
old_version= '3.4.3.c'
new_version= '3.4.5.0908'
def compare_version(old_version,new_version)... |
9a6120ce3658d2830ad5c069c623554b2bf7538f | VikonLBR/tkinter_tutorial | /t3.py | 640 | 3.921875 | 4 | import tkinter as tk
win = tk.Tk()
win.title('my 3rd tk window')
win.geometry('400x500')
var1 = tk.StringVar()
label = tk.Label(win, textvariable=var1, bg='orange', width=10, height=1)
label.pack()
var2 = tk.StringVar()
var2.set((1, 2, 3, 4, 5))
listbox = tk.Listbox(win, listvariable=var2)
list = [6, 7, 8, 9]
for ... |
ea5dd66460642f5a883f6db8dec1bbc7cba30a7a | jr31112/TIL | /algorithm/LinkedList 실습/LinkedList.py | 2,715 | 3.84375 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
def __del__(self):
print(self.data, '삭제')
class List:
def __init__(self):
self.head = None
self.tail = None
self.size = 0
def printlist(self):
if not self.head: # 공백 리스트인지 ... |
83f945dfef5a0315919671529d84340f4346eb50 | mbernhard7/unique-gmail-generator | /gmail_tracker.py | 6,609 | 3.828125 | 4 | import os
import sys
def get_local_directory():
file_directory=str(__file__).split('/')
del file_directory[-1:]
return '/'.join(file_directory)
def dotter(start,rest,emails,needed):
if len(rest)==1 or 2**len(start.replace(".",""))>=needed:
emails.append(start+rest)
else:
dotter(start+rest[:1],rest[1:],email... |
7f5cfad8b20aa57eaa8a29efdb673da35b7eeb89 | PeterKoppelman/Cracking-the-coding-interview---Chapter-16 | /subsort.py | 702 | 3.84375 | 4 | # subsort - problem 16.16
# Peter Koppelman January 31, 2018
def subsort(orig_list):
new_list = sorted(orig_list)
print(orig_list)
print(new_list)
lower = 0
higher = 0
for i in range(0, len(orig_list)):
if orig_list[i] != new_list[i]:
lower = i
... |
eb881d2430fcf838dacb62a93a2e1381b7e84099 | PeterKoppelman/Cracking-the-coding-interview---Chapter-16 | /tictactoe.py | 4,325 | 3.921875 | 4 | ''' Create an algorithm to determine if someone has won a game of
tic tac toe. Peter Koppelman Jan 4, 2018
There are nine boxes on a tic tac toe board. They will be numbered:
1 2 3
4 5 6
7 8 9
In case there are 16 boxes (4 x 4) on the board...
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
There are (2x... |
c2c087c9f2e80dd08ddf5c0f8313f3a91cf8c212 | haoyuchou/Machine_Learning_Practice | /KNN_Practice/main.py | 1,197 | 3.625 | 4 | import numpy as np
import pandas as pd
from sklearn import neighbors, metrics
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
data = pd.read_csv('car.data')
#print(data.head())
X = data[[
'buying',
'maint',
'safety'
]].values
y = data[['class... |
cac5aa6611c3ceb25d11fe498016cb6fd583f6d6 | ratnadeepb/Robotics | /ForwardKinematics/DegreesOfFreedom.py | 1,410 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue May 23 19:19:26 2017
@author: Ratnadeepb
"""
def grubler_criterion(n, j, d):
"""
This function returns the DoF of a system according to the Grubler
Criterion.
@Input:
n - Number of links
j - List:
len(j) = number of joints
... |
39f4d515a79380b5da03d50debc636dbd3be4a75 | Macinchen/LearnPython | /week1/01.py | 340 | 4.09375 | 4 | # 由于运行程序的时候,无法提示用户开始输入,所以提前写了一个print信息,这样不够简介。input()可以直接带提示信息
# hello world
"""
print("Please Input your Name:")
name = input()
print("hello",name)
"""
name = input("Please input your name:")
print("Hello", name, "Welcome to Python World!")
|
4db31ff807bf11408e723d7c05739c96ffe6f8b2 | Javed69/GUI_Tkinter | /API.py | 1,940 | 3.671875 | 4 | '''print does not work in tkinter'''
from tkinter import *
from PIL import ImageTk,Image
#from tkinter import messagebox #to use message box we need to import it
import sqlite3
import requests # needs to install
import json # inbuild in python
root = Tk()
root.title('Learn to code at codemy.com')
root... |
d8feb89430783948201453c395aa1d4a3c1ab9d2 | meet-projects/TEAMB1 | /test.py | 305 | 4.15625 | 4 |
words=["ssd","dsds","aaina","sasasdd"]
e_word = raw_input("search for a word in the list 'words': ")
check = False
for word in words:
if e_word in word or word in e_word:
if check==False:
check=True
print "Results: "
print " :" + word
if check==False:
print "Sorry, no results found."
|
1b5404d371c0af7e0d3b1b48d6f517966d7f9a03 | berchj/conditionalsWithPython | /condicionales.py | 2,007 | 4.375 | 4 | cryptoCurrency1 = input('Enter the name of the first cryptocurrency: ')
cryptoCurrencyVal1 = float(input('Enter the value of ' + str(cryptoCurrency1) + ': '))
cryptoCurrency2 = input('Enter the name of the second cryptocurrency: ')
cryptoCurrencyVal2 = float(input('Enter the value of ' + str(cryptoCurrency2) + ': '))
c... |
24ebd6ebce739a15bfc9d94fe7e9474eb82e9ba3 | LuisGPMa/my-portfolio | /Coding-First-Contact_With_Python/test_program_1.py | 68 | 4.03125 | 4 | x=int(input("What is the value of x? "))
y=x**2-12*x+11
print(y)
|
9da658156efec430d58dc7bdb3f4fe17697e94fb | knowlive/Python_Study | /py4e/book2/03/ex3_14.py | 115 | 4 | 4 | a= int(input("판별할 정수: "))
if a%3==0:
print("3의 배수")
else:
print("3의 배수 아님")
|
a25b63417b82a2a757e4d97e8274584e209a8db3 | knowlive/Python_Study | /py4e/final2/4.py | 192 | 3.921875 | 4 | def power(x,y):
res = x
for i in range(y-1):
res*=x
return res
x=int(input('x= '))
y=int(input('y= '))
result=power(x,y)
print(x, '의 ', y, '제곱= ', result)
|
2f2f248bdd6f8c381aa419efe550584a262607bd | knowlive/Python_Study | /py4e/book2/04/work04_16_2.py | 149 | 3.734375 | 4 | a = int(input("1부터 어느 정수까지?: "))
sum = 0
for i in range(1, a+1):
sum = sum + i
print("1에서",a,"까지의 합은: ", sum)
|
0202008c0fecb4896e01b93f78718567f50da6af | knowlive/Python_Study | /py4e/book2/03/ex3_13.py | 115 | 3.734375 | 4 | a=int(input("판별할 정수: "))
if a%2==0:
print("짝수입니다")
else:
print("홀수입니다")
|
6c882c2dbefbe8140366b87ac7fa6702d0bf8b6d | MarkCBJSS/python-stuff | /tokyoedtechtutorials/simple-calculator/main.py | 3,240 | 3.875 | 4 | # Simple Calculator tutorial by @TokyoEdTech
# https://www.youtube.com/watch?v=sY6MWch52Oo
# With some tweaks by me
import tkinter
root = tkinter.Tk()
root.title("Calculator")
expression = ""
# For use in Memory
# stored_values = []
# Functions
def add(value):
global expression
expression += value
labe... |
769304d7af0e14ecee06cde5cc3ee486da293997 | joshualross/python | /dijkstra.py | 4,353 | 4.4375 | 4 | """A simple dijkstra implementation."""
class Edge(object):
def __init__(self, from_node, to_node, weight):
self.from_node = from_node
self.to_node = to_node
self.weight = weight
def __repr__(self):
return "<Edge from:{} to:{} weight:{}>".format(
self.from_node.nam... |
0714ee327090adf271eedb8825a50b5fd1236559 | rumeyssaasya/for-beginning | /atm makinesi.py | 953 | 3.8125 | 4 | print("""
*********
ATM MAKİNESİNE HOŞ GELDİNİZ...
İŞlemler;
1.Bakiye Sorgulama
2.Para Yatırma
3.Para Çekme
PROGRAMDAN ÇIKMAK İÇİN 'q' YA BASINIZ
*********""")
bakiye = 1000
while True:
işlem = input("İşlemi Seçiniz:")
if (işlem == "q" ):
print("Tekrar Bekleriz.")
break
... |
c01be04e8acd8fda93d9c142f1f13535e4f83b38 | surajraj85/pythonProject | /CodingGame/FizzBuzzSum.py | 93 | 3.71875 | 4 | sum = 0
for i in range(1, 101):
if i % 3 == 0 and i % 5 == 0:
sum +=i
print(sum) |
9a96b1b2f50cb6d6bdf8c3bfcd6fa2ef5cfe1b6b | andreaneha/leet_code_python | /Two_Sum/two_sum_solution1.py | 1,152 | 3.90625 | 4 | """
note: typecasting a list!!
problem - Two Sum
--------------------------------------------
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example... |
7f9c909e6b9c0575d923b4f149f176b2f2ebb5be | josue-93/Curso-de-Python | /Py/Ejemplo8.py | 366 | 4.25 | 4 | #Realzar un programa que imprima en pantalla los numeros del 20 al 30
for x in range(20,31):
print(x)
'''La funcion range puede tener dos parametros, el primero indica el valor
inicial que tomara la variable x, cada vuelta del for la variable x toma
el valor siguiente hasta llegar al valor indicado por el segundo... |
3452b1e40ecc91f1b5347ed1fa01054d8ae9fa8b | mawhidby/wikipedia-example | /wikipedia/util.py | 329 | 3.65625 | 4 | import itertools
# Maximum number of items to return per chunk in `grouper`
MAX_CHUNK_SIZE = 50000
def grouper(iterable):
"""Via http://stackoverflow.com/a/8991553"""
it = iter(iterable)
while True:
chunk = list(itertools.islice(it, MAX_CHUNK_SIZE))
if not chunk:
return
yie... |
26496d81980fb3e25f80c65db67d110733c18d6a | segl2014/Python-Programming | /passdemo2.py | 93 | 3.671875 | 4 | for x in range(5):
if(x == 3):
pass #if has no effect
print("Number is",x) |
9ca0ff1d18c8bcaf6ce58c4fe0e9fccbf5f47495 | segl2014/Python-Programming | /for_else6.py | 124 | 4.15625 | 4 | # else with for loop, else portion runs at the end of the loop.
for x in range(6):
print(x)
else:
print("End of loop") |
85e0b3e5c4b7b695c819ad9820ac82be12e0341b | segl2014/Python-Programming | /if_demo.py | 57 | 3.5625 | 4 | x = 20
y = 10
if x>y:
print("X is Greater than Y") |
63f15390b441813b85bfa8c35efa0a06db9be552 | lachlanpepperdene/CP1404_Practicals | /Prac02/asciiTable.py | 434 | 4.3125 | 4 | value = (input("Enter character: "))
print("The ASCII code for",value, "is",ord(value),)
number = int(input("Enter number between 33 and 127: "))
while number > 32 and number < 128:
print("The character for", number, "is", chr(number))
else:
print("Invalid Number")
# Enter a character:g
# The A... |
7dfda54167d28c6afe5c13eb6cc956a209f4a5d7 | Abu-Siam/Vehicle-Showroom-CLI | /heavy_vehicle.py | 727 | 3.703125 | 4 | from vehicle import Vehicle
# HeavyVehicle class model
class HeavyVehicle(Vehicle):
def __init__(self, model_no=None, car_type="Heavy", engine_type="Diesel", engine_power=None, tire_size=None,
weight="None"):
super(HeavyVehicle, self).__init__(model_no, car_type, engine_type, engine_powe... |
960195335fc8cacbd26fbe925cafc1961ddb8a08 | TheDivexz/tedquizconsole | /quizscript/quizparse.py | 875 | 3.828125 | 4 | import re
def pComment(p):
'''Checks if the line is a comment'''
if p[0] == "#":
return True
return False
def pRbracket(p):
'''checks if the line is a closing bracket'''
if p == "}":
return True
return False
def plineEmpty(p):
'''checks to see if line is empty'''
if(p ... |
904e0c694e91f78a9ad48aa0f94de8ca8b9fbdbd | MBDev-LS/diceGame | /main.py | 1,318 | 3.921875 | 4 | import gameloop
import UserSystem
def choose_player(player):
user = UserSystem.get_user(name=input(f"Enter player {player}'s username: "))
while user == None:
user = UserSystem.get_user(name=input(f"Enter player {player}'s username: "))
return(user["id"])
while True:
choice = input("\u0332".join(" D... |
3c595f7cb19fc72b6da7331771fd4d8255b4f626 | IQQcode/Code-and-Notes | /Python/Pure Python/Basic Grammar/Demo/Demo/Demo2.py | 1,726 | 3.84375 | 4 | # 查看数据类型
num = 10.0
print(type(num))
# 字符串的内容用单,双引号
# 字符窜中包含了引号,就可以灵活使用
name = 'My name is "Mr.Q",age is 20'
print(name)
# and or not 逻辑运算
# 列表(list),可变对象
""" a = [1, 2, 3,"hehe", 4]
a[4] = 100
print(a[1:-1]) #切片操作 print(a[1:-1])
"""
# list 增删改查
words = ['a', 'b', 'c', 'd', 'e']
words.append('Q') # 添加
words.... |
58e337b7fc21e5d3a771f7b60746e28f9117b906 | itsthedoom/python_sandbox | /timezones.py | 288 | 3.53125 | 4 | import pytz
from datetime import datetime
utc = pytz.utc # utc is Coordinated Universal Time
ist = pytz.timezone('Asia/Kolkata') #IST is Indian Standard Time
now = datetime.now(tz=utc) # this is the current time in UTC
ist_now = now.astimezone(ist) # this is the current time in IST.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.