blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
a2af94fc47071d40b33c508ed4224f2f3ad4f407 | HasturAeon/Logia | /etap2/Ex3_LOGIA06.py | 1,094 | 3.78125 | 4 | from math import*
def numberToSyllabe(number, key):
letter0 = number - key
letter1 = 0
while(letter0 < 0):
letter += 676
while(letter0 % 26 != 0):
letter0 -= 1
letter1 += 1
letter0 = letter0 / 26
return chr(int(letter0) + 97) + chr(letter1 + 97)
def syll... |
f1479ff633b4afd94c22f3d4b6c4badf777fa204 | smrmkt/project_euler | /problem_050.py | 1,138 | 3.828125 | 4 | #!/usr/bin/env python
#-*-coding:utf-8-*-
'''
The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest sum of consecutive primes below one-thousand that adds to a prime,
contains 21 ... |
90e2aa39f1f77fa2e937a37c5e456ae852336d52 | murali-kotakonda/PythonProgs | /PythonBasics1/basics/functions/Ex4.py | 667 | 4.21875 | 4 | """
write a function that takes 2 nums as input and prints the bigger number.
"""
#how to write function
def big(x,y):
if(x>y):
print("Big = ", x)
else:
print("Big = ", y)
# x, y , bigger are the local variables
#how to call the function
big(30,13)
n1=56
n2=90
big(n1,n2)
n3= int(inp... |
387335fbe724b3bcf98c834a5466f88af7457bc3 | gandaierama/python-test | /conditional-logic/break-out-of-the-pattern.py | 186 | 3.984375 | 4 |
while True:
user_input = input('Type "q" or "Q" to quit: ')
if user_input.upper() == "Q":
break
for i in range(1, 51):
if i % 3 == 0:
continue
print(i)
|
9d9dc0460f8c3cd3a4f6615383d35711707bdab5 | abhishekkulkarni24/Machine-Learning | /Numpy/exercise2.py | 814 | 3.953125 | 4 | '''
You are given a number ‘N’. Your task is to find all the numbers ranging from 1 to N with the
fact that absolute difference between consecutive digits of a number is 1.
Input format:
Input contains integer N
Output format:
Output displays all the numbers that satisfy the given condition and ‘-1’ if no number is
pr... |
403a0ebabb9eb32c1124ae26ad84024fce103553 | saubhagyav/100_Days_Code_Challenge | /DAYS/Day29/Inverted_Star_Pattern.py | 229 | 3.953125 | 4 | def Inverted_Star(Test_input):
for i in range(Test_input+1, 0, -1):
for j in range(0, i-1):
print("*", end=" ")
print(" ")
Test_input = int(input("Enter N: "))
Inverted_Star(Test_input)
|
44643ae4133c942ecb59ad90beacae295fa4bcd4 | black3037/Nodes--Surfaces--Rays--and-Intersections-of-Objects--An-Example-of-OOP-in-Python- | /Adding and Scaling a Point.py | 1,301 | 4.125 | 4 | #/Users/Apollo/miniconda/bin/python
""" This problem will add two points together, or Scale a point by a scalar value """
x1 = int(raw_input('Enter your Point 1 x-coordinate :'))
y1 = int(raw_input('Enter your Point 1 y-coordinate :'))
point_1 = (x1,y1)
print "Point 1 is : %s" % (point_1,)
x2 = int(raw_input('Enter ... |
f6a8eefa511e4797d855afc8936b8f0dbf9d0c50 | olenggg/Test-Eudeka | /number1.py | 357 | 4.15625 | 4 | def result(num):
if num % 3 == 0 and num % 5 == 0:
print("Hello World")
elif num % 5 == 0:
print("World")
elif num % 3 == 0:
print("Hello")
if __name__ == "__main__":
num = int(input("En... |
2f34e6b4fb7daa9d47c888612a2c582925359180 | denny-Madhav/PYTHON-BASIC-PROJECTS | /Forloop/highest score challenge.py | 277 | 3.859375 | 4 | sh = input("input a list of student marks: ").split()
count =0
high=0
for n in range(0,len(sh)):
sh[n] = int(sh[n])
count =count+1
for score in sh:
if score > high:
high=score
print(f"Highest marks among all {count} students is : {high}")
|
333f5f37c62e11d356ea80af232a83143c01b26c | ShubhamKulkarni1495/List_python | /List/count.py | 260 | 3.671875 | 4 | numbers=[25, 40, 23, 70, 56, 12, 5, 10, 7]
index=0
count=0
length=len(numbers)
while(index<length):
if(numbers[index]>20 and numbers[index]<40):
count+=1
index+=1
print("numbers",count)
|
2cce17faa7a18a63621d90ea5456469b5bd0e6d5 | fbjxu/Data-Science-Python | /House hungting 1c.py | 1,413 | 3.90625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 1 17:08:10 2019
@author: lazybear
"""
semi_annual_raise = .07
r = 0.04
portion_down_payment = .25
total_cost = 1000000.0
#user-provided var
annual_salary = float(input('annual salary'))
#derived vars
down_payment = portion_down_payment * total_... |
3744873f4f8853304a8eb5bc589061b7fbe50d0e | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/bob/a2cc7e443ff04ce5a00a5b7036ca188a.py | 591 | 3.609375 | 4 | class Bob(object):
def hey(self, words):
phrase = Phrase(words)
if phrase.is_silent():
return "Fine, be that way."
if phrase.is_yelling():
return "Woah, chill out!"
if phrase.is_questioning():
return "Sure."
return "Whatever."
class Phra... |
5f3ca88b3366568b983118f161fb80c9f9f4880f | Zahidsqldba07/python_course_exercises | /TEMA 2_CONDICIONALES/Condicionales/ej2.5.py | 520 | 4.09375 | 4 | #!/usr/bin/python3
#Programa que te dice de una entrada de tres numeros cual es mayor
try:
num1=int(input("Introduce un número: "))
num2=int(input("Introduce un número: "))
num3=int(input("Introduce un número: "))
if num1 > num2 and num1 > num3:
print("El numero " + str(num1) + " es mayor")
elif num2 > num... |
610a5a044b079882ec81d808f3f647824d599b5b | CompetitiveCode/py.checkIO.org | /Home/Xs and Os Referee.py | 1,650 | 4.09375 | 4 | #Answer to Xs and Os Referee - https://py.checkio.org/en/mission/x-o-referee/
from typing import List
def checkio(game_result: List[str]) -> str:
start=0 #Used as an iterating variable
for i in game_result: #To check the horizontal values
if i[0] == i[1] == i[2] and i[0] != '.': #If the horizontal val... |
459cd0d683069e24f2f219d15375e5050a37ff3a | juanhurtado4/cs3 | /doubly_linked_lists/doubly_linked_list.py | 3,250 | 4.03125 | 4 | class Node():
def __init__(self, item):
self.previous = None
self.next = None
self.data = item
class Linked_list():
def __init__(self, items=None):
self.head = None
self.tail = None
self.size = 0
if items != None:
for item in items:
... |
675cfe0d2da655c4260f23c5bc35b4c044ce9e6c | appan-roy/Seleniun-Python | /LearnPython/Classes/MethodOverloading.py | 255 | 3.671875 | 4 | class Bird:
def fly(self, name = None):
if name == "Parrot": print("Can fly")
elif name == "Penguine": print("Can't fly")
elif name == None: print("No input")
obj = Bird()
obj.fly("Parrot")
obj.fly("Penguine")
obj.fly() |
1c3808af71ee940e4c7cef2cc4525a70d2b6768d | josedoneguillen/fundamentos_programacion_python | /tipos_de_datos/numeros_primos.py | 1,049 | 4.15625 | 4 | '''
Crea un programa que solicite al usuario ingresar un número y le
indique si el número ingresado es primo o no. El sistema debe mantenerse
corriendo hasta que el usuario indique lo contrario. Cada vez que indique si es
primo o no, debe preguntar al usuario si desea salir o ingresar otro número.
'''
# ... |
d07f993651bac342f688c47febb73a95612fde2e | DaPenguinNinja/Testing-Python | /ClassAndObjects.py | 1,079 | 3.875 | 4 | #From Module of Tools import the Car and Student class
from Tools import Car
from Tools import Student
#Created object with specifications
#Initilized person with " " array in case no name is given
#Could give it none
Car1=Car('red','small','toyota')
#Created a list of Cars with unique attributes
#The first object is... |
2304b76b5938c189478abe0ea1969453720236fe | terrencejames/Luxanna---Messenger | /modules/flip.py | 172 | 3.78125 | 4 | from random import randint
def flip(args):
res = randint(1,2)
if res == 1:
return "Flipped a coin: Heads"
else:
return "Flipped a coin: Tails"
|
5df2e256f2c01349814b61273f56448a6c5684ff | klmsathish/PythonBasics | /EvenOddUsingList.py | 294 | 4.125 | 4 | list1=[]
num = int(input("enter the no. of elements = "))
for i in range(num):
list1.append(int(input("enter the elements = ")))
odd =[]
even =[]
for j in list1:
if(j%2==0):
even.append(j)
else:
odd.append(j)
print(even,"are even")
print(odd,"are odd")
|
aa8a7266b08aa190e2d1354acfc48849b71ccfc5 | UX404/Leetcode-Exercises | /#728 Self Dividing Numbers.py | 1,080 | 4.125 | 4 | '''
A self-dividing number is a number that is divisible by every digit it contains.
For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.
Also, a self-dividing number is not allowed to contain the digit zero.
Given a lower and upper number bound, output a list of ev... |
d907e286799eab2d3b4b7a047e482070908d83e4 | Yatharthanand/practice-python | /55_print_first_n evens.py | 91 | 3.828125 | 4 | n = int(input("Enter value of n: "))
i = 2
while (i<=n*2):
print (i)
i=i+2 |
963046b7ba974054df780c4837110b1e2d473f19 | daniel-reich/ubiquitous-fiesta | /XoBSfW4j6PNKerpBa_4.py | 250 | 3.609375 | 4 |
def complete_factorization(num):
lst = []
while num != 1:
for i in range(2, num + 1):
if num % i == 0:
num //= i
lst.append(i)
break
lst.sort()
return lst
|
ce865cd7874983b009fc5258563e0fe4f3a62311 | Hfixdu2523/NguyenKhoaHaiDuy-C4T8-HW1-2 | /session5/BaiTap6.py | 552 | 4 | 4 | import math
print("ax^2 + bx + c = 0")
a = float(input("Enter a = "))
b = float(input("Enter b = "))
c = float(input("Enter c = "))
print(a, b, c)
if a == 0:
print("Equation can't be solved due to conditions")
if a != 0:
delta = (b**2 - 4*a*c)
print(delta)
if delta < 0:
print("There is no soluti... |
89565937eb060a57c0437fc55859f8215465be3d | mearghya/Python-Star-Project | /STAR.py | 389 | 4 | 4 | print("enter the number\n")
i=int(input())
print("enter the boolean number '0' or '1'\n")
z=int(input())
u=bool(z)
a=0
while 1:
if u is False:
while a<i:
print((i-a)*"*")
break
a=a+1
else:
while a<i:
print((a+1)*"*")
break
... |
3a9f792bcc752f84948ff80fe458c320e04718e4 | prashantlv/cv2-0520 | /img-segmentation/corners.py | 1,053 | 3.5 | 4 | import matplotlib.pyplot as plt
import numpy as np
import cv2
image = cv2.imread('images/waffle.jpg')
image_copy = np.copy(image)
image_copy = cv2.cvtColor(image_copy, cv2.COLOR_BGR2RGB)
plt.imshow(image_copy)
gray = cv2.cvtColor(image_copy, cv2.COLOR_RGB2GRAY)
gray = np.float32(gray)
dst = cv2.cornerHarris(gray, 2,... |
4f349795ea572ee9faeee2071d9174aedf15b3c0 | kamilczerwinski22/Advent-of-Code | /main_files/year_2015/day_6/year2015_day6_part2.py | 2,233 | 4.125 | 4 | # --- Part Two --- You just finish implementing your winning light pattern when you realize you mistranslated Santa's
# message from Ancient Nordic Elvish.
#
# The light grid you bought actually has individual brightness controls; each light can have a brightness of zero or
# more. The lights all start at zero.
#
# The... |
8ee1dec94054f14511090c34a096e06c83b767c5 | Kzshii/aulas | /revisao_6l.py | 164 | 3.84375 | 4 | dolar=float(input("Insira o valor em reais que possui: "))
reais=float(input("Insira o valor da cotação do dolar: "))
print("O valor em dolares é ",dolar*reais)
|
f23bfc4722dce7504c267fdda954ad4cdef39eb6 | SauravChittal/Platformer-Template | /Template.py | 7,208 | 3.515625 | 4 | """
This is basically a template for creating a platformer.
It has a scrolling background made of two pictures and 2 enemies along with a playable
character and also a flag indicating a win.
There are quite a lot of things which could be done to generlize these things for multiple things
such as more backgrounds(fai... |
232fe3facc29557b8c8e2ae3b32b93bbe918a87b | dlgosla/Python | /matrix-chain multiplication.py | 924 | 3.640625 | 4 | def order(p,i,j):
if(i==j):
print("A", i,end="")
else:
k = p[i][j]
print("(",end="")
order(p,i,k)
order(p,k+1,j)
print(")",end="")
d=[5,2,3,4,6,7,8]
n=len(d)-1
m=[[0 for j in range(1,n+2)] for i in range(1,n+2)]
p=[[0 for j in range(1,n+2)] for i i... |
471d903664c64e58f646f6bc06dd1d74bea31522 | CodeForProgress/demo-api-project | /main.py | 6,459 | 3.609375 | 4 | import tweepy
import lob
import googlemaps
import sunlight
import pprint
# imports for Weather API
import urllib2
import json
from datetime import datetime
lob.api_key = "test_32f9cf853c605d272e35567fadb984b4318"
gmaps = googlemaps.Client(key='AIzaSyBuBYoY9OiVXnJnQf3D1jFG_iBOjqJkzw8')
sunlight.config.API_KEY = "ed9d... |
fe1ee604483daf5017f3e0178fe1fd16d7a16319 | rutuja1302/NQT-20 | /ExamHall/SeatingArrangement.py | 3,476 | 3.984375 | 4 | '''At an exam center, M number of students are allocated for one classroom as per the University Rules.
The Examination staff has made sitting arrangements where the classroom contains N number of benches arranged in columns separated by a suitable distance occupying room space from the left to the right wall.
Given, M... |
e4106b9cfa297c7cbb0f42983cccf2e925365a32 | wspasindupanthaka/hands-on-nlp-with-python | /Regular Expressions/regex4.py | 1,063 | 3.859375 | 4 | # -*- coding: utf-8 -*-
import re
sentence1 = "Welcome to year 2019"
sentence2 = "Just ~% +++--- arrived at @Jack's place. #fun"
sentence3 = "I love you"
sentence1_modified = re.sub(r"\d","",sentence1)
print(sentence1_modified)
sentence2_modified = re.sub(r"[%@#~+-\.']","",sentence2)
print(sentence2_modified... |
fe600e1e9cbd3442cec32df5912070533338e186 | RawitSHIE/Algorithms-Training-Python | /python/How many char in it 2 smartway.py | 486 | 3.921875 | 4 | """How many char in it?? V.1"""
def how_many():
"""How many char in it?? V.1"""
alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
text = input()
chk = 1
for i in alpha:
if i in text:
print(i, ":", nub(text, i))
chk = 0
if chk:
print("\\@#!$#'\... |
f5c284d7227ae50cfa3944a63453e3e8d5adbcc5 | Hayk-Dadyan/IntroToPython | /Week 2/Practical/Problem-7.py | 185 | 4.03125 | 4 | #Problem 7
country = "Armenia"
years = 10
print("""Hi, where are you from?
I'm from """ + country + ". ")
print("""How long have you lived here?
For """ + str(years) + " years.") |
8a2b570008b08e7d9c57897eb789891ea74283cf | saulmont/programacion_python | /Bases/bucle_while.py | 993 | 3.78125 | 4 | # BUCLE WHILE
"""
Un bucle while es el que se repite/ejecuta siempre que se cumpla con una condicion.
Ejemplo:
while condicion:
###BLOQUE CODIGO###
else:
###FIN DE LA EJECUCION###
"""
contador = 0
limite = 5
pares = []
impares = []
while contador <= limite: # Condicion de ejecucion.
pr... |
4375dbcd48d71eae36b34119c99df79c01b7185a | snpushpi/P_solving | /230.py | 886 | 3.828125 | 4 | '''
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.
Note:
You may assume k is always valid, 1 ≤ k ≤ BST's total elements.
Example 1:
Input: root = [3,1,4,null,2], k = 1
Output: 1
'''
#Definition for a binary tree node.
class TreeNode(object):
def __init__(sel... |
561a8e4cc4b1133fdef4e051152b8aa08a77fc81 | aatul/AdvancePython | /008_ZipFunction.py | 732 | 4.65625 | 5 | """
zip function (Both iterators to be used in single looping construct):
This function is helpful to combine similar type iterators(list-list or dict-dict etc,) data items at ith position.
It uses the shortest length of these input iterators.Other items of larger length iterators are skipped. In case of empty iterat... |
dbaeb2d581468d5ce74920a10c6f1594ef0a7933 | pranavraj101/python- | /library_late_submission_of_book_program.py | 291 | 3.671875 | 4 | print('Number of days late :')
d=int(input())
print('Number of months late :')
m=int(input())
print('Number of year late :')
y=int(input())
fine=0
if(y>0):
fine=10000
elif(m>0):
fine=500*m
elif(d>0):
fine=15*d
else:
fine=0
print("Fine due to late submission of booK :",fine)
|
3117fa299ce4fcd01635cecc2295579b9ac375d7 | Kota-Yamaguchi/reinforcealgo | /work/src/environment.py | 9,265 | 3.53125 | 4 |
from turtle import done
from status import Status, Action
import numpy as np
from Agent import Agent
class Environment():
def __init__(self, grid : list, agent : Agent, move_prob =0.8):
self.default_rewarding = -0.04
self.grid = grid
self.row = len(grid)
self.column = len(grid[0])... |
fec1d65a61829a651c1bc8ecc8d3e57f56d2de09 | Mofmof2004/Natural_selection_Simulation | /Agent/Agent_movement/Search_for_food.py | 4,927 | 3.6875 | 4 | from Simulation.Display_settings import *
from Simulation.Array import world_array
from Agent.Agent_movement.Energy_cost import energy_cost
from Agent.Agent_movement.Random_movement import random_move
def search_for_food(agent_list, num):
"""
used to to make agent search and find food
:param ag... |
1ee448ea83cc8d07a230406b5a49d7629e00de1f | yanlingsishao/study | /day1/dict实例.py | 1,023 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
Created on 2017年5月9日
@author: WangQiyuan
'''
# 字典
# key:value
# 布尔值列表字典不能作为key,报错,value什么都行
# 无序,可迭代
dic = {
"fasd":"fads",
"k1":"fdasfads"
}
# x = dic.values()
# x = dic.keys()
# x = dic.items()
# print(x)
# j = dic.fromkeys(['fds','fasd'],123)#传一个序列,创建字典,并且... |
0ed9ebfced8b3d3d1ddfcb6de4d9d0a07a8b58b6 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2471/60781/286895.py | 779 | 3.734375 | 4 | n=input()
str1=input()
str2=input()
str3=input()
pan=0
if(str1=='{([])})' and str2=='()(' and str3=='([])'):
print('not balanced')
print('not balanced')
print('balanced')
pan=1
if(str1=='{([])}' and str2=='()' and str3=='([])'):
print('balanced')
print('balanced')
print('balanced')
pan=1... |
5b1eb131b1ab9213391198387ca0e20730ec3caa | simranjmodi/cracking-the-coding-interview-in-python | /chapter-08/exercise-8.4.py | 361 | 4.09375 | 4 | """
8.4 Power Set
Write a method to print all subsets of a set.
"""
import math
def print_power_set(set):
set_size = len(set)
pow_set_size = (int)(math.pow(2, set_size))
for counter in range(0, pow_set_size):
for j in range(0, set_size):
if ((counter & (1 << j)) > 0):
... |
edf261d362b7c8db1783f6b2f1b40ddd56f7eb22 | TejasviniK/Python-Practice-Codes | /StringSorter.py | 676 | 4.1875 | 4 | def sortString(the_string):
if not isinstance(the_string, str) :
return "Not a string!"
else :
capitalStr = ""
lowerStr = ""
spclStr = ""
spaceCount = 0
for s in the_string :
if ord(s) >= 65 and ord(s) <= 90 :
capitalStr += s
... |
0e946706a987e4e9065158827d8dd394c3005e1d | sungminoh/algorithms | /leetcode/solved/219_Contains_Duplicate_II/solution.py | 1,408 | 3.59375 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2020 sungminoh <smoh2044@gmail.com>
#
# Distributed under terms of the MIT license.
"""
Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i... |
5dfaf3b84c55cc66459550ebd90ba538a1585389 | venugopalrohit/code_samples | /rock_paper_scissors.py | 1,205 | 3.9375 | 4 | import re
import random
choice_array = ['r', 'p', 's']
while(1):
print("Please make a selection: ");
print("Rock(R) Paper(P) Scissors(S) Quit(Q)");
player_choice = input("Choice: ").strip().lower()
if not (len(player_choice) == 1 and re.match(r'[rpsq]', player_choice)):
print("Please... |
6c76389a3cef5ac6f66dc0877e4bd60839b60a60 | Oleksandr015/NIX_edu_solutions | /task_1/first_task_1.py | 482 | 3.546875 | 4 | # Как удалить дубли строк из файла?
list_duplicates = []
example_doc = open('with_duplicates.csv', 'r')
final_doc = open('no_duplicates.csv', 'w')
for line in example_doc:
if line in list_duplicates:
continue
else:
final_doc.write(line)
list_duplicates.append(line)
example_doc.close()
... |
56214b5b5d9a4470f943d74842161c3141ec64f9 | diego-90/progAvanzada | /ejercicio8.py | 254 | 3.546875 | 4 | cornflakes = int(input('introdusca cuantas cajas de cornflakes tienes:'))
trix = int(input('introdusca cuantas cajas de trix tienes:'))
peso1 = 750*cornflakes
peso2 = 500*trix
pesototal = (peso1+peso2)/1000
print('el peso total es',pesototal,'kg')
|
fbf9cae0e439b4c983f6ff51f11235525e101f63 | YaqoobAslam/Python3 | /Chapter01/Number_Print_Ranger.py | 258 | 4.03125 | 4 | def cheer2():
""" Same as cheer, but uses a for loop and range()
range uses a start number, a stop number and a step size. """
for ct in range(2,9,3):
print(ct,end=' ')
print()
print("Who do we appreciate?")
print("COURSERA!") |
78cb2456847bfe923b4d1863970a2df9a62e4cd6 | qwertpi/pihut-rgb-xmas-tree | /main.py | 973 | 3.546875 | 4 | from random import randint,random, choice
from time import sleep
from tree import RGBXmasTree
tree = RGBXmasTree(brightness=0.15)
tree.off()
def rc():
#heightened chance of landing in range 0-25 or 225-250
return choice(list(range(225, 251)) + list(range(0, 255, 50)) + list(range(0, 26)))
#the comma in 3 mak... |
b3a4ba838d6f1d4fe3ced382495a9964f32a5a63 | mohammed1916/Projects | /python_advanced_concepts/lambda_and_map_filter_reduce/lamda_power.py | 313 | 4.5 | 4 | """Create a lambda function which takes two inputs X and Y and performs X power Y
operation and returns the output. For Example: If X is 2 and Y is 3, then 2 power 3 = 2
* 2 * 2 = 8."""
power = lambda x,y: x**y
x = int(input("Enter base "))
y = int(input("Enter power "))
print(f'{x} power {y} is {power(x,y)}') |
7927186f45cb023948cb83c8a2baad6bd5d50753 | jscabraWork/Lab3Infracom | /python/appservidor/mainserver.py | 2,484 | 3.515625 | 4 | import socket
import threading
IP = socket.gethostbyname(socket.gethostname())
PORT = 9999
ADDR = (IP,PORT)
SIZE = 1024
FORMAT = "utf-8"
DISCONNECT_MSG = "!DISCONNECT"
TOTAL_CONNECTIONS = 25
connections = []
requiredCons = 10
barrier = threading.Barrier(requiredCons)
def handle_client(conn, addr):
print(f"[NEW ... |
902eee4978bc86a26618bb79233c58a3e2b833f7 | leichongxiang/sa_dev | /python/py_basic/sort/heapsort.py | 805 | 3.890625 | 4 | #!/usr/bin/python
def adjust_heap(lists,i,size):
lchild = 2*i + 1
rchild = 2*2 + 2
max = i
if i < size/2:
if lchild < size and lists[lchild] > lists[max]:
max = lchild
if rchild < size and lists[rchild] > lists[max]:
max = rchild
if max != i:
... |
faabc5578cc26ba1c046223788fecc306561c7c4 | atsangarides/mobile-analytics | /mobile-analytics/visualisations/user_journey_plots.py | 1,993 | 3.65625 | 4 | from stats.user_journey import sankey_df
def plot_user_flow(events, starting_step, n_steps=3, events_per_step=5, title='Sankey Diagram'):
"""
Function used to generate the sankey plot for user journeys.
:param events: (DataFrame)
Mixpanel events dataframe
:param starting_step: (s... |
5fc7e38d8e5f13c5ed1a29e784ee0bc0c52fed90 | mjcrgn/practicepython.org | /01_character_input.py | 1,305 | 4 | 4 | '''
210110
https://www.practicepython.org/exercise/2014/01/29/01-character-input.html
01 character input
input, strings, types, int
ask user to enter name and age
print msg telling them year they will turn 100
'''
name = input('Please enter your name: ')
age = int(input('Please enter your age: '))
had_birt... |
e5a67cad45cc8b27bed5a7b10fa345095d8f4668 | anastasia21112/Python_Work | /Python Crash Course/Chapter 1/favorite_number.py | 182 | 3.703125 | 4 | #Anastasia Dunca
#April 28, 2020
#This is a program that practices incorporating an integer in a String
favorite_number = 8
message = f"My favorite number is {favorite_number}"
print(message) |
f5fcf403b2e89e6a51a5f966528dc965e9ac3851 | Nurtal/CRYPT | /chiffre.py | 1,598 | 3.984375 | 4 | """
python 2
"""
from Crypto.Cipher import Blowfish
INPUT_SIZE = 8
def pad_string(str):
"""
encrypt string
"""
new_str = str
pad_chars = INPUT_SIZE - (len(str) % INPUT_SIZE)
if pad_chars != 0:
for x in range(pad_chars):
new_str += " "
return new_str
def encryptFile(key, fileName):
"""
encrypt text... |
a53cd571e26d4ef0e535db1353c81577fe64cbf2 | sakurasakura1996/Leetcode | /leetcode_二刷hot100/problem141_环形链表.py | 1,311 | 3.71875 | 4 | class ListNode:
def __init__(self, x):
self.val = x
self.next = None
# 进阶要求:使用O(1)内存来解决此问题
class Solution:
def hasCycle(self, head: ListNode) -> bool:
nodeSet = set()
if not head:
return False
while head:
if head not in nodeSet:
no... |
f5feab83602de8afacb348ce7d40a3f7958b0620 | Ideaboy/MyLearnRecord | /advance_features/custom_class.py | 935 | 3.5 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# 2018-12-4 11:33:18
# 类的属性动态处理设计
# 链式调用
class Chain(object):
def __init__(self, path=''):
self._path = path
def __getattr__(self, path):
return Chain("%s/%s" % (self._path, path))
def __str__(self):
return self._path
__repr__ = __... |
eaef2307413551fdac124cc7eea40b43781ea10b | eleruben/Takagi | /python/Ejemplos/variables.py | 1,311 | 3.984375 | 4 | # -*- coding: utf-8 -*-
mi_variable = 12
MI_CONSTANTE = 25
print mi_variable
mi_cadena = "Hola mundo"
print mi_cadena
mi_cadena_multilinea = """Esta es una cadena
que contiene muchas líneas
también imprime acentos.
"""
print mi_cadena_multilinea
edad = 35
edad2 = 035
edad3 = 0x35
edad4 = 35.2
print edad
print edad2
... |
0a9e36a10c9081fdfe062ba379b72fc4f103f438 | christophertbrown/bioscripts | /ctbBio/rc.py | 1,223 | 3.828125 | 4 | #!/usr/bin/env python3
"""
script for getting the reverse complement of a nucleotide sequence
"""
import sys
import os
from ctbBio.fasta import iterate_fasta as parse_fasta
rc = {'A': 'T', \
'T': 'A', \
'G': 'C', \
'C': 'G', \
'N': 'N', \
'a': 't', \
't': 'a', \
'g': 'c', \
... |
8268572a144e4906863439536640e56f7ee3dda3 | venus698/assignment2 | /area of circle.py | 121 | 4.125 | 4 | b=float(input("enter the radius of circle: "))
pie = 3.14
area= pie * b * b
print("Area of the circle is : %.2f" %area)
|
18e7504a0719f33f3458756ea6472f47193296c1 | H8to-jp/atcoder-easy-problems | /ABC162(A,B,C)/A.py | 160 | 3.75 | 4 | n = int(input())
hundred = n // 100
b = n % 100
ten = b // 10
one = b % 10
if hundred == 7 or ten == 7 or one == 7:
print('Yes')
else:
print('No')
|
3894f7dd5c67a567dbc16d0ce3d354e9993ba042 | indrajitrdas/Simple-Programs | /BinarySearchTree2.py | 6,016 | 3.84375 | 4 | # BST
class node:
def __init__(self, value):
self.value = value
self.rightchild = None
self.leftchild = None
class BinarySearchTree:
def __init__(self):
self.root = None
def insert(self, value):
if self.root is None:
... |
85bdb20c063b623b3ba8b576096318804c70b212 | sakar123/Python-Assignments | /Question24.py | 261 | 4.3125 | 4 | """24. Write a Python program to clone or copy a list."""
def clone_list(given_list):
new_list = []
for i in given_list:
new_list.append(i)
return new_list
print(clone_list([1, 2, 3, 4, 5]))
print(clone_list([(1, 2), ('hello', 'ji')]))
|
cecfd73944ae6a5054ee485d278bab9ba180978f | francescadamico/cracking_the_code_interview | /Chapter8_recursion/TripleStep.py | 566 | 4.34375 | 4 | '''
A child is running up a staircase with n steps and can hop either 1, 2 or 3 steps at a time. Implement a method to count how many possible ways the child can run up the stairs.
'''
steps_sum = {}
def ways_climb_steps(n):
if n == 0:
steps_sum[0] = 0
elif n == 1:
steps_sum[1] = 1
elif n == 2:
... |
c61904755e70790d05e71d271e0d4e2f1004030f | saurabh190802/septocode | /Day 3/SaurabhSatapathy_day3.py | 190 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Sep 23 10:01:14 2021
@author: saurabh satapathy
"""
L = list(map(int, input().strip().split(','))) #taking input
print(*L, sep="\n") #printing line by line |
76dd68371cc81e9e3e16084a6076ca26706e0d1c | lingxinglovecode/git_test | /设计问题与数学/Math_problems.py | 3,629 | 4.0625 | 4 | import math
import re
class Math:
##1.计数质数
#统计所有小于非负整数 n 的质数的数量。
def isPrimes(self,num):
if num == 0 or num == 1:
return False
if num == 2:
return True
for i in range(2, num):
if num % i != 0:
continue
return False
... |
8d14f764ebd46d53f6ddc5e527765d132ed92fca | Diogogrosario/FEUP-FPRO | /RE02/cast.py | 84 | 3.578125 | 4 | m = input("Enter number: ")
n=int(m)
nn= n*10 + n
nnn=n*100 + nn
print(n+nn+nnn)
|
fd6d871a3e14c68d58a97a33203e8e4de9462414 | Jiawei-Wang/LeetCode-Study | /2. Add Two Numbers.py | 2,179 | 3.890625 | 4 | # Definition for singly-linked list.
# class ListNode: # python class: https://www.w3schools.com/python/python_classes.asp
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
# 三个答案:相同逻辑,不同语法
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode ,c = 0... |
5bdcdbc9040e8db0d750952fbd3d7d6959851368 | Shabarish1346/PythonLearn | /Week 2/YoungerPerson.py | 278 | 3.6875 | 4 | name1 = str(input())
dob1 = str(input())
name2 = str(input())
dob2 = str(input())
if (int(dob1[6:10]) == int(dob2[6:10])):
if(name1<name2):
print(name1)
else:
print(name2)
elif (int(dob1[6:10]) > int(dob2[6:10])):
print(name1)
else:
print(name2) |
6ffa2ce1cfb05f809b904c33ebf6b0ea996095a2 | dilshamony/python_django | /django-master/Regular Expression/regexp_pgm2.py | 2,003 | 4.25 | 4 | import re
pattern='[abc]'#----> thie square bracket implies either a or b or c
matcher=re.finditer(pattern,"abc _z7KA@")#this pattern is the question
for match in matcher:
print(match.start())
print(match.group())
#check lower case alphabets from a to z
import re
pattern='[a-z]'#----> thie square bracket imp... |
caf7c31cd6239c7ee09f00b520b3a33f703ab580 | Jhouteddy/python_learn | /function_basic.py | 271 | 3.9375 | 4 | # 定義函式
def multiply(n1, n2):
print(n1*n2)
return n1*n2
# 呼叫函式
value = multiply(4, 6)
print(value)
# 程式的包裝
def calculate(max):
sum = 0
for n in range(1, max+1):
sum = sum+n
print(sum)
calculate(10)
calculate(100)
|
24ea4f287c797fe37ad14f55343783f2762d683a | felipemcm3/ExerPython | /Pythonexer/ExerPython/aprendendopython/ex025.py | 131 | 3.859375 | 4 | nome = str(input('Informe seu nome completo')).strip()
print('E {} que o nome {} tem SILVA'.format('SILVA' in nome.upper(), nome))
|
20ffb36fd1bcc475256c54cd8c2830429720869a | pydjamolpomaji/Python_Tutorials | /Constructor-Program-Account-Transaction-Program.py | 2,391 | 4.1875 | 4 | # Program 1 :-
# First Constructor Program in Python
class Test:
def __init__(self, a, b):
self.a = a
self.b = b
return
def display(self):
print('A value is :', self.a)
print('B value is :', self.b)
return
def main():
t1 = Test(10, 20)
t2 = T... |
c637cbea9b4da0b7608c44d7614df3fcc7acf3e6 | jasminekaur-prog/timetable-management-in-python | /viewsubjects.py | 1,749 | 3.828125 | 4 | from tkinter import *
import sqlite3
from tkinter.messagebox import showinfo
from tkinter.ttk import *
class demo:
def showdata(self):
self.t1.delete(*self.t1.get_children())
s="select * from subjects where degreename='"+self.cb1.get()+"' and semester="+self.cb2.get()
self.cr.execute(s)
... |
aa95b753dc99701a062f507845c7913ff56b0708 | Kronos2408/ANACONDA | /arofcir.py | 193 | 4.40625 | 4 | #python program to find area of circle using radius
pi=22/7
radius = float(input('ENTER THE RADIUS OF A CIRCLE'))
area = pi*radius*radius
print("Area of circle using given radius = %.2f" %area) |
6ae865688d3a6a23ac29fc9c7244c952a1d36308 | ShaneyMantri/Algorithms | /Trees/Sum _of_Root_To_Leaf_Binary_Numbers.py | 1,002 | 4 | 4 | """
Given a binary tree, each node has value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit.
For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could represent 01101 in binary, which is 13.
For all leaves in the tree, consider the numbers represented by th... |
02ed84cfaeb3b8487b43e92bffa88e77233264e8 | Koutarouu/MyLeetcode | /MergeSortedArray.py | 1,441 | 3.703125 | 4 | class Solution:
def merge(self, nums1: list, m: int, nums2: list, n: int) -> None:
"""
Do not return anything, modify nums1 in-place instead.
"""
if nums1 == [] or nums2 == []: return
nums1[:] = [nums1[i] for i in range(m)]+nums2
nums1.sort()
return nu... |
caaf4bee54f7ffeb2f703e952055798e143a3ab4 | keivalya/LP3HW | /ex13.py | 536 | 3.640625 | 4 | from sys import argv
# read WYSS section for how to run this
script, first, second, third = argv
print("The script is called:", script)
print("The first variable is:", first)
print("The second variable is:", second)
print("The third variable is:", third)
# What you should see
# WARNING! Pay attention! You... |
30404cbc745f26bee2b271123fae0e92a23fb40c | paner-xu/python-learning-code | /04高级数据类型/xp_01_列表基本使用.py | 1,039 | 4.3125 | 4 | name_list = ["zhangsan", "lisi", "wangwu"]
# 1.取值和取索引
print(name_list[0])
# 知道数据内容,想知道数据在列表中的位置
# 使用index需要注意,如果传递的数据不在列表内,程序会报错!
print(name_list.index("zhangsan"))
# 2.修改
name_list[1] = "李四"
# list assignment index out of range
# 列表指定的索引超出范围,程序会报错!
# name_list[3] = "李四"
# 3.增加
# append用于在列表末尾追加数据
name_list.append("王... |
cd695e20e9a50084d4004d399e7d76365933a11b | LachezarKostov/SoftUni | /02_Python-Advanced/03_Multidimention Lists/02-Exercise/08-Knight Game.py | 2,262 | 3.515625 | 4 | n = int(input())
matrix = []
i_knight, j_knight = 0, 0
K_count = 0
counter = 0
possible_moves = [
(-2, -1),
(-2, 1),
(-1, 2),
(-1, -2),
(1, -2),
(1, 2),
(2, -1),
(2, 1)
]
def index_validate(matrix_length, number):
if -1 < number < matrix_length:
return True
return False... |
d8ff8525d6d5046e2c7da3cf4d4bb012baa1f131 | SOFIAshyn/BaseProgramming_course_Basic_Python | /lab_12/Petryshyn_Sofiia_flatten.py | 455 | 3.75 | 4 | def flatten(lst):
"""
(list) -> list
Return list without inside lists
>>> flatten([1,[2]])
[1, 2]
"""
new_lst = []
if isinstance(lst, list):
for el in lst:
if isinstance(el, list):
new_lst.extend(flatten(el))
else:
new_lst... |
cf921d9a6a79067bdb1980c965b48e9269b8e5cb | KiKi-Gao123/Python-search-words | /Python自学代码集合/列表推导式.py | 427 | 4.21875 | 4 | #打印0,1,2,3,4,5,6,7,8,9
#常规方法
list1=[]
i=0
while i < 10:
list1.append(i)
i=i+1
print(list1)
#列表推导式
list2=[]
j=0
list2=[ j for j in range(10)]
print(list2)
#打印[(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)]
#常规方法
list3=[]
for k in range(1,3):
for m in range(3):
list3.append((k,m))
print(list3)
#列表推导式
list... |
e426dc4133c84459800cc0705cbc2e866acbbef5 | lixiang2017/leetcode | /problems/0989.0_Add_to_Array-Form_of_Integer.py | 765 | 3.609375 | 4 | #! /usr/local/bin/python3
class Solution(object):
def addToArrayForm(self, A, K):
"""
:type A: List[int]
:type K: int
:rtype: List[int]
"""
A_str = ''.join([n for n in str(A) if n.isdigit()])
A_int = int(A_str)
sum = A_int + K
return [int(c) f... |
1e26b582441ad129129ff8cbc23fe8b61db8cc39 | nakanishi-akitaka/python2018_backup | /1019/python_list_comprehension.py | 1,653 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
https://note.nkmk.me/python-list-comprehension/
Created on Fri Oct 19 12:11:24 2018
@author: Akitaka
"""
squares = [i**2 for i in range(5)]
print(squares)
squares = []
for i in range(5):
squares.append(i**2)
print(squares)
#%%
odds = [i for i in range(10) if i % 2 =... |
284782454e6e10599a53d9b7642769e8fb0c094a | hawk-praxs/exercism | /python/hello-world/hello_world.py | 488 | 3.65625 | 4 | '''
The classical introductory exercise. Just say "Hello, World!".
"Hello, World!" is the traditional first program for beginning programming in
a new language or environment.
The objectives are simple:
Write a function that returns the string "Hello, World!".
Run the test suite and make sure that it succeeds.
Submi... |
24a599fb4fa7dcf2a5fe305b6a0905429dc2d195 | ramlingamahesh/python_programs | /conditionsandloops/GCDorHCF.py | 779 | 4.125 | 4 | '''n1 = 48
n2 = 36
# find smaller
if (n1 > n2):
smaller = n2
else:
smaller = n1
# getting hcf
i = 1
while (i <= smaller):
if (n1 % i == 0 and n2 % i == 0):
hcf = i
i = i + 1
print("hcf = ", hcf)'''
# Method 2: Using Recursion
'''
def find_hcf(n1, n2):
if (n2 == 0):
return n1
... |
d957b8d292c627ddf866635e90535ea65ed4c1c0 | regisb/project-euler | /src/eratosthenes.py | 3,738 | 3.984375 | 4 | from math import sqrt
MAX_VALUE = 10000000
def init(max_value):
global MAX_VALUE
MAX_VALUE = max_value
PRIMALITY_SIEVE = None
def _init_primality_sieve():
global PRIMALITY_SIEVE
PRIMALITY_SIEVE = [True] * (MAX_VALUE + 1)
PRIMALITY_SIEVE[0] = False
PRIMALITY_SIEVE[1] = False
number = 2
... |
a6c7b89d83765ca50872aa09feebfd8006c40206 | songwei163/python_codehub | /StudentsSystem/StudentsSystem.py | 9,634 | 3.890625 | 4 | import os
filename = 'Students.txt'
def main():
while True:
menu()
choice = int(input('请选择:'))
if choice in range(0, 8):
if choice == 0:
answer = input('您确定要退出系统吗?(y/n):')
if answer == 'y' or answer == 'Y':
print... |
e2c0d0594ba1e160ef856b67ee5c1040af53ecbd | danladisagir/pythonProject6yh | /main.py | 2,781 | 3.859375 | 4 | # School Management program
# to accept student data and subjects offered in a nursary and primary school setting
import pickle
# 1. student data
stddata = {}
def stddet():
admno = input('admission number')
name = input('studenet name')
clas = input('class admitted to')
datebirth = input('date of bir... |
34baa78fc88c25e706f96f459be04354a30a3fcf | abhay-rana/python-tutorials. | /python tutorials/oops exercise.py | 805 | 4.03125 | 4 | #make a laptop class in which u have to mention brand_name,model_name,price
#and u have to give the discount on the given amount
#and show the price after the discounted amount
class laptop:
def __init__ (self,model,price,brand):
self.brand=brand
self.price=price
self.model=model
def di... |
a0087e53504d881a9cfcc0a0aa1523a3b8c53d0c | Dallas-Hays/TLEN-5410 | /hws/hw5/ch8.py | 1,016 | 4.25 | 4 | """ Dallas Hays
2/16/15
Homework 1
Exercise 8.1, 8.12
"""
# Exercise 8.1
# Prints the string in reverse, one letter per line
# I tried to not use a for loop or the reverse method because I don't
# think they wanted you to at this point of the book
def reverse_letters(word):
index = len(word) - 1
wh... |
b1dd96f1eeb8a1345932ac5edde5ce112578010b | hgupta7557/PythonNetwork | /MinMaxfromArray.py | 441 | 4 | 4 | list=[]
long=int(input("Enter the value of index : "))
for i in range(0,long):
print("Enter the value : ", i)
value=int(input())
list.append(value)
print(list)
min_element=list[0]
max_element=list[0]
for j in range(len(list)):
if list[j] < min_element:
min_element = list[j]
for k in ... |
1f9f5725dfff7650d881ed9ef1662a9789e9bb03 | yangzongwu/leetcode | /20200215Python-China/0319. Bulb Switcher.py | 1,285 | 4.03125 | 4 | ### [319\. Bulb Switcher](https://leetcode.com/problems/bulb-switcher/)
Difficulty: **Medium**
There are _n_ bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the... |
4157dd9290b650d5d1ef6ec73d32c4897a9d4e6a | aseemchopra25/Integer-Sequences | /Perrin Numbers/Perrin_Sequence.py | 676 | 4.15625 | 4 | ###############################
### Perrin Sequence ###
###############################
# Perrin Sequence Explanation
# P(n) = P(n−2) + P(n−3) for n ≥ 3, with P(0) = 3, P(1) = 0, P(2) = 2.
# Example : {3, 0, 2, 3, 2, 5, 5, 7, 10, 12, ...}
def Perrin_Seq(n):
first = 3
second = 0
third = 2
if n... |
97e39e1e65729a3a28e186af0864ab1208d1fbd5 | lordwayden/python__random_code | /remove_duplicate_values_from_list.py | 109 | 3.859375 | 4 | a = [3, 2, 5, 3, 9, 2, 9]
b = []
[b.append(x) for x in a if x not in b]
print(b)
c = set(a)
print(c) |
bf033e2cb935411417fee09ee703dd6d0fd1f8ec | xialuchao/zo | /test/Fib.py | 709 | 3.71875 | 4 | # def fab(max):
# n,a,b=0,1,1
# fib = []
# while n<max:
# fib.append(b)
# a,b = b, a+b
# n = n+1
# print(fib)
# return fib
# fab(5)
# class Fab:
# def __init__(self, max):
# self._max = max
# self.n,self.a,self.b = 0,0,1
#
# def __iter__(self):
# ... |
bc62282b778499ed3dc8adbb9a9d47d37ee06b88 | csoriano2832/holberton-system_engineering-devops | /0x16-api_advanced/2-recurse.py | 1,071 | 3.53125 | 4 | #!/usr/bin/python3
"""
This module defines the following function:
recurse(subreddit, hot_list=[])
"""
import requests
def recurse(subreddit, hot_list=[], next_page=None):
"""
Queries the Reddit API and returns a list containing the titles of all
hot articles for a given subreddit. If no results are f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.