blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
f425cd0c1db86232dd5c36ab3221b5835befcdc0 | isha-03/python-course | /Basics/002_variables.py | 190 | 3.625 | 4 | a = 13
b = -5
c = True
d = "Hello"
e = 7.5
print(a)
print(b)
print(c)
print(d)
print(e)
print(a + b)
print(a - b)
print(a + e)
print(d + "Hiiiii")
print("hey" + d + "Hiiiii")
print(d * 5)
|
0692911579364e769feb0f2864dd7c18252795dc | seokjaehong/albs_study | /study/class_old.py | 2,175 | 4.34375 | 4 | # class Human():
# '''인간'''
#
# # person = Human()
# # person.name = '석재'
# # person.weight = '100kg'
#
# def create(self, name, weight):
# # person = Human()
# self.name = name
# self.weight = weight
# return self
#
# def eat(self):
# self.weight += 1
# ... |
c602253a519ca9afbee76020edde7ba65897625c | WerapongSaejung/CP3-Werapong-S | /assignments/Excercise21_Werapong_S.py | 1,999 | 3.578125 | 4 | from tkinter import * #นำเข้าฟังก์ชั่นGUI
import math #นำเข้าฟังก์ชั่นคณิตศาตร์
def LefClickButton(event): #ฟังก์ชั่นสำหรับกดปุ่มแล้วนำคำนวนที่นี่
# print(float(textBoxWeight.get())/math.pow(float(textBoxHight.get())/100,2))
ResultBMI = (float(textBoxWeight.get())/math.pow(float(textBoxHight.get())/100,2))
... |
8977867e301ab8774b6e34f404163f7d04b3596c | gabriellaec/desoft-analise-exercicios | /backup/user_378/ch27_2019_03_11_14_30_09_941890.py | 103 | 3.671875 | 4 | a=int(input('quantos cigarros por dia?'))
b=int(input('há quantos anos fuma?'))
x=a*144
y=b*x
print(y) |
f67d4ce84f67b6cdfbc8f590f4b8c22bfacd0fce | dfworldwang/Python-Elementary-Practice | /Data Structure and Algorithms/Tree Structure/Finding_An_Item_In_A_Binary_Tree.py | 1,013 | 4 | 4 |
class binarynode(object):
def __init__(self, value, left = None, right = None):
self.value = value
self.left = left
self.right = right
# checking whether some value 'x' is in the binary tree
def search(self, value):
# returns True if value is in the tree
i... |
88bfdf5f78d75a1a85b52f89b686ce407fb656de | Kunvuthi/pythonlearningprojects | /Python Projects/Data Structures/binarysearchtree.py | 2,899 | 3.90625 | 4 | ## This Data Struture is very efficient in terms of searching as it minimize half its space complexity each time it iterate. ##
## This mean its big O complexity is O(logn) ##
class BinarySearchTree():
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def ... |
f8d909c9466f1aba220d9cc477972bb7fe07bedc | ashwin4ever/Human-memory | /perceptron_src/neuron.py | 2,427 | 3.609375 | 4 | """
Algorithm:
1. Calc error = output layer delta
2. Multiply inputs by error * derivative of activation = neuron delta
3. adjust
"""
import random
import math
import numpy as np
from connection import Connection
def sig(z):
"""The sigmoid function."""
return 1.0/(1.0+np.exp(-z))
def der_sig(z):
"""Deriva... |
67c27b65b861cc537c975f7a72fc8953d01555e8 | Heatscar/Graficacion | /example1/main.py | 834 | 3.65625 | 4 | import funciones as f
def agregar():
f.abrir()
nombre = input("Escribe el nombre: ")
precio = float(input("Escribe el precio: "))
cantidad = int(input("Escribe la cantidad: "))
f.agregar(nombre,precio,cantidad)
f.imprimir()
f.cerrar()
def cambiar_cantidad():
f.abrir()
nombre = inp... |
42020bd04303f42f250e00e0328634b64a328a48 | SimonFans/LeetCode | /Math/L415_Add_Strings.py | 2,334 | 3.796875 | 4 | Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.
Note:
The length of both num1 and num2 is < 5100.
Both num1 and num2 contains only digits 0-9.
Both num1 and num2 does not contain any leading zero.
You must not use any built-in BigInteger library or convert the inp... |
98bf379f9a96c562f23660aaf5934cc3d59d3dc6 | fvarnals/Lift-Automation | /src/lift.py | 4,786 | 3.6875 | 4 | class Lift(object):
def __init__(self, queues, capacity):
self.capacity = capacity
self.floors = list(range(0,len(queues)))
self.occupants = []
self.current_floor = 0
self.queues = {}
self.direction_of_travel = 'up'
self.destination_floor = None
self.... |
010fe7dc38d1c4bd06914a39c1ae65c614d60a3c | Tanya-L/SmartCodingHW | /hw_1_1.py | 797 | 4.03125 | 4 | # Question 1
# Design a function within a Python script that takes in a
# list of numbers, for example [1,2,3,4,5] and returns another
# list with each number multiplied
# by 2.
# One possible idea/solution looks like:
# def multiply_by_two(a_list):
# values_to_return = []
# # p... |
56797e30c38407f34f8551be16bf3d4664b03089 | kannanvr/Data-Structure | /practice-problems/8. Trie/trie-operations.py | 2,006 | 4 | 4 | # https://www.geeksforgeeks.org/trie-insert-and-search/
class TrieNode:
def __init__(self):
self.children = [None] * 26
self.isEndWord = False
class Trie:
def __init__(self):
self.root = TrieNode()
def insert(self, word):
p = self.root
for i in range(len(word)):
... |
b3454c31b9d15d098909cd1d8727c4b30a45b585 | cooper-mj/Nifty-Coding-Projects | /random_bag.py | 469 | 3.75 | 4 | '''
File: random_bag.py
Author: Michael Cooper
A simple implementation of the random bag data structure in Python.
'''
import random
class RandomBag:
def __init__(self):
self.bag = []
def push(self, item):
self.bag.append(item)
def pop(self):
if len(self.bag) == 0:
rai... |
d8f9487e0e8a7c0b2f5381c33e29d7664afbe781 | zhao13233065692/myproject | /day01/kaipf.py | 166 | 3.671875 | 4 | if __name__ == '__main__':
num = input("请输入一个数字:")
nu =int(num)**(1/2)
print("{numkey}的开平方是{nukey}".format(numkey=num,nukey=nu)) |
4455f14995ebdb0cd03ad4542f3c83c8b9de5046 | RuidongZ/LeetCode | /code/78.py | 1,444 | 3.6875 | 4 | # -*- Encoding:UTF-8 -*-
# 78. Subsets
# Given a set of distinct integers, nums, return all possible subsets (the power set).
# Note: The solution set must not contain duplicate subsets.
#
# For example,
# If nums = [1,2,3], a solution is:
#
# [
# [3],
# [1],
# [2],
# [1,2,3],
# [1,3],
# [2,3... |
5bb98168cc40eb7fec169c61c59ce01b4698f065 | ShiinaMashiro1314/Project-Euler | /Python/5.py | 204 | 3.765625 | 4 | def gcd(a,b):
if(b == 0):
return a
if(a < b):
return gcd(b,a)
else:
return gcd(a%b,b)
def lcm(a,b):
return a*b/gcd(a,b)
result = 1
for i in xrange(1,21):
result = lcm(i,result)
print result |
1a3f0514b009ed49fcc316dcb03aa4608ce09e69 | Ankit-29/competitive_programming | /Dynamic_Programming/rangeSumQueryImmutable.py | 810 | 3.921875 | 4 | '''
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.
Example:
Given nums = [-2, 0, 3, -5, 2, -1]
sumRange(0, 2) -> 1
sumRange(2, 5) -> -1
sumRange(0, 5) -> -3
Note:
You may assume that the array does not change.
There are many calls to sumRange function.
'''
from ... |
5931ab2dfe278e1d02729ecc8245ec225a01ecd3 | DoryanDaguin/IUT | /test_roulette.py | 1,813 | 3.6875 | 4 | """
Test 1 : On vérifie que la valeur est supérieur à 20
>>> montant_argent > 20
True
Test 2 : On verifie que si on a le meme chiffre on gagne
>>> gagne_ou_perdu(15,15)
Bravo
Test 3 : On verifie que si on a pas le meme chiffre on perd
>>> gagne_ou_perdu(15,13)
Perdu
Test 4 :On verifie que si on a la meme couleur o... |
0570dec012eeb4653292a6291dffe32ebe498cc3 | liyi0206/leetcode-self-practice | /high freq.py | 13,058 | 3.609375 | 4 | #206
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def reverseList(self, head):
if not head: return None
prev=head
cur=head.next
while cur:
tmp=cur.next
cur.next=prev
head.... |
08932d3ee87f3457120488199bcb0730dd5f95b4 | Sean-McGinty/ECS_32A | /HW4/tip.py | 169 | 3.90625 | 4 | Bill=float(input("Enter total bill:"))
for i in range (15,26,1):
Tip_Amount=(i/100)*Bill
tip_str = "${:.2f}".format(Tip_Amount)
print(str(i)+"% is",tip_str)
|
2fca0e98751616bd8d3d61689cca7787d2784155 | Naval30/datastructures | /binary.py | 367 | 3.765625 | 4 | def binary(alist, item):
first = 0
last = len(alist) - 1
found = False
while first <= last and not found:
mid = (first + last)/2
if alist[mid] == item:
found = True
else:
if alist[mid] > item:
last = mid - 1
else:
first = mid + 1
return found
list = [0,1,4,7,9,10,12,14,16];
pr... |
f63994cb30759ff3fde8ba363e4f55031a86cae8 | mwilso17/python_work | /user input and while loops/multiples_of_ten.py | 320 | 4.4375 | 4 | # Mike Wilson 15 June 2021
# This program asks the user to input a number and returns if that number is a
# multiple of 10 or not.
number = input("Please enter a number: ")
number = int(number)
if number % 10 == 0:
print(f"\nThe number {number} is divisible by 10.")
else:
print(f"\nThe number is not divisible by ... |
e126f3787089918dd999ece8c4af073ea64de8fe | br-kim/Programmers-Algorithm-Practice | /python/Level3/자물쇠와 열쇠.py | 1,698 | 3.53125 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/60059
def rotateLeft90D(board):
return list(zip(*[reversed(i) for i in board]))
def extendBoard(n, board):
newline = [1] * (2 * (n - 1)) + [1] * len(board)
newboard = []
for _ in range(n-1):
newboard.append(newline[:])
for b in board:
... |
4a8a0afc39e51553ddd46494d3d79283e5d6eb04 | SamyBlue/stroLL | /stroll/journeys/RadialJourney.py | 1,337 | 3.671875 | 4 | import math
import random
from .JourneyClass import Journey, kilometers, latitude, longitude, coordinates
class RadialJourney(Journey):
"""Creates a journey within a circular region by randomly generating waypoints within a radius"""
def __init__(self, origin: coordinates, destination: coordinates, radius: k... |
cb69991de628bf4eaf4333bf171e8405ea0ac61d | yanrs17/nine-mens-morris-solver | /autogame.py | 3,298 | 4.03125 | 4 |
from state import State
import random
class AutoGame:
"""
AutoGame class, use State class and let different strategy compete with each other.
"""
def __init__(self, state, strategy1, strategy2):
"""
player:
"u": strategy1
"c": strategy2
state:
... |
7093c9127d34143b7bf44ce82f876164817e6cfa | hosin211/TASK1_IP_CLASSIFIER | /main.py | 1,811 | 3.796875 | 4 | import sys
from Classes.ipCalcMainClass import ipCalcMainClass as ip
def main():
"""
This is the main function:
1. Check if the script has been run without arguments, and asks the user to give input and store it in "givenIP" as a string, then pass it to the main class.
2. Check if multiple arguments a... |
27b456755e7fdac31b214cd3a9f536b52242fde9 | willbaschab/COOP_2018 | /Chapter02/U02_EX10_ConvertKmtoMile.py | 900 | 4.84375 | 5 | # U02_EX10_ConvertKmtoMile.py
#
# Author: Will Baschab
# Course: Coding for OOP
# Section: A2
# Date: 28 Aug 2018
# IDE: PyCharm
#
# Assignment Info
# Exercise: 10
# Source: Python Programming
# Chapter: 2
#
# Program Description
# A program that converts a user's input of kilometers into a distance ... |
8285ae269aef683a26f9fed76805bd21880c916f | ZikaiLian/MeanMedianMode_Calculator | /meanmedianmodecalc.py | 609 | 3.703125 | 4 | def average(arr):
a = 0
for i in range(0, len(arr)):
a += arr[i]
print(a/len(arr))
from collections import defaultdict
def mode(arr):
arr.sort()
diction = defaultdict(int)
for i in range(0, len(arr)):
diction[arr[i]] += 1
max_key = max(diction, key=diction.get)
... |
6dd59e36e4c6a88ac4368b3f0cf75783fc70964f | alexwu2021/practice | /Python/isValidParenthesis.py | 1,371 | 3.703125 | 4 | import os, sys, unittest
class Solution(unittest.TestCase):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
lefties = ['(', '{', '[' ]
righties = [')', '}', ']']
stack = []
i, size = 0, len(s)
while i < size:
ch = s[i]
... |
d688055a174370d59cdea5ab00ec5885b119d410 | anirudh1808/Python | /python_tut/ADASTAIR.py | 421 | 3.5 | 4 | from sys import stdin,stdout
from functools import reduce
count =0
def count_Steps(x,y) :
x=int (x)
y=int (b)
if (x+b<y) :
count=count+1
return count
else :
return y
b=0
for _ in range (int(input())) :
a,b=stdin.readline().split()
a=int (a)
b=int (b)
lst=[]
co... |
7e8226288d3bc9339982bcd9605cd0737b99f1de | anuragpatil94/Python-Practice | /cracking-the-coding-interview/LinkedList/2.1_RemoveDups.py | 2,827 | 4.0625 | 4 | import sys
sys.path.insert(0, "../../")
from conceptual.linked_list import LinkedList
"""
Remove Dups: Write code to remove duplicates from an unsorted linked list.
FOLLOW UP
How would you solve this problem if a temporary buffer is not allowed?
"""
# print(sys.path)
def remove_dups_without_... |
449470da2634c71f972d2dcdcd053d419b5e62ff | Patmosk/mycode | /funcion compleja.py | 229 | 3.765625 | 4 | def operacion (var1 , var2):
resultado = var1 * var2
return resultado
contenedor1=(operacion(5,10))
contenedor2=(operacion(3,6))
total=contenedor1+contenedor2
print(total)
#print(contenedor1)
#print(contenedor2) |
0cdf42cbfb9a9f677ba07fb5b5859ebff0783124 | Ze1598/data-projects | /machine learning/examples/tensorflow/neural_nets.py | 6,026 | 3.5 | 4 | import numpy as np
import pandas as pd
from tensorflow.keras import layers
from tensorflow.python.feature_column.feature_column_v2 import BucketizedColumn
from tensorflow.python.keras.engine.sequential import Sequential
from tensorflow.python.keras.feature_column.dense_features_v2 import DenseFeatures
import tensorflow... |
f87a4568d59887a77e357cb2a7e887ef38dcb31e | PatrickVienne/wd1-20200323 | /Class1_Python3/example_00200_operations_integers_exercise.py | 136 | 3.609375 | 4 | # add the numbers 100, 120, 130
# and print the result
# write your code here
# check if 123 is divisible by 3
# write your code here
|
a2aac1070a32ae35d13e46353ccbed00fc4830ed | snehaa2632000/Scientific-Computing | /Matrix_inverse.py | 1,192 | 3.640625 | 4 | import numpy as np
n = int(input('Enter order of matrix: '))
a = np.zeros((n,2*n))
# Reading matrix coefficients
print('Enter Matrix Coefficients:')
for i in range(n):
for j in range(n):
a[i][j] = float(input( 'a['+str(i)+']['+ str(j)+']='))
# Augmenting Identity Matrix of Order n
for... |
c121511d70563ac1ee596ec6fb137320077cb365 | mridulrb/Basic-Python-Examples-for-Beginners | /Programs/MyPythonXII/Unit1/PyChap06/infile.py | 409 | 3.90625 | 4 | # File name: ...\\MyPythonXII\Unit1\PyChap06\infile.py
import os
print ("Enter file name which you want to read: ", end="")
filename = input()
if os.path.isfile(filename):
fileobj = open(filename, 'r')
print ("File information")
print ("----------------")
for line in fileobj.readlines():
... |
9c34ad1c0eb2ce2e5abb24ce087ad033900b6456 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_95/977.py | 1,036 | 3.5625 | 4 | def translate(string):
code_dict = {}
translation = []
strings_coded = ["ejp mysljylc kd kxveddknmc re jsicpdrysi", "rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd", "de kr kd eoya kw aej tysr re ujdr lkgc jv"]
strings_decoded = ["our language is impossible to understand", "there are twenty six factorial ... |
4869ed05da2ba3e4121c86421d798573d13e79a9 | midfielder16/Pypyhihi | /ex6_2.py | 550 | 3.90625 | 4 | #!/usr/bin/env python3
def chunk_a_list(animals, N):
''' Chia input_data thành các tuple chứa N phần tử (chunk a list).
Nếu tuple cuối không đủ phần tử thì bỏ đi.
'''
result = []
res = []
for i in range(len(animals)):
res.append(animals[i])
if len(res) == N:
result.ap... |
20ee9e2f11a2bf02cba3da3fa4444fac45a86729 | Everin-k/Tutorials | /9day.py | 222 | 3.875 | 4 | #program exiter***
import sys
while True:
print("Type 'exit' to exit")
response = input()
if response == "exit":
print("Exiting the program")
sys.exit()
print("You typed", response) |
63b9b7ea202d63f09aaf9cab6e0f83478a9c20b0 | priedearmesti/Capacitive-Soil-Moisture-sensors | /humidity_class.py | 2,250 | 3.5 | 4 | #******************************************************************
# Final Project: Communication between a pair of Capacitive Soil Moisture sensors and the raspberry pi
#
# Programmer: - Ismilsys Priede Armesto
# - Adam Neel
#
# Due Date: NA
#
# EGRE 491, Spring 2020 Instructor: Robert Klenke
#
# P... |
cce49ae085559dcbb562df25e1e49b4ffdb536d9 | jhonatang1988/holbertonschool-machine_learning | /supervised_learning/0x08-deep_cnns/1-inception_network.py | 4,368 | 3.59375 | 4 | #!/usr/bin/env python3
"""
builds the inception network as described in Going Deeper with Convolutions
https://arxiv.org/pdf/1409.4842.pdf
"""
import tensorflow.keras as K
inception_block = __import__('0-inception_block').inception_block
def inception_network():
"""
builds the inception network as describe... |
40ba9f887646ac80653c3873bea315dcf17e2f95 | adsl305480885/leetcode-zhou | /349.两个数组的交集.py | 2,452 | 3.625 | 4 | '''
Author: Zhou Hao
Date: 2021-02-05 14:35:28
LastEditors: Zhou Hao
LastEditTime: 2021-02-05 16:10:52
Description: file content
E-mail: 2294776770@qq.com
'''
#
# @lc app=leetcode.cn id=349 lang=python3
#
# [349] 两个数组的交集
#
# @lc code=start
class Solution:
#方法一:hash-table
# def intersection(self, nums1: List[in... |
bb72b83a6bfde449a24f2e86a0e2ea17346dce68 | andrew-kudrenko/university-labs | /exam_my.py | 1,096 | 3.96875 | 4 | from typing import List
def even(sequence: List[int]) -> List[int]:
extracted: List[int] = []
for idx, num in enumerate(sequence):
if idx % 2 == 0:
extracted.append(num)
return extracted
def repeats_for(sequence: List[int], count: int = 2) -> List[int]:
duplicates = []
matc... |
9d2b380453ebe7f934df6d84155090f97a740574 | harsha-vardhan-vytla/CS118_ML | /tutorial2/MLtut2.py | 480 | 3.625 | 4 | import numpy as np
import matplotlib.pyplot as plt
x= np.array([1,2,3])
y=np.array([1.2,1.9,3.2])
def values(x,y):
p=x.sum()
q=y.sum()
r=(x*x).sum()
s=(y*y).sum()
l=len(x)
w0=(r*q-p*s)/(r*l-p*p)
w1=(q-(l*w0))/p
return w1,w0
slope,intercept=values(x,y)
final_values=[slope*i+ intercept for i in x]
plt.title("Ma... |
141cda3f595644d418ed1b5edca223767cb78734 | HaroldBernieGarcia/GARCIA-H.---DATALGO | /gaQ2p2.39.py | 1,225 | 3.578125 | 4 | """ Harold Bernie P. Garcia
DATALOG lab02
Feb. 19, 2020
I have neither received nor provided any help on this (exercice) activity,
nor have I concealed any violation of the Honor Code.
"""
from abc import abstractmethod, ABCMeta
import math
class Polygon(metaclass=ABCMeta):
def __init__(self, side_length... |
0763df7d8258b39049617f93f5e84701728099fd | e0en/57_exercises | /python/03_print_quote.py | 160 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
quote = input("What is the quote? ")
author = input("Who said it? ")
print(author + " says, \"" + quote + ".\"")
|
31798d8f9b8ca892e189ae276f083441a422c668 | zubrik13/coding_intrv_prer | /min_search.py | 107 | 3.6875 | 4 | l = [5, 8, 4, 3, 5, 7]
min_val = l[0]
for i in l:
if i < min_val:
min_val = i
print min_val |
aef4c843cfdfb89f313595509dd5f42ceb90de75 | avico78/Building-Data-Science-Applications-with-FastAPI | /chapter2/chapter2_basics_01.py | 65 | 3.703125 | 4 | print("Hello world!")
x = 100
print(f"Double of {x} is {x * 2}")
|
5ed5e0b299c525632c30df982e41f7db07fa6501 | Angeall/pyTGF | /pytgf/game/api.py | 20,322 | 3.625 | 4 | """
File containing the definition of a basic API to interact with a game from a controller
"""
import copy
from abc import ABCMeta, abstractmethod
from typing import Tuple, Dict, Union, List
import pandas as pd
from .core import Core, UnfeasibleMoveException
from ..board import TileIdentifier
from ..characters.moves... |
f3d7244410133fe441699e81ac6081aac8d82655 | akshatk16/todo_python | /todo.py | 6,220 | 4.1875 | 4 | from datetime import date
import os
import sys
def addTodo(todoItem):
# ✓ add a single todo
# ✓ show error message when add is not followed by a todo
# ✓ add multiple todos
if os.path.isfile('todo.txt'):
with open("todo.txt") as f:
lines = f.readlines() # read existing todos
... |
ba0138cb15bda443526d7872b5139ecc06895090 | NoranAB/100daysofcodes | /Day66noran.py | 383 | 3.953125 | 4 | #Python String Formatting 2
quantity = 4
itemno = 626
price = 62
myorder = "I want {0} pieces of item number {1} for {2:.2f} dollars."
print(myorder.format(quantity, itemno, price))
age = 34
name = "Mohammad"
txt = "His name is {1}. {1} is {0} years old."
print(txt.format(age, name))
order = "I have a {carname}, it is ... |
f24931592eb8d5b19298e746ab32b61f4c6fe8b6 | JasonC07/program-arcade-games | /Lab 07 - Adventure/main_program.py | 1,951 | 4.3125 | 4 | #!/usr/bin/env python3
#Adventure.py
#Jason Cobb
#11/28/17
#Create an empty array called room_list
room_list = []
#Create a variable called room with an array of five elements.
room = ["the North hall pictures of angels fighting demons line the walls.", None, 4, 3, 1]
#Append the room to the room list
room_list.appe... |
a302fa44f40a9f74b1abaab98247554634748c88 | JamissonBarbosa/questPython | /codigosURIJudge/dividindoXpY.py | 228 | 3.78125 | 4 | n = int(input())
for i in range(n):
entrada = input().split(" ")
numeros = map(int, entrada)
x, y = numeros
if y == 0:
print("divisao impossivel")
else:
result = x / y
print(result) |
1fbb93f6e4f4f5f60aa6bae922f0b476e50d6be8 | jongjunpark/TIL | /Public/problem/beginner/6280.리스트,튜플6.py | 128 | 3.578125 | 4 | input1 = int(input())
result = []
for i in range(1,input1 + 1):
if input1 % i == 0:
result.append(i)
print(result) |
bee81dd521701fe40ed429a54bf7d699ce174921 | asyrul21/recode-beginner-python | /materials/week-4/src/for.py | 531 | 4.34375 | 4 | students = [ "Ali", "Abu", "John", "Siti", "Bob" ]
print("The For In Loop")
print("Print Students who name starts with an A:")
for student in students:
if student[0] == "A" or student[0] == "a":
print(student)
print()
print("The For in Enumerate Loop")
for index, student in enumerate(students):
pr... |
37814ba9d9da38f994f211414b81dedd5bc02846 | 2unde001/zignature_look | /python_tutoria/mit_edx/approximate_solution.py | 489 | 3.96875 | 4 | cube = 27
epsilon = 0.01
guess = 0
increament = 0.0001
num_quesses = 0
"""
Guess and check the cube root of a number and increament my guess by
0.0001 until guess number if close proximity the the cube
"""
while abs(guess**3 - cube) >= epsilon and guess <= cube:
guess += increament
num_quesses += 1
print("n... |
243a995465ae71646e50843d551d12b0c7eaa958 | Doerrler/Master | /CSci 1133/hw4.py | 659 | 3.609375 | 4 | n = eval(input("Enter a number > 1: "))
if n <= 1:
print("Error, value given is not greater than 1.")
quit()
nlist = list(range(2,n+1))
iterator = 0
while iterator < len(nlist):
m = nlist[iterator]
value = 2
firstmultiple = (m * value)
while (firstmultiple not in nlist) and (value <= m):
... |
85c78d257d7955b6ed7c434bc299d10dadc985d2 | scottwat86/Automate_Boring_Stuff_ | /ch6_manipulate_strings/PP4_table_printer.py | 1,046 | 4.34375 | 4 | # Automate the Boring Stuff with Python 3
# Ch 6 - Practice Project - Table Printer
# By Scott Watson
def printTable(table):
colWidth = []
numCol = len(table[0])
numRow = len(table)
for list in table:
# Sorts each sublist by length and returns sor... |
8da4f913c74b17c451e3847f2cacbeb3275eb6b9 | XixinSir/PythonKnowledgePoints | /多线程的练习/9、凑够一定数量才能一起执行.txt.py | 426 | 3.515625 | 4 | import threading
import time
bar = threading.Barrier(4)
def run():
for i in range(10):
print("%s--start" % (threading.current_thread().name))
time.sleep(1)
bar.wait() # 凑四个
print("%s--end" % (threading.current_thread().name))
if __name__=="__main__":
for i in r... |
a111ca77971b17bf54cf8505ec32adfd6557f131 | Otobi1/Bike-Demand-Prediction | /model_files/bike_demand.py | 1,682 | 3.765625 | 4 | import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import pickle
# Reading the dataset
dataset = pd.read_csv(
r"C:\Users\olutu\ML_BIKE_DEMAND\model_files\SeoulBikeDemand.csv",
encoding="unicode_escape",
)
# Dropping the date attribute
dataset = dataset.drop("Date", axis=1)
# Changing the ... |
8e00f75545dbe3903e2c05d2d18daabb597efc3e | adinath10/Python-Apps | /Unit-5 Dictionaries/Database_Admin_Program.py | 1,300 | 4.21875 | 4 | #Python Challenge 22 Database Admin Program
print("Welcome to the Database Admin Program")
users_login_info = {
"mooman74" : "alskes145",
"meramo1986" : "kehns010101",
"nickyD" : "world1star",
"george2" : "booo3oha",
"admin00" : "admin1234"
}
username = input("\nEnter your username: ")
if username in use... |
f7a14b84dd8c391d9fcb5bcfb542243eba123d48 | ronishz/fastest-prime-number-checker | /prime.py | 226 | 3.8125 | 4 | import os
num=input("Enter a number [0,10^37]\n")
a="factor "+str(num)+"| grep "+str(num)+"| cut -d : -f 2 | cut -d ' ' -f 2"
a2=int(os.popen(a).read())
if(a2==num):
print "Number is prime"
else:
print "Number is not prime"
|
61d9cb0ab5ce87a5acc9911c8d1f20c4eb3ae126 | dkirton24/PythonPractice | /practie1.py | 132 | 3.578125 | 4 | list1 = [1,5,7,4,3,8,7,4,6]
for i in range(0, len(list1)):
print(i, "\t", list1[i])
for e in list1:
print(e)
|
e061a979d18fecbbe6f72aea9d5db28f2df3b7b3 | Cattleman/python_for_everybody_coursera | /string_comparison.py | 867 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 25 12:09:56 2016
@author: Hensel
String Comparisions - Chapter 6 video 'Strings'
~~~~~~~
RESOURCE: https://docs.python.org/2/library/stdtypes.html#string-methods
#can do comparisons of equality == less and greater than > <
Extensive string library
"""
greet = 'Hello Bob... |
5ca1f7df42398d52dc2b33a580bb15a3b63a642e | ootz0rz/tinkering-and-hacking | /~Practice/Longest Common Subsequence/main.py | 787 | 3.921875 | 4 | '''
See readme.md for what this code is based off of.
'''
def LCS(X, Y, mem={}):
'''
Compute the Longest Common Subsequence of sequences X and Y
'''
i = len(X)
j = len(Y)
# init mem
if not (i in mem):
mem[i] = {}
if not (j in mem[i]):
mem[i][j] = []
# LCS of any set and an empty set is the empty set
... |
01cea75b46018b591bb745bcb6427a4258e279d2 | SYSU-TomJx/vscode-leetcode | /71.simplify-path.py | 2,948 | 3.609375 | 4 | #
# @lc app=leetcode id=71 lang=python
#
# [71] Simplify Path
#
# https://leetcode.com/problems/simplify-path/description/
#
# algorithms
# Medium (28.16%)
# Total Accepted: 143K
# Total Submissions: 506.2K
# Testcase Example: '"/home/"'
#
# Given an absolute path for a file (Unix-style), simplify it. Or in other
#... |
23fa8d334cde3a30fd8181a9f5ae4c468c5b4e1a | fraglesinho/python-poczatek | /funkcje/aaa.py | 214 | 3.9375 | 4 | phone_number = input("Podaj numer telefonu: ")
for digit in range(10):
digit_times_in_number = phone_number.count(str(digit))
print(f"Cyfra {digit} występuje w Twoim numerze: {digit_times_in_number} razy") |
8a620a3c0d4c80ec695ff0570673adbddb5de452 | zhangyudong0215/FightAgainstLeetCode | /Python3/530. Minimum Absolute Difference in BST.py | 664 | 3.703125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def getMinimumDifference(self, root):
"""
:type root: TreeNode
:rtype: int
"""
values = [] # 120m... |
a5f73d4526228f85a5bca666069844e9dfd0635c | DyLanCao/ipython | /base/file_handle/file_operation.py | 378 | 4.09375 | 4 | #!/usr/bin/env python3
#with open('somefile.txt','rt') as f:
#print('hello world', file=f)
#f.write('hello world')
# Read the entire file as a single string
file = open('testfile.txt','w')
file.write("Hello World\n\t")
file.write("This is our new text file\n\t")
file.write("and this is another line.\n\t") ... |
b76158d48e3b976caec35495c4135d5e0f9da1b8 | Bunny1438/CipherSchools_Assignment | /toMergeKSortedArrays.py | 1,256 | 3.875 | 4 | class Node:
def __init__(self, x):
self.data = x
self.next = None
def printList(node):
while (node != None):
print(node.data,
end = " ")
node = node.next
def mergeKLists(arr, last):
for i in range(1, last + 1):
while (True):
head_0 = arr[0]
head_i = arr[i]
if (head_i == None):
brea... |
5859e36d2db6ef2721ac81622be5dc770260a1a3 | eson27/untitled | /day43-前端/5 web框架/1 python简单端服务端_server.py | 1,229 | 3.5 | 4 | '''
1.实现最简web框架
'''
# # 1.最简web框架 v1.0 -实现浏览器访问-回复'hello this is from server!!'
# import socket
#
# server = socket.socket()
# ip_port =('127.0.0.1',9001)
# server.bind(ip_port)
# server.listen()
#
# while 1:
# conn,addr = server.accept()
# print(server.accept(),'conn:',conn,type(conn))
# from_client_msg ... |
94df7ef623912ec940a4a8fb8b851d9a3b678d0c | hideki/clustsrch | /clustering/text.py | 924 | 3.765625 | 4 | #!/usr/bin/env python
import re
import stopwords
def wordcount(words):
wc = {}
for word in words:
wc.setdefault(word, 0.0)
wc[word] += 1.0
return wc
def tokenize(text):
return cleanwords(re.split('\W+', text))
def cleanwords(words):
return _filterStopwords(_normalize(_filterEmpty... |
f290d91f8ab0c36e766018397f52845684acdf3e | Pato91/msft | /chapter4-algos/bubblesort-recursive.py | 843 | 4 | 4 | import unittest
def bubbleSort(arr):
''' implements the bubble sort on an array
returns an incrementally sorted array
Runtime: O(n^2) > worst case, and 0(n) > best case
'''
# bubble sort - recursive
flag = 0 # track the need for futher recursions
n = len(arr)
for i in range(n-1):
if arr[i] > arr[i+1]:
ar... |
4b7cc187dfaf62355cd2c474f53093b96258f8c6 | JeffLawliet/Paysage-python | /Camille/fonctionvoiture.py | 2,769 | 4.09375 | 4 | # voiture :)
from turtle import *
def aller(x,y,angle=0):
up()
goto(x,y)
down()
seth(angle)
def dessineRoue(x,y,diam):
aller(x,y)
color('black')
begin_fill()
circle(diam,360)
end_fill()
aller(x,y+(diam/3))
color('white')
begin_fill()
circle((2*diam)/3,360)
end_... |
d881d6c262b6bd567533cb876a0f4fcaa187a4a9 | Tmk10/Hacker-Rank | /pilling_up.py | 394 | 3.640625 | 4 | from collections import deque
for _ in range(int(input())):
cubes = int(input())
row = deque(input().split())
for _ in range(cubes):
if (int(row[0]) == int(max(row)) or int(row[-1]) == int(max(row))):
row.popleft() if row[0] >= row[-1] else row.pop()
else:
break
... |
6e4867e04e15c758a62d5c3a1d250192524288fc | monroy8888/universidad_python_udemy | /postgres_python/4_operador_unpacking/diccionarios.py | 597 | 3.796875 | 4 | diccionario = {'Sergio':27 , 'Valeria':7, 'Pau':4, 'Marlen':54}
print(diccionario)
#Agregando valor
diccionario['tatiana']=16
print(diccionario)
# """.get""" Metodo recupera llave sin lanzar excepcion
print(diccionario.get('Sergio','no se encontro'))
print(diccionario.get('Serg','no se encontro'))
#""".setdefault"... |
385c4f8ac562afeed252bfe677d184f73fe59a60 | kasem777/Python-codeacademy | /dictionary/unique_num.py | 490 | 4 | 4 | # Which Number Is Not like the Others?
# Create a function that takes a list of numbers and
# return the number that's unique.
def unique(lst):
dict = {}
for item in lst:
if item in dict:
dict[item] += 1
else:
dict[item] = 0
for item in lst:
if dict[item] ==... |
3c793d88f610767ee9fdbadd529d8095013644cf | mikail-masood/misc_python_repo | /pigLatinCipher.py | 1,116 | 3.703125 | 4 | ################################################################################
############################# Pig Latin Cipher #################################
################################################################################
# helper functions:
def convertToPL(message):
normalMessage = message.low... |
98089f7e47be957b500b9927c47622f0dc9c413c | leolivares/leolivares | /Avanzada/Semana 9/ayudantia09.py | 18,182 | 3.515625 | 4 | from collections import deque, namedtuple
from random import expovariate, randint, seed
class Restaurant:
def __init__(self, mesas, tiempo_simulacion, tasa_llegada):
# Guardamos en atributos al tiempo actual y el máximo
self.tiempo_actual = 0
self.tiempo_maximo = tiempo_simulacion
... |
4a6b17f0d1d7a51aeb417fb1272b6dd7688d0daf | ValiPython/Think-Python-2E-My_solutions | /Chapter 1/E2-2.py | 134 | 3.6875 | 4 | # "How many miles are there in 10 kilometers? Hint: there are 1.61 kilometers in a mile."
km_to_m = 10 / 1.61
print (km_to_m)
|
e8f0d8c693540b02cdaf072d3e26668d67fdac53 | Mauriciofrias22/Len-s-Slice-Pizzas | /lens_slice.py | 1,132 | 4.53125 | 5 | #List to keep track of the kinds of pizzas you sell
toppings = ['pepperoni', 'pineapple', 'cheese', 'sausage', 'olives', 'anchovies', 'mushrooms']
#list to keep track of how much each kind of pizza slice costs
prices = [2, 6, 1, 3, 2, 7, 2]
#variable to Find the length of the toppings list
num_pizzas = len(toppings)
p... |
266bd5890160c79e5c0e891bbe4f93cede81ec1f | fmv1992/data_analysis_and_interpretation_specialization | /02_data_analysis_tools/assignment_04/assignment_04_aux_subsetting_addhealth.py | 772 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 15 08:17:14 2016
Author: Felipe M. Vieira
"""
import pandas as pd # version '0.18.0'
# creates a map from meaningless names to meaningful ones
col_map = {
'H1ED11': 'grade_language_arts',
'H1ED13': 'grade_history_social_studies',
'H1ED12': 'grade_math',
... |
1a812811ef8a698761e0c8c38fbe83d7af448ed3 | CLima86/Python_C_C | /Documents/pythonfiles/python_c_c/Exer_Ch_6/pizza.py | 343 | 3.984375 | 4 | """
File: pizza.py
Original Author: C. D. Lima
"""
# Store information about a pizza being ordered.
pizza = {
'crust': 'thick',
'toppings': ['mushrooms', 'extra cheese']
}
# Summarize the order
print("Your " + pizza['crust'] + "-crust pie comes with the follwing toppings: ")
for topping in pizza['toppings']:
pr... |
1b9f71b851444365745727f0e32cf46f90fefc10 | Drummer7777777/test | /figurs.py | 590 | 3.65625 | 4 | class Figurs():
count_corner=0
radius=0
has_pr_corner="no"
class Circle(Figurs):
def __init__(self):
print("Это круг")
def pl(self,count_corner,radius,has_pr_corner):
print("Его площадь:", 3.14*int(radius)**2)
class Pryamougolnik(Figurs):
def __init__(self):
... |
17ddb56693786e117d1ca9d8d66f39e97fecb15e | rjsalamanca/list_exercises | /de_dup.py | 411 | 3.859375 | 4 | list_with_duplicates = [1,2,3,4,4,2,3,4,5]
unique_list = []
for i in range(len(list_with_duplicates)):
count = 0
for j in range(len(list_with_duplicates)):
if list_with_duplicates[i] == list_with_duplicates[j]:
count += 1
if count == 1:
unique_list.append(list_with_duplicates[i]... |
92602e73a6f5dd8e131ab45b0abdc504b0752d45 | YoushaExT/practice | /moreproblems/q88.py | 245 | 3.6875 | 4 | # By using list comprehension, please write a program to print the list after removing delete numbers
# which are divisible by 5 and 7 in [12,24,35,70,88,120,155].
L = [12,24,35,70,88,120,155]
L = [x for x in L if x%5!=0 and x%7!=0]
print(L)
|
56f2692d1321507400ecd02a39a33332df27df95 | TungstenRain/Python-classes-and-methods | /time2.py | 4,023 | 4.3125 | 4 | """
This module contains code related to
Think Python, 2nd Edition
by Allen Downey
http://thinkpython2.com
This is to complete the exercises in Chapter 17: Classes and Methods in Think Python 2
Note: Using Python 3.9.0
"""
class Time:
"""
Represents the time of day
att... |
f60f49aa4fe2be4671905381b1017c5880516035 | yunxifeng/pythonstudy | /03python--高级语法/08--p06.py | 1,639 | 4.1875 | 4 | # 线程常用属性案例
#导入包
import time
import threading
#定义三个子线程
def loop1():
print("Start loop1 at:", time.ctime())
time.sleep(6)
print("End loop1 at:", time.ctime())
def loop2():
print("Start loop2 at:", time.ctime())
time.sleep(1)
print("End loop2 at:", time.ctime())
def loop3():
print("Start loop3 ... |
aca002862847ab2f0a48404a57ce76073c689022 | LeroySalih/lessons-fop-validation-challenges | /starter.py | 224 | 3.71875 | 4 | def mySum (a, b):
return a + b
pupil_age = 15
if __name__ == "__main__":
word = input("Enter a word.")
print("The first letter is {0}".format(word[0]))
print("The last letter is {0}".format(word[-1:])) |
60a3ccb5ec13ad33e20599d95e5c1bb2a5c9387d | myousufkhan360/Artificial-Intelligence-searching-algorithm | /AI searching algorithms/a-hesteric=search/m_shp_w_graph.py | 4,725 | 3.984375 | 4 | # This PYTHON MODULE is a SECONDARY MODULE which is
# IMPORTED in ANOTHER MODULE which CONTAINS the main
# PROGRAMMING LOGIC. This MODULE is USED to IMPLEMENT
# a DIRECTED and WEIGHTED GRAPH. The GRAPH is
# IMPLEMENTED as a CLASS which CONTAINS various
# METHODS related to the creation and manipulation
# of the GRAPH. ... |
f2bd68eeb2f65c106758cfd70ee7a3b04f65a0d7 | mbuhot/mbuhot-euler-solutions | /python/problem-077.py | 1,839 | 3.84375 | 4 | #! /usr/bin/env python3
import math
import prime
from itertools import count
from memo import memoize
description = '''
Prime summations
Problem 77
It is possible to write ten as the sum of primes in exactly five different ways:
7 + 3
5 + 5
5 + 3 + 2
3 + 3 + 2 + 2
2 + 2 + 2 + 2 + 2
What is the first value which can... |
1853b84024d1084125dddf212ca6727c592b0190 | ohadomrad570/Sigit-Python | /Targil5 - Map Function.py | 548 | 3.9375 | 4 | """
Ohad Omrad
Python and Git
"""
import math
def Map(f, list):
# This function get a function and a list and apply the function on any item in the list
# Get: f (function), list = [x, y, ...]
# return: the function return a new list with the new items [f(x), f(y), ...]
return [f(item) for item in lis... |
df60cbe23c27c5bf91bbd1eea1e3d314da995278 | ianujvarshney/Python-Programs | /Intermediate Level Programs/Snake_Water_Gun.py | 2,402 | 3.703125 | 4 | import random
import winsound
sat=["s","w",'g']
freq=640
duration=1000
comp=0
user=0
chances=5
chance=0
print("\n\n\t\t\t\t\t\t\t\tWelcome To The SANKE , Water, GUN GAME Developed by : @ Satyam Tripathi & Company")
print("\nRules : \n1. You have only 5 chances !!\n2. S for Snake , W for Water , G for Gun !!")
while cha... |
a0dbee2b55b968f6860dfb5f49e00c75c40576ab | Narcolapser/LittleLibs | /Python/linearAlgebra.py | 4,972 | 3.65625 | 4 | #linearAlgebra -
# Purpose - this contains the vectors and matrices and associated maths.
# data types - vec2,vec3,vec4,matrix2x2,matrix3x3,matrix4x4.
# functions - vecx(+,-,*,dot,cross(only for vec3), matrixx(+,-,*,det,inverse)
import math
EPSILON = 4.94065645841e-324
class Vec2:
def __init__(self,x,y):
self.x =... |
3841592e58017b4065a57049f8d589c5f9f9d6f6 | eduwr/python | /estruturas_controle_projetos/fibonacci_v8.py | 304 | 4.03125 | 4 | #! usr/local/bin/python3
# 0, 1, 1, 2, 3, 5, 8, 13, 21,...
def fibonacci(quantidade, sequencia=(0, 1)):
#importante! Condição de parada
if len(sequencia) == quantidade:
return sequencia
return fibonacci(quantidade, sequencia + (sum(sequencia[-2:]), ))
print(fibonacci(20)) |
d306736ffd5b0074ae5fdb915931777f249826c0 | akshayrao1012/Machine-Learning | /Great Learning/Statistics/Project 1/Stats Assignment-1.py | 2,997 | 4.15625 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Read the data set and replace dashes with 0 to make sure you can perform arithmetic operations on the data. (5 points)
# In[1]:
import numpy as np #import library numpy as np
import pandas as pd #import library pandas as pd
import warnings #importing warnongs library to ign... |
5a184e419120884b307dc6d25aa35062e92dcbd3 | Gary35-bot/lists-tuples | /main.py | 320 | 3.75 | 4 | # task 2
ages = [2, 12, 12, 14, 15, 16, 16, 17, 18, 14, 20, 20]
ages1 = [2, 4, 12, 14, 15, 16, 16, 17, 18, 14, 20, 20]
def common_data(ages, ages1):
for x in ages:
for y in ages1:
if x == y:
return "true"
else:
return "false"
print(common_data(ages, ages1))
|
344f6de3fc5a30b875e2c016b8bb4a3680c8367b | hirenpat/Python | /problem_set_1/ps1c.py | 1,240 | 4.1875 | 4 | #ps1c
starting_salary = float(input('Enter the starting salary: '))
saving_rate = 0
total_cost = 1000000
semi_annual_raise = 0.07
portion_down_payment = 0.25*total_cost
monthly_salary = starting_salary/12
r = 0.04
number_of_months = 0
total_salary = 0
while number_of_months < 36:
if number_of_months % 6 == 0:
... |
f4379b5fdc63908d6b97351a6b951c871f04d1eb | itsraf/CURSE | /SE_script/assignment5.py | 43,140 | 4.34375 | 4 | import sqlite3
import getpass
# database file connection
database = sqlite3.connect("CURSE.db")
# cursor objects are used to traverse, search, grab, etc. information from the database, similar to indices or pointers
cursor = database.cursor()
######################################################################
# SQL... |
436b0991fed84371c68777a5147c856ea9202c94 | Kawser-nerd/CLCDSA | /Source Codes/AtCoder/abc049/A/4926904.py | 103 | 3.984375 | 4 | c=input()
vowels=["a","i","u","e","o"]
if c in vowels:
print("vowel")
else:
print("consonant") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.