blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
cc7e59cd236bcd7099466fcd0c8ae81b08639a61 | gratus907/Gratus_PS | /BOJ Originals/[BOJ Steps] BOJ 단계별로 풀어보기/[05] 실습 1/10817 세 수.py | 120 | 3.578125 | 4 | mem = input().split()
a = 0
b = 1
for i in range (0,3) :
mem[i] = int(mem[i])
smem = sorted(mem)
print (smem[1])
|
5cb87538a3b33dd04ec2d3ded59f0524c04519c4 | pkongjeen001118/awesome-python | /data-strucutre/dictionaries.py | 480 | 4.375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# simple dictionary
mybasket = {'apple':2.99,'orange':1.99,'milk':5.8}
print(mybasket['apple'])
# dictionary with list inside
mynestedbasket = {'apple':2.99,'orange':1.99,'milk':['chocolate','stawbery']}
print(mynestedbasket['milk'][1].upper())
# append more key
myba... |
23310258133eaae83937885a1edc2e5bd0e686ee | nischalshrestha/automatic_wat_discovery | /Notebooks/py/ariadneadler/xgboost-gridsearchcv-stratified-k-fold-top-5/xgboost-gridsearchcv-stratified-k-fold-top-5.py | 6,366 | 3.703125 | 4 | #!/usr/bin/env python
# coding: utf-8
# ## Introduction ##
#
# This notebook is written in python.
# The feature engineering is the work of Sina and the code below is inspired by ["Titanic best working classifier"][1].
#
#
# [1]: https://www.kaggle.com/sinakhorami/titanic-best-working-classifier
# In[1]:
impor... |
1be6fb8430ecac7bd031eb6b9cff01bfd8745940 | wandoufan/mycode | /study_note/python_learn/function/function_closure.py | 925 | 4.3125 | 4 | # 主要介绍python函数中的闭包closure概念
# 如果一个函数引用了其外层函数中的变量(不是全局变量),且外层函数的返回值是该函数的引用,则该函数就是闭包的
# 示例1:test2是一个闭包函数
# 注意:test1中的变量x也是局部变量,但是在test1的内部函数test2中也只能对x进行访问,不能修改
def test1(x):
print('x:', x)
def test2(y):
print('y:', y)
return x * y
return test2
print(test1(5)) # x为5,y没有赋值
print('\n')
prin... |
4578a59399c3511eea1ae768730db51762f1997e | karimeSalomon/API_Testing_Diplomado | /EduardoRocha/Primo.py | 571 | 3.921875 | 4 | def is_prime_number(x):
if x >= 2:
for y in range(2,x):
if not ( x % y ):
return False
else:
return False
return True
def calculate_prim(num1, num2):
# list = [i for i in range(num1, num2)]
result = []
for num in range(num1,num2):
if is_prime_... |
1821ced4810fa58f69b6b7e4ec3415ad37e6f842 | younik/gemballs | /gemballs/gemballsclassifier.py | 7,799 | 4.125 | 4 | import abc
import numpy as np
class Ball:
"""
Ball(center, radius, label)
This class is aimed to model a ball of the GEM-balls classifier.
Parameters
----------
center : array-like
The center of the sphere.
radius : float
The radius of the sphere.
label : int
... |
b3b41e9c45e3fe285df1d16d9da3d28be5d98faa | kumarishalini6/chatbot | /bye.py | 476 | 3.796875 | 4 | from tkinter import *
from PIL import ImageTk
def Back():
root.destroy()
import his
root=Tk()
root.title("thanks")
root.geometry("441x380")
root.resizable(0,0)
photo=ImageTk.PhotoImage(file="cbot.jpg")
photo_image=Label(image=photo).pack()
Label(root,text="Thanks",font=("arial",26,'bold'),bg="white",fg="black... |
40cd88ba1f7a86e90a05522c75ccef1a12541982 | superniaoren/fresh-fish | /effective_python_learn_v1/1_parallel_concurrent/test_subprocess_lock.py | 1,342 | 3.546875 | 4 | import os, sys, time, subprocess
import threading
from threading import Thread
from threading import Lock
class Counter(object):
def __init__(self):
self.count = 0
def increment(self, value):
self.count += value
class LockingCounter(object):
def __init__(self):
self.lock = Loc... |
ff889840b34f80572d820dc47ffbfbe57ca82892 | iamasik/Python-For-All | /C7/in_Dictionary.py | 364 | 4.03125 | 4 | DIC={"Name":"Delwar","Age":23,"Movie":["coco","mowna"]}
if "Name" in DIC:
print("Ok")
else:
print("Not Ok")
#Value Not Check
if "Delwar" in DIC: #Not Ok Becouse "Delwar" in to "Name"
print("Ok")
else:
print("Not Ok")
#For Value Check
#Values method
if ("Delwar" or 23) in DIC.values():
... |
e38727b177ff3419e36b4b60d46435d70466d4ce | dilippuri/PAN-Card-OCR | /src/crop_to_box.py | 1,696 | 3.75 | 4 | #!/usr/bin/env python
"""Crop an image to the area covered by a box file.
The idea is that we're only interested in the portions of an image which
contain text. The other parts can be removed to get better accuracy and smaller
images.
"""
import sys
from PIL import Image
from box import BoxLine, load_box_file
def fi... |
7715958379ab0f643187b71060af5be2f4b7c44a | nbro/ands | /ands/algorithms/dp/fibonacci.py | 4,229 | 4.5625 | 5 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
# Meta-info
Author: Nelson Brochado
Created: 20/07/2015
Updated: 29/03/2022
# Description
In this file, you can find some functions that return the nth fibonacci number,
but they do it in different ways, which has also an impact on the performance
and asymptotic ... |
fed97d71e7f17068e8749c2e0a78b773ee31cb6b | sandeeps311094/Python-Programs | /P5_Student_Total_avg_Class.py | 1,085 | 3.9375 | 4 | #-- A simple student marks card report program
import os
import time
def main():
os.system('clear')
name = str(input("Enter name: "))
math = int(input("Enter math score: "))
science = int(input("Enter science score: "))
music = int(input("Enter music score: "))
total, avg = calc_avg(math, science, music)
g... |
b174e40d3f0b89c9ba2ae0e454221f4b093988b6 | tooreest/ppkrmn_gbu_pdf | /pyhton_basic/q01l02/task_05.py | 2,181 | 3.734375 | 4 | print('Geekbrains. Факультет python-разработки')
print('Четверть 1. Основы языка Python')
print('Урок 2. Встроенные типы и операции с ними')
print('Домашнее задание 5.\nРеализовать структуру «Рейтинг», представляющую собой не возрастающий набор натуральных чисел.\n\
У пользователя необходимо запрашивать новый элемент р... |
bdfbebde8b7eefb859c3a3618a67bd5f0039536a | adosib/PyLearn | /Corey_Schafer_Beginner_Tutorial/Lists-tuples-sets.py | 600 | 4.375 | 4 | # ----------------------- Lists --------------------------
# Extend lists
courses = ['Hisotry', 'Math', 'CompSci', 'Physics']
courses2 = ['Japanese', 'Statistics']
courses.extend(courses2)
print(courses)
# Remove values from a list
courses.remove('Math')
print(courses)
# Remove last element of a list
courses.pop() #... |
2acf1b66611e3690afea44815294807f6a2ae6e4 | peppo-su/pcap-modules | /02module/number_systems.py | 468 | 3.640625 | 4 | octa = 0o123
hexa = 0x123
def show(octa,hexa):
# octa = 0o123
# hexa = 0x123
print(octa)
print(hexa)
show(octa,hexa)
f = .45
f2 = .97
print(f + f2)
print("-----------------------------------")
print(2e4)
print(34e8) # e=base10
print(6.62607E-34)
print(0.0000000000000000000001)
pr... |
db68d24f4ed3286a8b2b24bf113a23f3df74d8aa | Oiselenjakhian/Drawing-Adinkra-Symbols-using-Python | /damedame.py | 3,671 | 3.859375 | 4 | """
Project Name: Drawing Adinkra Symbols using Python
Symbol Name: Dame Dame
Developer Name: Truston Ailende
Email Address: trustonailende@gmail.com
"""
import turtle
import math
# Square
def drawSquare(length):
turtle.penup()
turtle.setposition(-length/2.0, length/2.0)
turtle.pendown()
... |
aadd85237c44dfc98f889504aa882bb1d2d885fa | garimadawar/LearnPython | /Average_02.py | 127 | 3.5 | 4 | print("This program calculates the average of two numbers.")
print("numbers are 4 and 8")
print("Average is:" , (4 + 8) /2)
|
b93ffd786ab3f4ff9e5ef020a86dd94a1c4eb239 | Izardo/pands-problem-sheet | /sqrt_task5.py | 1,933 | 4.5625 | 5 | # This program defines a function which returns the
# square root of a number using Newton's method
# Author: Isabella Doyle
# numList stores the result of the for loop iterations from the sqrt function
numList = [0, 0]
# the sqrt function takes in two values, the second is pre-defined
def sqrt(number):
a ... |
6fa35a1d52798546e8b09abab952a99019dc53e1 | adbag19/booksearch | /routes.py | 3,190 | 3.53125 | 4 | #!/usr/bin/env python3
from flask import Flask, render_template, request, url_for, redirect, jsonify
from Templates import BookTemplate, setAttributes, AuthorTemplate
from getData import goodreads_get_book_data, goodreads_get_author_data
# Init Flask
app = Flask(__name__)
@app.route('/')
def form():
return render... |
60257e249b423d7f7eb387768bc07e8977e9a627 | Retkoj/AOC_2020 | /src/5_2_find_seat_plus_binary_impl.py | 1,376 | 3.8125 | 4 | import fileinput
def get_seat(lst):
lst.sort()
diffs = []
for i in range(0, len(lst) - 1):
diffs.insert(i, lst[i + 1] - lst[i])
if lst[i + 1] - lst[i] == 2:
print(f'index {i}, {lst[i:i+2]}')
def binary_implementation(lst):
"""
Converts the seatdescription to the binar... |
60e76dfcc6c77debd84b424628db4083fb812607 | tvaisanen/AlgorithmsAndDatastructures2016 | /list_main.py | 626 | 3.921875 | 4 | from linkedlist import *
def main():
# Empty linked list
coll = LinkedList()
coll.head = None
# Insert 0..9 into list
for i in range(10):
list_insert(coll, i)
print('Original list:')
print_list(coll)
# Remove even keys
L = [2 * x for x in range(5)]
... |
2c104830051a53a77912fc1fabfb361410e9743c | michal-jewczuk/python-problems | /test_example.py | 1,902 | 3.96875 | 4 | import unittest
import example as example
class TestSortedWithoutMinMax(unittest.TestCase):
def test_with_empty_list(self):
initial = []
expected = []
result = example.getSortedWithoutMinMax(initial)
self.assertEqual(result, expected)
def test_with_one_element(self):
... |
d8d6d2203c84a514259cb1061a8542da96f9d2ca | stone1949/study-1 | /20170712/elif.py | 127 | 4.15625 | 4 | age=int(raw_input('input your age : '))
if age>= 18:
print 'adult'
elif age >=6:
print 'teenager'
else:
print 'kid' |
a4bcec136f2be7c05e2c8348e8281b4ba3b17806 | eBLDR/MasterNotes_Python | /Concurrency_MultiThreading/thread_objects.py | 2,099 | 3.953125 | 4 | # Different types of thread objects.
import threading
import time
# TIMER OBJECTS - certain function will be executed after certain time
def salute():
print('Ave Caesar!')
# timer.object(@seconds, @function) - function will be executed after @seconds
# from start() call
my_timer = threading.Timer(5, salute)
my_... |
56f13f64677e95f9a0790e48e12eb402613de7c8 | mtouhidchowdhury/CS1114-Intro-to-python | /Homework 2/hw2q1a.py | 331 | 4.40625 | 4 | #calculate the BMI of person by taking their weight and height
weight = float(input("please enter weight in kilograms:")) #user weight input
height = float(input("please enter height in meters:"))# user height input
BMI = weight / (height**2) #using the BMI formula
print ("BMI is", round(BMI,7))#printing the... |
43e6c04d80b84ad93d8a3a346510b8fc3078b726 | pragatij17/Algorithms | /bit_magic/power_of_two/efficient_method.py | 136 | 4.03125 | 4 | def isPower(n):
if(n == 0):
return True
return ((n & (n - 1)) == 0)
n=int(input("Enter the number:"))
print(isPower(n)) |
a71cbb1cb9c5e2e44f1f66e1461099b60caf81cb | gitghought/python1 | /myexcel/myexcel.py | 3,739 | 3.515625 | 4 |
import xlrd
from datetime import date,datetime
single_num = 20
mul_num = 10
pan_num = 10
def read_student_excel():
#指定学生答案在第几列
student_answer_pos = 1
single_answer = []
single_start_pos = 4
mul_answer = []
mul_start_pos = 26
pan_answer = []
pan_start_pos = 38
#存储学生答案的数据结构
... |
05764e0266c28a2792f0223ec7607c0f25983a32 | dkurchigin/gb_algorythm | /task2.py | 702 | 4.21875 | 4 | # Выполнить логические побитовые операции «И», «ИЛИ» и др. над числами 5 и 6.
# Выполнить над числом 5 побитовый сдвиг вправо и влево на два знака
# 5 = 101
# 6 = 110
a = 5
b = 6
print(f"Дано: {a} и {b}")
print(f"Побитовое \"И\" = {a & b}")
print(f"Побитовое \"ИЛИ\" = {a | b}")
print(f"Побитовое \"Исключительное ИЛИ... |
3157bf712b55ed5b931ecb94bd7e387cbdcd3d4e | EddylianOrigin/Chapter2_Python | /Dictionnaries.py | 608 | 4.03125 | 4 | names = ["Ben","Jan"]
grades=[1,2]
#dict {(key, value)}
names_and_grades={"Ben":1,"Jan":2}
print(names_and_grades)
names_and_grades.update({"Pia":3})
print(names_and_grades)
names_and_grades["Jan"] = 1
print(names_and_grades)
names_and_grades.pop("Jan")
print(names_and_grades)
#keys
for k in names_and_grades.keys... |
5bf26b8b42e8cec869b5fe299e1f42b5e6a3f58a | ariadnecs/python_3_mundo_2 | /exercicio047.py | 220 | 3.953125 | 4 | # Exercício Python 47: Crie um programa que mostre na tela
# todos os números pares que estão no intervalo entre 1 e 50.
for pares in range(2, 52, 2):
print(pares, end=' ')
print('\nNúmeros pares entre 1 e 50!')
|
0ef5fe4e1ba7ca92fdd225859a76cb024af30a12 | AGoodDataScientist/ProjectEuler-Python-Solutions | /Prob0002.py | 678 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Project Euler Problem 2: Even Fibonacci numbers
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values ... |
d6628d6f000a25e4769cee812f1631f64cc43a26 | damodardikonda/Python-Basics | /core2web/Week6/Day35/prime_sum.py | 543 | 3.9375 | 4 | ''' Write a Program to check whether a number can be
express as sum of two prime numbers.
Input: 20
Output: 20 = 7 + 13
'''
def primeOrNot(num):
for itr in range(2,(num/2)+1):
if num%itr ==0:
return 0;
return 1;
num = input("Enter the number : ")
flag = 0
for itr in range(2,(num/2)+1):... |
1dd6ee10167f2aa8a9c9a197daaf99a5248d66fc | jgross21/Programming | /Notes/Chapter6.py | 6,547 | 4.5625 | 5 | # Chapter 6 notes, More Loops
# Learn to master the FOR loop.
# more printing
print('Francis', 'Parker') # Python automatically puts a space in between
print('Francis' + 'Parker') # Smushes them together
print('Python' * 10) # Printing miltiple times
# Python automatically adds '\n' to the end of every print()
print()... |
59bd0f24aa0a7b43fd129e500dee841f74ca7442 | CoenvdStigchel/nogmaals | /coins.py | 1,747 | 3.796875 | 4 | # name of student:
# number of student:
# purpose of program:
# function of program:
# structure of program:
toPay = int(float(input('Amount to pay: '))* 100) # vraagt hoeveel je moet betalen en zet het om in centen
paid = int(float(input('Paid amount: ')) * 100) # vraagt hoeveel je betaalt hebt en maakt dat... |
1e4be77c6c6e7471fcd7df5c5aec22d3f03993fc | randy36/intro-y-taller | /Examenes/Parcial #1- Introduccion a la programacion.py | 2,038 | 3.8125 | 4 | def formarLista(num):
if num > 0 and isinstance (num,int):
return formarLista_aux(num)
else:
return: "El numero ingresado no es positivo y entero"
def formarLista_aux(num):
if num == 0:
return: []
elif num % 10 %2 == 0:
return: num % 10 formarLista_aux(num)
else:... |
8b7c7d81b56e8e24a6de03771eb169ade9e5227b | klimmerst/py111-efimovDA | /Tasks/e0_breadth_first_search.py | 622 | 3.6875 | 4 | from typing import Hashable, List
import networkx as nx
def bfs(g: nx.Graph, start_node: Hashable) -> List[Hashable]:
"""
Do an breadth-first search and returns list of nodes in the visited order
:param g: input graph
:param start_node: starting node for search
:return: list of nodes in the visit... |
4b7623d1615d45b9919e7bcee71166e888642aad | Johannes-Walter/tml-reader | /tml-reader.py | 6,658 | 4 | 4 | """
TML-Reader-Module (Turtle-Markup-File).
https://github.com/Johannes-Walter/tml-reader
"""
import shapes
class Tag():
"""
A Class which reads tag-pairs.
This class saves the position of the tags in a given text with their
starting/endig position and the name of the tag.
"""
def __init__... |
11b691cd28eaa88f7174768c366b51e82295db47 | marcfs31/joandaustria | /M3-Programacion/UF1/Practica5.py | 2,747 | 4.46875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#Practica 5:Instrucions d'entrada i sortida
"""
#1
A=int(input("Pon un numero: "))
B=int(input("Pon otro numero: "))
#A,B= B,A metodo mejor pero solo para python
A=A+B
B=A-B
A=A-B
print(A,B)
#2
A=int(input("Numero 1: "))
B=int(input("Numero 2: "))
print A+B
#3
edad=int... |
0d3df6a3c68aa1748d7568f070a75baea15cbd31 | aav789/study-notes | /notes/reference/moocs/udacity/cs50-introduction-to-computer-science/source/bubble_sort.py | 384 | 3.515625 | 4 | arr = [5, 100, 3, 2, 101, 100]
swap_count = 1
while swap_count:
swap_coun = 0
for n in range(len(arr)):
next = n + 1
try:
if arr[n] > arr[next]:
arr[n], arr[next] = arr[next], arr[n]
swap_count = 1
except IndexError:
# If it's the ... |
bed0b39252ac9d8b75c94e825797177871fbf587 | Nichollsean/Selection | /Selection SAC EX3.py | 1,212 | 4.09375 | 4 | #Sean Nicholls
#30/09/14
#SAC EX3
day=int(input("Please enter the day in number format e.g '14' : "))
month=int(input("Please enter the month in number format e.g 'july = 7' : "))
year=int(input("Please enter the year in 2 digit format e.g '05' :"))
if day >=4 and day <=20:
day1 = ("{0}th".format(day))
... |
c5371b7c9555859a5f0d016365b33fc37cd4dbfe | Godmode-bishal/Python | /final_exam.py | 362 | 3.765625 | 4 | #Final Exam
print "Hello"
try:
print "Fred"
st=int("fred")
print "World"
except:
print "Error !!"
print "Yo"
print ""
tot = 0
for i in range(5):
tot = tot + i
print tot
print ""
def hello():
print "Hello"
print "Fun"
hello()
hello()
print ""
x = -1
for value in [3, 41, 12, 9, 74, 15] :
... |
229e77ac3d0b6ba3dd7eb119eb5a5c85ec205751 | rsauhta/ProjectEuler | /p014.py | 1,628 | 3.875 | 4 | # https://projecteuler.net/problem=14
#
#
# Longest Collatz sequence
# The following iterative sequence is defined for the set of positive integers:
#
# n -> n/2 (n is even)
# n -> 3n + 1 (n is odd)
#
# Using the rule above and starting with 13, we generate the following sequence:
#
# 13 -> 40 -> 20 -> 10 -> 5 -> 1... |
6d3f882a0ebe74f18cce2aa2371f125032143066 | dharunsri/Python_Journey | /Bubble_Sort.py | 503 | 4.15625 | 4 | # Bubble sort
# Bubble sort takes 1st two values and compare if its big it swaps and then values get iterated and check for next 2 values and it continued
def sort(lst):
for i in range(len(lst)-1,0,-1): # outter loop - focus on total iteration
for j in range(i): ... |
0e44b0d4de2846035cc30ae1a7b4da8668a7be53 | JagadeeshmohanD/PythonTutorials | /ArrayProgramPractice/arrayMonotonic.py | 405 | 4.09375 | 4 | #An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for all i <= j, A[i] >= A[j].
def isMonotonic(A):
return (all(A[i]<=A[i+1]for i in range(len(A)-1)) or
all(A[i]>=A[i+1]for i in range(len(A)-1)))
#driving program
# A = [6,5,4,4]
A=[5,4,7,9,3]
if boo... |
5d48b02ae607f6f754a1523f224958b06350bd33 | BIDMAL/codewarsish | /LeetCode/Python/200-NumberOfIslands.py | 3,575 | 3.59375 | 4 | from typing import List
from collections import deque
"""
Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.
An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all
four edges of the... |
9702b373677360f58f4a0cea397df47f339b45e5 | dayananda30/Crack_Interviews | /Comprehensive Python Cheatsheet/Syntax/lamda_functions.py | 923 | 4.4375 | 4 | """
Python Lambda Functions are anonymous function means that the function is without a name.
Syntax:
lambda arguments: expression
This function can have any number of arguments but only one expression, which is evaluated and returned.
"""
lamdbda_print = lambda input_string: print(input_string)
lamdbda_print("Lear... |
53874022e9ca00d8e3b286fcf27c6bb0d9e20f08 | zelmaru/python_algorithms | /binary_search.py | 447 | 3.921875 | 4 |
def binary_search(list, item):
low = 0
high = len(list) - 1
while low <= high: # while we did not eliminate it to 1 element
mid = (low + high) // 2 #get answer w/o the remainder
guess = list[mid]
if guess == item:
return mid
if guess > item:
high = mid - 1
else: low = mid + 1
... |
fbf15b64c9b9050c954401cb0e0a923879b10f4b | kutipense/py-works | /mazegen.py | 1,425 | 3.578125 | 4 | import random
import sys
class Node():
def __init__(self, *args, **kwargs):
self.isVisited = False
self.type = 0 # 0: wall, 1: free space
def __str__(self):
return str(self.type)
class MazeGen():
directions = (
(2,0,1,0),
(0,2,0,1),
(-2,0,-1,0),
(0... |
32a124b55238e3d8fa6bcc8f85ebb4d13909c658 | ahmed-kaif/python-for-everybody | /course_2/ex_09_01.py | 563 | 3.796875 | 4 | # dictonary type in python
name = input("Enter file:")
if len(name) < 1:
name = "mbox-short.txt"
fh = open(name)
counts = dict()
for line in fh:
if not line.startswith('From '):
continue
else:
line = line.rstrip()
pieces = line.split()
words = pieces[1]
counts[words... |
309f7f242a35637c8967cfe49f668e91041e30ea | cagatayonder/Cs50x-2019 | /pset6/credit/credit.py | 2,068 | 3.625 | 4 | from cs50 import get_int
import math
card_number = get_int("Credit card number: ")
n = 0
integars = []
while card_number >= 1:
integar = card_number % 10
card_number = math.floor(card_number / 10)
n += 1
integars.append(integar)
def luhn(integars):
i = 1
tf =... |
e8ed76db7df63bb28ab3d6f62c74f5070f69c4a9 | beyondzhou/algorithms | /newarray2d.py | 2,287 | 3.640625 | 4 | from newarray import Array
class Array2D:
# init
def __init__(self, nrows, ncols):
self._theRows = Array(nrows)
for i in range(len(self._theRows)):
self._theRows[i] = Array(ncols)
# the number of rows
def numRows(self):
return len(self._theRows)
# the number o... |
5761fa86e10617cb63a5d3e70689a83660b4b9d1 | amahes7/Python-Basics | /Section 1-4/practiceCode1.py | 98 | 3.546875 | 4 | character="Jon snow"
print(character)
price=10
print(price)
x = 1
y = 2
z = 3
print(((x*y)**z)/8) |
b9e2fa8e2b71434188b844afe805a583e0c63ff8 | seanhugh/Project_Euler_Problems | /Problem_5.py | 1,078 | 3.8125 | 4 | #!/usr/bin/env python
#Problem_5 Soulution
'''multiplication = []
palindromes = []
temp = 0
def check_palindrome(num):
#abcde
if num > 10000:
num = str(num)
if (num[0]==num[-1] and num[1]==num[-2] and num[2] == num [-3]):
return 'true'
else:
pass
def multiply... |
62b15d04491574ceb78161dc271c4aa6ef734fa0 | syurskyi/Python_Topics | /125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/187/howold.py | 826 | 3.890625 | 4 | from dataclasses import dataclass
from dateutil import parser
from dateutil.relativedelta import relativedelta
@dataclass
class Actor:
name: str
born: str
@dataclass
class Movie:
title: str
release_date: str
def get_age(actor: Actor, movie: Movie) -> str:
"""Calculates age of actor / actress w... |
99c4237a54103df0dfa9a6a3e6c54115b19c0904 | Villtord/python-course | /src/16 Scientific Libraries/03 Pandas/02_selection.py | 2,237 | 4 | 4 | import pandas as pd
import pylab as pl
pd.set_option('display.precision', 1)
pd.set_option('display.width', None) # None means all data displayed
pd.set_option('display.max_rows', None)
def inspect(item):
print()
print(item)
print(type(item))
print("------------------")
def main():
df = pd... |
c5719ef09d0912a23820dc9da7643d16ae95fab3 | sidaker/dq | /python_interview/code_interviews/Iterator_1.py | 902 | 4.25 | 4 | from itertools import count, chain, cycle
def iter1():
c = count()
print(next(c))
print(next(c))
print(next(c))
# you can go on
def iter2():
d = cycle([1,2,3])
print(next(d))
print(next(d))
print(next(d))
print(next(d))
def iter3():
e = chain([1,2],{'adv:1'},[4,5,6],{'sid:... |
991f6e079212986349f96145ce8e0fe1d6c52088 | thomas-rohde/Classes-Python | /exercises/exe81 - 90/exe081.py | 376 | 3.609375 | 4 | n = []
n0 = []
n1 = []
#Insira um valor
while True:
n.append(int(input('Digite um valor: ')))
r = str(input('Quer continuar? [s/n] '))
if r in 'Nn':
break
#Separação PAR / ÍMPAR
for c in n:
if c % 2 == 0:
n0.append(c)
else:
n1.append(c)
print(f'''A lista completa é {n}
A list... |
3b40792a7692227eddb152f01f664fc5c7eae17a | martinamalberti/BicoccaUserCode | /FakeRate/EffAnalysis/batch/test.py | 1,176 | 3.765625 | 4 | #! /usr/bin/python
import sys
import os
import stat
args=sys.argv
# check the command line and if wrong raise an error
if len(args)!=2:
print 'Usage:\n'+\
'%s CMSSW_dir rootfilelistfile basedir castor_dir queue\n' %args[0] +\
'Example:\n'+\
'%s ./CMSSW_1_2_3 mylist.txt /tmp 8nm... |
fe0a10db93ead8b760557a024bcd6c52ad32a754 | 222010326010/gradingassignment-222010326010-main | /1_problem.py | 1,014 | 4.125 | 4 | """
sum of first n odd numbers
Exmple 1:
input=3
output=9
Example 2:
input=7
output=49"""
import unittest
def sum_of_odd_numbers(n):
def oddSum(n) :
sum = 0
curr = 1
i = 0
while i < n:
sum = sum + curr
curr = curr + 2
i = i + 1
return sum
# Driver Code
n = 20
print ("... |
c9023dbe50645422efffafcd06e1223a0a89b6c3 | malienko/projecteuler_python | /problem50.py | 1,574 | 3.828125 | 4 | '''
The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equal to 953.
Which prime,... |
13e67dc7f9af4caf03239050248557db16cc90f1 | bbwong23/flask101 | /service/calculator.py | 777 | 3.828125 | 4 | ##################################################################
# *** DO NOT EDIT THIS FILE ***
# All the functions below take a list of numbers as an argument
##################################################################
def mean(number_list):
size = len(number_list)
return 0 if size == 0 else ... |
2fa3eba5d32abe0eb4810a10b8aca354cf77d53c | Rahulgarg95/datastructures-python | /linked_list.py | 2,128 | 4.0625 | 4 | class Element(object):
def __init__(self,value):
self.value=value
self.next=None
def print_el(self):
print("Element: ",self.value)
class LinkedList(object):
#Function for initialization
def __init__(self, head=None):
self.head=head
#Add new el to end of list
... |
0a44d7b648fcb19bfc40ce10f77cbd177cad4898 | branislavblazek/notes | /Python/1.lesson/vstup.py | 425 | 3.625 | 4 | print('Zadajte celočíselné hodnoty a stlačte Enter, v prípade skončenie stlačte Enter')
total = 0
count = 0
while True:
try:
line = input('čislo: ')
if line:
number = int(line)
except ValueError:
print('Zadajte celé číslo!')
continue
except EOFErro... |
f596322d2f4e0f561f725d2ef15fcaf71cfb922f | Soham2020/Python-basic | /lists/multiplyAllElemnts_Array.py | 171 | 4 | 4 | a = []
print("Enter the Array Elements::")
for i in range(5):
n = int(input())
a.append(n)
p = 1
for i in a:
p = p*i
print("Product of all Elements are :: ", p) |
a6f6efb3c9d04f4a026d63a26ce97f891ab76deb | nvansturgill/Guessing-Game | /myGuessingGame.py | 797 | 4.125 | 4 |
# Import built-in module for generating (random) number
import random
# Prompt, store, and print user name as `user`
user = input("Hello, there. Enter your name to begin... ")
print("Alright, {}!".format(user))
print("I'm thinking of a number between 1 and 10")
# Generate random integer and store as `num`
number = r... |
df92204548760384933e84f3468e88d28ce625da | clonest1ck/advent_of_code_2020 | /day3.py | 934 | 3.828125 | 4 |
class Tile:
def __init__(self, is_tree):
self.is_tree = is_tree
def Travel(tiles, dx, dy):
mapwidth = len(tiles[0]) - 1
mapheight = len(tiles)
x = dx % mapwidth
y = dy
trees = 0
while y < mapheight:
is_tree = tiles[y][x].is_tree
if tiles[y][x].is_tree:
... |
64325183606c8f39513076e9cc44baeda37598f5 | qorjiwon/LevelUp-Algorithm | /Programmers/Programmers_여행경로.py | 992 | 3.546875 | 4 | '''
Programmers 여행경로
Prob. https://programmers.co.kr/learn/courses/30/lessons/43164?language=java
Ref. https://dailyheumsi.tistory.com/22
Start Day: 2019. 09. 15
End Day: 미완성 - 오름차순 경로 불가능
'''
def dfs(node, tickets, visit, temp, answer, cnt):
answer.append(node)
if cnt is len(tickets):
... |
31a9cb894d9791660b213c21fc44c5302a71e5e3 | sarim26/my-caluclator | /goodbasiccaluclator.py | 1,109 | 4.15625 | 4 |
def addition():
num1 = input("Enter a number")
num2 = input("Enter a number to add")
answer_add = float(num1) + float(num2)
print(answer_add)
def subtract():
num3 = input("enter a number")
num4 = input("enter your second number")
answer_substract = float(num3) - float(num4)
pr... |
69de20cdb70a735114caf7349daef8071cac6fd0 | npkhanhh/codeforces | /python/round537/1111A.py | 359 | 3.609375 | 4 | v = {'a':1, 'e':1, 'i':1, 'o':1, 'u':1}
s1 = input()
s2 = input()
if len(s1) != len(s2):
print('No')
else:
res = True
for i in range(len(s1)):
if s1[i] in v and s2[i] not in v:
res = False
break
elif s1[i] not in v and s2[i] in v:
res = False
b... |
21c112b4ec3d0fa090e216706ea6f2803fa1a9be | krishna-j-rajan/movielist | /mymovielist.py | 1,164 | 3.546875 | 4 | import mysql.connector
db_connection = mysql.connector.connect(
host="localhost",
user="krishna",
passwd="k@tt46v@zha.c0m",
database="NAME"
)
db_cursor = db_connection.cursor()
db_cursor.execute("CREATE TABLE mymovielist (Slno INT, movie_name VARCHAR(255),actor_name VARCHAR(255),actress_name VARCHAR(255),... |
08d1d43b365e2aaff7cd46a668cd9326162b6b75 | txwjj33/leetcode | /problems_100/023_mergeKLists.py | 6,603 | 4 | 4 | '''
题目:合并K个排序链表
描述:
合并 k 个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。
示例:
输入:
[
1->4->5,
1->3->4,
2->6
]
输出: 1->1->2->3->4->4->5->6
'''
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
'''
把每个值对应的ListNode串起来,head,tai分别保存这个串的首位
然后把k... |
7a2ff7c720d5d51599867a0bd22344aa3462039f | kazuya075/c_of_school | /python/Py20200417/Py20200417/Py20200417.py | 105 | 3.734375 | 4 |
d={'name':'guide','birthday':1964}
ss="{0[birthday]}is{0[name]}'s birthday"
ss=ss.format(d)
print(ss) |
ed61dd4fa36618fa3891b3c50820638ba3c46cdf | Thearakim/basic_python | /week01/ex/e20_decode.py | 553 | 4.3125 | 4 | a = str()
string = input("Enter your encrypted message:\n>> ")
if string == "": #if string empty print Nothing to decode
print("Nothing to decode")
else:
for x in string:
x = ord(x) #convert x to ord
if x >= 65 and x+13 <= 103:
x += 13
if x > 90: #103-13 because if plus 1... |
ff29f225940677e543096fba0421f015e871df31 | aricsanders/pyMez3 | /Code/Analysis/Fitting.py | 23,347 | 3.546875 | 4 | #-----------------------------------------------------------------------------
# Name: Fitting
# Purpose: Functions and classes for fitting data
# Author: Aric Sanders
# Created: 9/9/2016
# License: MIT License
#-----------------------------------------------------------------------------
""" Fi... |
9b52048b72f40f783aa89db51f56f111fca377d6 | Yogesh-Singh-Gadwal/YSG_Python | /Core_Python/Day-7/5.py | 130 | 3.71875 | 4 | # Python
a = 10
b = 20
if a == b:
print('Both value are same .')
else:
print('Condition is false')
|
b49c3d38b867b774f24c12fa33ba8bf9b4c53f76 | Gafanhoto742/Python-3 | /Python (3)/Ex_finalizados/ex007.py | 451 | 3.859375 | 4 | #média aritmética
nota1 = float(input('Primeira nota do aluno: '))
nota2 = float(input('Segunda nota do aluno: '))
soma = nota1 + nota2
media = soma /2
print('A média entre {} e {} [e igual a {:.2f}.'.format(nota1,nota2,media))
#segundo modo de fazer o mesmo exercio
n1 = float(input('Primeiro nota do aluno: '))
n2 = f... |
9e244edca3f7b67893fc89daa0db8df13124a12c | angelvv/HackerRankSolution | /Python/02.Strings/17.FindAString.py | 438 | 4.0625 | 4 | def count_substring(string, sub_string):
#return string.count(sub_string) # .count only count non-overlapping occurence
return sum(1 for i in range(len(string)) if sub_string == string[i:i+len(sub_string)])
# interestingly, this doesn't throw error of "out of index"
if __name__ == '__main__':
string = ... |
395c15c74176a3ea6cac8324a1bef011cd0dc526 | jgrafton/raspberrypi | /src/led_blink.py | 982 | 3.765625 | 4 | #!/usr/bin/env python
## led_blink.py
# created by John Grafton
import sys
import time
import signal
import RPi.GPIO as GPIO
try:
# this is a demo, may get an error that channel is
# already in use, disable
GPIO.setwarnings(False)
# use BCM GPIO 00..nn numbers
GPIO.setmode(GPIO.BCM)
# Setup... |
0906b4d38e31ce55502e82b84bfd869c44e47e14 | love554468/leetcode | /solution/50_Pow_x_n.py | 913 | 3.953125 | 4 | class Solution:
def myPow(self, x: float, n: int) -> float:
"""
x^10 = x^5 * x^5.
Now we have odd power, but it is not a problem,
we evaluate x^5 = x^2 * x^2 * x.
Special Case: If we have n < 0 negative power, return positive power of 1/x.
Base Case:
... |
0fe5f904a16806d949ab33f5b97743a109ce09e2 | KevinKnott/Coding-Review | /Month 01/Week 03/Day 03/a.py | 1,899 | 4.15625 | 4 | # Diameter of Binary Tree: https://leetcode.com/problems/diameter-of-binary-tree/
# Given the root of a binary tree, return the length of the diameter of the tree.
# The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
# The l... |
5b686552453f2ce0e2c94a499e19bb688324bc66 | AmreshTripathy/Python | /67_pr8_08.py | 147 | 4 | 4 | def multiplication(n):
for i in range(1, 11):
print (f'{n} * {i} = {n * i}')
n = int(input('Enter a number: '))
multiplication(n) |
62a72dde23755fb918ee1e1fa73336fa6bbbb8f2 | ShushantLakhyani/Python-Projects | /password_generator.py | 1,253 | 4.25 | 4 | #This programs output will create a password for you, as per your needs
#you just have to enter the number of letters, numbers and symbols you need in the password
import random
letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G'... |
fdfea37a69904a48d2c710c2ebe54b5d9e899145 | Toetoise/python_test | /lesson1.py | 3,219 | 3.96875 | 4 | myCatName = "黑猫警长"
age = 6
weight = 17.365
print('我的小猫的名字叫%s,它的年龄是%06d,它的体重是%.1f' % (myCatName, age, weight))
print(f'我的小猫的名字叫{myCatName},它的年龄是{age},它的体重是{weight}')
print('我的小猫的名字叫{},它的年龄是{},它的体重是{}'.format(myCatName, age, weight))
num = 7 # int类型不可以被迭代not iterable
str1 = 'wwww'
t1 = (1, 2, 3, 4, 5)
dic1 = {'name'... |
8235c33a5753c8baebda701e9439ee83aba798c3 | Argonauta666/coding-challenges | /interviews.school/02-loops/third-maximum-number.py | 623 | 3.859375 | 4 | # https://leetcode.com/problems/third-maximum-number/
from typing import List
class Solution:
def thirdMax(self, nums: List[int]) -> int:
fm = sm = tm = None
for num in nums:
if fm is None or num > fm:
tm = sm
sm = fm
fm = num
... |
ac61186f91092f5a551b2fb1727c1faae2a1426b | Audarya07/eduAlgo | /edualgo/backtracking_algorithms/Rat_in_a_Maze.py | 7,370 | 4.09375 | 4 | # Rat in a Maze Problme via Backtracking
# the function rat_in_a_maze() takes the maze as an input (as 0 and 1)
# Source :- Top Left
# Destination :- Bottom Right
# Moves allowed is DOWN, UP, LEFT and RIGHT
from __init__ import print_msg_box
from time import time
import sys
sys.setrecursionlimit(150000)
def rat_... |
e3b98a4aca3905b51b594501d99bdf5e44e0e8d3 | bitcraftlab/bots-n-plots | /ipynb/examples/02. Learning Python/botsnplots/module_demo.py | 1,052 | 4.09375 | 4 | """
Hello I am a module
"""
print "Executing stuff inside the module"
some_string = "What ???"
arbitrary_number = 123
def add(x, y):
""" this function is mine """
return x + y
def mul(x, z):
""" this function is yours """
return x * z
def exclaim(s, n=3):
""" this function does something "... |
5157e3a00a6bff09aceab6a1aa7db15b02b4add6 | danwaterfield/LeetCode-Solution | /python/LinkedList/LinkedList Structure/LinkedList Structure.py | 390 | 3.78125 | 4 | # single-linked list
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
# double_linked list
class DoubleListNode(object):
"""
A more specific implement for double-linked list is shown in recommend order-9: 707 Design Linked List
"""
def __init__(self, x):
... |
85fff2cd731c8f10c13b49961400b688d408498d | LeRoiFou/mooc_instructions | /ex003_sizeCompany.py | 919 | 3.765625 | 4 | """
Écrire un programme qui calcule la taille moyenne (en nombre de salariés) des Petites et Moyennes Entreprises de
la région. Les tailles seront données en entrée, chacune sur sa propre ligne, et la fin des données sera signalée par
la valeur sentinelle -1. Cette valeur n’est pas à comptabiliser pour le calcul de ... |
3c549bfd10dd2be72efab996beb013eff226cd3f | Baidaly/datacamp-samples | /14 - Data manipulation with Pandas/chapter 3 - Slicing and Indexing/7 - Slicing time series.py | 1,121 | 4.28125 | 4 | '''
Slicing is particularly useful for time series since it's a common thing to want to filter for data within a date range. Add the date column to the index, then use .loc[] to perform the subsetting. The important thing to remember is to keep your dates in ISO 8601 format, that is, yyyy-mm-dd.
Recall from Chapter 1 ... |
3b5bdb41dfd14bab0fb964a11b7f1a62f0d3172d | Natnaelh/Algorithm-Problems | /Dynamic Programming/DagShortestPathDp.py | 1,492 | 3.734375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon May 4 23:05:41 2020
@author: natnem
"""
class Graph(object):
def __init__(self,G):
self.graph = G
def itervertices(self):
return self.graph.keys()
def Inverse_neighbors(self,u):
neighbors = []
for x in self.... |
6a47ca3d047516b312792dc8b92cf583ab1a27c4 | SOURAV-ROY/2020-PYTHON | /Sum.py | 523 | 3.9375 | 4 | # def add_two_number(first, second):
# return first + second
#
#
# number_1 = 10
# number_2 = 40
# sum_result = add_two_number(number_1, number_2)
# print(f'{number_1} + {number_2} = {number_2 + number_1}')
# print(f'{number_1} + {number_2} = {sum_result}')
print("1")
def complicated_logic(value_1, value_2):
p... |
5606958f15ed9a80214ac47040ca95fc42b285a2 | tcandzq/LeetCode | /Sort/ContainsDuplicateIII.py | 2,183 | 3.625 | 4 | # -*- coding: utf-8 -*-
# @File : ContainsDuplicateIII.py
# @Date : 2020-02-18
# @Author : tc
"""
220 存在重复元素III
给定一个整数数组,判断数组中是否有两个不同的索引 i 和 j,使得 nums [i] 和 nums [j] 的差的绝对值最大为 t,并且 i 和 j 之间的差的绝对值最大为 ķ。
示例 1:
输入: nums = [1,2,3,1], k = 3, t = 0
输出: true
示例 2:
输入: nums = [1,0,1,1], k = 1, t = 2
输出: true
示例 3:
输... |
a96ac383f7e0f7f0a9301d31767244fcf8cd642b | trimardianto27/jobsheet-6 | /LINK LIST DAN FILTER.py | 644 | 3.6875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[6]:
def multiply(x) :
return (x*x)
def add(x) :
return (x+x)
funcs = [multiply, add]
for i in range(5):
value = list(map(lambda x: x(i), funcs))
print (value)
# In[9]:
#List alfabet
alfabet = 'a', 'b', 'c', 'e', 'i' 'k', 'o', 'z',
# fungsi penyaring... |
d3f4049ebda4c62866aba9cb805f2ea00ed7e6a9 | subodhss23/python_small_problems | /easy_probelms/does_number_exit.py | 367 | 4 | 4 | ''' Create a function which validates whether a given number exists, and could
represent a real life quality. Inputs will be given as a string.'''
def valid_str_number(n):
try: float(n)
except: return False
return True
print(valid_str_number("3.2"))
print(valid_str_number("324"))
print(valid_str_num... |
435f45fb6908b48738cd99f36e2663b4e0ea4ba0 | zdravkob98/Fundamentals-with-Python-May-2020 | /Exercise Lists Basics/Bread Factory.py | 1,153 | 3.6875 | 4 | day_events = input().split('|')
coins = 100
energy = 100
flag = True
for e in day_events:
event = e.split('-')
command = event[0]
num = int(event[1])
if command == 'rest':
if energy >= 100:
print(f'You gained {0} energy.')
print(f'Current energy: {energy}.')
... |
36eac0b793a1d2abcd7318ba110ddf5f759afd74 | shenxiaoxu/leetcode | /questions/1488. Avoid Flood in The City/avoid.py | 1,635 | 4 | 4 | '''
Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of water. If it rains over a lake which is full of water, there will be a flood. Your goal is to avoid the flood in any lake.
Given an integer array rains where:
rains[i... |
1d4ac51059b3081020345fb7f99b562dee11213c | ryndovaira/leveluppythonlevel1_300321 | /topic_06_files/practice/files_3_save_set_to_file_json.py | 1,015 | 3.6875 | 4 | """
Функция save_set_to_file_json.
Принимает 2 аргумента:
строка (название файла или полный путь к файлу),
словарь JSON (для сохранения).
Сохраняет словарь (JSON) в файл.
Загрузить словарь JSON (прочитать файл),
проверить его на корректность.
"""
import json
def save_set_to_file_json(my_path, my_json):
... |
a01577f33de71ba1b6b676da877097817df15d43 | 20050924/All-projects | /Assignment 18 Tic Tac Toe 3.py | 14,577 | 4.0625 | 4 | #Michael Li
#Programming 11
#2021/10/5
#Assignment 18, A tic tac toe game program that player aginst Ai.
#Ai smarter(can place a X when ai is able to win)
#have a bug when game ends it pops out a error(don't know how to fix: Internal error: bunch of codes file name etc and then OSError: [Errno 22] Invalid argument)
fro... |
a3d22f691a153f15207a0ecce9ad73e1d5242ae6 | mertkasar/hackerrank-solutions | /algorithms/warmup/gem_stones.py | 440 | 3.5625 | 4 | import sys
input_list = [inp for inp in sys.stdin.read().split("\n")]
del input_list[0]
def is_gem(element):
for member in input_list:
if element not in member:
return False
return True
tested = []
gem_count = 0
for stone in input_list:
for element in stone:
if element not i... |
a90436ede3214073b017bdac07736e0e26d5c431 | Aringan0323/Beginner-Projects | /PA4/Problem4.py | 170 | 3.765625 | 4 | def fun3():
v = 4
for i in range(1,6):
for x in range(v):
print(" ", end="")
v = (v-1)
for y in range(i):
print("* ", end="")
print()
fun3()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.