blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
7853029fe7680eae5ff283221a6d8d7d389e87ab | naveenramees/python-pro | /sumofno.py | 115 | 4.03125 | 4 | value = int(input("Enter the number:"))
sum1 = 0
while(value > 0):
sum1 += value
value -= 1
print sum1
|
5642b33791f3dc4992f6d22b2002953d0a799653 | naveenramees/python-pro | /timeshello.py | 86 | 3.84375 | 4 | times = int(input("Enter the times u want:"))
for i in range(0,times):
print "Hello"
|
89f1a314750a766f418398f0aa34de71a55f4ac6 | naveenramees/python-pro | /totalofnum.py | 96 | 3.765625 | 4 | no = int(input("Enter the number:"))
a = 1
for i in range(0,no):
a = i + a
a = a - 1
print a
|
9d4dabab7c9c01df44403e20ee3c9f3db389d443 | naveenramees/python-pro | /isalphabet.py | 123 | 3.640625 | 4 | jam = raw_input("Enter a case: ")
if jam.isalpha() == True:
print "Alphabet"
if jam.isalpha() == False:
print "No"
|
db2d8d20cc41679bfe954fa76e564db5210e0686 | naveenramees/python-pro | /nochecking.py | 82 | 3.671875 | 4 | taj = int(input())
if taj >= 0 and taj < 10:
print "yes"
else:
print "no"
|
b2db4d94cf56805aeeb7bcf61c22f29e605e8f06 | adou12138/python13-api-test | /study_reflect.py | 2,031 | 3.9375 | 4 | # coding: utf-8
# python13-api-test
# study_reflect
# shen
# 2019/1/28 22:41
"""
反射
静态---运行前,如果要调用类的属性或者而方法,我需要实例化它的对象
动态---运行时,我就获取类的属性或者方法,甚至更改它的属性或者方法
"""
class Girls:
'这个是个女孩类'
single = False
def __init__(self, name, age):
self.name = name
self.age = age
def singe(self):
... |
3f1dff753c6428a14e8fb7491af45fae73be7fb1 | marcochang1028/Curve-Type-Detection-by-CNN | /Program/curve_net_gen_images.py | 6,983 | 3.75 | 4 | import numpy as np
import matplotlib.pyplot as plt
import os
def gen_initial_params(max_point_range, max_func_num):
"""Generate initial parameters randomly for image generation
Args:
max_point_range: the maximum range of the number of points for a curve
max_func_num: the number of curver types.... |
eed8510447d7e2fb9054f0e1532b60e9c6ea088a | shobhit-nigam/training | /collins/10June19/day3/exceptions.py | 2,365 | 3.828125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
10/0
# In[2]:
print(varx)
# In[3]:
lista = [5, 9, 10]
# In[4]:
lista[5]
# In[5]:
sum(lista)
# In[6]:
listb = []
try:
res = sum(listb)/len(listb)
print(res)
except NameError:
print("listb not created")
# In[10]:
listb = []
try:
res... |
5fb8d45db26da2586796c88839647a4e1a1fcb5d | dumontal/advent-of-code-2020 | /day_3.py | 1,254 | 3.96875 | 4 | from inputs.reader import read_input_file
def build_locations(lines):
return [list(line) for line in lines]
def count_trees(locations, slope_x, slope_y):
x_pos, y_pos = 0, 0
x_bound = len(locations[0])
y_bound = len(locations)
count = 0
while True:
if locations[y_pos][x_pos % x_boun... |
3d4247fdd95033d3d092878bfd6881aabed5b391 | dumontal/advent-of-code-2020 | /day_4.py | 2,728 | 3.625 | 4 | import re
from inputs.reader import read_input_file
def gather_passports(lines):
passports = []
current_passport = {}
for line in lines:
if line == '':
passports.append(current_passport)
current_passport = {}
continue
for word in line.split():
... |
7d7f7e058cfa72e21d73f681572e3ff3c66ec74a | ShadowElf37/StatsProject | /main.py | 5,192 | 3.625 | 4 | # written by Yovel
class Participant:
K = 32
def __init__(self, name):
self.name = name
self.answers = []
self.score = 0
self.elo = [1000]
self.expected_scores = []
def calc_elo(self, participants, win: int):
my_elo = self.elo[-1]
other_elo = 0
... |
2a575b03af1d4347b73917510fd275583fa674c3 | GrandPa300/Coursera-RiceU-Python | /01_Rock-paper-scissors-lizard-Spock/Rock-paper-scissors-lizard-Spock.py | 2,074 | 4.15625 | 4 | # Mini Project 1
# Rock-paper-scissors-lizard-Spock
# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
# helper functions
import random
def number_to_name(number):
# fil... |
5d0a0f67d7e73d958d4d69054932e912b56cb268 | ogundare-eben/OnlineCoding | /hello1.py | 166 | 3.78125 | 4 | def hello():
print("hello from hello 1")
x = input("First name please: ")
y = input ("Last name please: ")
#print (x.title(),"you're welcome to python class")
|
56c314c41cd3d0cb8529a98b26216918d254062e | 260734/260734 | /inputnumb.py | 272 | 4.09375 | 4 | # program to check the input number
num=eval(input())
if type(num)==int:
print("real number")
elif type(num)==float:
print("float number")
elif type(num)==str:
print("string")
elif type(num)==complex:
print("complex number")
elif num==0:
print("Zero")
|
052484820db25ff540c79e0de0ede14fed802749 | 260734/260734 | /mergedict.py | 237 | 3.84375 | 4 | # Python script to merge two dictionaries
my_dict1={1: "blue", 2: "red", 3: "yellow"}
my_dict2={4: "green", 5: "black"}
print("Without Merge")
print(my_dict1)
print(my_dict2)
my_dict1.update(my_dict2)
print("After Merge")
print(my_dict1) |
f9e5cbaf79f6c551ebe2641f64d8e15a88d6551d | SnailForce/LeetCode-Old | /HOT100/Easy/234. Palindrome Linked List.py | 2,139 | 3.84375 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def isPalindrome(self, head: ListNode) -> bool:
if not head or not head.next:
return True
slow = fast = head
stack = []
... |
4e7f072a7025ffc10eb111d87fe21fb6a33da52c | SnailForce/LeetCode-Old | /HOT100/Easy/461. Hamming Distance.py | 660 | 3.65625 | 4 | class Solution:
def hammingDistance(self, x: int, y: int) -> int:
temp = x ^ y
count = 0
while temp:
if temp & 1:
count += 1
temp >>= 1
return count
def hammingDistance3(self, x: int, y: int) -> int:
return str(bin(x ^ y... |
aa5c1e4bd61422ba8ab46296f9d18fb6f99e62ee | SnailForce/LeetCode-Old | /HOT100/Easy/69. Sqrt(x).py | 893 | 3.65625 | 4 | class Solution:
def mySqrt(self, x: int) -> int:
if x == 0:
return 0
cur = 1
while True:
pre = cur
cur = (cur + x / cur) / 2
if abs(cur - pre) < 1e-6:
return int(cur)
def mySqrt2(self, x: int) -> int:
le... |
407372ad617b35b014ec6e91544d80428291eca9 | SnailForce/LeetCode-Old | /HOT100/Medium/19. Remove Nth Node From End of List.py | 563 | 3.65625 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
if not head:
return head
pre = ListNode(None)
pre.next = hea... |
73d776f9cfdd50658d245fbe1c07414342f303d3 | SnailForce/LeetCode-Old | /HOT100/Easy/101. Symmetric Tree.py | 1,921 | 3.9375 | 4 | # Definition for a binary tree node.
from typing import List
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def isSymmetric(self, root: TreeNode) -> bool:
if not root:
return True
if ro... |
54d35850fbdd7c3367bf8e11e14481fe57b05292 | SnailForce/LeetCode-Old | /HOT100/Easy/108. Convert Sorted Array to Binary Search Tree.py | 1,188 | 3.875 | 4 | from typing import List
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def sortedArrayToBST(self, nums: List[int]) -> TreeNode:
if not nums:
return None
... |
d64b78f988edcef37929fe43610169227a2743d4 | SnailForce/LeetCode-Old | /HOT100/Easy/543. Diameter of Binary Tree.py | 622 | 3.640625 | 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 diameterOfBinaryTree(self, root: TreeNode) -> int:
def getDepth(r: TreeNode) -> int:
if not hasattr(getDepth,... |
5149da6bf8fd8dc0cb4533519346206d916c7b9e | gcaliskan/CSE4095S17_Group7 | /Info_Gain.py | 2,461 | 3.671875 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import xlrd
DataUrl = "C:/HR_Data.xlsx"
data = pd.read_excel(DataUrl)
# Calculates the entropy of the given data set for the target attribute.
def entropy(target_attr):
val_freq = {}
data_entropy = 0.0
# Calculate the frequency of ea... |
179df373fbcb84d0d22b1edd18af9dbb12c7841b | collbb/CSC555 | /ProjectPhase2_backup/lineCustMapJoin.py | 473 | 3.65625 | 4 | #!/usr/bin/python
import sys
# input comes from STDIN (standard input)
for line in sys.stdin:
line = line.strip().split('|')
if line[1].startswith('Customer#'):
if line[5] == 'AMERICA': # Return on matching records
print line[0], '\t', line[4], '\t', 'customer'
# lineo... |
e5ecee4cd5ea203899765ae6f5c450b35b201f30 | FighterFong/lintcode-algorithms | /01-classical-binary-search.py | 1,419 | 3.84375 | 4 | # encoding=utf-8
import time
# return one match result
def binary_search(nums, target):
first = 0
last = len(nums) - 1
while first <= last:
mid = first + (last - first) // 2
print('[INFO] Current Position:{}'.format(mid))
if nums[mid] > target:
last = mid - 1
el... |
5f4b4b40a0fd6895f5798fda25417a4b4448d9e0 | Qingzhuoranguo/boyuEducation | /python_turtle/turtle_demo.py | 443 | 3.828125 | 4 | import turtle
alex = turtle.Turtle()
turtle.speed(500)
alex.pensize(10)
# for loop
for i in range(360*3):
check = i%3
if check ==1:
alex.color("red")
elif check == 2:
alex.color("yellow")
elif check ==3:
alex.color("purple")
else:
alex.color("blue")
alex.forward(0.01 * i)
alex.left(1... |
b391cb1447cc8fd1bb06ca18f73ac161497d75e8 | peterzalewski/advent2019 | /advent.py | 1,414 | 3.609375 | 4 | #!/usr/bin/env python
INTCODE_ADD = 1
INTCODE_MULTIPLY = 2
INTCODE_STOP = 99
def run_intcode(intcode):
assert(len(intcode) > 0)
opcodes = intcode[:]
i_p = 0
while opcodes[i_p] != INTCODE_STOP:
instruction = opcodes[i_p]
if instruction == INTCODE_ADD:
left, right, dest = opcodes[i_p + 1:i_p + 4... |
71864136009925fbd6555d1807228b4789af9380 | guitarengineer/Learn_Python | /run shell command/run_command.py | 317 | 3.703125 | 4 | #!/usr/bin/python
#another way to run a shell command from python
import os
import sys
if len(sys.argv) != 2:
#if the user didnt pass the correct amount of arguments
print "usage:", sys.argv[0],"command"
#show them how to use it
quit()
#and exit
command = sys.argv[1]
print os.system(command)
|
4994e7746a49ec41c730838de8f108beb889b444 | misaelvalentim/student50 | /loops.py | 448 | 4.0625 | 4 |
#types of collections
name_list = ["Khutso","Rori","Ditheto"] # list
name_variable = "Khutso"
name_tuple = ("Khutso","Matlala")
di_set = set() # wont repeat duplicates in a set
di_set.add(1)
di_set.add(4)
di_set.add(1)
di_set.add(3)
mapping = {"Khutso":27,"Pono":30,"Dad":65} # dictionaries/mapping
map... |
44521741f94443d098930015e1d9c57a2049d0e3 | LiangZhang21/sudoku_auto_solver | /sudoku_solver/sudoku_backtracking.py | 2,195 | 4.0625 | 4 |
# Search the matrix location of the empty spot
def check_empty_spot(arr, empty_location):
for i in range(9):
for j in range(9):
if (arr[i][j] == 0):
empty_location[0] = i
empty_location[1] = j
return True
return False
# check row is safe
def ... |
3b93346c2fc37f6672a47ddf9aa60baea18d885e | Archanaaarya/file | /Question4_by_w3.py | 234 | 3.703125 | 4 | # Write a Python program to read last n lines of a file.
my_file=open("Question_file4.txt","r")
read=my_file.readlines()
stor=read
# my_file.close
i=0
count=0
while i<len(stor):
count=count+1
i=i+1
print(count)
my_file.close
|
a18d38be4417b00162bd95a4f99a3ffac3db9c22 | hiimbex/SummerPractice | /binsearchtest.py | 488 | 3.96875 | 4 | #Binary search test
def binarySearch(alist, find_item):
first = 0
last = len(alist) - 1
found = False
while first <= last and not found:
midpoint = (first + last) // 2
if alist[midpoint] == find_item:
found = True
else:
if find_item < alist[midpoint]:
... |
82787a30bf66c5ef52b522039f6f807f29d584af | Ssamirr/OOP-tasks | /motocycle.py | 1,904 | 3.84375 | 4 | class Vehicle():
positionX = 50
positionY = 50
speed = 60
isOn = False
def __init__(self,numofWheels,color,engine):
self.numofWheels = numofWheels
self.color = color
self.engine = engine
def accelerate(self):
self.speed +=1
def moveForward(self,x,y):
self.pos... |
66dca308dded21abc0509cd24802891564c63c0d | Taylorsuk/Game-of-Hangman | /hangman.py | 2,950 | 4.125 | 4 | import random
import re
# import the wordlist
txtfile = open('word_list.txt', 'r')
wordsToGuess = txtfile.readlines()
allowedGuesses = 7
incorrectGuesses = []
correctGuesses = []
randomWord = random.choice(wordsToGuess).strip()
guessWord = []
maskCharacter = '*'
# we have a random word so we can now start the game
pr... |
fd79532dba300d9607822d1f19d4940e2c165c08 | a-oliveira-tlmt/Cadastro | /Participante.py | 2,452 | 3.828125 | 4 | from datetime import date
import json
class Participante():
def __init__(self, nome, email, nascimento):
self.nome = nome
self.email = email
self.nascimento = nascimento
def sair(self):
pass
def carregarParticip(self):
try:
f = open("participantes.txt"... |
10141fc04abc42e174a367d86b69e9d5f8240a92 | ibrahimek76/Python-le-Kodlama-Denemelerim | /Kolay Yüzde Hesaplayan Program.py | 213 | 3.6875 | 4 | #Kolay Yüzde Hesaplama İşlemi
#üzerinde Çalişilabilnir
a=int and float(input("Yüzdesini Almak İstediğiniz Sayıyı Giriniz:"))
b=int(input("% Kaçı :"))
print("Hesaplanıyor...")
c=(input(a/b)*100) |
4583b598a674a6c0e0ec298a7f55d5664c98f3c0 | ibrahimek76/Python-le-Kodlama-Denemelerim | /2 Sayıyı Toplama İşlemi.py | 174 | 3.765625 | 4 | # 2 Sayıyı Toplayan Program
a=int and float(input("Bir Sayıyı Giriniz:"))
b=int and float (input("İkinci Sayıyı Giriniz:"))
print("işleminizin sonucu:" , (a+b)) |
8eae85373ee25185c5f477b42957cd3806635d2a | ibrahimek76/Python-le-Kodlama-Denemelerim | /Len Fonsşyonunla if else (Kullanıcı parola).py | 617 | 3.875 | 4 | #Kullanıcı adı ve parolanın uzunluğunu veren program
kullanıcı_adı =input("Kullanıcı Adınız:") #Değer
parola= input("Parolanız\t\t\t\t:") #Değer
toplam_uzunluk =len(kullanıcı_adı)+len(parola) #Değer
mesaj= "Kullanıcı Adı Ve Parolanız Toplam {} Karakterden Oluşuyor" #Değer
#Değerler Yazılır daha so... |
04997007514fb747725964a39fd17ccfa915bcc8 | GustavoMR99/ufrj_gustavoM | /L2001.py | 400 | 3.984375 | 4 | #---------------
#UFRJ
#
#IM
#
#TMAA-2019.1
#
#GUSTAVO MACIEL
#---------------
print('Calculadora da soma dos dígitos de n elevado a m')
n = int(input('Digite um valor para n: '))
m = int(input('Digite um valor para m: '))
x= n ** m
soma = 0
while (x != 0):
resto = x % 10
x = (x - ... |
c2ab6c64e5e834ae6b0ded9c953d8a2b07d51e1a | arthurDz/leetcodely | /python/binary_tree_zigzag_level_order_traversal.py | 2,416 | 3.59375 | 4 | """Created by sgoswami on 8/8/17."""
"""Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then
right to left for the next level and alternate between)."""
import collections
class BST:
def __init__(self):
self.root = None
def add(self, item)... |
b6f71ae7265f64973f32de45dae47f9f18964576 | cromox1/KodPerang_kata | /4kyu_roman_numeral_helper.py | 5,462 | 4.09375 | 4 | """
Task
Create a RomanNumerals class that can convert a roman numeral to and from an integer value.
It should follow the API demonstrated in the examples below. Multiple roman numeral values will
be tested for each helper method.
Modern Roman numerals are written by expressing each digit separately starting with the... |
39a60c4ab6cef6dd959fa76d51866d809a83c82f | GozaRuu/project-euler-marathon-python | /pb19_cnt_sundays.py | 937 | 3.59375 | 4 | #!/usr/bin/env python
import datetime
#simple solution to this otherwis tedious problem using python datetime library,
#just add 1 day between 2 datetime objects and count results
time_delta, res = datetime.timedelta(days=1), 0
y1, m1, d1 = 1901,1,1
y2, m2, d2 = 2000,12,31
a = datetime.datetime(y1, m1, d1)
b = datet... |
fc7615db96ab788bfeedd37826cbde810a584068 | GozaRuu/project-euler-marathon-python | /pb26_reciprocal_cycles.py | 965 | 3.828125 | 4 | #!/usr/bin/env python
from Euler import prime_sieve
#this is an application of well known Fermat Permality test that comes from the
#Little theory of Fermat, the idea is that for a prime number p: 1/p produce
#an infinite cycle of length n if 10**(n) - 1 mod p = 0 (this condition triggers just once)
#there is an edge... |
9c5421156cd7778fd42c4d30d62e62ed3ed027f1 | aiqingr/python-lesson | /pythonProject/python1/exercise_1.py | 260 | 3.734375 | 4 | temp = [10,-20,-289,100]
def c_to_f(c):
if c < -273.15:
# print("Temprature can not be less than 273.15 Celsius")
return "emprature can not be less than 273.15 Celsius"
else:
return c*9/5+32
for i in temp:
print(c_to_f(i))
|
d9d547405f72a184f41d5ae06a733e006a755d84 | aiqingr/python-lesson | /BreakContinueAndElse/BreakContinueandElse.py | 477 | 3.890625 | 4 | shopping_list = ["milk", "pasta", "eggs", "spam", "bread", "rice"]
for item in shopping_list:
if item == "spam":
print("I am ignoring")
continue
print("Buy " + item)
meal = ["egg", "bacon", "spam", "sausages"]
#python is case sensitive
nasty_food_item = ""
for item in meal:
if item == "spam":
nasty_food_ite... |
78182f8b7eeed49d51da5ad194732dbee021ddf4 | aiqingr/python-lesson | /pythonProject/python1/inputExample.py | 319 | 4.21875 | 4 | # num_input = input("Input a number")
# print(num_input ** 2)
# First two line will popup an error because the input function always return a string
# This will be Method One
# num_input_1 = input("input a number: ")
# print(int(num_input_1) ** 2)
num_input_2 = int(input("input a number: "))
print(num_input_2 ** 2)
|
06fb91955d9e1c0713fa0bcc7c9e4b3afe2c6f7c | srhimel/office-python | /listcomprihencer.py | 332 | 3.515625 | 4 | li = [1,9,8,5]
newli = []
for i in li:
newli.append(i*2)
print(newli)
newli = [2 * i for i in li]
print(newli)
li = [1,2,4,5,6,8,9,12,15,18]
newli2 =[]
for j in li:
if j%2 == 0:
newli2.append(j)
print(newli2)
newli2= [ j for j in li if j%2 == 0]
print(newli2)
li = [1,2,3,4]
newli3 = [x*x for x in li]
p... |
50174feb1087bb3ee74c4acd371a13043222ed03 | srhimel/office-python | /namota.py | 212 | 3.8125 | 4 | def namota(number):
for i in range(11):
namota = i*number
print(number, "x", i, "=", namota)
while True:
number = input("kotor ghorer namota? ")
number = int(number)
namota(number) |
f70a269d576ee27ad42e8f57a9a2e8dd8b65c380 | leducanh300795/c4e17-New-Cause-old-one-got-retk-so-bad- | /Fundamental/Session5/game.py | 1,439 | 3.5625 | 4 | px=1
py=1
bx=2
by=2
while True:
for y in range(4):
for x in range (4):
if x==px and y == py:
print("P", end="")
elif x==bx and y == by:
print("G", end="")
elif x==1 and y == 3:
print("B", end="")
else:
... |
d29cee18474c26e1f5f18987bf85ecdd774049df | leducanh300795/c4e17-New-Cause-old-one-got-retk-so-bad- | /Fundamental/Session3/moody_review.py | 160 | 3.515625 | 4 | from random import randint
n = randint(1,100)
print(n)
if n <30:
print("I feel sad :'('")
elif n<60:
print("I feel normal")
else:
print("Oh yeah")
|
6d9962a7a59c467611c944c879254ce2c28dc72c | leducanh300795/c4e17-New-Cause-old-one-got-retk-so-bad- | /Fundamental/Session5/Homework/exlythuyet.py | 276 | 3.578125 | 4 | import operator
n=input("Input: ").lower()
count = {}
# for letter in n:
if letter == " ":
continue
count[letter]=count.get(letter,0) + 1
count = sorted(count.items(), key=operator.itemgetter(0))
for key,value in count:
print("{0}:{1}".format(key,value))
|
914cae859b8f58e07b1390b78d257ae49febfe15 | leducanh300795/c4e17-New-Cause-old-one-got-retk-so-bad- | /Fundamental/Session1/turtle_exemple.py | 340 | 3.65625 | 4 | from turtle import *
color("red")
#Change shape to turtle
shape("turtle")
forward(100)
left(90)
forward(100)
left(90)
forward(100)
left(90)
forward(100)
left(30)
forward(100)
left(90)
forward(100)
left(90)
forward(100)
left(90)
forward(100)
left(30)
forward(100)
left(90)
forward(100)
left(90)
forward(100)
left(90)
forw... |
5b55fe911da2af996bdfe9c4075b360f1dede8c0 | leducanh300795/c4e17-New-Cause-old-one-got-retk-so-bad- | /Lab/Session3/Homework/draw_square.py | 262 | 3.796875 | 4 | from turtle import *
def drawsquare(x,y):
speed(0)
color(y)
a = x*10
for _ in range (4):
forward(a)
left(90)
for i in range(30):
drawsquare(i * 5, 'red')
left(17)
penup()
forward(i * 2)
pendown()
mainloop()
|
99f9b763a2dc5c076ff5ec41c036dedeb36371f6 | leducanh300795/c4e17-New-Cause-old-one-got-retk-so-bad- | /Fundamental/Session4/Homework/word_jumble_2.py | 430 | 3.671875 | 4 | from random import choice
x = ["champion","meticulous","hexagon"]
for _ in range(len(x)):
a = choice(x)
b = list(a)
x.remove(a)
for i in range(len(a)):
c = choice(b)
print(c, end = " ")
b.remove(c)
print()
run = True
while run:
e = input("Your Answer: ")
... |
e0472dbd3f15042f7ed26cae2dacb2321d9f2162 | leducanh300795/c4e17-New-Cause-old-one-got-retk-so-bad- | /Webmodule/Session4/Homework/testdes.py | 687 | 3.609375 | 4 | from random import randint,choice
def measurements():
mesurements = [randint(85,95), randint(55,65), randint(85,95)]
return (mesurements)
mesure = measurements()
print(mesure)
def description():
characters = ['dễ dãi', 'vui vẻ', 'hòa đồng', 'yêu đời',
'khéo léo', 'hài hước', 'ngáo đá', '... |
be5b07024a7b3e7159f29cb850d61aa478a7a40e | leducanh300795/c4e17-New-Cause-old-one-got-retk-so-bad- | /Fundamental/Session2/Maze.py | 103 | 3.765625 | 4 | from turtle import*
shape("turtle")
for i in range (0,400,10):
forward(i)
left(90)
mainloop()
|
88995fb4ad1cfdb39fffc9d74a149f3a96d7f54a | leducanh300795/c4e17-New-Cause-old-one-got-retk-so-bad- | /Fundamental/Session3/Homework/shop.py | 1,090 | 3.875 | 4 | items = ['T-Shirt', 'Sweater']
while True:
command=input('''Welcome to our shop, what do u want?(C, R, U, D)
(If you want to exit type "done"): ''')
if command =="done":
print("Thanks")
break
else:
if command == "R":
print("Our items: ", end = "")
print(*ite... |
7e1e447fb59567638d35c65f839b1454ebe32445 | leducanh300795/c4e17-New-Cause-old-one-got-retk-so-bad- | /Fundamental/Session2/sum2.py | 106 | 4.0625 | 4 | n = int (input("Enter a number: " ))
total = 0
for i in range (n + 1):
total = total + i
print(total)
|
39bb6f69f2ed0dbcbcbcc2169ed53f35ee3e0bb9 | katehoward/Python-Intro | /sample.py | 105 | 4.15625 | 4 | list_of_numbers = [1,2,3,4,5]
for num in list_of_numbers:
if num <= 3:
print num
else:
print num-1 |
4a2fe3560b99e1da84917da30939ff948067a876 | PeterJochem/Snake | /Neural_Network.py | 8,392 | 3.5625 | 4 | import numpy as np
import random
import copy
# This class implements the neural network
class Neural_Network:
# NumInputs is the number of input neurons to the NN
# HiddenArch is a list of the number of neurons at each HIDDEN layer of the NN
# numOutput is the number of output neurons
def __init__(se... |
3cbb4f36557cca7557dea5d4ebd1783a97a7cfb3 | mxfOnTheWay/crawler_learn | /test--/threading_test.py | 288 | 3.734375 | 4 | import threading,time
def run(n):
print("task",n)
time.sleep(2)
print("task done",n)
start_time=time.time()
for i in range(50):
t=threading.Thread(target=run,args=("t-%s"%i,))
t.start()
print("---- all threads had fineshed")
print("cost:",time.time()-start_time)
|
b94167d2f55b1336d2ad950182f247dc2f4ac141 | UC3MSocialRobots/robot_wardrive | /scripts/locations_to_yaml.py | 1,094 | 3.59375 | 4 | '''
Functions to parse YAML locations.
:author: Victor Gonzalez-Pacheco
:date: 2015-05
Example of how to use these functions:
>>> import yaml
>>> # Load:
>>> locations = None
>>> with open('locations_roboticslab.yaml', 'rw') as locs:
>>> locations = [loc for loc in yaml.load_all(locs)]
>>... |
0fb3f688ee7b45eae8a7270447a908eaac731348 | Abby-w/Intro-to-python-3005- | /week10/Abigail_Ward_HW10_3005.py | 4,737 | 4.25 | 4 | #1
def recFactorial(x):
"""Returns the factorial of the integer
Parameters
----------
x: an integer
Returns
-------
factorial: The value of the factorial of x
"""
#set the base case
if x==0:
return 1
if x == 1:
return x
#call the recursive function
... |
5d4dc521183224af45ae2156b63ddefb387a38b9 | lutv/jeli-recruitment-test | /q12.py | 151 | 3.671875 | 4 | spasi=5
for x in range(6):
for k in range(spasi):
print(end=' ')
spasi=spasi-1
for y in range(0,x):
print('*' ,end='')
print()
|
11bf33aef9fcf9988667128c362ff5077fd84891 | 3ub41r/belajar_python | /restaurant.py | 1,451 | 3.953125 | 4 | meals = {
1: {
'name': 'Chicken Burger',
'price': 16.50
},
2: {
'name': 'Asam Pedas Chicken',
'price': 6.80
},
3: {
'name': 'Chips',
'price': 4
},
4: {
'name': 'Drinks Free Flow',
'price': 0
}
}
def print_orders(orders):
... |
c5c7fdf68bf712e0d95cb48379e4e02cc57ae2fb | Michasa/100DaysofSnek | /Beginners_Tuts/moshTutorial_Functions.py | 1,409 | 3.9375 | 4 | def welcome_message(robot_name):
print(f"hi there, I am {robot_name}")
print("what is your name?")
# parameters = the placeholders in the function
# argument = the actual values given the function is called
welcome_message('Mr Robot!')
# you can set up key word argument, they explictly define which paramete... |
c837464cbff6fb6655a6ec567d893016fd598e53 | iamdurza/python-1 | /review/dice | 192 | 3.671875 | 4 | #!/usr/bin/env python3
import colors as c
import random
while True:
print(c.clear + '')
dice = input('> ')
outcome = ["1","2","3","4","5","6"]
print(random.choice(outcome))
|
ed65dfd74e27a4b8a5baca4eae12867e9e1d1bd6 | iamdurza/python-1 | /8ball | 1,013 | 4.0625 | 4 | #!/usr/bin/env python3
import colors as c
import random
print(c.red + '''Welcome to the magic 8ball! Please enter your
questions!''' + c.reset)
answers = ['Yes',
'No',
'Maybe.',
'Tots Magoats',
'Outlook not so good',
'awwww haaiiil naw',
'Neva in a m... |
84dc258fad5665260b4c84e17fd25e0668135820 | HiroakiMikami/procon-workspace | /src/atcoder/abc093/a.py | 93 | 3.765625 | 4 | S = input()
ans = "a" in S and "b" in S and "c" in S
print("Yes" if ans else "No")
print()
|
760eb2a36bc867bb00de87a662b019ad5d4c43a0 | HiroakiMikami/procon-workspace | /src/atcoder/abc071/b.py | 158 | 3.796875 | 4 | S = input()
ans = None
for i in range(26):
c = chr(i + ord('a'))
if not c in S:
ans = c
break
print("None" if ans is None else ans)
|
713bf745c4724e82a5fb8be56383d18a3283cfc4 | HiroakiMikami/procon-workspace | /src/atcoder/code-festival-2016-qualc/a.py | 176 | 3.921875 | 4 | s = input()
x = ""
for ch in s:
if x == "" and ch == "C":
x = "C"
elif x == "C" and ch == "F":
x = "CF"
ans = x == "CF"
print("Yes" if ans else "No")
|
90c86c5bc967da1537453b28b4507ae59a291605 | HiroakiMikami/procon-workspace | /src/atcoder/abc086/a.py | 108 | 3.765625 | 4 | a, b = [ int(x) for x in input().split() ]
ans = "Even" if (a * b) % 2 == 0 else "Odd"
print(ans)
print()
|
55f470598a7baab3be1437ed6be7493185fe81a6 | HiroakiMikami/procon-workspace | /src/atcoder/abc102/a.py | 87 | 3.625 | 4 | N = int(input())
if N % 2 == 0:
ans = N
else:
ans = 2 * N
print(ans)
print()
|
41f5e6f840c904003060d552290eeeb90d926a53 | HiroakiMikami/procon-workspace | /src/atcoder/abc097/b.py | 255 | 3.75 | 4 | X = int(input())
from math import sqrt
for i in range(1, X + 1):
if i == 1:
ans = i
for b in range(2, int(sqrt(i)) + 1):
tmp = b * b
while tmp < i:
tmp *= b
if tmp == i:
ans = i
print(ans)
|
ed53f670ad926a6cfdf3f166d5f9a2d9ecef81ad | HiroakiMikami/procon-workspace | /src/atcoder/abc065/a.py | 161 | 3.65625 | 4 | X, A, B = [ int(x) for x in input().split() ]
if B <= A:
ans = "delicious"
elif B > A + X:
ans = "dangerous"
else:
ans = "safe"
print(ans)
print()
|
d68ccd2d079780a03519495814ca5ffa20a90211 | daandouwe/glove | /data/scripts/construct-vocab.py | 1,475 | 3.546875 | 4 | import os
import argparse
from collections import Counter
def main(args):
print('Building vocabulary...')
word_counts = Counter()
with open(args.inpath, 'r') as f:
for line in f:
words = line.strip().split()
word_counts.update(words)
if args.max_size > -1:
print('Buidling vocab from top {} most-common... |
c264fb75f59388b8e57128882df66772218725dd | knaranjo357/introduccion-a-programacion | /Python/histories/PENSAMIENTO COMPUTACIONAL/lambda_ex.py | 167 | 3.796875 | 4 | #lambda <vars>: <expresion>
sumar = lambda x, y: x + y
n = int(input('escribe un numero entero : '))
m = int(input('escribe un numero entero : '))
print(sumar(n,m)) |
41aed98b579dcc9e7621c9356685aacc33fcf7e9 | fivaladez/Learning-Python | /EJ10_P2_Classes.py | 981 | 4.28125 | 4 | # EJ10_P2 Object Oriented - Classes
# Create a class
class exampleClass:
eyes = "Blue"
age = 22
# The first parameter MUST be self to refers to the object using this class
def thisMethod(self):
return "Hey this method worked"
# This is called an Object
# Assign the class to an a variabl... |
93e3239657297ebf2a7d476b1e571e65b2c5faf9 | fivaladez/Learning-Python | /EJ14_P2_Dates.py | 1,156 | 3.578125 | 4 | # EJ14_P2 Dates
# You MUST import the moduel "datetime"
import datetime
# help(datetime.date)
gvr = datetime.date(1956, 1, 31)
print gvr
print gvr.year
print gvr.month
print gvr.day
mill = datetime.date(2000, 1, 1)
dt = datetime.timedelta(100)
print "\n ", mill + dt
print "\n ", gvr.strftime("%A, %B %d, %Y")
mes... |
ebbdc407c8e93e02618d8aec68213b2229de61ec | fivaladez/Learning-Python | /EJ21_P2_Lambda.py | 1,006 | 4.375 | 4 | # EJ21_P2 Lambda expression - Anonymous functions
# Write function to compute 3x+1
def f(x):
return 3*x + 1
print f(2)
# lambda input1, input2, ..., inputx: return expression in one line
print lambda x: 3*x + 1
# With the above declaration we still can not use the function,
# we need a name, so, we can do the... |
99002d0f430011ee9f40ac32feac98b84b435544 | fivaladez/Learning-Python | /EJ11_P2_SubClasses_SuperClasses.py | 1,065 | 4.40625 | 4 | # EJ11_P2 Object Oriented - subClasses and superClasses
# SuperClass
class parentClasss:
var1 = "This is var1"
var2 = "This is var2 in parentClass"
# SubClass
class childClass(parentClasss):
# Overwrite this var in this class
var2 = "This is var2 in childClass"
myObject1 = parentClasss()
prin... |
ec99320a00acedf941d4827de5d55d34bd347272 | B50calabrese/PerfectPictureWebcam | /src/python/TestPMWPi.py | 1,113 | 3.578125 | 4 | # Gives control of the GPIO pins on the raspberry pi.
import RPi.GPIO as GPIO
# Used for time delays.
import time
# Used for key input.
import cv2
#def set(property, value):
# f = open("/sys/class/rpi-pwm/pwm0/" + property, 'w')
# f.write(value)
# f.close()
# The pin that we will be using to control the servo.
o... |
f1ed13f858879ff31c1a4c64e05e232825f44a57 | SanjayStark/guvicodekata | /p2.py | 78 | 3.984375 | 4 | no=int(input())
if ((no%2)==0):
print("Even")
else:
print("Odd")
|
3194e6d5a08128b1eb943b29f579bf3bf72b1d68 | tanish522/python-coding-prac | /stack/stack_1.py | 415 | 4.15625 | 4 | # stack using deque
from collections import deque
stack = deque()
# append() function to push element in the stack
stack.append("1")
stack.append("2")
stack.append("3")
print('Initial stack:')
print(stack)
# pop() fucntion to pop element
print('\nElements poped from stack:')
print(stack.pop())
print... |
5b01e7b750df3c9c7c2e1f08962af023249e6331 | tanish522/python-coding-prac | /recursion/recursion_4.py | 191 | 4.125 | 4 | print("sum off all even numbers from 0 to n")
def rec(n):
if(n == 0 ):
return 0
else:
return n+rec(n-2)
no = int(input("enter an even no \n"))
print(rec(no)) |
ff684b5a98439d0b819cc19190d119695cb7c2a0 | sjangada/python | /basics/FindingSquare.py | 117 | 3.8125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[2]:
num = int(input("Enter a number: "))
print(num*num)
# In[ ]:
|
04bd98c3bd4c54fda4fbffcbeb516c2e33776b95 | 316141952/Practica01 | /Codigos/Ejercicio01.py | 343 | 3.5625 | 4 | # -*- coding: utf-8 -*-
'''Aquí está el Ejercicio 1'''
import Ejercicio01F
from Ejercicio01F import *
x = input('Dame una lista: ')
print 'La suma de los números es',
print suma_l(x)
print 'El número máximo es',
print max_l(x)
print 'El número mínimo es ',
print min_l(x)
print 'Los números primos de la lista son ',
p... |
2e1f82907b455f15ddaa77b4a3841c2dd61f6de5 | ArsenArsen/claw | /claw/interpreter/commands/cmd_sass.py | 1,764 | 4.125 | 4 | """
Takes the given input and output directories and compiles all SASS files in the input into the output directory
The command takes three parameters, namely target, directory, and glob:
sass <source> <target> [style]
The source parameter is relative to the claw resource directory
The target parameter is where th... |
e467704dbddd8c34eaf38dd2d258f90f44b1ed72 | iEuler/leetcode_learn | /q0093.py | 1,817 | 4.09375 | 4 | """
93. Restore IP Addresses
Medium
https://leetcode.com/problems/restore-ip-addresses/
Given a string s containing only digits, return all possible valid IP addresses that can be obtained from s. You can return them in any order.
A valid IP address consists of exactly four integers, each integer is between 0 and 255,... |
109d121f6e743685cd5b453fe6a77c89f37a0fb4 | iEuler/leetcode_learn | /q0526.py | 4,611 | 3.75 | 4 | """
526. Beautiful Arrangement
Medium
https://leetcode.com/problems/beautiful-arrangement/
Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of the following is true for the ith position (1 <= i <= N) in this array:
The num... |
1793f85bca070e0765a1caa3ce46999117306149 | iEuler/leetcode_learn | /q0227.py | 1,356 | 3.765625 | 4 | """
227. Basic Calculator II
https://leetcode.com/problems/basic-calculator-ii/
Implement a basic calculator to evaluate a simple expression string.
The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should truncate toward zero.
Example 1:
Input: ... |
c0276b60529eb55fbc38284c61c646c74c257200 | iEuler/leetcode_learn | /q0514.py | 4,141 | 4.0625 | 4 | """
514. Freedom Trail
Hard
https://leetcode.com/problems/freedom-trail/
In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring", and use the dial to spell a specific keyword in order to open the door.
Given a string ring, which represents the co... |
49a3e575dc8306a981c8fad4a8e36ff163203cce | iEuler/leetcode_learn | /q0003.py | 1,222 | 4.09375 | 4 | """
3. Longest Substring Without Repeating Characters
https://leetcode.com/problems/longest-substring-without-repeating-characters/
Given a string, find the length of the longest substring without repeating characters.
Example 1:
Input: "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
Exa... |
3f59312beea6943aad8784953bb5f45179b0c3c1 | iEuler/leetcode_learn | /q1307.py | 4,583 | 4.03125 | 4 | """
1307. Verbal Arithmetic Puzzle
Hard
https://leetcode.com/problems/verbal-arithmetic-puzzle/
Given an equation, represented by words on left side and the result on right side.
You need to check if the equation is solvable under the following rules:
Each character is decoded as one digit (0 - 9).
Every pair of diff... |
2c57714c341a600c745cca79acc83e1d7a77c12c | iEuler/leetcode_learn | /q0130.py | 3,335 | 3.96875 | 4 | """
130. Surrounded Regions
Medium
https://leetcode.com/problems/surrounded-regions/
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.
A region is captured by flipping all 'O's into 'X's in that surrounded region.
Example:
X X X X
X O O X
X X O X
X O X X
After running you... |
649df4c7b9f19ab38d3924cd2dc68f956b70f90b | iEuler/leetcode_learn | /q0282.py | 1,461 | 4.28125 | 4 | """
282. Expression Add Operators
https://leetcode.com/problems/expression-add-operators/
Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value.
Example 1:
Input: num = "123", ta... |
8bfb023d24a52cdbb02bc1acd892d660dba139b9 | ROHITDH/ML_Assignments | /ML_assignment5/assignment5.py | 6,028 | 4.0625 | 4 | #assignment_5 ML 28/Aug/2020 RDH
#QN:1.Download employee retention dataset from here:
# https://www.kaggle.com/giripujar/hr-analytics. OR you can choose any data set.
# 1.Now do some exploratory data analysis to figure out which variables
# have direct and clear impact on employee retention (i.e. whether they
# l... |
a053acb205422ba74c0dc16c0f28543a5bd15cf4 | soooosuhan/suhaedal | /Data_test.py | 730 | 3.671875 | 4 | print(5+7)
print(5-7)
print(5*7)
print(5/7) #나누기
print(5//7) #몫 구하기.
print(2**1)
print(2**2) #제곱
print("안녕하세요")
print('안녕하세요')
print('"안녕하세요"라고 말했습니다.') #큰 따옴표 중복 되면 구문 오류난다.
print("안녕하세요"+"반갑습니다.")
#리스트를 선언합니다.
array=[273, "문자열", True]
print(array)
#한가지 값만 알고싶다면, 순서시작 0부터!!!
print(array[0])
#list 값 변경
array[0]=274
... |
444ef66071c458cf92cfff248f813ab29608c91e | Prashant1099/Simple-Python-Programs | /Count the Number of Digits in a Number.py | 318 | 4.15625 | 4 | # The program takes the number and prints the number of digits in the number.
n = int(input("\nEnter any Number = "))
count = 0
temp = n
while (n>0):
n //= 10
count += 1
print("-----------------------------------")
print("Number of Digits in ",temp, " = ",count)
print("-----------------------------------") |
ef64c588046fa5f0e6a76dbd008ca398c3b62cba | Prashant1099/Simple-Python-Programs | /Exchange the Values of Two Numbers Without Using a Temporary Variable.py | 394 | 4.03125 | 4 | # The program takes both the values from the user and swaps them without using temporary variable.
a = int(input("\nEnter First Number = "))
b = int(input("Enter Second Number = "))
a = a + b
b = a - b
a = a - b
print("----------------------")
print("After Swapping:")
print("----------------------")
print("First Nu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.