blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
77c0c33393d0df7df1adfe9765feb07d4f0978d0 | whocaresustc/LeetCode-Solutions-Python | /1095. Find in Mountain Array.py | 2,201 | 3.9375 | 4 | # """
# This is MountainArray's API interface.
# You should not implement it, or speculate about its implementation
# """
#class MountainArray(object):
# def get(self, index):
# """
# :type index: int
# :rtype int
# """
#
# def length(self):
# """
# :rtype int
# ""... |
8d8b7843ee181c0feddbf94b2d0b98da83552475 | YusefQuinlan/PythonTutorial | /Intermediate/2.3 BeautifulSoup/2.3.1_BeautifulSoup_Introduction.py | 2,385 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 18 12:47:42 2020
@author: Yusef Quinlan
"""
# We must import requests and BeautifulSoup in order to webscrape with
# BeautifulSoup.
import requests
from bs4 import BeautifulSoup
# First we need to request the url and get it contents etc with
# requests.get(url).
page = ... |
224737857b2b5ec072400a7b65c696ccdba0a28f | AlakiraRaven/ProjectEuler | /HelloWorld_and_SomeFun.py | 351 | 3.65625 | 4 | x = 'Hello World'
s = 'Sander'
m = 'Marta'
ListOfNames = [m, s]
l = []
print(x + ', ' + s + ' and ' + m)
for i in range(len(ListOfNames)):
print(x + ', ' + ListOfNames[i])
for name in ListOfNames:
print(x + ', ' + name)
for i in range(2, 20):
if i % 2 == 0:
print(i)
else:
print(... |
a840e333d2e491409b7dcbf2dde1172d880083b1 | tarrlikh/Casimir-course | /old_stuff/test.py | 284 | 3.671875 | 4 | print('hello world')
print('bye world!')
print('Hi Yaroslav! I changed your code')
x=2+2
print(x==4)
'''This is Klara's first comment on this code, we want to merge comments from all of us here!'''
"""THERE ARE LLAMAS OUTSIDE OR ALPAKAS I AM NOT SURE SINCE THEY LOOK THE SAME"""
|
440e4d1194605237e34f37e8b5c81fb3d398ce79 | YujiaBonnieGuo/learn_python | /ex10条件判断.py | 922 | 4.15625 | 4 | # age=2
# print('your age is',age)
# if age>=18:
# print('adult')
# elif age>=6:
# print('tennager')
# else:
# print('kid')
hight=float(input('请输入身高(单位:米):'))
weight=float(input('请输入体重(单位:千克):'))
# BMI=weight/(hight*hight)
BMI=weight/(hight**2)
if BMI<18.5:
print('过轻')
elif BMI<25:
print('正常')
elif BMI<28:
pr... |
75d9ab5215e9cd485bb81eb9bffedd19e76e6be2 | sti11wind/pythontutor | /calculations.py | 7,374 | 3.890625 | 4 |
# Задача «Последняя цифра числа»
# Условие
# Дано натуральное число. Выведите его последнюю цифру.
a = int(input('Введите число '))
print(a % 10)
# Задача «МКАД»
# Условие
# Длина Московской кольцевой автомобильной дороги —109 километров. Байкер Вася стартует с нулевого километра МКАД и едет со скоростью v километров... |
db072b1375c4f0ae9c411b89582e21e4ecfd15f7 | rafdanzi/git_lesson | /src/my_square.py | 155 | 3.65625 | 4 |
def my_square(x):
"""take a value and returns the square value
use the ** operator
"""
return(x **2)
print(my_square(4))
|
05c15d71a8ca22611288097ecd50f01daae69272 | pparonson/LPTHW | /review_notes.py | 1,710 | 4.15625 | 4 | # Assign "formatter" var to "%r %r %r %r"
formatter = "%r %r %r %r"
# print value of formatter var with hard values passed into parameter
print "This will print hard values.", formatter % (1, 2, 3, 4)
print "This will pass variables.", formatter % ("one", "two", "three", "four")
print formatter % (formatter, formatter... |
5fe95312c939d79334c79fecc72e93e3410cd071 | LuluOS/WorldDomination2 | /main.py | 6,564 | 3.71875 | 4 | from bs4 import BeautifulSoup #""" http://www.crummy.com/software/BeautifulSoup/bs4/doc/ """
import requests
#############################################################################################################
#""" Functions """
#""" function to check if a substring is part of a string """
def checkSubInStr(s... |
d5460ce6c0f4829a773b94ceb08ac546bd5cc174 | vstarman/python_codes | /8day/06.生成器的使用.py | 1,129 | 4.125 | 4 |
'''# 生成器是特殊的迭代器可用next()获取下一个值
# 如果在函数里出现了yield这个关键字,它就是生成器
def fib(num):
a = 0
b = 1
current_index = 0
print("---------1---------")
while current_index < num:
result = a
a, b = b, a+b
current_index += 1
print("---------2---------")
# 如果函数里出现了yield表示生成器
... |
85d66d3a20f79d265626067e460c91809f79d2df | nachande/PythonPrograms | /AssignmentOperator_10.py | 301 | 3.9375 | 4 | a,x=10,2
b=20
print("Addition of ",a,b,"is =",a+b)
print("Subtraction of ",a,b,"is =",a-b)
print("Multiplication of",a,b,"is =",a*b)
print("Division of ",a,b,"is =",a/b)
print("Modulus of ",a,b,"is=",a%b)
print(a,"to the power of ",x," is =",a**x)
print("Floor Division of",a,b,"is=",a//b)
|
a4d998be3c76fd5db9df580d84cf7699d6d02ba8 | HenryBalthier/Python-Learning | /Leetcode_easy/linkedlist/203.py | 1,160 | 3.640625 | 4 |
class Solution(object):
def removeElements(self, head, val):
"""
:type head: ListNode
:type val: int
:rtype: ListNode
"""
if head == None:
return head
while head.val == val:
head = head.next
if head == None:
... |
b411ac4668d81b05f86ae0789e34aaee41ed9efd | RoyHoffman/python-NEAT-implementation | /XOR_test.py | 921 | 3.5 | 4 | # -*- coding: utf-8 -*-
import globals
import math
def test_network(network,run,debug = False):
fitness = 16
fitness -= (abs(0-network.run(0,0,globals.BIAS)[0])*2)**2
fitness -= (abs(1-network.run(1,0,globals.BIAS)[0])*2)**2
fitness -= (abs(1-network.run(0,1,globals.BIAS)[0])*2)**2
fitness -= ... |
ff96864b7bc73043721afd18a6c7645430590dec | vuminhph/randomCodes | /Techniques/DynamicProgramming/knapsack_problem.py | 1,460 | 3.609375 | 4 |
def main():
val = [10, 40, 30, 50]
wt = [5, 4, 6, 3]
items = dict(zip(wt, val))
weight = 10
lookup = [[-1 for i in range(weight + 1)] for j in range(len(items))]
print(solve_knapsack(len(items) - 1, items, weight, lookup)[0])
def solve_knapsack(index, items, capacity, lookup):
if index ==... |
cd4d11dac06e7a0453a9f133af3409190c76c29e | icodetohack/pythonProject | /codewars_replaceWithAlphabetPosition.py | 577 | 4.34375 | 4 | """
Welcome.
In this kata you are required to, given a string, replace every letter with its position in the alphabet.
If anything in the text isn't a letter, ignore it and don't return it.
"a" = 1, "b" = 2, etc.
Example
alphabet_position("The sunset sets at twelve o' clock.")
Should return "20 8 5 19 21 14 19 5 20... |
f23aab913b77cae96e354e4285358191358a7b95 | kalyan-dev/Python_Projects_01 | /demo/oop/doctor.py | 1,940 | 3.890625 | 4 | from abc import ABC,abstractmethod
class Doctor:
def __init__(self, name, specialization, phone_no):
self.name = name
self.specialization = specialization
self.phone_no = phone_no
def print(self):
return self.name + "[" + self.specialization + ", Ph-" + str(self.ph... |
78a05b99b762de6027e43591d9127fda73550e36 | soonhyeok/Python_DataStructure_codeit | /Chap04/05_Linked_List.py | 1,077 | 4.25 | 4 | class Node:
"""링크드 리스트의 노드 클래스"""
def __init__(self,data):
self.data = data # 노드가 저장하는 데이터
self.next = None # 다음 노드에 대한 레퍼런스
class LinkedList:
"""링크드 리스트 클래스"""
def __init__(self):
self.head = None
self.tail = None
def append(self, data):
"""링크드 리스트 추가 연산 ... |
fba379fc20c4a387e22a96c7a191dd77da10f52a | ganqzz/sandbox_py | /examples/job_queue.py | 521 | 3.8125 | 4 | # Circular Queue demo
from collections import deque
import random
jq = deque()
for j in list('ABCD'):
jq.append({'label': j, 'completed': random.randint(5, 25)})
while len(jq) > 0:
current = jq[0]
current['completed'] -= 5
if current['completed'] > 0:
print('Job {0} has {1} remaining'.forma... |
8404f41ae1485c6f07c517fb13d341d4ff1e8c86 | Xuu666/algorithm023 | /Week_07/#433 最小基因的变化.py | 750 | 3.5 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
class Solution(object):
def minMutation(self, start, end, bank):
"""
:type start: str
:type end: str
:type bank: List[str]
:rtype: int
"""
bank = set(bank)
if end not in bank: return -1
q = [(st... |
23b0e689463443300974acc1f27388e93e66bf27 | kts1297/Leetcode | /443.py | 723 | 3.578125 | 4 | # https://leetcode.com/problems/string-compression/?envType=study-plan-v2&envId=leetcode-75
class Solution:
def compress(self, chars: List[str]) -> int:
res = ""
count = 1
c = chars[0]
for ndx in range(1, len(chars)):
if c == chars[ndx]:
count += 1
... |
7c104931288427d82cf99a0caf7dfc1439a6534c | tennyson-mccalla/PPaItCS | /lineSeg.py | 999 | 4.21875 | 4 | from graphics import *
def main():
# Create the window
win = GraphWin("Line Segment Information", 1000, 1000)
win.setCoords(0, 0, 1000, 1000)
# Explain to user what the app does
intro = Text(Point(250, 975), "This app will draw a line segment between two mouse clicks and show some info about it."... |
8fccaecf919b896a13273999c4c8314b05f628c8 | UberBudderCow/L1-Python-Tasks | /Giftcard.py | 417 | 3.84375 | 4 | giftcard = 50
print("Giftcard balance: ${}".format(giftcard))
decision = input("Do you wish to purchase skins and weapons for your game?")
if decision == "Yes":
giftcard -= 35
print("You have purchased skins and weapons")
print("Your new balance is: ${}".format(giftcard))
elif decision == "No":
print("Y... |
107461172a4a2d9597c2219f4848a4beb01385e2 | rishabhkashyap/pyCookbook | /com/algo/trie/trie.py | 1,448 | 3.953125 | 4 | from com.algo.trie.node import Node
class Trie:
def __init__(self):
self.root = Node('')
def add_word(self, word):
if (word is not None and isinstance(word, str)):
current_node = self.root
for char in word:
node = current_node.get_neighbour(char)
... |
32ea461137c4352a5309cbf57356484858ace417 | Nischal47/Python_Exercise | /#13.py | 528 | 4.0625 | 4 | '''Question:
Write a program that accepts a sentence and calculate the number of letters and digits.
Suppose the following input is supplied to the program:
hello world! 123
Then, the output should be:
LETTERS 10
DIGITS 3
'''
Letters_count=0
Digits_count=0
x=input("Enter a sentence:")
for i in range(len(x)):
if (x[... |
7d3dcac4e75c47e87299c8abf3572d7ffcf7de89 | harshitsoni01/codes | /kinter.py | 1,005 | 3.921875 | 4 | from tkinter import *
m = Tk()#initializing the tkinter window
m.title("Title of GUI")
m.geometry("600x600")#size of the window # its "x" not "*"
thelabel = Label(m, text = "Welcome to GUI!")
thelabel.pack(side = TOP)#pack method for placements of objects
b1 = Button(m, text = "Button1", fg="white", bg="black")
b1.pack... |
9794530e59a070c7545bca1dce5c7fadc0f6c760 | jefinagilbert/problemSolving | /hr105_missingNumbers.py | 398 | 3.828125 | 4 | def missingNumbers(arr, brr):
arr1 = []
for i in brr:
if i in arr:
arr.remove(i)
else:
if i not in arr1:
arr1.append(i)
arr1.sort()
return arr1
arr = []
brr = []
k = input().split()
for i in k:
arr.append(int(i))
k = input().... |
9095ecdd33337bcd414c28728f0fc49a602c3ce0 | confar/simple-db-auth | /main.py | 1,101 | 4.03125 | 4 | import sqlite3
import getpass
conn = sqlite3.connect('firstbase.sqlite')
print "Connecting database ";
cursor1 = conn.execute("SELECT id, access, login, password from loginlist")
for row in cursor1:
print "id = ", row[0]
print "access = ", row[1]
print "login = ", row[2]
print "and the password is", row... |
71b5db48fc51dbd82b53663b6cb4cc08458c878d | justien/lpthw | /ex5.py | 1,017 | 4.03125 | 4 | # Describe Zed Shaw - the Hard Way!
# -*- coding: utf-8 -*-
# here we define our variables
my_name = "Zed Shaw"
my_age = 35 # not a lie
my_height = 74 # inches
my_weight = 180 # pounds
my_eyes = 'Blue'
my_teeth = 'White'
my_hair = 'Brown'
# now we print out information about Zed, using the above defined variables
... |
8ff8b85c5c9a82404db175a5883183d338b562b6 | petitblue/Python | /games/tictac.py | 8,220 | 4.4375 | 4 | # -----------------------------------------------------------------------------
# Name: tictac
# -----------------------------------------------------------------------------
'''
Module to implement a Tic-tac-toe game between human player and computer
player. The players take turns marking the spaces in a ... |
9aaaf68ad3259e6474020dd6ecc5f1f480a638df | anton-dovnar/CodeWars | /kyu6/decode_the_morse_code.py | 295 | 3.5 | 4 | def decodeMorse(morse_code):
translate = [MORSE_CODE[code] if code else '' for code in morse_code.split(' ')]
result = ""
for value in translate:
if value == '':
result += ' '
else:
result += value
return result.replace(' ', ' ').strip()
|
5fd557303d4a7628cb6b303b650622981fe33e06 | gautam417/Python-Files | /CIS41A/ICE_F.py | 1,521 | 3.84375 | 4 | """
Gautam Mehta
CIS 41A Fall 2017
ICE_F
"""
myInt=3
myList= [0,1,2]
def byVal(y):
print ("Original ID of parameter in byVal is:", id(y))
x= y+7
print ("ID of parameter in byVal after change is:", id(x))
def byRef(b):
print("Original ID of parameter in byRef is:",id(b))
w=len(b)-1
print("Origin... |
126afe024cddd389bde6bfd97586b4257bd4f7f0 | redpanda-ai/ctci | /solutions/group_anagrams_2.py | 360 | 3.8125 | 4 | from collections import defaultdict
def group_anagrams(anas):
groups = defaultdict(list)
for word in anas:
x = "".join(sorted(word))
groups[x].append(word)
solution = []
for key in groups.keys():
solution.extend(groups[key])
print(solution)
test = ["ABC", "BAC", "DEF", "... |
18020c4f50b78b0fe35baf22dc529ee9e07fd7a4 | citlalygonzale/TC1014 | /e.py | 208 | 3.71875 | 4 | def calculate_e(c):
x = c
ce = (1+1/x)**x
return float(ce)
r = int(input("Number of decimal points of accuracy: "))
resulte = calculate_e(r)
print("The estimate of the constant e is:",resulte)
|
a98bd51799efc96e2ed24bb96c1c785603d193d2 | Jiaweihu08/EPI | /16 - Dynamic Programming/16.3 - number_of_traversals_matrix.py | 814 | 3.953125 | 4 | """
Given a nxm grid starting at the top-left corner. Compute the number of
distinct paths to get to the bottom-right corner if we're only allowed
to go right or down.
"""
import functools
def number_of_traversals_matrix(n, m):
"""
O(nm) space and time complexity
"""
@functools.lru_cache(None)
def number_of_trav... |
3f033c2a5a58803eb8147ec612bd172dee24b318 | NAVEENMN/MyArchives | /avltree/bstnew.py | 4,410 | 3.875 | 4 | import random, math
#------------------------------------------------------------------------ BST Section start
class BstNode():
def __init__(self, key):
self.key = key
self.left = None
self.right = None
class BSTTree():
def __init__(self, *args):
self.node = None
sel... |
6a655b9cec1a3a6d45eb047b82f5f186582db1f4 | sbeaumont/AoC | /2021/AoC-2021-1.py | 866 | 3.578125 | 4 | #!/usr/bin/env python3
"""Solution for Advent of Code challenge 2021 - Day 1"""
__author__ = "Serge Beaumont"
__date__ = "December 2021"
def part_1(entries):
raised = 0
for i in range(1, len(entries)):
if entries[i] > entries[i-1]:
raised += 1
return raised
def part_2(entries):
... |
a392987a5b1455949ccc720689b5c585c383940f | wangjm12138/python_other_script | /sockets_server.py | 1,193 | 3.578125 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
#import sys
##reload(sys)
##sys.setdefaultencoding('utf8')
#import socket
## 建立一个服务端
#server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#server.bind(('127.0.0.1',1080)) #绑定要监听的端口
#server.listen(5) #开始监听 表示可以使用五个链接排队
##flag=1
##while True:# conn就是客户端链接过来而在服务端为期生成的一个链接实例... |
0f140cdc0dbfbea690e8a9b843bee1fd6d655356 | madelinecodes/beginner-projects | /TurnBasedPokemon/pokemongame.py | 3,258 | 3.984375 | 4 | import random
import time
print('*' * 36)
print('''\nThis is a turn based Pokemon style game against the computer.
You both have 100 health to start. You cannot go above full health.
Option 1 deals between 18 and 25 damage, option 2 between 10 and 35.
Option 3 heals you by 18 to 25 health points. \n''')
print('*' ... |
cf9912fae71a8f01e96f87773edfc174aeef211a | kwngo/NYC_Subway_python | /plot_entries_per_hour.py | 716 | 3.671875 | 4 | from pandas import *
from ggplot import *
def plot_weather_data(turnstile_weather):
entries_per_hour = turnstile_weather.groupby(["hour"], as_index=False)["ENTRIESn_hourly"].sum()
# Plot with day of week relabeled as abreviation
plot = ggplot(entries_per_hour, aes('hour', 'ENTRIESn_hourly')) + \
g... |
03184a2f469e1ce27641847dc30183d3a658359d | flogothetis/Technical-Coding-Interviews-Algorithms-LeetCode | /Grokking-Coding-Interview-Patterns/14. Top K Numbers/KpointsClosestTwoOrigin.py | 1,047 | 3.765625 | 4 | '''
Problem Statement #
Given an array of points in the a 2D2D2D plane, find ‘K’ closest points to the origin.
'''
from heapq import *
# Time Comp : O(NlogK)
# Space Comp : O(K)
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __lt__(self, other):
self.euclidean_dist() > other.eu... |
c4d9084f7bafc58f473dcec142ddac37eac2b8cd | EshwaryForReasons/Python-Scripts | /Python Calculator/Calculator Multiplication.py | 946 | 4.09375 | 4 | import time
import clipboard
print("Welcome to the multiplication calculator")
p = input("Which profile would you like?")
pi = int(p)
#multiply two digit numbers
def calculator():
i1 = input("What is the first number?")
i2 = input("What is the second number?")
v = int(i1) * int(i2)
print(v)
clip... |
a5db0f6958a3ee88727eefae105cf6ad98139f3a | chprabhu/earnings-trade-strategy | /compute_strategy.py | 2,892 | 3.515625 | 4 | import pandas as pd
import numpy as np
from constants import *
def get_pre_earnings_trading_returns(ticker):
'''
This function returns a list of return rates, assuming that we buy at the open 'num_days'
before the earnings announce date, and sell near the close of the earnings announce date
BTO = Before Trading... |
4c973fa53432d84ac1b819869fee27d195a34b41 | fernandocampello/PythonClasses | /List_15.py | 363 | 3.5 | 4 | x = [5,2,3,10]
n = len(x)
sum = 0
for _x in x:
sum = sum + _x
'''sum + = _x'''
print(sum)
mean = sum/n
print(mean)
sse = 0
for _x in x:
sse = sse + (_x - mean)**2
print(sse)
ssen = sse/n
std = ssen**0.5
print(std)
ssen1 = sse/(n-1)
stds = ssen1**0.5
print(stds)
x = [5,2,3,10]
n = len(x)
sum = 0
for... |
c99809cb53127eb3e5c35be41268f2c6fd573e33 | BhagyaRB/python93 | /Activity_04.py | 486 | 3.984375 | 4 | Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> n=int(input("enter the value for n="))
enter the value for n=4
>>> m=int(input("enter the value for m="))
enter the value for m=8
>>> p=n+m
>... |
3ee4d84864be39ec52aeb986e4c79cb23b4d6e79 | JohanEddeland/AdventOfCode | /2018/05/aoc_05.py | 2,433 | 3.625 | 4 | """ aoc_05.py
Solution for Advent of Code 2018
"""
import aoc_05_input
def replace_all_polymer(aoc_input):
aoc_input = aoc_input.replace('\n', '')
# Start counting at the second letter
current_letter_index = 1
result = [aoc_input[0]]
while current_letter_index < len(aoc_input):
if... |
17d8eda143520015721cc5adf206e46293dc5cfc | yui-chouchou/AMECOBA_PROJECTS | /AMECOBA_SEMESTER1/ADRIAN_PROJECTS/AMECOBA_PROJECT/SECTION_1/python/part1/amecoba-answer.py | 3,980 | 4 | 4 | #端末で初めてのHELLOWORLDを出力してみよう
print("hello world")
print(10-1)
#文字列や数字を合わせて表示する
print("NUMBER", 10 + 2)
print("WELCOME" + "to" + "AMECOBA")
#モジュール(部品)を使って簡単なおみくじプログラムを作ってみよう
import random #シャフルするので、Randomという部品を使います。
kujibiki = ["VERY LUCKY", "LUCKY", "GOOD", "NOT BAD", "BAD", "VERY BARD"]
#変数 = [要素0, 要素1, 要素2, ... |
d36df4cd5c9559fd808fc7df7527d68db7724da2 | Xenever/pavlov | /WithoutKeys.py | 930 | 3.734375 | 4 | #Extended Euclidean algorithm
def egcd(a, b):
x, lastX = 0, 1
y, lastY = 1, 0
while (b != 0):
q = a // b
a, b = b, a % b
x, lastX = lastX - q * x, x
y, lastY = lastY - q * y, y
return (lastX, lastY)
#дробь по модулю(num-числитель,denom-знаменатель)
def Exponent(num,denom,... |
0a85876b84a26926f7bea8593e86ff15105867bb | chizom/python-tutorial | /guessing_game_v1.py | 319 | 3.859375 | 4 | # This is a guessing game that can be inproved on. Just gettnig version one on
the_mind = 10
users_guess = 0
chances = 1
end_game = False
while chances <= 3:
users_guess = input('Guess: ')
chances += 1
if users_guess == the_mind:
print('You win')
break
else:
print('Sorry you failed')
|
7185fa4a9ec0703f6a61c37884a34dfd0b2b6707 | BufteacEcaterina03/Rezolvare-problemelor-IF-WHILE-FOR | /1pr.py | 343 | 3.921875 | 4 | n=int(input('Introduceti numarul de zile:'))
if (n>=28 and n<=31):
if (n==28 or n==29):
print('Februarie')
elif n==30:
print('Aprilie,Iunie,Septembrie,Noiembrie')
else:
print('Ianuarie,Martie,Mai,Iulie,August,Octombrie,Decembrie')
else:
print('Nu exista luna cu asa n... |
8cf9b52617ed8eb6b6588a7033ec081ac885f0d3 | mtbutler93/pythonprojects | /buffets.py | 327 | 3.765625 | 4 | # playing with lists, creating tuples
# mtb 03.20.2018
buffets = ('eegs','bacon','waffles','omlette','sausage')
print ('Original buffet items:')
for buffet in buffets:
print(buffet)
buffets = ('pizza','toast','waffles','omlette','sausage')
print ('\nUpdated buffet items:')
for buffet in buffets:
print(bu... |
9c84cd16cfdbfbd5bf925fbb560892e0752681b1 | Abrar-04/DSA-Practice | /02.LinkedLists/4.ReversedLL.py | 829 | 4.03125 | 4 | class Node:
def __init__(self,data):
self.data=data
self.next=None
class LinkedList:
def __init__(self):
self.head=None
# insert at beginning
def Push(self,key):
new_node=Node(key)
new_node.next=self.head
self.head=new_node
def ReversedLL(self):
... |
74f6a7f39d6173fe523f5c4d57d4c457feb0331a | meloncloud/python-calc | /Class_Persona2.py | 601 | 4.03125 | 4 | class Persona:
def __init__(self,name, age):
self.name = name
self.age = age
def show (self):
print('your name is : ',self.name, ', and your age is :', self.age, 'years old' )
class Persona2(Persona):
def __init__(self,name, age,height):
self.name = name
... |
1653a4d478cbae57fd5a72159fb8354cad7ddc09 | green-fox-academy/Angela93-Shi | /week-02/day-8/write_multiple_lines.py | 935 | 4.21875 | 4 | # Create a function that takes 3 parameters: a path, a word and a number
# and is able to write into a file.
# The path parameter should be a string that describes the location of the file you wish
# to modify
# The word parameter should also be a string that will be written to the file as individual
# The number par... |
eb792677600bf534dccd8b0e928174c2653cfa87 | nishitpatel01/Data-Science-Toolbox | /algorithm/Array/755_Pour_Water.py | 1,566 | 3.515625 | 4 | class Solution:
def pourWater1(self, heights, V, K):
"""
:type heights: List[int]
:type V: int
:type K: int
:rtype: List[int]
"""
# W
# | # |
# |######|
for _ in range(V):
for d in (-1, 1):
i = low = K
... |
abb6b549a2f4ce4842747b38cd544f4ea6e633e6 | ssf-czh/paper_system | /tools/random_pick.py | 297 | 3.53125 | 4 | import random
def random_pick(probabilities):
x = random.uniform(0, 1)
cumulative_probability = 0.0
for item_probability in probabilities:
cumulative_probability += item_probability
if x < cumulative_probability:
return probabilities.index(item_probability) |
a6c1cda5a52bce28900f7e9ed5bac297f59d53f7 | OmarLahzy/Python-scripts | /Function.py | 2,039 | 3.578125 | 4 | def pig_latin (word):
first_letter = word[0]
if first_letter in 'aeiou':
return word+'ay'
else:
return word[1:]+first_letter+'ay'
def Sumnumbers (*args):
return sum(args) * 0.05
def Vegtiable(**kwargs):
if 'fruit' in kwargs:
print('My fruite choice is {}'.format(kwargs['frui... |
388dacbe23bf519a8a4505d82fd8fb417b33bb36 | vadsimus/Python | /HackerRank/Python Challenge/MergeTheTools!.py | 476 | 3.609375 | 4 | # https://www.hackerrank.com/challenges/merge-the-tools/problem
def merge_the_tools(string, k):
for i in range(int(len(string) / k)):
line_str = string[i * k:i * k + k]
line = list(line_str)
j = len(line) - 1
while j > -1:
if line.count(line[j]) >= 2:
de... |
fd42d88656031d97048692f32ffa162a52eeb1e0 | idobleicher/pythonexamples | /examples/functional-programming/itertools_examples/itertools_compress.py | 508 | 4.34375 | 4 | # compress(iter, selector) :- This iterator selectively picks the values to print from the passed container according
# to the boolean list value passed as other argument.
# The arguments corresponding to boolean true are printed else all are skipped.
import itertools
# using compress() selectively print data values
p... |
ade7d89656382c39b72c08bf1c6c2b6e9311c097 | syurskyi/Python_Topics | /125_algorithms/_exercises/exercises/Python_Hand-on_Solve_200_Problems/Section 4 Condition and Loop/check_triange_solution.py | 794 | 4.03125 | 4 | # # To add a new cell, type '# %%'
# # To add a new markdown cell, type '# %% [markdown]'
# # %%
# # ---------------------------------------------------------------
# # python best courses https://courses.tanpham.org/
# # ---------------------------------------------------------------
# # Write a Python program to chec... |
69794166935dfc48225128ed5ad48a6c6882ca8f | William-Mou/Coding365-Practice | /week_1/41.py | 1,078 | 3.890625 | 4 | tree = {"first":['null']}
roots = []
not_root = []
global first
first = "first"
def printf(root = first):
#print(root)
tree[root] = sorted(tree[root])
if root == "first":
pass
elif root == first:
print(root,end = "")
for j in tree[root]:
print(j,end ="")
if j in tree:... |
f8dc19c96a106c79df790bf93ea0c950e9eb8686 | peiss/ant-learn-python-100P | /p008_remove_elements_from_list.py | 395 | 3.984375 | 4 | def remove_elements_from_list(lista, listb):
for item in listb:
lista.remove(item)
return lista
lista = [3, 5, 7, 9, 11, 13]
listb = [7, 11]
print(f"from {lista} remove {listb}, result : ", remove_elements_from_list(lista, listb))
lista = [3, 5, 7, 9, 11, 13]
listb = [7, 11]
data = [item for item in lista if... |
cab2a3884a184839d61196ce7eff3f3df32ef7ff | syedmeesamali/Python | /5_Homeworks/Previous/py funcs.py | 1,712 | 4 | 4 | #Simple function to add numbers
def add(a,b):
mysum = a + b
return mysum
#Function to find intersection of two lists
def intersect(s1,s2):
#res is empty list to store numbers
res = []
for x in s1:
if x in s2:
res.append(x)
return res
#Function to create random password ... |
b99422ffb2d756fd5739524abcb8cd535ceb0da0 | onerbs/w2 | /structures/linked_list.py | 3,366 | 4.09375 | 4 | from structures.node import Node
from typing import Iterable
class LinkedList:
"""Unordered linked list."""
def __init__(self, values: Iterable = None):
self._head = None
for value in (values or [])[::-1]: # O(k)
self.unshift(value)
def push(self, value): # O(n)
""... |
b5bd5b6b996c1b19db36a4d9a7b347be6c1c0188 | vardanohanyan/homework | /VardanOhanyanHomeWork6/VardanOhanyanHomeWork6.py | 2,576 | 3.96875 | 4 | #Problem 1
#Create a file manually with some text in it like "My favourite fruits are:".
#Then write a program to append the file with the fruits that you love.
import os
#f = open(r"C:\Users\ASUS\Desktop\problem1.txt", "a")
#f.write("banana, apple, mango, qiwi, orange")
#f.close()
#Problem 2
#Create a file that h... |
95b9ceae2d2103c971cf84fe74d7ec924d11f218 | HieuChuoi/nguyenminhhieu-fundamental-c4e25 | /session3/BTVN S3/sheep_4.py | 437 | 3.84375 | 4 | sheep = [5, 7, 300, 90, 24, 50, 75]
print("Hello, my name is Hieu and this are my ship size ",end='')
print(sheep)
print()
biggest_sheep = max(sheep)
print("Now my biggest sheep has size ",biggest_sheep," let's shear it")
print()
sheep[2] = 8
print("After shearing, here is my flock ",sheep)
print()
z = int(len(sh... |
845ddda7fab5ab148bb377a3cb317c84e97f033e | lamtharnhantrakul/coding-interview-bootcamp | /elements_of_programming/rotateMatrix.py | 272 | 3.984375 | 4 | a = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
def rotateImageC(a):
a = zip(*reversed(a))
a = [list(item) for item in a]
return a
def rotateImageCC(a):
a = zip(*a)
a = [list(item) for item in a]
a.reverse()
return a
print(rotateImageCC(a))
|
2e3e259848e37aec019a69927d267565a86fa8ed | nirmalnishant645/Python-Programming | /Competitive-Programming/Formatted-Number.py | 1,086 | 4.3125 | 4 | '''
Have the function FormattedNumber(strArr) take the strArr parameter being passed,
which will only contain a single element,
and return the string true if it is a valid number that contains only digits with properly placed decimals and commas,
otherwise return the string false.
For example: if strArr is ["1,093,222.... |
c0dc478236e9965fbd0c08c5381b6839aeb61a7c | SpielerNogard/SecuredSocket | /send_mail.py | 1,395 | 3.515625 | 4 | import socket
server_info = ("192.168.10.45", 25)
socket = socket.socket()
socket.connect(server_info)
def send_message(data):
arr = bytes(data, 'utf-8')
socket.send(arr)
username = input("Enter your username: ")
password = input("Enter your password: ")
recipient = input("Recipient: ")
data =... |
dfac81b97868421a0e73b8485634fba6908db9ce | Suprit5/synerzip_training | /Bank-Management-System/account_section.py | 5,852 | 3.625 | 4 | from database import *
import prettytable
def savings_account():
bank_db=accessing_db()
bank=bank_db.cursor()
print('--------Enter the following details--------')
name=input('Enter Full Name :- ')
address=input('Enter The Address:- ')
p_number=int(input('Enter Phone Number:- '))
email=input... |
4477911c7d80a3f414731925051acff1817b15b8 | Candace-Beall/python_kata | /talk_python_to_me/02_guess_that_number_game/program.py | 355 | 3.625 | 4 | import random
from talk_python_to_me.helpers.header import print_header
print_header('GUESS THAT NUMBER GAME', 65)
the_number = random.randint(0, 100)
guess_text = input('Guess a number between 0 and 100: ')
guess = int(guess_text)
if the_number > guess:
print('too low')
elif the_number < guess:
print('too... |
fcea9ef0d1bb2489fb5cfd511ef2f85eef1acd0f | samruddhi221/Python_DS_Algo | /CodingQuestions/Google1.py | 1,730 | 3.640625 | 4 | """
Question: In a nxn chessboard, the position of king and queen is specied as K->(kx, ky) and Q->(qx, qy).
Other pieces are denoted by '1's and blank spaces are denoted by '0'. The king can move one step in any
direction. There are j jumps, i.e. the king can share the space with a piece j times.
Write an algorithm t... |
3a8d4317313e40a7bff3a18d7f97ab0b8b4b30d9 | gowthamrajceg/python | /pythoncode/stringmethod3.py | 309 | 4.09375 | 4 |
quote = 'Let it be, let it be, let it be'
result = quote.find('let it')
print("Substring 'let it':", result)
result = quote.find('small')
print("Substring 'small ':", result)
# How to use find()
if (quote.find('be,') != -1):
print("Contains substring 'be,'")
else:
print("Doesn't contain substring")
|
8d9b15cf0add58beed7dca83ebbd5f84a0f248b8 | joedeller/pymine | /mandel.py | 2,074 | 4.21875 | 4 | #!/usr/bin/python
# Joe Deller 2014
# A very simplified version of the Mandelbrot set
# Level : Intermediate
# Uses : Libraries, variables, lists
# I have taken some example code for how to draw the Mandelbrot set from Wikipedia
# and made it compatible with the Pi.
# This isn't a true fractal program as we can't zo... |
c51aca1b16e6fd05d1f43514c99e9c94e3579be9 | vetiveria/pollutants | /pollutants/io/directories.py | 1,469 | 3.6875 | 4 | """Module directories"""
import os
class Directories:
"""
Class Directories
"""
def __init__(self):
"""
Constructor
"""
@staticmethod
def cleanup(directories_: list):
"""
Deletes a directory, after deleting its contents
:param directories_: A l... |
310b8833f6f2c7f54707764b6f2f4b3c9a35437a | eddyD45/CSC321PythonAssignment | /part3/logic/logic.py | 180 | 3.765625 | 4 | def is_even(integer):
return integer % 2 == 0
def in_an_interval(number):
return (2 <= number < 9) or (47 < number < 92) or (12 < number <= 19) or (101 <= number <= 103)
|
7f837173bad966ae54b48ffbc996515f462db51f | Ming-H/Code_more | /python_test.py | 6,133 | 3.90625 | 4 | 1、对list去重
l1 = [1,1,2,3,2]
print(list(set(l1)))
l2 = {}.fromkeys(l1).keys()
print(l2)
l1 = ['b','c','d','b','c','a','a']
l2 = []
[l2.append(item) for item in l1 if not item in l2]
2、创建字典
dict1 = {}.fromkeys(('x','y'),-1)
print(dict1)
dict2 = {}.fromkeys(('a','b','c'))
print(dict2)
3、合并两个有序list
#遍历两个list,选择小的加入到新lis... |
4d1172ad0f9a35d17d3bd5a2d5740583e5f8b535 | teohklun/imdc2020_DHL_Google | /project DHL/class/hello.py | 338 | 3.890625 | 4 | class Person:
def __init__(self, name, age):
self.name = name
self.age = age
class Student:
def __init__(self, name, course):
self.course = course
self.name = name
def get_student_details(self):
print("Your name is " + self.name + ".")
print("You are studyin... |
62d4809fa51155b55dd1f77f5b55bd99ffff2924 | pxu/LeetCode-1 | /Maximum Difference Between Node and Ancestor/Maximum Difference Between Node and Ancestor.py | 1,490 | 3.796875 | 4 | '''
Given the root of a binary tree, find the maximum value V for which there exists different nodes A and B
where V = |A.val - B.val| and A is an ancestor of B.
(A node A is an ancestor of B if either: any child of A is equal to B, or any child of A is an ancestor of B.)
Example 1:
Input: [8,3,10,1,6,null,14,null,nul... |
4d066e23610ef5224be97ccc1005134e4beb0025 | Fullmoon8507/PythonPracticeProject | /apply/class_variable_test2.py | 831 | 4.03125 | 4 | ###################################################################
# インスタンス変数が存在しない場合、「インスタンス.変数名」は
# クラス変数を参照する。
# 「インスタンス変数.変数名」に値を代入した時点で
# インスタンス変数が生成され、以降はインスタンス変数が参照される。
###################################################################
class MyClass:
PI = 3.14
if __name__ == "__main__":
a1 = MyClass()... |
c78eb7cabe947aad80c1ae46c99a59e5d521a074 | syurskyi/Python_3_Deep_Dive_Part_3 | /Section 3 Dictionaries/71. Counter - Coding.py | 7,993 | 3.984375 | 4 | print('#' * 52 + ' ')
from collections import defaultdict, Counter
sentence = 'the quick brown fox jumps over the lazy dog'
counter = defaultdict(int)
for c in sentence:
counter[c] += 1
print('#' * 52 + ' We can do the same thing using a `Counter` - unlike the `defaultdict`'
' we dont specify a... |
bb0beadea13777bd963e5e7557e2bf8bbadfbeee | shivamnegi1705/Competitive-Programming | /Atcoder/AtCoder Beginner Contest 179/A - Plural Form.py | 137 | 3.859375 | 4 | # Question Link:- https://atcoder.jp/contests/abc179/tasks/abc179_a
s = input()
if s[-1]!='s':
print(s+'s')
else:
print(s+'es')
|
9224003f9e5b1d473f5133d0e1d448ca78ab84c5 | learnwithaman/data-structure-and-algorithm | /python/product_sum.py | 343 | 3.921875 | 4 | # O(n) time | O(d) space
def product_sum(array, multiplier=1):
total_sum = 0
for element in array:
if type(element) is list:
total_sum += product_sum(element, multiplier + 1)
else:
total_sum += element
return total_sum * multiplier
print(product_sum([5, 2, [7, -1], ... |
2baa2b6d9cfd6365af7653627fc696382de416ab | yongxing-zou/hello-world | /Class-1.py | 794 | 3.890625 | 4 | class Student():
# __init__是一个特殊方法用于在创建对象时进行初始化操作
# 通过这个方法我们可以为学生对象绑定name和age两个属性
def __init__(self, name, age):
self.name = name
self.age = age
def study(self, course_name):
print('%s正在学习%s.' % (self.name, course_name))
# PEP 8要求标识符的名字用全小写多个单词用下划线连接
# 但是部分程序员和公司更倾向于使用... |
dace61374c704342e525c4cf70b1b9e0e76c6d36 | Do-code-ing/Python_Built-ins | /Methods_Set/copy.py | 410 | 3.875 | 4 | # set.copy()
# set의 얕은 복사본을 반환한다.
# = 을 사용해서 복사하면 set의 내용이 바뀌게 되는 경우, 원본과 복사본 모두 바뀌게 된다.
# copy()를 사용해서 복사하면 원본의 내용을 건드려도, 복사본의 내용은 바뀌지 않는다.
a = {1,2,3,4}
b = a # 그냥 복제
c = a.copy() # copy로 복제
a.clear()
print(b)
# set()
print(c)
# {1, 2, 3, 4} |
04621d57ad9a50740d97371b4853902c2bbe14f8 | canselkyo/Patika.dev-Python | /Temel-Python-Proje1.2.py | 592 | 3.921875 | 4 | # Verilen listenin içindeki elemanları tersine döndüren bir fonksiyon yazın. Eğer listenin içindeki elemanlar da liste içeriyorsa onların elemanlarını da tersine döndürün.
l = []
print("Listede kaç eleman olacağını girin:")
n = int(input())
i=1
for _ in range(n):
m = []
print("Listenin", i , ". elemanında ka... |
6b3153d2686b3f271354acce5cd2432257c5a6c1 | washie254/udacity-Intro | /LESSON 5 SCRIPTING/l02 Scripting with raw input/001introinput.py | 410 | 4.3125 | 4 | # using input() -> takes user input as a string
name = input("Enter Your Name: ")
print("Hello , "+name.title())
# changing to other datatypes"
age = int(input("Age ?: "))
age+=10
print("You'll be {} years old in 10 years".format(age))
#Eval -> evaluates a string as a line of python
x = eval(input('enter an expresio... |
9069dc333f1a21e3226ff85dc18671ff07c20960 | talktobrent/holbertonschool-higher_level_programming | /0x0A-python-inheritance/1-my_list.py | 235 | 3.859375 | 4 | #!/usr/bin/python3
""" MyList module
"""
class MyList(list):
""" custom list class inherits from list class
"""
def print_sorted(self):
""" prints list in ascending order
"""
print(sorted(self))
|
c08fd2fa4a5175df373c3481205740f63621a9f5 | LynneWest/PythonPractice | /pandas_csv.py | 425 | 3.515625 | 4 | import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
cars = pd.read_csv("vehicletest.csv")
#print(cars)
x = cars['29'] #city mpg
y = cars['37'] #hwy mpg
print(np.corrcoef(x,y))
plt.scatter(x,y, s=1)
plt.xlabel('City mpg')
plt.ylabel('Highway mpg')
plt.title("Correlation of a vehicle's highway and ci... |
f58d9f2bcb291784e2c6903308883c6fd42aa8b3 | Malika939/PreHakaton2 | /Problem6.py | 99 | 3.875 | 4 | b = input()
if b != b[::-1]:
print('it s not palindrome')
else:
print('It s palindrome')
input() |
235df04db19f74b8f31cb31accc44558e1a80177 | Deser12/DataScienceFundamentals- | /word-checker.py | 453 | 3.921875 | 4 | wrong_words = ["worsd", "wlong", "si", "plogram", "displai"]
good_words = ["words", "wrong", "is", "program", "display"]
input_words = input("Write down a sentence")
check_words = input_words.split(" ")
index = 0
for word in check_words:
# if check_words in wrong_words
if word in wrong_words:
index = wrong_w... |
0747c3d897cb13c78e9e2d7e710406fdd8d56a14 | snowlance7/Python-Projects | /week2/even_or_odd_checker.py | 279 | 4.09375 | 4 | print("Even or Odd Checker\n")
def main():
num = int(input("Enter an integer: "))
print("This is an " + str(calc(num)) + " number.")
def calc(n):
if n % 2 == 0:
return "even"
else:
return "odd"
if __name__ == "__main__":
main() |
0a50bf094eaa16099e109a6e3028a32a6ce1bc1d | hamza-yusuff/Python_prac | /python projects/alif.py | 527 | 3.640625 | 4 | def make_sin(number):
string_num=str(number)
total_odd=0
total_even=0
for i in range(8):
if i%2!=0:
if 2*(int(string_num[i]))>10:
num=2*(int(string_num[i]))
num=int(str(num)[0])+int(str(num)[1])
else:
num=2*(int(string_num[i... |
99f64e39bfa99671e289698b7003e58b24da5e3f | sn3ak1/GraphTheoryProject | /main.py | 5,531 | 3.515625 | 4 | class Graph:
class Edge:
def __init__(self, capacity):
self.capacity = capacity
self.remaining = capacity
class Node:
def __init__(self, label):
self.label = label
self.predecessors = {}
self.successors = {}
def __... |
4f81d626d75b7a334e1cc60ac9ed48688dddda3a | yunusemregunduz/Python101-Course | /convert_function_F_to_C.py | 302 | 3.6875 | 4 | def converti(fahrenheit):
return (fahrenheit - 32) * 5 /9
print(converti(76))
#interesting because it is working :D
def quadratic(a,b,c,x):
f = a + x **9
s = b * c
t = c * x
return f + s + t
print(quadratic(2,5,4,8))
print(quadratic(4,5,4,78))
#it is really working "yep mann =D"
|
6af55cb01fb9139afa6043c8cf38d9847e68e3d9 | SupersonicCoder18/Class-109 | /Dist.py | 2,770 | 3.5 | 4 | import pandas as pd
import plotly.express as px
import plotly.figure_factory as ff
import statistics
import csv
df = pd.read_csv("Student.csv")
Height = df["Height(Inches)"].to_list()
Weight = df["Weight(Pounds)"].to_list()
HeightMean = statistics.mean(Height)
WeightMean = statistics.mean(Weight)
Height... |
8734eb117bdf957bcd9648c3c39da563df530de8 | linshiyi/test | /yeah.py | 569 | 4.125 | 4 | #!/bin/env python
months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
]
ending = ['st','nd','rd'] + 17 * ['th'] \
+ ['st','nd','rd'] + 7 * ['th'] \
+ ['st']
yeah = raw_input('Yeah: ')
mo... |
cdaf5133a81cbd8dfc88a2bc1ef2071e120ae603 | MohamedFawzy/python-datastructure | /week1/while-loop.py | 144 | 3.53125 | 4 | __author__ = 'Mohamed fawzy'
fruit = 'banana'
index=0
while index < len(fruit):
letter = fruit[index]
print index, letter
index= index+1
|
11e95605df00a24cdb27a1bc196ab32c1aecc074 | ImSahilShaikh/LearnOpenCV | /shapes.py | 901 | 3.71875 | 4 | #Functions to draw geometric shapes on images
import cv2
img = cv2.imread('face.png',-1)
#line| arrowedLine(image, start_pts, end_pts, colorBGR,thickness)
img = cv2.line(img,(0,0),(255,255),(0,0,255), 3)
img = cv2.arrowedLine(img,(255,100),(255,255),(0,255,255), 2)
#rectangle(image,x1y1,x2y2,colorBGR,thic... |
8dcc1bdad13c2a37c6edf738ef3813b8c823aa94 | gk12happy/Subgraph-Classifier | /src/bipartition.py | 2,510 | 3.6875 | 4 | class Node:
def __init__(self, x, n):
self.childs = []
self.data = x
self.lvl = n
def __repr__(self):
return self.data
def addToChilds(self, x):
nodex = Node(x, n+1)
self.childs.append(nodex)
def addToList(t,a,b):
... |
283edaa26b111f1488412c90c50b0ff719eee530 | thunderbump/euler | /017/017.py | 1,303 | 4.0625 | 4 | #!/usr/bin/python
"""Computes the number of letters in all numbers below a given X"""
import sys
argc = len(sys.argv)
X = 1000
usage = """017.py [X]
Computes the number of letters in all numbers below a given X. If no X given,
1000 is used."""
raw_number = {0:0, 1:3, 2:3, 3:5, 4:4, 5:4, 6:3, 7:5, 8:5, 9:4, 10:3, 11:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.