blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
8dca2ad23efa6a399aad51eaae166ad4572be487 | INKGROUP/python | /bmr2.py | 682 | 3.96875 | 4 | """
author:nick
"""
def main():
y_or_n = input("quit?(Y/N): ")
while y_or_n != "Y":
gender = input("sexy: ")
wight = float(input("weight:(kg) "))
height = float(input("height:(cm) "))
age = int(input("age: "))
if gender == "男":
bmr = 13.7 * wight + 5.9 *... |
5e756d8e70a248a7e0db43791bafb98ee79c5e36 | sergeymokhin/python | /read4.py | 422 | 3.75 | 4 | a = input() # исходный
b = input() # зашифрованный
c = input() # эту зашифровать
d = input() # эту расшифровать
f = dict(zip(a,b))
for i in c:
if i in f.keys():
print(f[i], end='')
inv_f = {value: key for key, value in f.items()}
print(f)
print(inv_f)
'''
for j in d:
if j in f.values():
print(f.get(key[default]),... |
1f41e72e8502499c6b60319ac45cb97fc80649fc | 1109israel/AprendiendoGit | /RubenVg/autogridr/main(palindromo).py | 616 | 4.1875 | 4 | #Un palíndromo es una palabra o una frase que se lee igual al derecho y al revés, por ejemplo "anita lava la tina".
#Tú tarea crea un programa que recibe una frase como entrada (esto está automatizado gracias a AutoGradr) y determina si esta frase es un palíndromo.
frase = input('')
mifr = frase.lower()#lower sirve par... |
480204970713e0ed458b5c3e81704e655bbfba16 | mwnickerson/python-crash-course | /chapter_7/movie_tickets_vers2.py | 632 | 4 | 4 | # movie tickets vers 2
# chapter 7 exercise 6
# ask for age and assign ticket price with a conditional loop
prompt = "\nHow old are you?"
prompt += "\n(enter 'quit' when finished)"
message = ""
while message != 'quit':
message = input(prompt)
if message != 'quit':
message = int(message)
customer... |
4e17a085fd4af625d00e49896d4eb467bad36dc8 | Liyang-butcher/pywork | /liuyun/lianxi.py | 4,478 | 3.546875 | 4 | # print("xixi ",end="")
# print(23333,2.33,(),[],{})
# print("xixi"+"haha")
# print(233+322)
# name = "李四"
# print(name)
# res = (1+10%3+10/5+1*3)
# print(res)
#
# a = input("请输入: ")
# print("刚才输入的值: ",a)
# res = (2**4)
# print(res)
# a = input()
# print(type(a))
# a = input("请输入: ")
# b = input("请输入: ")
# print("... |
92380f374434d5b94a0a0b7979647f3366cd15f8 | Haruka0522/AtCoder | /PAST/201912-A.py | 136 | 3.625 | 4 | def small_letters():
return [chr(i) for i in range(97, 97+26)]
S = str(input())
try:
print(int(S)*2)
except:
print("error")
|
8caed403ebe86100809ed73e265f42f4b9e99a60 | Guilherme2020/ADS | /Algoritmos 2016-1/1-lista(professor_fabio)/17.py | 333 | 3.84375 | 4 | '''
Leia o valor da base e altura de um retangulo, calcule e escreva sua area. (area = base * altura)
'''
base = float(input(" Digite o valor da base do retangulo: "))
altura = float(input("Digite o valor da altura do retangulo: "))
area_retangulo = base*altura
print("O valor da area do retangulo eh %.2f"%(area_... |
5b882632aabbed545b172024d526fc3be8566f01 | jxhangithub/leetcode | /solutions/python3/2.py | 517 | 3.75 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
left = 0
dummy = cur = ListNode(-1)
while l1 or l2 or left:
left... |
c09bc191dd754fa3d0079a593216998c9e10fd89 | loganpassi/Python | /Algorithms and Data Structures/HW/HW2/PP/findRecursion.py | 1,776 | 3.953125 | 4 | #Logan Passi
#09/19/19
#findRecursion.py
#Implement a recursive function with signature find(path, filename) that
#reports all entries of the file system rooted at the given path having the
#given file name.
import os
def find(path, fName):
if path == "":
return
for entry in os.listd... |
148270571abf0de9662eecceb994be1f8216574c | seyidaniels/data-structures-practice | /graph/breath_first_search.py | 2,084 | 3.6875 | 4 | class Vertex:
def __init__(self, n):
self.name = n
self.neighbours = list()
self.distance = 9999
self.color = 'black'
def addNeighbour(self, neighbourName):
if neighbourName not in self.neighbours:
self.neighbours.append(neighbourName)
self.neighb... |
a9500ab85b85be4c32b9909d2f1dcc707f78cce3 | vigneshpr/sample | /inheri.py | 1,733 | 3.953125 | 4 | class calculate():
result = 0
def add(self,num1,num2):
self.result = num1+num2
return self.result
def sub(self,num1,num2):
self.result=num1-num2
return self.result
def mul(self,num1,num2):
self.result = num1*num2
return self.result
def div(self,num1,num2):
self.result = num1/num2
return self.... |
b18d6973c9671e9b8e38231079772507a7b51760 | mumughal/python-stuff | /task2.py | 770 | 3.78125 | 4 | def check_number_ascending(number):
number_list = [int(x) for x in str(number_list)]
if sorted(number_list) == number_list:
return True
def last_number_by_peter(number):
number_list = [int(x) for x in str(number)]
flag = True
last_number = number
while flag:
if sorted(number... |
7e655c51d38931f7bbe9a89f2eec0e36038ffdc1 | sanjibsinha/discretemathsdatastructures | /PythonDiscrete/ArrayExamples/MaximizeMedian.py | 1,786 | 3.8125 | 4 | # Python 3.6 manipulation of an array so that the median is maximized
def getMaximizedMedian(arrayToManipulate, lengthOfTheArray):
# when size of the array is even
if lengthOfTheArray % 2 == 0:
# find 1st maximum element
maxElement1 = arrayToManipulate.index(max(arrayToManipulate))
# ... |
c34e7750947c68e3ebb69ab28e7059121246ef6a | aadiupadhyay/CodeForces | /codeforces/520/A.py | 151 | 3.671875 | 4 | def solve():
n=int(input())
s=input().lower()
s=set(s)
if len(s)==26:
print("YES")
else:
print("NO")
solve()
|
aad3d5f142e06ba7178eb6c8acc3a1d15ba0ea09 | xhom/py-demos | /src/003运算符.py | 2,458 | 4.21875 | 4 | # coding=UTF-8
def computeResult(x, y, op):
result = ""
if op == "+":
result = x + y
elif op == "-":
result = x - y
elif op == "*":
result = x * y
elif op == "/":
result = x / y
elif op == "%":
result = x % y
elif op == "**":
result = x ** y
... |
4eb8a931d55c034113b5ef7fa2b2adce5a5b2ade | rafaelperazzo/programacao-web | /moodledata/vpl_data/199/usersdata/273/81755/submittedfiles/al14.py | 189 | 3.78125 | 4 | # -*- coding: utf-8 -*-
n=int(input('Digite o valor de n: '))
soma=0
i=n
while(n>0):
a=int(input('Digite o valor da idade: '))
soma=soma+a
n=n-1
print('%.2f'% soma/i)
|
f0ee6b89b44cb5020f0873bcfc40b4e8cb6d3bf9 | rodya-mirov/advent-of-code-2017 | /days/advent11.py | 5,130 | 3.78125 | 4 | """ Do Advent of Code 2017, Day 11 """
import unittest
def advent_11a(file_name):
""" Do the full flow for day 11a """
with open(file_name) as input_file:
steps = [token for token in input_file.readline().strip().split(',')]
return distance_to_origin(steps)
def advent_11b(file_name):
""" D... |
f516c8b9f3f32e0f1a094a3f1076ad0bf906a08b | vikiten10/Python-file-organizer | /gui.py | 773 | 3.53125 | 4 | import tkinter
import mover
from tkinter import filedialog
def folder_selector():
selcted_path = filedialog.askdirectory(initialdir=initial_directory,title="Please select a file directory")
mover.main_function(selcted_path)
initial_directory = r"C:\Users\Yuga\Desktop"
caption_title = "This is a a... |
33c81dd46f8902a8b20bc9787af775ba9b3d528f | bingheimr/HaloProject1 | /jackal_class.py | 2,617 | 3.78125 | 4 | class Jackals:
"""Modeling Jackal enemies."""
def __init__(self, name, rank, type, armor_color, shield, grenade_count,
shield_strength, health_points, points, *weapon):
"""Establish the attributes of a Jackal."""
self.name = name.title()
self.rank = rank.title()
... |
93f74df8d2a9973de19ba8360ee62b1ebb82050c | behrouzmadahian/python | /pandas/11-operatingOnData.py | 4,149 | 4.125 | 4 | import numpy as np
import pandas as pd
ser = pd.Series(np.random.randint(0, 10, size=4))
print(ser)
df = pd.DataFrame(np.random.randint(0, 10, size=(3, 4)), columns=['A', 'B', 'C', 'D'])
print('If we apply a NumPy ufunc<universal function> on either of these objects, the result'
' will be another Pandas o... |
d751ca5e9da456b65fb4358be24fe4009e054943 | GrishaAdamyan/All_Exercises | /The curcumference and area of cirlce.py | 333 | 4.125 | 4 | def circle_length(radius):
pi = 3.14159
length = 2 * radius * pi
return length
print(circle_length(5))
def circle_area(radius):
pi = 3.14159
area = pi * (radius ** 2)
return area
print(circle_area(10))
def main():
radius = float(input())
print(circle_length(radius), circle_area(radi... |
824d482afa640ccc6a585136ba40c4a2d99d09c9 | pimier15/CsPy_Util_Tool | /Py/Util_Tool/Statistic_Tool/Statistic_Tool/csv_Tool.py | 912 | 3.53125 | 4 | import csv
import os
class IO_csv():
def ReadCsv(self,path):
output = []
with open(path,'rb') as f:
reader = csv.reader(f)
for row in reader:
output.append(row.split(','))
return output
def WriteCsv(self,dataList,path):
with open(... |
570c9430326dbf5f157f9a90085885856db875b8 | d1sd41n/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/1-search_replace.py | 161 | 3.96875 | 4 | #!/usr/bin/python3
def search_replace(my_list, search, replace):
n = []
for i in my_list:
n.append(replace if i == search else i)
return n
|
6f36a47eb1f9d7d79b532278a9ca24ba0189535a | ByDiego20/Diego20 | /pajarita.py | 307 | 3.984375 | 4 | def pajarita ():
filas = int(input("Filas: \n"))
filasm = filas/2
for i in range (1,filas+1):
if i <=filasm:
print ("*"*(i)+" "*((filas-2*i))+"*"*((i)))
elif i>filasm:
print("*"*((filas-i))+" "*((filas-2*(filas-i)))+"*"*((filas-i)))
pajarita()
|
9ecfcd189556a3d2c38bec654ddd7d194b3f4801 | preview1/edx | /pset6/credit.py | 2,963 | 3.859375 | 4 | def main():
print("Number: ", end = "")
while True:
cc_num = check_input(input()) # check input and assign it to cc_num
length = len(str(int(cc_num))) # get length of cc number
if cc_num != 0: # break while if check input returns valid value
... |
239e8ec2979b0e8d743b390e75352c675c7e54b7 | davenfarnham/glob | /algos/i/b/trie/fast_trie.py | 1,350 | 3.890625 | 4 | # implementation a trie with dicts; almost x7 faster than list implementation
def augment(trie, index):
addition = {}
trie[index] = addition
return trie
def add(word, trie):
original = trie
for char in word:
index = ord(char) - 97
# don't need to place actual char into trie; let ind... |
73bdaa82297e58ea315eb5775f10c925a09d6965 | Megasteel32/learnpython_practice | /exercise1_characterinput.py | 378 | 3.953125 | 4 | from datetime import *
current_year = int(date.today().strftime("%Y"))
name, age = input("What is your name and age? ").split()
age = int(age)
message = f"Howdy, {name}! You will turn 100 years old in the year {current_year + 100 - age}"
print(message)
repetitions = int(input("How many times would you like to repeat th... |
2820c4f6a22a0386dfc9d2edef68dced34889c62 | arpitdixit445/Leetcode-30-day-challenge | /Day_20__Construct_Binary_Search_Tree_from_Preorder_Traversal.py | 1,683 | 4.03125 | 4 | '''
Problem Statement ->
Return the root node of a binary search tree that
matches the given preorder traversal.
(Recall that a binary search tree is a binary tree
where for every node, any descendant of node.left
has a value < node.val, and any descendant... |
0187cb1197affad707e0dc7c6d2a482069a7d0e0 | omarafifii/bikeshare-2 | /bikeshare_2.py | 8,660 | 4.375 | 4 | import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_filters():
"""
Asks user to specify a city, month, and day to analyze.
Returns:
(str) city - name ... |
780995e45ab2ef26efabe0e50307c7481eb4c0c8 | aakash525/orbitdeterminator | /orbitdeterminator/kep_determination/gibbsMethod.py | 9,043 | 3.984375 | 4 | '''
Converts a set of three psoition vectors into state vector using Gibb's method
from which orbital elements can be found easily.
'''
import sys
import os.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
import numpy as np
import math
import re
sqrt = np.sqrt
pi = np.p... |
1045885afe55b7fef348512bac042464bf29a960 | BeemerCodes/Estudos-de-Python | /Guanabara/Desafio - seno, cosseno e tangente.py | 320 | 3.890625 | 4 | from math import cos,tan,sin,radians
n1 = float(input('Qual anulo: '))
s = sin(radians(n1))
print('O ângulo de {} tem o Seno {:.2f}'.format(n1, s))
c = cos(radians(n1))
print('O ângulo de {} tem o Cosseno {:.2f}'.format(n1, c))
t = tan(radians(n1))
print('O ângulo de {} tem a Tangente {:.2f}'.format(n1, t))
|
4d3922f80bb305a9859017c5ae6e3d8ee45a2269 | woyaonidsh/software_project | /step3-4/step3.py | 8,267 | 3.5 | 4 | import time
import re
from collections import Counter
import os
class Count:
def __init__(self, n, stopName, verbName, k):
self.letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z']
self.... |
0c1d9054f01c4ecbcb61bfccc925de29bb6c32bc | Jaime885/cti110 | /M3T1_AreasOfRectangles_JaimeRodriguezmiller.py | 400 | 4.21875 | 4 | #CTI-110
#M3T1-Areas Of Rectangles
#Jaime Rodriguezmiller
# cti 110
#Septemeber 24, 2017
def main():
print ("This program will calculate the area " + \
"of a rectangle.")
width = int(input("Enter the width: "))
height = int(input("Enter the height: "))
# A = W * H
ar... |
12dc8ce39723b34eb1eb0d803a1761e512e376df | us0173ol/milesdb | /mileage.py | 2,658 | 3.90625 | 4 | import sqlite3
db_url = 'mileage.db' # Assumes the table miles have already been created.
"""
Before running this test, create test_miles.db
Create expected miles table
create table miles (vehicle text, total_miles float);
"""
class MileageError(Exception):
pass
def create_table_miles():
c... |
fdd1632ac719b9953d6ea517f39666322bb9c1bb | matcianfa/playground-X1rXTswJ | /python-project/Variables_et_fonctions/Programme_calcul3_Correction.py | 357 | 3.65625 | 4 | def mon_programme(n):
#Ne pas toucher ce qui précède
#Les valeurs pour les variables en entrée seront automatiquement données
#Ecrire ci-dessous en n'oubliant pas d'indenter
pass
a = 2 * n
print(a)
a += 5
print(a)
b = n**2
print(b)
a, b = b, a
print(a,b)
a, b = 3*a ... |
29adb017d80760e727ece4c0d361daf88f32cb39 | rajeshk7/Retiming_Using_ML | /dist_model_1.py | 1,237 | 3.65625 | 4 | import math
import re
from collections import Counter
# regular expression
# \w matches any alphanumeric character and the underscore
# + causes the RE to match 1 or more repetitions of the preceding RE
WORD = re.compile(r'\w+')
def textToVector(text):
words = WORD.findall(text)
# unordered collection where ... |
3b268fa472045a668520db4492a6e357cd23c292 | rayjiang2013/CareerCup | /CareerCup/anagrams_checker_1_4.py | 1,305 | 3.53125 | 4 | '''
Created on Sep 23, 2015
@author: ljiang
'''
from __builtin__ import True
def check_anagram(st1, st2):
st1, st2 = list(st1), list(st2)
if len(st1) != len(st2):
return False
x=0
while x < len(st1):
if st1[x] in st2:
del st2[st2.index(st1[x])]
del st1[x]
... |
8dc86cf876439a42f13eff2a0f172cc13ad891e9 | nildiert/holbertonschool-higher_level_programming | /0x03-python-data_structures/7-add_tuple.py | 536 | 3.765625 | 4 | #!/usr/bin/python3
def add_tuple(tuple_a=(), tuple_b=()):
new_tuple = (0, 0)
if (tuple_a == ()):
tuple_a = new_tuple
if (tuple_b == ()):
tuple_b = new_tuple
if len(tuple_a) is 1:
tuple_a = (new_tuple[0] + tuple_a[0], new_tuple[1])
... |
e8f2c1cf884317ae4d876e85aea642d5c2cc51c8 | jayohhhh/IntroToProg-Python | /Assigment05_Starter.py | 4,868 | 3.859375 | 4 | # ------------------------------------------------------------------------ #
# Title: Assignment 05
# Description: Working with Dictionaries and Files
# When the program starts, load each "row" of data
# in "ToDoToDoList.txt" into a python Dictionary.
# Add the each dictionar... |
6a113313dfeff7237c0aead374785ac88499f72c | arnab0000/CodingNinjas-DS | /5_sql/sqlite/sqliteStart.py | 629 | 3.53125 | 4 | import sqlite3 as sql
db = sql.connect("University.sqlite")
cur = db.cursor()
# sql_query = 'create table Student(rollno int Primary key, Name Text, Age int)'
# cur.execute(sql_query)
# cur.execute('insert into Student values(101, "Arnab", 24)')
# db.commit()
# cur.execute('insert into Student values(102, "Jyoti... |
01da994ca131afa3e8adcc1ff14e92ca5285f376 | tanmaysharma015/Tanmay-task-1 | /Task1_Tanmay.py | 657 | 4.3125 | 4 | matrix = []
interleaved_array = []
#input
no_of_arrays = int(input("Enter the number of arrays:")) #this will act as rows
length = int(input("Enter the length of a single array:")) #this will act as columns
print(" \n")
for i in range(no_of_arrays): # A for loop for row entries
a =[]
print("e... |
ad2e7f52bd7c4dd3a601a823a5f985230b9dfdda | PrettyPrinted/youtube_video_code | /2019/10/28/Python Tutorial for Beginners #1 - Printing, Input, and Variables/main.py | 280 | 4 | 4 | print('Hello World!')
#print(5 * 10)
#name = 'Pretty Printed'
name = input('Enter your name: ')
print(name)
x = input('Enter the first number: ')
y = input('Enter the second number: ')
#print(int(x) * int(y))
z = int(x) * int(y)
print(f'The result of { x } * { y } = { z }') |
9f41d21af7eac358a1edf6336d40b61b343c67f5 | bajun/checkiotasks | /speechmodule.py | 1,449 | 3.671875 | 4 | FIRST_TEN = ["one", "two", "three", "four", "five", "six", "seven",
"eight", "nine"]
SECOND_TEN = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen"]
OTHER_TENS = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy",
... |
240402162613a41e7a0637916156d06f8db01892 | pratapbhanusolanki/3D | /Experiment/stepper_test.py | 424 | 3.546875 | 4 | from stepper import Stepper
import stepper
global ReceiverStepper
print 'Choose one of the following steppers: \n1.Base \n2.Receiver'
input = raw_input(">> ")
if int(input) ==1:
Stepper = Stepper(7,6,2,'full_step')
else:
Stepper = Stepper(10,11,9,'full_step')
while(1):
print 'Enter the angle in degree to rotate the... |
5598f86ec9092bfe2c69ef18138e6d64bfd266ec | missrhea/Cryptography-and-System-Security | /multiplicativecipher.py | 1,844 | 3.828125 | 4 | import fractions
import collections
# Resource : http://www.nku.edu/~christensen/section%206%20multiplicative%20ciphers.pdf
def findModInverse(a, m):
#if gcd(a, m) != 1:
# return None # no mod inverse exists if a & m aren't relatively prime
u1, u2, u3 = 1, 0, a
v1, v2, v3 = 0, 1, m
while v3 != ... |
4a598a6c36e8ef2b5e4ccbd0c719f62b4bd7eb07 | the07/Python | /Algorithms/gcd_array.py | 276 | 3.984375 | 4 | #!/bin/python3
#Python program to find the GCD of an array of numbers
def gcd(a):
result = a[0]
for i in a[1:]:
while i % result != 0:
i, result = result, i % result
return result
arr = list(map(int, input().split()))
h = gcd(arr)
print (h)
|
346b0aa9273c970f67ecae387934e987b0199032 | oldcast1e/Python | /Python Lecture/1.19/T10.py | 841 | 3.546875 | 4 | """ 임의의 자연수 n1과 n2를 입력 받고,
두 자연수를 전달 받아 두 자연수의 최대 공약수를 구하여 반환하는 함수를 작성하라.
# 호출 프로그램 (함수 호출 예시)
n1 = int(input())
n2 = int(input())
print(get_gcd(n1, n2))
[입력 예시 1]
4
6
[출력 예시 1]
2
[입력 예시 2]
15
27
[출력 예시 2]
3 """
#dsdssdsddsdsdsdsds
""" # Type or paste your code in this area
def get_gcd(n1,n2):
i = min(n1,n2)
... |
1cd904e829d51175a704b4014798bc85f46cf7cd | Harshavarthan07/gst_calculator_py | /gstcalc.py | 346 | 3.859375 | 4 | cp = float(input('Enter the cost of product: '))
CGST = float(input('Enter tax % imposed by centre, i.e. CGST: '))
SGST = float(input('Enter tax % imposed by state, i.e. SGST: '))
total = 0
Amount_CGST = ((CGST/100) * cp)
Amount_SGST = ((SGST/100) * cp)
total = cp + Amount_CGST + Amount_SGST
print(f'Total cost o... |
26c0dff3a9025bd52f1ae3cafc22b6b196f41aed | Mayurg6832/Sorting-algorithms-python | /selection_sort.py | 310 | 3.640625 | 4 | def selection(arr):
for i in range(len(arr)):
min_index=i
for j in range(i+1,len(arr)):
if arr[min_index]>arr[j]:
min_index=j
arr[i],arr[min_index]=arr[min_index],arr[i]
return arr
lst=list(map(int,input().split()))
print(selection(lst))
|
48bbaaef55601a90ca184cee0e4dc8a61c63e13f | jackfo/algorithm | /cfyd/jz/base/InsertSort.py | 368 | 4.09375 | 4 | #coding:utf-8
#直接插入排序
#时间复杂度 O(n的平方)
#空间复杂度 O(1)
class Solution:
def insert_sort(array):
for i in range(len(array)):
for j in range(i):
if array[i] < array[j]:
array.insert(j,array.pop(i))
return array
print insert_sort([1,0])
print eval("1... |
8517ed1b3e59cdbced81005f0082c14e29236019 | cpingor/leetcode | /113.路径总和-ii.py | 918 | 3.625 | 4 | #
# @lc app=leetcode.cn id=113 lang=python3
#
# [113] 路径总和 II
#
# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def pathSum(self, root: Tr... |
7900c13a9a8087d5d6a42fe83cb803c2048c4323 | HecFranco/course_python | /01_Basic/Examples/06_Exercise.py | 446 | 3.78125 | 4 | n = 0
while n < 10: # while = mientras
if (n % 2) == 0: # if = si (de condicion)
print(n,'es un número par')
else: # else = sino (def condicion)
print(n,'es un número impar')
n = n + 1
# 0 es un número par
# 1 es un número impar
# 2 es un número par
# 3 es un número impar
# 4 es un número ... |
f0d96c70ffb627c79d098289d50640df9920d387 | sraisty/code_challenges | /zero-matrix/zeromatrix.py | 1,589 | 4.21875 | 4 | """Given an NxM matrix, if a cell is zero, set entire row and column to zeroes.
A matrix without zeroes doesn't change:
>>> zero_matrix([[1, 2 ,3], [4, 5, 6], [7, 8, 9]])
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
But if there's a zero, zero both that row and column:
>>> zero_matrix([[1, 0, 3], [4, 5, 6], [7, 8,... |
a0a502f0c4e8597c5b5e90e8e741dbf5b5cc2d1b | soumyajit4419/Emotion-Recognition-from-Psychological-Signals | /Wavelet/wavelet_transform_std.py | 637 | 3.5 | 4 | import pandas as pd
import numpy as np
import pywt
def applyWavelet(col):
"""
Parameter:
col: Channel for which wavelet is applied
Output:
f_bands: list of frequency band from a channel
"""
f_bands = []
cA5, cD5, cD4, cD3, cD2, cD1 = pywt.wavedec(
df[i], wavelet="db4",... |
f6117008f37c2858b49059f93a5ada75df2fc5aa | Sharim-Spartan/Lesson-5 | /Home WORK.py | 2,436 | 4.09375 | 4 | import csv
import pandas as pd
#with open are used to open the csv file
# csv means comma seperated values
#'r' means read, you can used 'w' for the purposes of writing a new or exsiting file
#as will assign the csvfile as the variable containing the data
with open('Border_Crossing_Entry_Data.csv', 'r') as csvfile:
... |
e48144ae4429d80dad3b075461e09177c206e0c5 | Isaac0liveira/AcademicProjects | /Python/Lists/sortIntervals.py | 664 | 3.5625 | 4 | def ordena_intervalos(lista_intervalos):
guarda_valor = None
for i in range(len(lista_intervalos)):
for j in range(len(lista_intervalos)):
if lista_intervalos[i][0] < lista_intervalos[j][0]:
guarda_valor = lista_intervalos[j]
lista_intervalos[j] = lista_... |
9811597a50a0f863170b67e5838412d9e2047762 | leandromarson/PythonWorks | /02 - primitive types/des01.py | 470 | 3.75 | 4 | print("-----DESAFIO 004----")
n = input('Digite algo: ')
print("Type: ", type(n))
print("Numereric: ", n.isnumeric())
print("Alpha: ", n.isalpha())
print("AlphaNum: ", n.isalnum())
print("Upper: ", n.isupper())
print("Lower: ", n.islower())
print("Printable: ", n.isprintable())
print("Digit: ", n.isdigit())
print("Titl... |
b850f2ff9f939953b6573e88ceca60d1f0514d1c | SanjanaSawant1234/python | /keyword argument function.py | 182 | 3.65625 | 4 | def printList(upper_limit,step=1):
print("upper limit:",upper_limit)
num_list=list(range(0,upper_limit,step))
print("list",num_list)
printList(upper_limit=5,step=2)
|
3c399d68e245f1d63605d2d1938c9d48eba243e8 | hcarlens/epi-python | /solution_16_1.py | 1,470 | 3.828125 | 4 | """ Count the number of score combinations """
POSSIBLE_POINTS = [7, 3, 2]
def count_number_of_combinations_slow(final_score, points_per_play=POSSIBLE_POINTS):
""" Exponential in number of differently scoring plays! """
number_of_combinations = 0
# just one type of play
if len(points_per_play) == 1:... |
680c2af3b44e55f44f0844ee39ba70fe204ad0d3 | Suiname/LearnPython | /sets.py | 620 | 4.4375 | 4 | print set("my name is Eric and Eric is my name".split())
a = set(["Jake", "John", "Eric"])
b = set(["John", "Jill"])
print "a"
print a
print "b"
print b
print "a.intersection(b)"
print a.intersection(b)
print "a.symmetric_difference(b)"
print a.symmetric_difference(b)
print "a.difference(b)"
print a.difference(b)
prin... |
9c2e90ad7b49ef9e1229e314d438f8d681b2c93e | arpita-lataye14/NESTED_LIST | /magic.py | 781 | 3.78125 | 4 |
magic_square = [
[8, 3, 4],
[1, 5, 9],
[6, 7, 2]]
i=0
while i<len(magic_square):
j=0
sum=0
while j<len(magic_square[i]):
sum=sum+magic_square[i][j]
j=j+1
print(i,'row',sum)
j=0
sum1=0
while j<len(magic_square):
sum1=sum1+magic_square[j][i]
j=j+1... |
1413c3f5685cbe2730709e612727f4ff2f9fbe32 | elsud/homework-repository | /homework8/storage.py | 1,340 | 4.0625 | 4 | from typing import Any
class KeyValueStorage:
"""It is a wrapper class for key-value storage readen from a file,
where each line is represented as key and value separated with = symbol.
If value is a number it's treated like a number, otherwise like a string.
Keys and values become accessible as colle... |
4ffacaf9ac0fa9f9da835dbbce2fe33cc386506f | Diegooualexandre/PycharmProjects | /pythonProject/desafio043.py | 495 | 3.84375 | 4 | '''
Programa que calcula o IMC
Autor: Diego L.Alexandre
Data: 10/07/2021
'''
peso = float(input('Digite o peso: '))
altura = float(input(' Digite altura: '))
imc = peso / pow(altura, 2)
if imc < 18.5:
print(f'IMC:{imc:.1f} | Abaixo do peso')
elif 18.5 <= imc < 25:
print(f'IMC:{imc:.1f} | Peso ideal'... |
ee0d2a02cbb3557edc0dcdc7583569c330b5ff00 | mahrrony/python_toturial_anis | /42_List_Comprehensions.py | 355 | 3.890625 | 4 |
'''num = [1,2,3,4,5,6,7,8,9]
result = list(map(lambda x : x*x , num))
print(result)
num = [1,2,3,4,5,6,7,8,9]
#[expression for item in list ]
result = [x*x for x in num]
print(result)
'''
num =[1,2,3,4,5]
result=list(filter(lambda x : x%2==0, num))
print(result)
num =[1,2,3,4,5]
result = [x for... |
716d35a28c48a35d09664b05d5e2422732573779 | BornRiot/Python.Udemy.Complete_Python_BootCamp | /methods_and_functions/makes_twenty.py | 362 | 3.90625 | 4 | def makes_twenty(n1,n2):
"""My attempt"""
if n1 == 20 or n2 == 20 :
return True
elif n1 + n2 == 20:
return True
else:
return False
def makes_twenty_c(n1,n2):
"""Correct answer"""
return (n1+n2)==20 or n1==20 or n2==20
print(makes_twenty(10,11))
print("This is the corre... |
5a15d172a0595061722c6b7e079cb9ce9e918c0a | AkankshaRakeshJain/CodeChef | /FLOW006_SumOfDigits.py | 153 | 3.859375 | 4 | user = int(input())
for value in range(user):
number = input()
sum = 0
for values in number:
sum += int(values)
print(sum)
|
feaa272266a1f77851d576d542bf4a20545cf2a0 | Anirban2404/LeetCodePractice | /468_validateIPAddress.py | 3,779 | 4.25 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 3 13:59:42 2019
@author: anirban-mac
"""
"""
468. Validate IP Address
Write a function to check whether an input string is a valid IPv4 address or
IPv6 address or neither.
IPv4 addresses are canonically represented in dot-decimal notation, whic... |
023ab74cbdd89266517f93f5e7af032f84630c82 | phapdv/project_euler | /pe25.py | 421 | 3.796875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from base import Problem
class Solution(Problem):
def solve(self, input_):
a = 1
b = 1
count = 2
while len(str(b)) < input_:
a, b = b, a + b
count += 1
print('Solve problem {}'.format(self.number))
... |
c3afd1bc37fb3a18332d2f5e16e0235b45b38f92 | HanifCarroll/DSA-Practice | /python/arrays/string_compression.py | 429 | 3.640625 | 4 | def compress_string(string):
if len(string) <= 1:
return string
new_string = ''
count = 0
prev_letter = string[0]
for letter in string:
if letter != prev_letter:
new_string += f'{count}{prev_letter}'
count = 0
prev_letter = letter
... |
7ccc540616f3e5e85133b0fbcc18ff2b03ecc9c9 | BiplabG/python_tutorial | /Session II/problem_1.py | 533 | 4.15625 | 4 | """Write a python program which has name, address, age and profession already set in the variables.
Then, ask user what information they want. Then, display only that information."""
name = "Biplab Gautam"
address = "Kathmandu"
age = 24
profession = "Engineer"
information = input("What do you want? \n")
if informatio... |
b3f7cc4240fd480566cb6badc80704d8181f2df0 | kliver98/Soccer_Game_Client_Server | /src/client/model/campo.py | 2,378 | 3.890625 | 4 |
class Campo():
#Constantes
LOCACION_RESOURCES = "../../../resources/"
"""Constante string que tiene la ruta basica y plana de la imagen que representa el jugador"""
IMAGEN_CAMPO = f"{LOCACION_RESOURCES}images/soccer_field"
"""Constante string que tiene el tipo de extencion de la imagen del ca... |
39e45f3f11119da8c02661bac467e72738fb1e1b | rhuidean/algorithm_codingwar | /car_park_escape.py | 477 | 3.625 | 4 | def escape(carpark):
parking_floor=len(carpark)
count=0
for floor in range(parking_floor):
if floor == parking_floor:
staircase = carpark[floor].index(1)
parking_lot = carpark[floor].index(2)
moving_space=parking_lot-staircase
case space <0
"L"+str(moving_space)
cas... |
32c2ea53519f288337aac98cbf9ea6818c517d3a | HKarpenko/Python | /wdi-han.py | 233 | 3.75 | 4 | def hanoi(wys,koll,kols,kolp):
if wys>=1:
hanoi(wys-1,koll,kolp,kols)
moveDisk(koll,kols)
hanoi(wys-1,kolp,kols,koll)
def moveDisk(fp,tp):
print("moving disk from",fp,"to",tp)
hanoi(3,"A","B","C")
|
bf21dfb4a35cc73f3f35b0ce6081644decdf6de0 | perara/failMaze | /failMaze/gym_maze/envs/maze.py | 23,951 | 3.5625 | 4 | # -*- coding: utf-8 -*-
import random
from queue import PriorityQueue
import pygame
import numpy as np
import scipy.misc
import pickle as pl
class Maze(object):
COMPASS = {
"N": (0, -1),
"E": (1, 0),
"S": (0, 1),
"W": (-1, 0)
}
def __init__(self, width=15, height=15, compl... |
12f493cd50cc2886e14dfaaa91916187954a019c | edwardsong05/competitive-programming | /concepts-learned/UnionFindNoTreeCompression.py | 1,585 | 3.65625 | 4 | # for the "Where's My Internet??" Problem on Kattis
# this problem could also be solved using sets but sets can be slow and would likely run out of time
# therefore union find should be implemented
# get number of houses and number of network cables
inp = input()
inp = inp.split()
num_houses = int(inp[0])
num_... |
bdb253c5274a351ae5378905b16b47db4b334185 | Ngulefac/Python_for_everyone | /Introduction to python programming/Hello_world.py | 203 | 3.9375 | 4 | # Welcome to my python course
# This is how you write a comment in python
import sys
print("Hello world!") #using double quotes
print('Hello world!') #using single quotes
sys.stdout.write("Hello world!") |
de92e5ddf93c0ec325fe4cd7af08fb50d67bb470 | AbeForty/Dojo-Assignments | /Python/Python Fundamentals/coinTosses.py | 552 | 3.640625 | 4 | import random
print "Starting the program..."
headCount = 0
tailsCount = 0
for i in range(1,5001):
random_num = random_num = random.randint(0,1)
if random_num == 0:
headCount+=1
print "Attempt #" + str(i) +": Throwing a coin... It's a head! ... Got " + str(headCount) + " head(s) so far and " + s... |
361c142cd8b650b15a93841727fbb302bde07e43 | brianlee1188/Alien_invasion | /settings.py | 1,112 | 3.59375 | 4 | #Setting class
class Settings():
"""Setting class to store settings for Alien_invasion"""
def __init__(self):
"""game's settings including width, height and background colour"""
self.screen_width = 1200
self.screen_height = 800
self.bg_colour = (230, 230, 230)
# reason why we put the ship speed here is t... |
dbeb8b9a2ca4b49bf9a7c9fc7e699b48e8c44f32 | cudworth/atbswp | /chapter17/resizeAndAddLogo.py | 1,689 | 3.703125 | 4 | #! /usr/bin/python3
# # resizeAndAddLogo.py - Resizes all images in current working directory to fit
# in a 300x300 square, and adds catlogo.png to the lower-right corner.
import os
from PIL import Image
SQUARE_FIT_SIZE = 300
LOGO_FILENAME = 'catlogo.png'
logoIm = Image.open(LOGO_FILENAME)
logoWidth, logoHeight = log... |
c9cc25daaa22cb51324d2ee2f96e96691bc8f0b0 | VigneshSE1/Newstuck-ArticleClusterinng | /TestFiles/test.py | 147 | 3.515625 | 4 | xx = "skdnfkjsdjfkdsjfnkjnd\nfdsdfsdfsdfsdfsd\nfsdfsdfsdf"
xx = xx.replace('\n',"")
print(xx)
if '\n' in xx:
print('yes')
else:
print('no') |
c86998647bdecd6995139d6747859ca8aa5cccaf | chelseatroy/mathofintelligence | /gradient_descent.py | 3,600 | 3.546875 | 4 | import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import pandas as pd
from ui_tools import colors
from ui_tools import regression_plot_with_feature_weights
# MATH OF INTELLIGENCE WEEK 1 ASSIGNMENT
# TODO:
# add the option to step until the total cost is below a certain threshold... |
6930598ca03af862f6344dde1a9c9c2c5eb5661e | Ongakute/PT-2021-komunikator | /Client/split_msg.py | 849 | 3.71875 | 4 |
def split_by_chars(word):
return [char for char in word]
def split_msg(msg):
iterator = 0
old_iterator = 50
while iterator <= len(msg) -1:
if iterator % 50 == 0:
if msg[iterator] == " ":
msg[iterator] = '\n'
else:
j = iterator
... |
7fe274c980f14257cd423b918000165183785a82 | damianhinch/eulers_pythons | /python/src/problem001.py | 588 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Feb 1 15:28:05 2015
Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5,
we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
@author: Damian Hinch
"""
a = 0
mult = 0
rangeUpper = ... |
1cb6fe8def5987e18cc0a7e660018bf8544705be | Janepoor/Python-Practice- | /35. Search Insert Position.py | 312 | 3.875 | 4 |
def searchInsert(nums,target):
low = 0
high = len(nums) - 1
while low <= high:
mid = (low+high)/2
if (nums[mid] == target):
return mid
elif nums[mid] > target:
high = mid - 1
else:
low = mid + 1
return low |
35ef05ab4708e5f5633f64f4b686e9629af9d34b | Simochenko/stepic_python | /sixth_module/6.2_math_module.py | 8,511 | 4.5 | 4 | # Модуль math – один из наиважнейших в Python. Этот модуль предоставляет обширный функционал для проведения вычислений с вещественными числами (числами с плавающей точкой).
# import math
# from math import *
#
# num1 = math.sqrt(2) # вычисление корня квадратного из двух
# num2 = math.ceil(3.8) # округление числа ввер... |
33cf2867390ba522528fb622f2209883d958639e | durveshvpatil01/Python-GUI | /__layoutmanage.py | 525 | 3.71875 | 4 | from tkinter import *
import tkinter
root=Tk()
label1 = Label(root,text="Enter Username")
label2 = Label(root,text="Enter Password")
text1 = Entry(root)
text2 = Entry(root)
checkbox1 = Checkbutton(root, text="Keep Me Logged In")
button = Button(root,text="LoginIn")
label1.grid(row=0,column=0,sticky=E)
label2.grid(... |
0f24590b2da9570ce0abdfbb0eb858be067cd679 | kiboiWanjohi/Tkinter-Calculator | /calculator.py | 3,665 | 4.09375 | 4 | from tkinter import *
root = Tk()
root.title("Simple Calculator")
# entry widget
e = Entry(root, width = 40, borderwidth=5)
e.grid(row = 0, column=0, columnspan=8, rowspan=1, padx=20, pady=10)
def buttonClick(number):
current = e.get()
e.delete(0, END)
e.insert(0, str(current) + str(number))
... |
3c482c7bbd6da1c0781bbdda679ffbb521455cbb | RyanHrist/backend-challenge | /util/model.py | 399 | 3.640625 | 4 | from abc import abstractmethod
class Model:
_dao = None
_collection: dict = dict()
def __init__(self, dao, collection: dict = None):
Model._dao = dao()
Model._collection = collection or dict()
@abstractmethod
def get_by_id(self, _id: str) -> 'Model':
return Model
@ab... |
89e65045be5264158b974d3271b07440c44b70d2 | vukasm/Problem-set-2019-Programming-and-Scripting- | /question-ix.py | 676 | 4.3125 | 4 | #Margarita Vukas, 2019-03-20
#Program that reads in a text file and outputs every second line.
#The program takes the filename from an argument on the command line.
#Asking a user to input a filename.
filename= input("Enter a filename:")
#Opening that file for reading.
with open(filename, 'r') as f:
#S... |
75458e9984f321385a20e2470927000f5356248c | Lilongshipython/shiyanlou-code | /jump7.py | 63 | 3.734375 | 4 | a = 0
while a <= 10:
a += 1
if a == 5:
continue
print(a)
|
eb094efd4daa51270469d152c7b591f7ce4a6e03 | geo-wurth/URI | /Python/1096 - Sequencia IJ 2.py | 102 | 3.515625 | 4 | for i in range(1,10,+2):
for j in range(7,4,-1):
print("I=" + str(i) + " J=" + str(j))
|
d5c20d444ba718acd7f0326b89fbacfbdba32ddd | dzaja123/travelling-salesman-problem | /HillClimbingAlgorithm/HillClimbingAlgorithm.py | 2,081 | 3.71875 | 4 | def Solution(put):
cities = list(range(len(put)))
solution = []
for i in range(len(put)):
CityA = cities[0]
solution.append(CityA)
cities.remove(CityA)
return solution
def routeLength(put, solution):
routeLength = 0
for i in range(len(solution)):
... |
68fe26abd31c090399a8dbc2134dfa1a5a43adf4 | Jiangdongzhi/pyproj | /leetcode/prob2.py | 1,364 | 3.828125 | 4 | import sys
import os
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
iter1 = l1
iter2 = l2
result = None
temp = None
... |
dbf9f321e31a04dac8115a35452be91d1147e187 | LucasDLino/Data_Science_Learning | /Introd_a_Ciencia_de_Dados/Tasks/Bootstrap_Task.py | 1,453 | 3.859375 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#Criação da população
population = np.random.randint(0,600, size=100)
#Lista contendo as amostras bootstraps
#Lista com as médias ("estatísticas") de cada amostra
samples = []
statistics = []
for i in range(100):
bootsamples = np.random.choice... |
7b4c30833f17edb0dd6fe420c8412e97282dbc8c | rahulmah/sample-cloud-native-toolchain-tutorial-20170720084529291 | /lib/gen_valid.py | 10,295 | 3.625 | 4 | #!/usr/bin/env python
r"""
This module provides valuable argument processing functions like
gen_get_options and sprint_args.
"""
import sys
import os
import gen_print as gp
###############################################################################
def svalid_value(var_value,
invalid_values=[]... |
5c12e6ab1d369fbb90a881ed3be9756be467330b | JIdigit/Part3-Task2 | /task2.py | 300 | 3.90625 | 4 | input_words = input()
word_list = input_words.split(' ')
sorted_list = sorted(word_list, key = len)
print(' '.join(sorted_list))
# sorte
# for i in range(len(word_list)):
# for j in range(len(word_list)):
# if word_list[i] < word_list[j]:
# print(' '.join(input_words.split(' ')))
|
1bce627f1ad268b7fb2af456e75d51d440ce3e41 | Jason0LiYaoCN/University-Assignments | /DataStructure_implementation/Sorting/searching.py | 490 | 3.859375 | 4 | def binary_search(sorted_list, item):
if len(sorted_list) == 0:
return False
mid_index = len(sorted_list)//2
if sorted_list[mid_index] == item:
return True
elif sorted_list[mid_index] < item :
return binary_search(sorted_list[mid_index + 1:],item)
else:
retur... |
afdbf486b74d598c7c49694f79761aa5368bd2bc | unclefrans/Peer2Peer-Chat | /Eind na 5 weken/main.py | 19,476 | 3.703125 | 4 | '''
TCP/IP Client and Server
Application name: Peer2Peer Chat
Application version: 1.0
Author name(s): Frans Tuinstra - frans.tuinstra001@fclive.nl
Jan Hendrik Haanstra(collega)
This program should do the following:
1. Contact manager
1.1 Add contacts
1.2 Edit contacts
1.3 Remove contacts
2. Who is online from... |
5e3318271395c81d81e5086d131b7778ca974982 | renanstn/redes-neurais-artificiais-python | /perceptron_uma_camada/exemplo_01.py | 375 | 3.84375 | 4 | def soma(entradas, pesos):
soma = 0
for i, j in zip(entradas, pesos):
soma += i * j
return soma
def step_function(soma):
return soma >= 1
entradas = [-1, 7, 5]
pesos = [0.8, 0.1, 0]
soma = soma(entradas, pesos)
print("Resultado da soma:")
print(soma)
resultado = step_function(soma)
print("R... |
1a4ba3157c760152e979cc57d987c1c4156635d1 | AnyaTrivedi/Davis_Putnam_Algorithm | /backend.py | 1,331 | 3.546875 | 4 | #python interface.py inputDPLL outputDPLL
#Runs the main function of the algorithm. Provides the front end and back end. Takes as input a text files, and prints the output into the output file
import sys
from contextlib import redirect_stdout
from collections import defaultdict
import DPLL
def backend(V,data, index... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.