blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
b9b6aa8fb43cbd2d73baf5b53a79b4754ce58316 | r-portas/python-tkinter | /ex1.py | 1,147 | 3.859375 | 4 | """
Example 1
Todo list application
"""
import tkinter as tk
class TodoApp(object):
"""A todo list app"""
def __init__(self, master):
self.master = master
self.master.title("Todo list app")
self.items = []
# Top frame
self.topFrame = tk.Frame(master)
... |
4ef373e91493f52c1ccb578ff29c48bad7d37a7b | lplade/sea_battle | /player_io.py | 3,431 | 4 | 4 | from constants import *
def msg(string):
"""
This just wraps print()
:param string:
:return:
"""
print(string)
def get_input(prompt):
"""
This just wraps input()
:param prompt:
:return:
"""
return input(prompt)
def interactive_get_placement_coord(ship):
"""
... |
aecf1ed25fccc90018be962f7dbfe32e80fad616 | rakesh-29/data-structures | /data structures/searching/binary search/interview problems on binary search/find floor of an element.py | 576 | 3.921875 | 4 | def floor_of_an_element(list,searchnumber):
left_index=0
right_index=len(list)-1
while left_index<=right_index:
mid_index = (left_index + right_index) // 2
mid_number = list[mid_index]
if mid_number==searchnumber:
print("search number found in the list")
... |
b24dfb43d58adbc20d2e265188a1449e727ae259 | riaz4519/python_practice | /programiz/_46_taking_input_console.py | 236 | 4 | 4 | #taking input
input1 = input()
print(input1)
#type casting int
num1 = int(input())
num2 = int(input())
print(num1 + num2)
#type casting float
float1 = float(input())
print(float1)
#string
string1 = str(input())
print(string1) |
646131d005c58889195bc46c51e672d361d581f3 | Team-Gillet/cs207-FinalProject | /build/lib/superautodiff/autodiff.py | 12,800 | 4.3125 | 4 | from collections import Counter
import math
class AutoDiff():
"""Creates an object for autodifferentiation
ATTRIBUTES
==========
var : name of variables
val : the value of the object
der : the derivative of the object
EXAMPLES
========
>>> x = AutoDiff("x",4)
>>> x.var
'x'... |
a7da0d5e7774cd277562647de84c16add64b429a | Spiderjockey02/CodeSnippets-Python | /files/Some sort of (d)encryption GUI.py | 3,185 | 3.703125 | 4 | ##--Imports--#
import time
import random
import tkinter
##--Random number generator--##
Key = 8
window = tkinter.Tk()
print("Th key is:", Key)
##--Functions--##
##-Opening encoding window
def Encoding_msg():
msg = Ent.get()
if len(msg) != 0:
print("Creating encryption.")
print("=-=-=-=... |
efc5e78aa5d82db7d64c647dd13e36c8493d99a7 | cr8onski/simplePycode | /two.py | 1,084 | 4 | 4 | #testing out the mod arithmetic and discrete log, even primitive root
#start with a prime number
num = int(raw_input('enter a prime number:'))
#add a another number
root = int(raw_input('enter a smaller number:'))
#how many iterations
count = int(raw_input('how many times do you want to do this?'))
# repeatedly ta... |
a5414dfd75b0ca25fa0665313381b2e1b5147505 | WesleyPereiraValoes/Python | /Curso em Python Mundo 2/ex054.py | 314 | 3.671875 | 4 | from datetime import date
dt = date.today().year
nm = 0
em = 0
for c in range(0,7):
nasc = int(input('Digite o ano de nascimento: '))
idade = dt - nasc
if idade >= 21:
em = em + 1
else:
nm = nm + 1
print('{} pessoas sรฃo de maior idade รฉ {} pessoas ainda nรฃo sรฃo'.format(em,nm))
|
01ccae6872189fbed929e9f25bc0828c74075f5c | zinderud/ysa | /python/first/dictionary.py | 579 | 3.71875 | 4 | alien_0 = {"speed": "slow", "x_position": 0}
alien_1 = {"speed": "medium", "x_position": 0}
alien_2 = {"speed": "fast", "x_position": 0}
Aliens = [alien_0, alien_1, alien_2]
x_increment = 0
for item in Aliens:
if item['speed'] == 'slow':
x_increment = 1
item['x_position'] = x_increment
prin... |
d2ca60641eb3e8cc1d12b4574c10531301e6becc | alexandre-mazel/electronoos | /chatbot_simple_test/chatbot_sklearn.py | 4,593 | 3.546875 | 4 | # simple chatbot exploration for education purpose
# started from https://medium.com/analytics-vidhya/building-a-simple-chatbot-in-python-using-nltk-7c8c8215ac6e
# later look at: https://chatbotslife.com/how-to-create-an-intelligent-chatbot-in-python-c655eb39d6b1
# https://www.tophebergeur.com/blog/projet-chatbot-pyth... |
5fa07c8feadae476a515aa7e11eba7aceccbca75 | RicardoLima17/lecture | /week06/lectures/lambdaFunction.py | 955 | 4.03125 | 4 | # more messing with functions
# Anonymous functions
#def doubler (num):
#return num * 2
#def tripler (num):
#return num * 3
# print True only doubler just IF/ False print tripler
isMax = True
if isMax:
# when use lambda the function does not have name. you can use the lambda and delet the function
... |
c3c409ba171421eea6e0e2d18f10097cf997ad8e | ShaneRich5/D-A-Python-Training | /lab60.py | 1,067 | 4.25 | 4 | '''
Instructions
============
1. Create a file named "math_helpers.py" with a function called "smart_divide" that accepts two parameters, a numerator and a denominator.
2. If the numerator or denominator are zero, False, or None, return zero. Otherwise, perform the division and return the result.
3. Create a file nam... |
02dfec2dff9978a190fe0813d1cdb2b071890c2b | markku63/mooc-tira-s20 | /Viikko_2/bothsame.py | 361 | 3.6875 | 4 | def count(s):
characters = {}
counter = 0
for i in range(len(s)):
if s[i] in characters:
characters[s[i]] += 1
else:
characters[s[i]] = 1
counter += characters[s[i]]
return counter
if __name__ == "__main__":
print(count("aaa")) # 6
print(count("ab... |
67020fc0ebd0b407dd6e206cbea6c4956483176c | btulsayin/example-python-codes | /readFile.py | 692 | 4.0625 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Finding the repeat number of words in a txt file
from collections import Counter
def main():
#use open() for opening file.
#Always use `with` statement as it'll automatically close the file for you.
with open(r'/home/hp/Documents/image_test.txt') as f:
... |
8345f5ae6d661dc6c621b79303cb49e8011efec6 | anushreedas/Adaline_Model | /adaline.py | 4,440 | 3.828125 | 4 | """
adaline.py
This program implements an adaline model
@author: Anushree Das (ad1707)
"""
from utils import *
Adaline = namedtuple('Adaline',['eta', 'weightColMat', 'trace'])
def makeAdaline(eta,n,fn,trace):
"""
Returns a Adaline named tuple with the given parameters
:param eta: learning rate
:pa... |
afe65ed98df095884cbeae973709f3b4a5e1e96c | mketiku/python-tutorials | /src/fun/revieew.py | 1,812 | 4.0625 | 4 | class Employee:
'Common base class for all employees'
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1
def displayCount(self):
print "Total Employee %d" % Employee.empCount
def displayEmployee(self):
print "Name... |
44747624665656aa503bba394f613c2bb286bc84 | malusarea06/Python_work | /Learn/import_sample.py | 294 | 3.859375 | 4 | import Demo1
str = "ANIKET"
s = 'lwk'
string1 = "{0:.2f}".format(7/5)
name = "{2} {0} {1}".format("aniket","satayawan","malusare")
print(str[-4:-1])
string2 = "|{:<8}|{:^20}|{:>8}|".format('Geeks','for','Geeks')
print(string2)
print(repr(str and s))
print(repr(s or str))
print(repr(not s))
|
7fdccbaca768fe27fc3e2082d8afdd8d84d513d2 | fagan2888/distributed_value_function | /env.py | 8,457 | 3.96875 | 4 | """
A simple grid environment to develop distributed value functions
"""
import gym
import numpy as np
from gym.spaces import MultiDiscrete
def compare_two_array(left, right):
""" Compare two arrays and set 0: same, 1 less, 2: greaterใ
If the type is float, we will add a tolerant value.
Args:
... |
ab4390d562d3eaa75aa5300f76e005aaf58df4ff | goFrendiAsgard/python-sqlite-example | /contoh-dictionary.py | 473 | 3.875 | 4 | print('contoh dictionary ---------------------')
# {'key1': 'value1', 'key2': 'value2'}
orang = {
'nama': 'Dono',
'alamat': 'Jakarta',
'hobby': 'Memancing'
}
orang['pendidikan'] = 'D3'
print(orang)
print(orang['nama'])
print(orang['alamat'])
print(orang['hobby'])
print('parse dictionary -------------------... |
6c66634fd7820b9f8b39dd3cc470908fbf0a5bb7 | harrylee0810/TIL | /swexpert/python01/6238.py | 256 | 3.53125 | 4 | # 1๋ถํฐ 100์ฌ์ด์ ์ซ์ ์ค ํ์๋ฅผ for ๋ฌธ์ ์ด์ฉํด ๋ค์๊ณผ ๊ฐ์ด ์ถ๋ ฅํ์ญ์์ค.
# ์
๋ ฅ:
# ์
๋ ฅ๊ฐ ์์
# ์ถ๋ ฅ
# 1, 3, 5, 7, 9, ... 95, 97, 99
lst= []
for i in range(1, 100, 2):
lst.append(i)
print(', '.join(map(str,lst))) |
1ff1c77a349350b67db3cd9a13adde820694577a | njg89/codeBasics-Python | /printANDstrings.py | 617 | 4.25 | 4 | print('Hello World. For this example, I used single quotes for my string.')
print("We can also use double quotes for strings.\n")
#concatenating properly
print("Now it's time to learn the different ways to concatenate properly.")
print('concatena'+'tion')
print('hello','there')
print('I am',5)
#escaping ch... |
1f1e6f424e9125d9b3933da81b7de81066f1cc24 | IliaZenkov/phys-simulations | /Monty Hall Problem/Monthy_Hall.py | 4,454 | 4.34375 | 4 | '''
#Monty Hall Problem Simulation
#There are three doors, behind one of which is a prize, and behind the other two is not a prize
#We choose 1 random door of 3
#One of the prize-less doors are revealed
#We may stick with or change our choice of door (the prize door being either the one we picked, or the other un-reval... |
052d2f1c754978352f9ddcb8e4ba4d56cce012a4 | AnkitDogra-07/cars_price | /data.py | 1,447 | 3.609375 | 4 | # Define a function 'app()' which accepts 'car_df' as an input.
import streamlit as st
import numpy as np
import pandas as pd
# S6.2: Design the View Data page of the multipage app.
# Import necessary modules
import numpy as np
import pandas as pd
import streamlit as st
# Define a function 'app()' which a... |
7068467fadd7f3832a37ef5a9b7be35ba0263ca3 | themikesam/1072-Python | /stddev.py | 846 | 4.09375 | 4 | # ๅญธ่๏ผ104213069
# ๅงๅ๏ผ่ฆ่ไบฎ
# ไฝๆฅญไบ
# ้ก็ฎ๏ผhttps://hackmd.io/s/S12vSV-OV#
import math
def meanStddev(data) :
sum = 0 # ็ดฏๅ ๆๅๅฒ็ใๆธใๅพ๏ผๅ่ๆผ็ธฝๅๆธๅพๅนณๅๆธ
for x in data :
sum = sum + x
avg = sum / len(data)
sum = 0 # ๅฐๆๅๅฒ็ใๆธใๆธๅนณๅๆธๅนณๆนๅพ็ดฏๅ
for x in data:
sum = sum + (x-avg)*(x-avg)
dev = math.sqrt(sum/l... |
66d381f54f3dd78b89d4bf511f3ecfd0193d89cf | leonardofernando/api_cashback | /tests/controller/purchase_controller_test.py | 877 | 3.5625 | 4 | import unittest
from app.controller.purchase_controller import PurchaseController
from app.database.sqlite import SqliteConnection
class PurchaseControllerTest(unittest.TestCase):
def test_get_purchases_success(self):
"""
Testa se lista de compras e retornada coretamente.
:return:
... |
7a230c4730261301e15f8a033c6aa3355bcf60a3 | xudaniel11/interview_preparation | /number_letter_combinations.py | 2,838 | 4.125 | 4 | """
A message containing letters from A-Z is being encoded to numbers using the following mapping:
'A' -> 1
'B' -> 2
...
'Z' -> 26
Given an encoded message containing digits, determine the total number of ways to decode it.
Example :
Given encoded message "12", it could be decoded as "AB" (1 2) or "L" (12).
The num... |
28fe96741f04cfc4efc55a18a81b62730f13b829 | madhavms/OOP_CODE | /Employer.py | 552 | 3.640625 | 4 | class Employer:
def get(self,First_name,Last_name,Salary):
self.First_name=First_name
self.Last_name=Last_name
self.Salary=Salary
def __init__(self):
self.First_name=None
self.Last_name=None
self.Salary=None
def set(self):
email=self.First_name+".... |
6fd7f672c2f5d5388401b967fef4a3da1578e65a | BabyCakes13/Python-Treasure | /Laboratory 5/problem3/dice.py | 679 | 3.59375 | 4 | """Module which contains the dice support class."""
from random import randint
class Dice:
"""Class which contains the dice methods."""
def __init__(self):
"""Initialises the face of the dice with 0."""
self.face = 0
def roll_dice(self):
"""Method which rolls the dice and prints ... |
4baf747b81f0aca652d3729053d0ed38d4af2fae | raxahai/Sorting_Algorithms-in-Python | /insertion_sort.py | 199 | 3.65625 | 4 | def insertion_sort(inp):
for i in range(len(inp) - 1):
j = i
while j >= 1 and inp[j-1] > inp[j]:
inp[j-1],inp[j] = inp[j],inp[j-1]
j = j - 1
return inp |
e42dbc763cab19f260fc1dd097aa74d4f2bd4f47 | KristofferFJ/PE | /problems/unsolved_problems/test_724_drone_delivery.py | 925 | 3.765625 | 4 | import unittest
"""
Drone Delivery
A depot uses $n$ drones to disperse packages containing essential supplies along a long straight road.
Initially all drones are stationary, loaded with a supply package.
Every second, the depot selects a drone at random and sends it this instruction:
The road is wide enough that dro... |
a44a31b971c9addc3439d61c0726d40bfc31d4bc | fourwood/OutflowCone | /Cone.py | 9,228 | 3.65625 | 4 | #!/usr/bin/env python3
import OutflowCone as oc
import numpy as np
import numpy.ma as ma
class Cone:
""" Galactic wind outflow cone model.
"""
def __init__(self, inc=0, PA=0, theta=60, r_in=0.0, r_out=5.0):
""" Create a new outflow cone.
Keywords:
inc --... |
347839bc6efa5e7cb9eca33fda20693435e5ecc5 | samiuluofc/Python-Code-Snippets | /CPSC 231_Win17/week_6/codes_by_me/code1.py | 358 | 3.875 | 4 | # Find geometric mean of N numbers
# Take inputs and store them in a list
num_L = []
while True:
num = input()
if num == 'EOF':
break
num_L.append(float(num))
# Calculating Geometric mean
multi = 1
for num in num_L:
multi = multi * num
res = multi ** (1.0/len(num_L))
pri... |
9d1d43bfda0c1b3f5dc9de55d6c13257c386203b | changeAwei/homework | /P21061-้ฉ้็บข/็ฌฌไบๅจไฝไธ/job.py | 2,620 | 4.09375 | 4 | # 1. ๅฆไฝไธบๅฝๆฐๅฎไนkeyword-onlyๅๆฐ๏ผๅๅบไธชไพๅญๅณๅฏ๏ผ๏ผ
"""ๅจไธไธชๆๅทๅๆฐๅใๆ่
ไธไธชๅฏๅไฝ็ฝฎๅๆฐๅ็ๅฝขๅ
ๅฝๆฐ่ฐ็จๆถๅฟ
้กปไฝฟ็จๅ
ณ้ฎๅญๅๆฐไผ ๅ
่ฐ็จๆถๅฆๆๆฒกๆ้ป่ฎคๅผ๏ผๅๅฟ
้กปไผ ้ๅฎๅ๏ผๅฆๅๅฐๆๅบTypeError็ผบๅฐkeyword-onlyๅๆฐๅผๅธธ"""
james = {'name': 'James', 'age': 20}
bob = {'name': 'Bob', 'age': 22}
def compare(a, b, *, key):
return a[key] > b[key]
# ๅ
ณ้ฎๅญkeyๅจๆๅท*ๅ๏ผๅฝๆไปฌไปฅไฝ็ฝฎ้กบๅบ่ฐ็จๆถ๏ผ
# ไผๅพๅฐ้่ฏฏ๏ผ
# TypeError: compare() t... |
4a82b1801dc56fbc81aec4c683c38a19fc23f0d4 | PaulCristina/predict_basketball_scores | /2_1_cleaning_data.py | 21,816 | 3.59375 | 4 | #------------------------------------------------------------------------------------------------------------#
### 1.0 LOAD LIBRARY'S ----
import os, sys
import pandas as pd
import numpy as np
import dateutil
import re
# Workflow
# 1. Take the Teams and Games CSV files and load them into their own DataFrames.
# Donโt ... |
aad17c05e270c4962bb567cf8065194f9ebc02f6 | AlliotTech/python-scripts | /Learnpy/Python/scripts/control.py | 8,119 | 4.03125 | 4 | # -*- coding:utf-8 -*-
# ้ๆฉ็ปๆ
# ่พๅ
ฅไธไธชๅญฆ็็ๆ็ปฉ,ๅฐๅ
ถ่ฝฌๅไธบ็ฎๅๆ่ฟฐ: ไธๅๆ ผ(ๅฐไบ60),ๅๆ ผ(60-79),่ฏๅฅฝ(80-89),ไผ็ง(90-100)
# ๆนๆณ1
"""
score = int(input("่ฏท่พๅ
ฅๅๆฐ:"))
grade = " "
if (score < 60):
grade = "ไธๅๆ ผ"
if(60 <= score < 80):
grade = "ๅๆ ผ"
if(80 <= score < 90):
grade = "่ฏๅฅฝ"
if(90 <= score <= 100):
grade = "ไผ็ง"
print("ๅๆฐๆฏ{0},็ญ็บงๆฏ... |
ffd4e9b9422409ec4a38af124c90f7b93c41eabe | y2ksayed/test2 | /homework/student_submissions/LogisticRegression-BankMarketing-Lab_lindseybang.py | 2,328 | 3.703125 | 4 | #-----------------------------------------------Logistic Regresion Lab
"""Step 1: Read the data into Pandas"""
import pandas as pd
bank = pd.read_csv(r'C:\Users\bangli\Desktop\test\bank.csv')
bank.head()
bank.isnull().sum(axis=0)
bank.columns.values.tolist()
bank.dtypes
bank.describe()
"""Step 2: Prepare... |
ee87e98287d365e857a79c50d668f559fd95c2d2 | Sandro37/Dissecando-variavel-PYTHON-EXERCICIO | /Main.py | 476 | 4.125 | 4 | texto = input("Digite Algo: ")
print("INFORMAรรES DA SUA ENTRADA")
print("____________________________\n")
print("o tipo primitivo รฉ = " , type(texto))
print("Existe sรณ espaรงo = ", texto.isspace())
print("ร um nรบmero = " , texto.isnumeric())
print("Alfabรฉtico = ", texto.isalpha())
print("Alfanumรฉrico = ", texto.isalnu... |
45a2aa3ff2faab26481de163ba2b1d593758e1d1 | daniel-reich/turbo-robot | /TJHwPqtA7DRGKJitB_7.py | 1,445 | 4.03125 | 4 | """
In probability theory, a _probability matrix_ is a matrix such that:
* The matrix is a square matrix (same number of rows as columns).
* All entries are probabilities, i.e. numbers between 0 and 1.
* All rows add up to 1.
The following is an example of a probability matrix:
[
[0.5, 0.5, 0.0],
... |
3dcb7a824f21bc89a62461b4b1d58d3b8b59aac0 | sunt727/Intro-to-Programming-by-Python | /PS4/part_a/ps4a.py | 2,719 | 4.09375 | 4 | # Problem Set 4A
# Name: Tuo Sun
# Collaborators: None
# Time Spent: 0:30
# Part A0: Data representation
# Fill out the following variables correctly.
# If correct, the tests named data_representation should pass.
tree1 = [[1, 10], 2]
tree2 = [[15, 9], [[9, 7], 10]]
tree3 = [[12], [2, 4, 2], [6]]
# Part A1: Multipl... |
d8e8d4001287958ac890cf6278a0f9681d0101be | ravijaya/june08 | /psmakearchive.py | 1,562 | 3.5 | 4 | from abc import ABC, abstractmethod
from zipfile import ZipFile
from tarfile import TarFile
from glob import glob
class UnSupportedArchiveError(Exception):
"""custom/user defined exception"""
class ArchiveManager(ABC):
"""abstract class"""
@abstractmethod
def save(self):
"""abstract method"... |
374a4e6fa164f61741695565decbba988f38f3be | pedrovponte/MNUM | /Praticas/tercos.py | 372 | 3.625 | 4 | import math
def f(x):
return pow(math.sin(x), 2)
def tercos(a,b,prec):
while(abs(b - a) > prec):
prop = (b - a) / 3
c = a + prop
d = b - prop
if(f(c) > f(d)):
a = c
else:
b = d
if(a == c):
return [c, d, b]
else:
return [a,... |
000e56c897e371e793c06048689dbf1550da4762 | TOM-SKYNET/AL_NIELIT | /NLP/Day7_Dec13/q2.py | 1,049 | 3.9375 | 4 | """
Create a few sentences . Find the frequency count of the words in the vocabulary.
2. Cluster the words in the sentences based on the count.
4. Visualise the results.
"""
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
import numpy as np
from sklearn.feature_extraction.text import TfidfVector... |
70d51940cafb1df90f468c04ffef77097d7e9f06 | bro-wer/test_app_calculator | /main.py | 983 | 3.578125 | 4 | import sys
def ValidateArgsCount():
if len(sys.argv) != 4:
raise Exception("Unexpected args count!")
def ValidateArgs():
try:
CheckIfInt(sys.argv[1])
CheckIfInt(sys.argv[2])
CheckIfValidEquation(sys.argv[3])
except Exception as e:
raise e
def CheckIfInt(var):
t... |
8cd9426c2525ef50726c81496053d49cdc0fdb1d | jaredasch/Softdev-Spring2019 | /16_listcomp/comps.py | 1,151 | 3.6875 | 4 | def passwordThreshold(password):
nums = [1 for c in password if '0' <= c <= '9']
upps = [1 for c in password if 'A' <= c <= 'Z']
lows = [1 for c in password if 'a' <= c <= 'z']
return len(upps) > 0 and len(lows) > 0 and len(nums) > 0
print("Does 'jaredasch' pass the threshold? " + str(passwordTh... |
20c505da3b6f060b02546358e0524a2611635142 | Ricard-Garcia/Glyphs_scripts | /Testing/New tab with character to space.py | 800 | 3.71875 | 4 | # MenuTitle: New tab with character to space
# Ricard Garcia - 06.06.2019
# -------------------
# -*- coding: utf-8 -*-
__doc__="""
Creates a new tab with the selected character between all letters.
"""
# --------------------------------
from random import randint
f = Glyphs.font
# List with letters -----------------... |
f1be35537e086cac0ead59cbd9e99ae12519c5a1 | JeanGrijp/Algorithms | /Estruturas de Dados/lista-encadeada.py | 825 | 3.8125 | 4 | class No:
def __init__(self, value):
self.value = value
self.next = None
class Linked_list:
def __init__(self):
self.first = No(None)
def insert(self, value):
if self.first.value is None:
self.first = No(value)
else:
aux = self.first
... |
29d640d113ca4d54ab6833587477cff9afbcea3d | reshma-jahir/GUVI | /pro58.py | 224 | 3.65625 | 4 | pin = int(input())
q = []
d = pin//2 + pin
for i in range(1,pin+1):
if i%2==0:
q.append(i)
for i in range(1,pin+1):
if i%2!=0:
q.append(i)
for i in range(1,pin+1):
if i%2==0:
q.append(i)
print(d)
print(*q)
|
15899ea15e14d7d6ebc630edf041b9f30697db59 | Anzerkhan27/python_logbook_2019 | /bag_of_sweets.py | 429 | 4.09375 | 4 | """
Diving the total number of Sweets among total number of students
The remaining sweets are given to the teacher
"""
Number_of_sweets = 32
Number_of_students = 15
Sweets_per_student = int(Number_of_sweets/Number_of_students)
Sweets_teacher = int(Number_of_sweets % Number_of_students)
print("Each student will ... |
2def97b80651285f1cafb6362bbb79a21d4e8647 | stflihanwei/python_learning_projects | /DataSciencefromScratch/Python basics.py | 3,071 | 4.5 | 4 | # List comprehension
even_numbers = [x for x in range(5) if x%2 ==0] # why put an x in front of the for?
print(even_numbers)
squares = [x* x for x in range(5)] # range (5) is 0 1 2 3 4
print(squares)
even_squares = [x*x for x in even_numbers]
print(even_squares)
# turn list into dictionaries
square_dict = {x: x*x f... |
1b9e33865b415ef229cd555e614f50fe3217ee92 | KTyanScavenger/Class-Examples | /tuppling.py | 893 | 3.65625 | 4 | ##***TUPLE***
##game_list=("God of War","Horizon Zero Dawn","Elder Scrolls",
## "Last of Us","Red Dead Redemption","Spiderman",
## "Assassin's Creed","Fallout","Mario","Tetris","Battlefront",
## "Smite","Halo","Dishonored","Destiny")
##print(len(game_list))
##num5game=game_list[4]
##print(... |
3cdeb962634047a956f56fe0077cb84d534d4cf7 | akshay-sahu-dev/PySolutions | /Leetcode/Easy/Intersection of two linked lisyt.py | 630 | 3.625 | 4 | ## https://leetcode.com/problems/intersection-of-two-linked-lists/
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
... |
b5d4ee86eccfdb61560c3d1121562d8004d0b98f | AdamZhouSE/pythonHomework | /Code/CodeRecords/2392/60762/258258.py | 437 | 3.515625 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
t = int(input())
for i in range(0, t):
re = 0
s = input().split(" ")
p = int(s[1])
l = [int(x) for x in input().split(" ")]
l.sort()
for j in range(0, len(l)):
if(p%l[j]==0):
if((l.count(p//l[j])==2 and l[j]^2==p) or (l.count(p//l[j])... |
c7b7e889a0be44893d49b0aff09711340d7af055 | clevelandhighschoolcs/p4mawpup-DexterCarpenter | /Versions/WebScraper8.py | 4,232 | 3.53125 | 4 | #
# Web Scraper
# Version: 8
"""
cd C:\Users\Dexter Carpenter\Documents\GitHub\WebScraper\environment
c:\Python27\Scripts\virtualenv.exe -p C:\Python27\python.exe .lpvenv
.lpvenv\Scripts\activate
# on at home computer:
cd C:\Users\dexte\Documents\GitHub\WebScraper\environment
"""
# import libraries
import sys
im... |
872e0058bde7a73bb318be54b8aa0a22d3ba6c8c | mannerslee/leetcode | /451.py | 512 | 3.75 | 4 | class Solution:
def frequencySort(self, s):
freq_map = {}
for char in s:
freq_map[char] = freq_map.get(char, 0) + 1
freq_map = {k: v for k, v in sorted(freq_map.items(), key=lambda item: item[1], reverse=True)}
result = ""
for key in freq_map.keys():
... |
de0953403d8cb9cd93640edb1a0beb4f77cbd9e6 | badordos/Doliner-labs-Python-2018 | /4) ะฆะธะบะป For/Task2.py | 1,038 | 3.984375 | 4 | #ะะฑะพััะดะพะฒะฐะฝะธะต ัะธัะผั ะฒ ัะตะทัะปััะฐัะต ะธะทะฝะพัะฐ ะธ ััะฐัะตะฝะธั ััะตะฝัะตััั ะฝะฐ p% ะตะถะตะณะพะดะฝะพ.
#ะกะพััะฐะฒััะต ะฟัะพะณัะฐะผะผั, ะบะพัะพัะฐั ะฟะพ ะฟะตัะฒะพะฝะฐัะฐะปัะฝะพะน ััะพะธะผะพััะธ ะพะฑะพััะดะพะฒะฐะฝะธั
#ะธ ะฒัะตะผะตะฝะธ ะตะณะพ ัะบัะฟะปัะฐัะฐัะธะธ ะฒััะธัะปัะตั ัะตะบัััั ััะพะธะผะพััั ััะพะณะพ ะพะฑะพััะดะพะฒะฐะฝะธั.
year = int(input('ะะฒะตะดะธัะต ะดะฐัั ะฝะฐัะฐะปะฐ ัะบัะฟะปัะฐัะฐัะธะธ ะพะฑะพััะดะพะฒะฐะฝะธั'))
yearLast = int(input('ะะฒะตะดะธ... |
23f1b19988e599429118d128cb41fb90f6352347 | QAlexBall/Python_Module | /Python_lxf/Python_Basic_Operation/Python_Basic/basicValueAndFunc/Partialfunc.py | 423 | 3.875 | 4 | print(int('12345'))
print(int('12345', base=8))
print(int('12345', base=16))
def int2(x, base=2):
return int(x, base)
print(int2('11001'), '\n')
# functools.partialๆฏๅธฎๅฉๅๅปบๅๅฝๆฐ็
import functools
int2 = functools.partial(int, base=2)
print(int2('1001'))
kw = { 'base' : 2 }
print(int('1010', **kw), '\n')
max2 = functool... |
c78bba5ef37c42f94d44469e8c07d69c00404bf3 | coolzzz20/python | /test03/mega/list07.py | 1,054 | 3.6875 | 4 | food = ['๋ผ๋ฉด', '์ปคํผ', '์์ด์คํฌ๋ฆผ', '๋ผ๋ผ', 'ํฅ๋น์']
#์ธ๋ฑ์ฑ : ๋ฆฌ์คํธ์ ํ๋ํ๋ ๊ฐ์ ์๋ ๊ฒ
print(food[0])
print(food[-1]) #์ฌ์ด์ฆ๋ ํ์ ์๋๋ฐ ๋์ ๋ฌด์์ด ์๋์ง ์๊ณ ์ถ์ ๋ ์ด์ฉ
print(food[-2])
#์ฌ๋ผ์ด์ฑ : ๋ฆฌ์คํธ์ ๊ฐ ์ค a~ b๊น์ง ๊ฐ์ ์๋ ๊ฒ.
print(food[0:2]) # a~b ๊น์ง ์ธ ๋ : ์ ์ฌ์ฉํ๋ค. a:b๋ ๋ด๊ฐ ๊ฐ์ง๊ณ ์ถ์ b ๊ฐ๋ณด๋ค +1 ํฌ๊ฒ ํด์ผํ๋ค.
# ์ ๋ ๊ฒ ํ๋ฉด ๋ผ๋ฉด ์ปคํผ 2๊ฐ ๋์จ๋ค.
print(food[2... |
39cdf0709c247ee6501f671ca9da2e82386a27cb | Panda4817/Advent-Of-Code-2016 | /11.py | 4,105 | 3.578125 | 4 | from copy import deepcopy
from itertools import combinations
from queue import PriorityQueue
class GameState(object):
def __init__(self, floors, lift_floor=1, moves=0):
self.floors = floors
self.lift_floor = lift_floor
self.moves = moves
self.num_floors = len(floors)
@proper... |
68a0bdbb37532dcee481bed1d6a52ee901647c9b | merry-hyelyn/Programmers_weekly_challenge | /Week8/answer.py | 369 | 3.65625 | 4 | def solution(sizes):
cards = [(max(size), min(size)) for size in sizes]
width, height = zip(*cards)
return max(width) * max(height)
print("answer : ", solution([[60, 50], [30, 70], [60, 30], [80, 40]]))
print("answer : ", solution([[10, 7], [12, 3], [8, 15], [14, 7], [5, 15]]))
print("answer : ", solution... |
d04b8e44574ecd5df8f60ec7df6e7f8aae16d36d | gussiciliano/python101 | /2.0-funciones/ejercicios_alumnos/Zardain Sergio/ej10.py | 486 | 3.984375 | 4 | #!/usr/local/bin/python3.5
# -*- coding: utf-8 -*-
'''
@author: sergioZ
@summary: Revertir una lista.
'''
def invertir(lista):
listaInvertida = []
for i in range(len(lista) - 1,-1,-1):
if type(lista[i]) is list:
listaInvertida.append(invertir(lista[i]))
else:
listaInver... |
548ed8d74b8b157995a99cb497ae38508fcc57f1 | mwhit74/practice_examples | /scientific_python/ch_2/repeated_sqrt.py | 1,570 | 3.84375 | 4 | """Explore round-off errors from a large number of inverse operations"""
# repeated_sqr.py
from math import sqrt
#functions have not been introduced in the text yet but
# I feel the need to use them here so that two different
# 'chuncks' of code can be ran
def func1():
for n in range (1, 60):
r = 2.0
#taking t... |
91548c7e9d8f10a16f25df67dbaa1bea30827be5 | kali-physi-hacker/Data-Structures-and-Algorithms | /ADTs/python/Array/_array.py | 1,456 | 3.671875 | 4 | import ctypes
class _ArrayIterator:
def __init__(self, theArray):
self._arrayRef = theArray
self._curNdx = 0
def __iter__(self):
return self
def __next__(self):
if self._curNdx < len(self._arrayRef):
item = self._arrayRef[self._curNdx]
self._curNd... |
34499b44a9884e0cc793eca02bc25942bf99cdd5 | skatesham/S2Python | /Max_min.py | 1,498 | 4.03125 | 4 | import unittest
def max_min(x):
'''
:param seq: uma sequencia
:return: (min, max)
Entra com uma lista X, ele retorna o Maior numero e o Menor; Tempo em O(n).
'''
def min_max_calculator(maior, menor, lista, count):
if(count == 0): # condiรงรฃoo de parada
return lista[menor], ... |
b701a14894c75e4056e1a06f4123d249ce65c8ce | lockyluchiano/sms | /lab2/queueing_problem.py | 4,376 | 3.9375 | 4 | '''
Queueing Problem
Author: doodhwala
This implements the queueing problem for M counters and N customers.
For implementing single server, modify value of M and remove counter from the list of keys
And Abdul-Bakra is implemented in lab3
'''
import random
import sys
import csv
# M = 2
# N = 20
M = int(input('Enter t... |
f83b476a3402467073bcdb276c418ced176443e4 | harry1pacman/Bussines-IT | /22task.py | 339 | 3.96875 | 4 | a = int(input())
b = int(input())
c = int(input())
if a<b and b>c:
print('ะพะฑะฐ ะฝะตัะฐะฒะตะฝััะฒะฐ ะฒะตัะฝั')
else:
if a<b:
print('1 ะฝะตัะฐะฒะตะฝััะฒo ะฒะตัะฝo')
elif b>c:
print('2 ะฝะตัะฐะฒะตะฝััะฒo ะฒะตัะฝo')
else:
print('ะพะฑะฐ ะฝะตัะฐะฒะตะฝััะฒะฐ ะฝะตะฒะตัะฝั')
|
a47f49290197e702b6b5f0798974a9fab6e1576a | mohithpothineni/sample | /cspp1-practice/m3/hello_happy_world.py | 103 | 3.921875 | 4 | """hello happy world """
HAPPY = int(input("Enter a number: "))
if HAPPY > 2:
print("hello world")
|
66bce9ce8210f2a5cd8a690d2b8992eadd025383 | antonioleitebr1968/Estudos-e-Projetos-Python | /Exercicios&cursos/Curso_em_video(exercicios)/ex059.py | 1,190 | 3.96875 | 4 | from time import sleep
v1 = int(input('Digite um valor: '))
v2 = int(input('Outro valor: '))
sair = False
while not sair:
print('[ 1 ] para somar')
print('[ 2 ] para multiplicar')
print('[ 3 ] para ver o maior')
print('[ 4 ] para novos nรบmeros')
print('[ 5 ] para sair do programa')
opรงรฃo = int(i... |
f00bafd4b19f27578cc36881e26f5e0ae5ca429b | Lakssh/PythonLearning | /basic_learning/file_handling.py | 1,349 | 4.40625 | 4 | """
file handling -
Open("<file path>","<mode>") - To open a file
file.close() - To close a file
mode : "r" - read only mode
: "w" - write only mode
: "r+" - read and write mode
: "a" - append file
read a file - file.read()
read file line by line - file.readlin... |
8cedabb4f86abcc7d38e80dcd3f83beb4987b00a | OrangeB0lt/holbertonschool-higher_level_programming | /0x0B-python-input_output/1-number_of_lines.py | 256 | 4 | 4 | #!/usr/bin/python3
"""
Contains number_of_lines function
"""
def number_of_lines(filename=""):
"""returns number of lines in a text file"""
with open(filename, encoding='utf8') as f:
for line in f:
count += 1
return count
|
f304685642341569b6fe58ceb04e7fba5e96bafd | 2damny/Algorithm_Python | /PYTHON/ํ์&์๋ฎฌ๋ ์ด์
/BB1.py | 820 | 3.5 | 4 | # ํ๋ฌธ๋ฌธ์์ด ๊ฒ์ฌ
import sys
sys.stdin = open("input.txt", "rt")
n = int(input())
# 1
#for i in range(n):
# s = input() #๋ฌธ์์ด ์
๋ ฅ๋ฐ๊ธฐ
# s = s.upper() #๋ฌธ์์ด์ ๋ค ๋๋ฌธ์ํ ์ํค๊ธฐ(.upper)
# size = len(s) #s์ ๊ธธ์ด๋ฅผ ๊ตฌํด์ฃผ๊ธฐ
# for j in range(size//2): #๋ฌธ์์ด์ 2๋ก ๋๋์์๋์ ๋ชซ๋งํผ๋งํ์ ํ๋ฉด ๋จ
# if s[j] != s[-1-j]: #์์ชฝ๋์ด ๊ฐ์ง ์์ผ๋ฉด
# pri... |
4301a1721adf7b6db63033b0bfd585e580f5714f | Luckyaxah/leetcode-python | /ๅพ_ๅฎฝๅบฆไผๅ
้ๅ.py | 647 | 3.859375 | 4 | from ๅพ import Node
def bfs(node):
if not node:
return
from queue import Queue
q = Queue()
s = set() # ไธ่ฎฉ่็น้ๅค่ฟ้ๅ
q.put(node)
s.add(node)
while not q.empty():
cur = q.get()
print(cur.value)
for nextNode in cur.nexts:
if not nextNode in s:
... |
845029d3ecbd490d40ec73862cb8a48ff79544ad | sidamarnath/CSE-231-Projects | /proj02.py | 4,082 | 4.21875 | 4 | ###########################################################
# Computer Project #2
# Algorithm
# User inputs a purchase price
# User inputs a dollar price
# Program will calculate the change reauired
# If the user inputs a dollar amount greater than purchase, an error is printed
# When user enteres 'q', program d... |
ded21c0d77e6c4ba658f56219cfadca2cab0db37 | Noor-Ansari/Personal-Projects | /Calculator.py | 4,804 | 3.828125 | 4 | # First import the libraries/modules that we will use
import tkinter as tk
import numpy as np
from tkinter import END
# Define different functions to perform different task
def press(num):
current = txt.get()
txt.delete(0,END)
txt.insert(0,str(current) + str(num))
def butt... |
95456166606442a5cde2fa02bf989d53be099584 | Sens3ii/PP2-2020 | /!Less/!LES3.0/week3main.py | 2,279 | 3.890625 | 4 | # list1 = [1, 2, 3, 4]
# list2 = []
# for i in list1:
# list2.append(i*2)
# print(list2)
# import math
# def isPrime(x):
# if x == 1:
# return False
# for i in range(2, int(math.sqrt(x))+1):
# if x % i == 0:
# return False
# return True
# list1 = li... |
a353eb8c35cf97307383f56d820c5caa0bda43c0 | 39xdgy/Knight_Tour | /Board.py | 1,673 | 3.78125 | 4 | import turtle
from Point import Point
def makeSquare(board):
for i in range(4):
board.forward(256)
board.left(90)
def L_shape(board):
board.forward(512)
board.right(90)
board.forward(64)
board.right(90)
board.forward(512)
board.left(90)
board.forward(64)
board.left... |
87df1ab0d7c8c1ecd8bc730ef5e633d99d6085f3 | tomaszkyc/text-searcher | /text_search_task.py | 884 | 3.515625 | 4 | import logging
import os
class TextSearchTask:
def __init__(self, filepath, text_to_search):
self._filepath = filepath
self._text_to_search = text_to_search
self._occurences = 0
def occurences(self):
return self._occurences
def text_to_search(self):
return self._... |
d13470af4f09f9bdf676f3c615653d51d6d30014 | elena23sarov/I_want_to_be_an_Artezio_employee | /cat.py | 585 | 3.875 | 4 | """UNIX cat command. Do the next things:
1. Display the contents of a file(s) - cat filename1 filename2 ...
"""
import sys
def cat(*args):
"""Display files' contents one by one."""
for arg in args:
try:
with open(arg, 'r+') as file_cont:
print file_cont.read()
... |
62fa042a79482b23644ce6dc77449e8470c861e7 | elluscinia/smoothsort | /smoothsort.py | 9,070 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
ะ ะตะฐะปะธะทะฐัะธั ะฐะปะณะพัะธัะผะฐ ะฟะปะฐะฒะฝะพะน ัะพััะธัะพะฒะบะธ
"""
import heapq
import random
import unittest
import sys
import time
def numbersLeonardo(size):
"""
ะคัะฝะบัะธั ัะพัะผะธััะตั ัะฟะธัะพะบ ัะธัะตะป ะะตะพะฝะฐัะดะพ, ัะฒะปัััะธั
ัั ัะฐะทะผะตัะฐะผะธ ะบัั
:param size: ัะฐะทะผะตั ะฒั
ะพะดะฝะพะณะพ ะผะฐััะธะฒะฐ ะดะปั ะฟะปะฐะฒะฝะพะน ัะพััะธัะพะฒะบะธ
:param r... |
74cdb991497a621f067d8a9b02941ef2708d585f | dbialon/LeetCode | /add_digits.py | 647 | 3.796875 | 4 | # https://leetcode.com/problems/add-digits/
# Given a non-negative integer num, repeatedly add all its digits until
# the result has only one digit.
class Solution:
def addDigits1(self, num: int) -> int:
while num > 9:
sum_n = 0
for digit in str(num):
sum_n += int(di... |
244c31096380db92279da33f10a0202d000c6a52 | allbrandon/papercut-2019-csesoc-hackathon | /item.py | 672 | 3.90625 | 4 | class Item():
def __init__(self, name, quantity, price, store):
self._name = name # Name of item
self._quantity = quantity # Quantity of how much you bought
self._price = price # Price of 1 item
self._store = store # Store you bought it from
# Properties
@property
... |
c59cad6c1555a27c3bfcbefa66c8d4b28b0bea2f | ParkSangIn/practicepython.org | /ex16.py | 277 | 3.84375 | 4 | import random
import string
def pw_generator(size = 12, chars = string.ascii_letters + string.digits + string.punctuation):
return ''.join([random.choice(chars) for _ in range(size)])
print(pw_generator(int(input("Enter a number for the digits of your password : ")))) |
db06a4ab9cb0196467e7c3ae4601527b892e65ab | Eunsunn/python_algorithm | /letter-combinations-of-a-phone-number.py | 1,408 | 3.71875 | 4 | from typing import List
class Solution:
def letterCombinations(self, digits: str) -> List[str]:
## ๋ฐฉ๋ฒ1 ##
# BFS๋ก ๋ฌธ์ ํ๋์ฉ ์ด์ด๋ถ์ด๊ธฐ (with list comprehension)
letters = {"2":"abc", "3": "def", "4":"ghi", "5":"jkl",
"6": "mno", "7":"pqrs", "8":"tuv", "9":"wxyz"}
if... |
86a686eb8be0f34e06a2e2ca6b35effebaccf9aa | gwhite256/prg105 | /program2.3.py | 947 | 4.03125 | 4 | print("Welcome to the monthly income assessor!")
income = float(input("What is your monthly income?:"))
house = float(input("How much do you spend on housing?:"))
transport = float(input("How much do you spend on transportation?:"))
phone = float(input("How much is your phone bill?:"))
utility = float(input("How m... |
c26a833730268d8b4e676e6358cac4a747b6ab76 | 0x000613/Outsourcing | /Python/2020-05-05-์กฐ๊ฑด๋ฌธ๊ธฐ๋ณธ๋ฌธ๋ฒ/Exercise2.py | 2,167 | 3.84375 | 4 | # ์์, ์๋ฃ ์ข
๋ฅ
print("Select category.")
sel = input("\t1:Food 2:Drink\n") # ์์, ์๋ฃ ์ ํ
# ์์์ ์ ํํ์ ๊ฒฝ์ฐ
if sel == '1':
print("You have selected FOOD. Select category")
sel = input("\t1:Korean\t2:Chinese\t3:American\n") # ํ์, ์ค์, ์์ ์ ํ
# ํ์์ ์ ํํ์ ๊ฒฝ์ฐ
if sel == '1':
print("You have selected KOREAN FOOD... |
b9ff9e58511d4a6216ac43453434a06b18d5da2f | Researching-Algorithms-For-Us/3.Greedy | /baekjoon/python/1541.py | 874 | 3.609375 | 4 | # source code
'''
17:05 ~ 17:37
์์, + - ๊ดํธ ์์ ๊ฐ์ง๊ณ ์์ ๋ง๋ฌ
๋ง๋ ํ ๊ดํธ๋ฅผ ๋ชจ๋ ์ง์
๊ดํธ๋ฅผ ์ณ์ ์์ ๊ฐ์ ์ต์๋ก ๋ง๋ ํ๋ก๊ทธ๋จ์ ์์ฑ
---
์ฒซ๋ฒ์งธ ์ค์ ์์ด ์ฃผ์ด์ง๊ณ
์๋ 0์ผ๋ก ์์ํ ์ ์๋ค
์ฒ์๊ณผ ๋ง์ง๋ง์ ์ซ์
# 1-(2+3+4)-5
# 1+2-(3+4)-5
# 1+2+3-(4)-(5)
'''
def set_input():
value = input().split('-')
return value
def main():
input_list = set_input()
... |
d339e107b93c088dc70791d78074676fd0962da3 | OleksandrParkhomenko/python-code-formatter | /file01.py | 173 | 3.53125 | 4 |
def func():
return 3 + 2
"""
dsfsdf
sdfs
dfsdfsdf
sdf"""
class A:
def s(self):
pass
A.s = None
a = {1, 2}
b = 3
c = "asdasd"
print(func(), a, b)
|
1de857e3543790973f1b57abbf103e4b72bfa766 | CCallahanIV/data-structures | /src/radix_sort.py | 2,100 | 4.1875 | 4 | """Implement an insertion sort algorithm."""
import sys
from queue_ds import Queue
def radix_sort(sort_list):
"""Return a sorted list using the radix sort algorithm."""
buckets = {char: Queue() for char in list('0123456789')}
max_digits = 0
digit = -1
while True:
for item in sort_list:
... |
9842bfc385590c0c1c3f8cedb4ff8cd6e91b4ea9 | GersonSales/AA | /28912-Lista_1-AAbasico-2016.2/P3-Night_at_the_Museum.py | 296 | 3.640625 | 4 | import string
def indexOf(letter) :
return string.lowercase.index(letter)
usrInput = raw_input()
actualLetter = 'e'
summ = 0;
for letter in usrInput:
maxx = max(indexOf(actualLetter))
minn = min(indexOf(letter))
summ = summ + (26 - (maxx - minn))
actualLetter = letter
print summ
|
f7cadf3d20866f6de80bdf13d87c67df8b80d975 | tqpatil/Python-Games | /Python/CalculatorExpressionTree/calculator.py | 3,996 | 3.640625 | 4 | #Name:Tanishq Patil
#File: calculator.py
# Student ID:1961827
# #Date:11/17/2022
from stack import Stack
from treecalc import BinaryTree
from treecalc import ExpTree
def isNumber(strVal):#A function to determine if the value is a number and not an operator
possibleOps=["(",")","/","*","+","-","^"]
... |
c803f82d8ba9da1a12c4937eabdc4def9a43626c | jqu224/Fan_hhkr101 | /`11_numpy/2_transpose_flatten.py | 334 | 3.671875 | 4 | https://www.hackerrank.com/challenges/np-transpose-and-flatten/problem
import numpy as np
n, m = map(int, input().split())
arr = []
for _ in range(n):
arr += [list(map(int, input().split()))]
a = np.array(arr,int)
# solution a
print(np.transpose(a))
print(a.flatten())
# solution b: same thing
print(a.T)
print... |
a67c0299907c6d7239cf8d41e6b101e949ccf1f0 | amccarthy9904/foobar | /LeetCode/Medium/AddTwoNumbers.py | 2,034 | 3.953125 | 4 | # https://leetcode.com/problems/add-two-numbers/
# 2. Add Two Numbers
# Medium
# You are given two non-empty linked lists representing two non-negative integers.
# The digits are stored in reverse order, and each of their nodes contains a single digit.
# Add the two numbers and return the sum as a linked list.
# You... |
5f1322ff2ea60ee77674dc8dc13c0d87f43a7b86 | Chacon-Miguel/CodeForces-Solutions | /chatRoom.py | 262 | 3.9375 | 4 | phrase = list(input())
hello = 'hello'
for char in 'hello':
if char in phrase:
while hello.index(char) != hello.index(char):
del phrase[hello.index(char)]
if phrase == hello:
print("YES")
else:
print("NO") |
0af1bcd41091c3f80c2b9da691325e2ec73cf1bb | si21lvi/tallerlogicadeprogramacion_camilogomez | /11.py | 238 | 4.09375 | 4 | import math
radio=float(input("ingrese el radio", ))
medida=float(input("ingresar medida", ))
apotema=(math.sqrt((radio**2)-(medida/2)**2))
area_de_un_hexagono=(3*medida*apotema)
print("el area de un hexagono es",area_de_un_hexagono) |
3cfa6f29c70c9ef832b52ca6f57a81b7623c6838 | lucijajagnjic/PAF | /Vjezbe_2/zad1.py | 610 | 3.625 | 4 | import matplotlib.pyplot as plt
F = float(input("Sila u N:"))
m = float(input("Masa u kg: "))
g = 9.8
a = F/m
dt = 0.1
t = 0
v = 0
x = 0
brzina = []
pomak = []
vrijeme = []
akceleracija = []
for i in range(100): #t konacno je 10, a dt je 0.1 pa range mora biti 100
v = v + a*dt
x = x + v*dt
t += dt
brzi... |
9bb87956d901ec92fc54836d2100e1d368174ea0 | zsh2401/hello-python | /day02/hw/lhl/4-13.py | 192 | 3.78125 | 4 | foods = ('yu','wa','fan','cai','tang')
for foods2 in foods:
print(foods2)
foods = ('yu','wa','fan','cai','tang')
print(foods)
foods = ('yu','wa','fan','cai','tang','xia')
print(foods)
# 4 |
af2097f50c1b610919d44a5c1d5f7ab198f9998c | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_35/425.py | 1,918 | 3.5 | 4 | #!/usr/bin/env python
import sys
t = int(sys.stdin.readline())
for mapIx in xrange(t):
#print "processing map %d"%mapIx
h,w = tuple(map(int,sys.stdin.readline().split(" ")))
#print "h,w: %s"%[h,w]
rows = []
for i in xrange(h):
rows += [map(int,sys.stdin.readline().split(" "))]
#print "... |
6c9450cbcfe8dc98b94aff301d8feb36ae3dffd9 | nekapoor7/Python-and-Django | /PythonNEW/Function/UniqueElements.py | 292 | 3.953125 | 4 | """Write a Python function that takes a list and returns a new list with unique elements of the first list. Go to the editor
Sample List : [1,2,3,3,3,3,4,5]
Unique List : [1, 2, 3, 4, 5]"""
def unique(l):
s = set(l)
return list(s)
l = list(map(int,input().split()))
print(unique(l)) |
a72959d615a806df522346a334c3efa3779a286c | KevinZWong/Kevin_PythonClasses | /Assignment5/Assignment5e.py | 905 | 4.125 | 4 | def calFactorial(num):
factorial = 1
# check if the number is negative, positive or zero
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
return 1
else:
for i in range(1,num + 1):
... |
bd68b5c4f6ebf98125ce546d6c72814eecfb0b27 | AshrafAliS/MSRIT-Python-Lab-Programs | /6b.py | 448 | 4.125 | 4 | #(b) Write a python program to calculate the area of the circle and catch appropriate user defined exception.(Hint: check for invalid radius)
import math
try:
n=int(input("Enter Radius: "))
if n<0:
raise RuntimeError()
except:
print('Invalid radius', RuntimeError('No characters Please','Non Negat... |
7d95859d07c6d7c8ff3293dc8ed24501aba44298 | maet3608/nuts-ml | /nutsml/examples/pytorch_/mnist/utils.py | 810 | 3.5 | 4 | """
Utility functions for downloading the MNIST data set.
"""
import requests
import pickle
import gzip
from pathlib import Path
def download_mnist():
"""Download MNIST from web to data folder."""
folder = Path("data/mnist")
filename = "mnist.pkl.gz"
fullpath = folder / filename
url = "http://dee... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.