blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
ac823fc82a766a20e82be7ba14604e0c087e8cae | FabianOmoke/Data-Structures-And-Algorithms-In-python-Exercises-and-Projects | /venv/Tkintorial/tkinterOverview.py | 703 | 4.09375 | 4 | from tkinter import *
root = Tk() #creating the root widget
e = Entry(root, bg="black", fg="white")
e.insert(0,"Your Name?")
e.grid(row=0, column=0)
def showMe():
myLabel1 = Label(root, text="Hello World")
myLabel2 = Label(root, text="Do you know who I am?")
myLabel3 = Label(root, text=e.get())
myLab... |
32fa7f1d7531d7a3aa544df593a20978a495a646 | vineel2014/Pythonfiles | /python_exercises/22pythoninterviewexercises/reprex.py | 131 | 3.96875 | 4 | s=input("Enter any String:")
print("String form of given String is:",str(s))
print("String form of given String is:",repr(s))
|
4713f2768cd5fafc10baf6d968f43f51d4d7dbad | gauffa/mustached-dubstep | /wip/ch4ex11.py | 804 | 4.4375 | 4 | ########
#Matthew Hall
#Chapter 4
#Exercise 11
#09/22/2013
########
def main():
print("This script converts seconds to other units of measurement"+\
"if the number of seconds is greater than 60.\n")
#get input from user
seconds = float(input("Enter a number of seconds, please.\n"))
#math the input
if float(seco... |
454e7d2c24ab6ce5775f3b85e562ea54f369e5f2 | joohoyo/LeetCode | /python3/easy/E28.py | 1,359 | 3.515625 | 4 | # 28. Implement strStr()
# https://leetcode.com/problems/implement-strstr/
# 16:52 ~ (min)
# time limit exceeded
import unittest
class Solution:
def strStr(self, haystack: str, needle: str) -> int:
if needle == "":
return 0
for i in range(len(haystack)):
if haystack[i] =... |
aaf4282d942d53ebfa880117adeaa6e52b6c4d33 | akshat-52/FallSem2 | /act1.22/1.22.2.py | 66 | 3.578125 | 4 | squares={}
for x in range(6):
squares[x]=x*x
print(squares) |
545cf37a2c55da4b8ae9f35663d6f047e6e96507 | lilaboc/leetcode | /1507.py | 586 | 3.875 | 4 | # https://leetcode.com/problems/reformat-date/
import re
class Solution:
def __init__(self):
self.months = lambda x: str(["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].index(x) + 1).rjust(2, "0")
self.days = lambda x: re.search('\d+', x, re.I|re.M|re.S).group(... |
8e17968a3f84cab491c65c9b9e0b3497327dd89f | kiranrraj/100Days_Of_Coding | /Day_55/print_num_and_square.py | 410 | 3.875 | 4 | # Title : Print number and square as tuple
# Author : Kiran raj R.
# Date : 24:10:2020
userInput = input(
"Enter the limit till you need to print the sqaure of numbers :")
square_tup = ()
for i in range(1, int(userInput)+1):
square_tup += (i, i**2)
try:
for j in range(0, len(square_tup), 2):
p... |
53103572cea19b54591bc5650ae20bbcc04e4287 | ekg15/geneticalg | /genetics.py | 6,752 | 3.625 | 4 | from copy import deepcopy
from functools import *
import numpy as np
"""
1. Set k := 0. Generate an initial population P(0).
2. Evaluate P(k).
3. If the stopping criterion is satisfied, then stop.
4. Select M(k) from P(fc).
5. Evolve M(k) to form P(k + 1).
6. Set k := k + 1, go to step 2.
"""
def main():
c1 = np... |
5924aa05dfecc9d641dd63ac09472e13e47ae387 | HatsuneMikuV/PythonLearning | /leetcode_1.py | 1,269 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name: leetcode_1
Description : ^_^ !!!
Author : anglemiku
Eamil : anglemiku.v@gmail.com
date: 2019-08-23
-------------------------------------------------
Change Activity: 2019... |
4fea3d63b9aa61a0844f3445fe53877a6dd21d90 | ahdeshpande/Interview-Questions | /General/island_count.py | 1,972 | 3.625 | 4 | # def mark_island(binary_matrix, i, j, row_count, col_count):
# if i < 0 or i >= row_count - 1 or j < 0 or j >= col_count - 1:
# return
# else:
# if binary_matrix[i - 1][j] == 1:
# binary_matrix[i - 1][j] = -1 # visited
# mark_island(binary_matrix, i - 1, j, row_count, c... |
f4c3ebfe2159f9ea58922589096fd350bfe9f0a3 | MaartenUijen/pp_fibonacci_mpu | /pp_fibonacci_mpu/fibonacci_iteration.py | 2,255 | 4.34375 | 4 | from typing import List
class FibonacciIteration:
def __init__(self):
self.lookup_table = {0: 0, 1: 1}
self.reverse_lookup_table = {0: 0, 1: 1}
def get_fibonacci_number(self, n: int) -> int:
"""
Iteration method of the n-th fibonacci number.
0(n) time, 0(1) space
... |
7c723a52c3fa41668715381cd9703c53a0bf7d73 | jeremypotter/python | /timing.py | 174 | 3.75 | 4 | import time
start_time = time.time()
answer=raw_input("Type something: ")
elapsed_time = int(time.time() - start_time)
print "It took you " + str(elapsed_time) + " seconds"
|
5f8a63d7b4f5af971351e3f5a9e517488eec1749 | Eunbae-kim/PracticeCoding | /python/2021_02_28_7.py | 344 | 4.1875 | 4 | # python
# Returns a flat list of all the values in a flat dictionary
# we can use values() funciton to get all values in dictionary
# then using list() function, we can make it as a list
def valuesList(dictionary):
return list(dictionary.values())
ages = {
"eunbae":100,
"soojeong":103,
"yea":99,
}
... |
851f67e322bacbc4fa07f8d524e00f96ddd150a9 | stevestar888/leetcode-problems | /617-merge_two_binary_trees.py | 1,680 | 3.984375 | 4 | """
https://leetcode.com/problems/merge-two-binary-trees/
Strat:
This can be done both iteratively and recursive, like most tree problems,
but the recursive way is really straightforward. If both nodes are empty,
then the node to return is also empty. If one node is empty, then just
return the other n... |
377dd7633e93cdcf7987dbb59e2bb9a186f4843a | ZainabSayyed/Python-Codes | /Python/LargestSet.py | 684 | 3.65625 | 4 | import itertools
# Complete the function below.
#Program to find largest possible set of elements which sum is less then equalt to k.
#There are 3 inputs, no of elements in the set a_cnt, list of elements a and k.
a_cnt = 0
a_cnt = int(input())
a_i=0
a = []
while a_i < a_cnt:
a_item = int(input())
a.append(a_it... |
a584b98bebf6b3d05016b5c061d0ec7f2caf2264 | ferruvich/training-leetcode | /arrays_strings/three_sum/python/test_three_sum.py | 734 | 3.640625 | 4 | import unittest
import three_sum
class TestThreeSum(unittest.TestCase):
def test_three_sum(self):
for nums, solution in [
[[-1, 0, 1, 2, -1, -4], [[-1, -1, 2], [-1, 0, 1]]],
[[], []],
[[0, 1], []],
[[0], []],
[[1, 2, 3, 4, 5, 6], []],
... |
e4c105031618ca2f39183c837d191c4a9cf55f9a | AlexanderIvanofff/Software-University | /Office Chairs.py | 526 | 3.796875 | 4 | number_room = int(input())
total_free_chairs = 0
has_enough_space = True
for i in range(1, number_room + 1):
room_data = input().split()
chairs_count = len(room_data[0])
numbers_of_seat = int(room_data[1])
if chairs_count >= numbers_of_seat:
total_free_chairs += chairs_count - numbers_of_seat
... |
e37c9eda49ecef76cece74ba2904d8d06c506100 | ShadAhmed122/Public | /python practice/v8/Dictionary.py | 321 | 3.546875 | 4 | a={"Saad":19,"Anik":33,"Kam":"O0","Shad":(1,2,3,4,5,6)}
print(type(a))
a["Ahmed"]="Ullah"
print(a)
del a["Kam"]
print(a)
a["hmed"]="Habib"
a.update({"sad":"A+"})
print(a)
print(a.items())
print(a.values())
print(a["Shad"][2])
b=a.copy()
# be aware of pointer
print(b["Shad"])
print(b.get("Shad"),end=" ")
print(a.keys())... |
b4fc1dda648dacbda99f7567d0157f755eed8c43 | meenapandey500/Python_program | /program9-11/ex.py | 123 | 3.9375 | 4 | a=int(input("Enter NUmber a : "))
b=int(input("Enter NUmber b : "))
c=a/b
print("divde =",c)
c=a+b
print("sum : ",c)
|
81857f71e31022f3488d6e2393bc3f9bee5fe426 | rouse666/leetcode_python | /01.数组/JZ04.二维数组的查找.py | 538 | 3.546875 | 4 | # -*- coding:utf-8 -*-
class Solution:
# array 二维列表
def Find(self, target, array):
# 从右上角往下找,>就消除所在行继续向下,<就消除所在列
for i in range(len(array)):
for j in range(len(array[0])):
if target < array[i][j]:
j -= 1
continue
... |
20383c15ee1f8d14006aeea9570987e72f2d2631 | qmnguyenw/python_py4e | /geeksforgeeks/python/python_all/135_6.py | 2,809 | 4.625 | 5 | Python | Reversed Order keys in dictionary
While working with dictionary, we can sometimes, have a problem in which we
require to print dictionaries in the reversed order of their occurrence. Let’s
discuss certain ways in which this problem can be solved.
**Method #1 : Usingreversed() + sorted() + keys() \... |
4009c148feb132b0815a40610a661afde4142607 | cory-weiner/python-euler | /1.py | 187 | 3.703125 | 4 | def solution(max):
valid_values = []
for i in range(0,max):
if i%3 == 0 or i%5 == 0:
valid_values.append(i)
return sum(valid_values)
print(solution(1000)) |
189b72c15dd454c4d0d102e0c8f21a8050f973d2 | jfhilliard/TestProject | /Sandbox/test/test_playground.py | 841 | 3.671875 | 4 | # -*- coding: utf-8 -*-
import unittest
from Sandbox.playground.playground import sum_list
class TestPlayground(unittest.TestCase):
"""Test my playground functions"""
def test_add_list2(self):
"""Test addition of list of 2 elements"""
x = [1, 2]
y = sum_list(x)
expected_val... |
64b24e0ef77ff75ae54ac29a80c016c234bdf614 | ksenijaa21/SP-Midterm-Exam | /task2.py | 351 | 3.78125 | 4 | def recStep(p, d):
print(str(p))
while True:
if d < 0:
if n > 0:
recStep(p-m, d)
else:
recStep(p+m, d * -1)
else:
if p < n:
recStep(p+m, d)
else:
return
n = int(input("N: "))
m = in... |
531128ef62bd27774a6abeaf43ed0e57529f3781 | codecamjam/knowledge-based-intelligent-system | /GetData.py | 776 | 3.515625 | 4 |
def getAttributes(file):
count = 1
attList = []
for line in file:
cur = [x.strip() for x in line.split()]
if len(cur) == 3 and cur[0][-1].endswith(':'):
binPos = {cur[1]: count}
binNeg = {cur[2]: -count}
attList.append(binPos)
attList.append(b... |
878ca0bfdb761837d17eb675f6586faf36f0ad20 | j4rthur/cxbasico | /caixa_eletronico.py | 634 | 3.65625 | 4 | saque=int(input('Valor do saque (min=10 reais / max = 600 reais) >> '))
# Notas
notas100=saque//100
notas50=saque//50
notas10=saque//10
notas5=saque//5
notas1=saque//1
# bloco PARA NOTAS DE CINQUENTA
aux=notas100*100
saque=saque-aux
notas50=saque//50
# bloco PARA NOTAS DE DEZ
aux=notas50*50
saque=saque-aux
notas10=... |
3f003a116ff3293aef8583769543d9f8a8e8c069 | jimchiang/ProfessionalDevelopment | /MIT-6.00SC/ps9/ps9.py | 8,170 | 3.90625 | 4 | # 6.00 Problem Set 9
#
# Intelligent Course Advisor
#
# Name:
# Collaborators:
# Time:
#
import itertools
SUBJECT_FILENAME = "subjects.txt"
SHORT_SUBJECT_FILENAME = "shortened_subjects.txt"
VALUE, WORK = 0, 1
#
# Problem 1: Building A Subject Dictionary
#
def loadSubjects(filename):
"""
Returns a dictionary ... |
a2608a1e60f6879d9cd53b5ada9283a55769d944 | simeonikratko/python_class | /zadacha_2_grupa2.py | 113 | 3.515625 | 4 | limit = input('Enter the limit: ')
distance = input('Enter the distance: ')
def speeding(limit, distance):
|
bdf2dfdda1784e6f6767a4d22fb949349af00b7c | Ivychen99/AE402_KUKUO | /mouse.py | 1,415 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 13 10:27:24 2021
@author: konan
"""
import pygame,random
def randColor():
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
return(r,g,b)
BLACK = (0 ,0 ,0 )
WHITE = (255 ... |
e396c335bc628850f698b4288fee9bf4ccd00762 | plooney81/python101 | /first/print_even_0_to_99.py | 294 | 4.3125 | 4 | # for loop that prints only even numbers from 0 to 99
for counter in range(100):
# boolean var that is true if the counter is even
is_even = counter % 2 == 0
# if our boolean var is true (aka the counter is even) then we will print that number
if is_even:
print(counter) |
9e9e5bc5df964eb49301dd4df9e414cc69828106 | patelsandeep07/FST-M1 | /Python/Activities/Activity7.py | 375 | 3.890625 | 4 | numList = []
while True:
num = int(input("Enter the nuumber: "))
numList.append(num)
repeat = input("If you want to stop then press y or press any other key: ").lower()
if (repeat=="y"):
break
# printing input number list
print(numList)
#logic for adding each number in list
sum = 0
... |
6273a568885bbd22442138e907cb14de5bc74bc3 | smmilut/smmilutils | /simplegui/tk.py | 1,995 | 3.734375 | 4 | """
Get a list of files using Tkinter
started 2011-01-16
by Pil Smmilut
"""
# For handling paths
import logging
import os.path
import tkFileDialog
#==============================================================================
global logger
logger = logging.getLogger("tkfilesel")
#--------------... |
bdd85d34caa30676e43d30cfe4930850edbe540b | arinablake/new_python-selenium-automation | /initials_kata.py | 612 | 3.921875 | 4 | # Write a function to convert a name into initials. This kata strictly takes two words with one space in between them.
#
# The output should be two capital letters with a dot separating them.
#
# It should look like this:
#
# Sam Harris => S.H
#
# Patrick Feeney => P.F
name1 = input('Enter name ')
def name_to_initial... |
abed6e27f2d9f2afd6c0e4d81b088fd9e93d929d | simrangrover5/Advance_batch2020 | /bank_app.py | 2,363 | 4.125 | 4 |
"""
This file consists of bank app function use for performing banj operations
"""
from getpass import getpass
data = {'1001' : ["simran", "passwd", 12000, '1601'], \
'1002' : ["shahid", "admin", 10000, '2810'], \
'1003' : ["rahul", "passpass", 13000, '0505'], \
'1004' : ["tushar", "pass... |
e63c97321d60e4d3be1e817fb398b9effc65bb56 | K-J-HYEON/good | /baekjoon/10808_count of alphabet.py | 1,049 | 3.71875 | 4 | # 알파벳 소문자로만 이루어진 단어 S가 주어진다.
# 각 알파벳이 단어에 몇 개가 포함되어 있는지 구하는 프로그램을 작성하시오.
# my_word = list(str(input())) #리스트 형식으로 입력값 저장해주고
# alphabet = ['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']
# # 알파벳 나열 해준 다음(비효율적인거 같다,,)
# for i in range(le... |
e65f12fb0b42c76f291f0029f4882b6a768dc1f6 | stevalang/Coding-Lessons | /SoftUni/Python Developmen/Python-Fundamentals/04_Lists/battle_ships.py | 1,035 | 4.125 | 4 | """
You will be given a number n representing the number of rows of the field. On the next n lines you will receive each row of the field as a string with numbers separated by a space. Each number greater than zero represents a ship with a health equal to the number value. After that you will receive the squares that a... |
71610ec74e235a76bd054719bd76b2c379ed5c0d | crystal30/DataStructure | /PycharmProjects/hash/Student.py | 1,011 | 3.765625 | 4 | # -*- coding: utf-8 -*-
class Student():
def __init__(self,grade, cls, firstname, lastname):
self.grade = grade
self.cls = cls
self.firstname = firstname
self.lastname = lastname
def hashCode(self):
B = 31
myhash = 0
# [self.grade, self.cls, self.firstna... |
fe14efc404f417aaff6365b1b18d9005137fdb18 | LeviMorningstar/Exercicios-relacionados-a-aulas-Feitas | /Ex. 8 (Corrigido).py | 2,107 | 3.65625 | 4 |
def IMC(peso,altura):
IMC = peso / (altura*altura)
return IMC
def class_imc(sexo,peso,altura):
valor_imc = IMC(peso,altura)
if sexo == 'm':
if valor_imc < 20.7:
return 'Abaixo do peso.'
elif valor_imc >= 20.7 and valor_imc <= 26.4:
return 'No peso Nor... |
7da676692ce0686bfcd8ce61e7c0b6f4c16042ad | bridgette/Python100 | /mystery_cipher/cipher.py | 2,895 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Cipher
Translate the mystery string.
"""
import unittest
from english_scorer import ScoreEnglish
class CaesarCipher:
'''
Caesar Cipher is a substitution cipher in which each letter in the
plaintext is replaced by a letter some fixed number of positions
down the alphabet.
... |
ef7c6875cef54128da85135e7a758bf61301da5b | Sharan-Xia/Python_operator | /10_thread.py | 6,628 | 4.1875 | 4 | #Python3提供两个线程模块为:_thread和threading
#_thread 提供了低级别的、原始的线程以及一个简单的锁,它相比于 threading 模块的功能还是比较有限的。
#Python中使用线程有两种方式:函数或者用类来包装线程对象
#函数式:调用 _thread 模块中的start_new_thread()函数来产生新线程:
# 语法:_thread.start_new_thread ( function, args[, kwargs] )
# function - 线程函数。
# args - 传递给线程函数的参数,他必须是个元组(tuple)类型。
# kwargs - 可选参数
impo... |
bc9ce304cccc768e252e25c0def38d72aea5d777 | YunheWang0813/RPI-Repository | /CSCI 1100/LAB/LAB11/lab11files/Ball.py | 811 | 3.734375 | 4 | class Ball(object):
def __init__(self,x,y,dx,dy,radius,color):
self.x,self.y=x,y
self.radius=radius
self.dx,self.dy=dx,dy
self.color=color
def position(self):
return self.x,self.y
def move(self):
self.x+=self.dx
self.y+=self.dy
... |
f959f24808c43a2fb78f48bf9892ee1e06d21913 | lucas-deschamps/LearnPython-exercises | /ex44.py | 5,614 | 4.375 | 4 | # When you are doing this kind of specialization, there are three ways that the parent and child classes can interact:
# Actions on the child imply an action on the parent.
# Actions on the child override the action on the parent.
# Actions on the child alter the action on the parent.
### Implicit Inhe... |
c84e9a3be2c120fa65032a5b7c867f2e61fb04e6 | akaliutau/cs-problems-python | /problems/sort/Solution57.py | 963 | 3.65625 | 4 | """ Given a set of non-overlapping intervals, insert a new interval into the
intervals (merge if necessary). You may assume that the intervals were
initially SORTED according to their start times.
Example 1: Input: intervals
= [[1,3],[6,9]], newInterval = [2,5] Output: [[1,5],[6,9]]
IDEA:
1... |
df9d509c9b5fea8355643b60d239c38d55067369 | ianhom/Python-Noob | /App/run_cal.py | 464 | 3.984375 | 4 | while True:
distance = input("Please input the kms: ")
mins = input("Please input the minuts: ")
secs = input("Please input the seconds: ")
min_temp = (mins+secs/60.00)
speed = 60.00*distance/min_temp
pace = min_temp/distance
r_min = int(pace)
r_sec = int((pace - r_min)*60)
... |
a67e8137b6382dfa30411b014ca781d899ed33d4 | Alexcode88/HashTable | /HashTable.py | 1,380 | 4.09375 | 4 |
class HashTable:
def __init__( self, cap ):
self.cap = cap
self.length = 0
nums = []
for i in range(0, cap, 1):
nums.append( None )
self.storage = nums
def printHashTable( self ):
print( "Capacity: ", self.cap )
print( "Length: ", self.le... |
2885d93e8d9855f7fc7fdfbec587491472dbcf50 | pavel-sysopov/mipt.ru | /lab1/008_square_spiral.py | 167 | 3.609375 | 4 | from turtle import *
shape('turtle')
x = 10
angle = 90
count = 0
circle = 10
while count < 360 * circle:
lt(angle)
fd(x)
x += 10
count += angle
done()
|
2bb5ed782610993af4d20311da05c2b63f4d57e8 | SamT16/CS1-Labs | /Python/Lab 72/oddchecker.py | 221 | 3.671875 | 4 | def isOdd( num ):
var = num%2
if var == 0:
return False
else:
return True
print isOdd( -11 )
print isOdd( 18 )
print isOdd( 17 )
print isOdd( 100 )
print isOdd( 99 )
|
ded7ecea10f5e281bab7c8b1ae306a5f437936e8 | luyandamncube/UNISA | /year2/COS2633/Roots_NewtonRaphsonMethod.py | 367 | 3.6875 | 4 | import numpy as np
# from sympy import *
import sympy as sym
# define what is the variable
x = sym.symbols('x')
# define the function
# f(x) = x^2 - 4x-5
f = x**2-4*x-5
xn = 1
for i in range(10):
xn = xn - float(f.evalf(subs= {x:xn})) / float(f.evalf(subs= {x:xn}))
print(f'The {i+1} iteration xn is {xn:.2} a... |
982e6431342f5d821bbf6cde46c41d8b11a77a07 | standrewscollege2018/2020-year-11-classwork-padams73 | /movie-list.py | 321 | 4.40625 | 4 | """ This programs asks the user to enter 3 movies, then stores them in a list, finally printing them out. """
# set up an empty list to store the movies
movies = []
# start loop to ask for three movies
for i in range (0,3):
movie_name = input("Name a favourite movie: ")
movies.append(movie_name)
print(movies... |
ff933c74ac72a9de839d3873f3c67e5743c6e8cd | Leedokyeong95/PythonWorks | /Ch10/10_5_Register.py | 1,446 | 3.703125 | 4 | """
날짜 : 2021/03/04
이름 : 이도경
내용 : 파이썬 데이터베이스 프로그래밍
"""
import pymysql
# 데이터베이스 접속
conn = pymysql.connect(host='192.168.10.114',
user='ldk',
password='1234',
db='ldk',
charset='utf8')
while True:
print('0:종료, 1:등록, 2:조회')... |
47fa1d52c4892e6534ae0cb94f2447d297f1b3c4 | mombasawalafaizan/wrapup | /wrapup/filepath.py | 779 | 4.09375 | 4 | from pathlib import Path
def getfilepath(filename: str) -> Path:
"""
Searches for the filepath in the current directory and parent directory
If an empty string or nothing is passed as the parameter, sets the current working directory as path
Args:
filename: An str object that represents a file... |
49add5e021b8f0bc2874b512a1d65052ae601de3 | lincolen/Python-Crash-Course | /8 functions/sandwiches.py | 290 | 3.546875 | 4 | def make_sandwich(*ingridients):
print("\nmaking a sandwich useing the following ingridents")
for ingridient in ingridients:
print("- "+ingridient)
make_sandwich("tomato", "cheese", "pepers")
make_sandwich("ham", "lettece")
make_sandwich("avocado", "egg", "lettece" , "halapinio")
|
c583aa19d6ab31a79064f722356539a97e7b2855 | Suryashish14/Suryashish-Programs | /SpecialNumber.py | 536 | 4.25 | 4 | #This Program Is Only For Positive Numbers
#To Get Sum Of Digits In A Given Number
a=int(input('Enter A Number:'))
numcopy=a
b=a
c=a
sum=0
while numcopy > 0:
remainder=numcopy%10
sum+=remainder
numcopy=numcopy//10
#To Get Product Of The Digits
product=1
while b > 0:
remainder=b%10
p... |
262ba27855cce0081ce8af2443a3acfe6cc476e2 | Khushal-ag/Python_Programs | /Data Structures/Strings/count_char.py | 157 | 3.96875 | 4 | s = input("Enter a string = ")
s1 = ""
for i in s:
if i not in s1:
s1 += i
for i in s1:
print("{} is occuring {} times".format(i,s.count(i))) |
1b73de1fe572bc55349a74d9af9fd3ecd1b6af52 | IvanWoo/coding-interview-questions | /puzzles/valid_palindrome_ii.py | 881 | 3.953125 | 4 | # https://leetcode.com/problems/valid-palindrome-ii/
"""
Given a string s, return true if the s can be palindrome after deleting at most one character from it.
Example 1:
Input: s = "aba"
Output: true
Example 2:
Input: s = "abca"
Output: true
Explanation: You could delete the character 'c'.
Example 3:
Input: s = "ab... |
7aab041f8f0605fa8d992eb049970ffb70073aad | EdwinOliveira/artifical-intelligence | /first-lesson/exercices.py | 600 | 3.828125 | 4 | #1
#a)
a = 2**3*3
print(a)
#b)
b = 2**(3*3)
print(b)
#c)
c = 3*5+2//7
print(c)
#d)
d = 3*5//2
print(d)
#e)
e = 5//2*3
print(e)
#f)
f = 22%8/4
print(f)
#g)
g = 22%(8/4)
print(g)
#h)
h = 34/8*3
print(h)
#2
#a
a2 = 'carro'+'casa'
print(a2)
#3
#a - V
#b - F
#c - F
#d - F
#e - F
#f - V
#g - V
#h - V
#i - F
#j - V
... |
af38c609cc1ced724a6bfe73a12dce6768fef809 | tpessoa10/-ifpi-ads-algoritmos2020 | /Fabio03_For/Q8.py | 291 | 3.859375 | 4 | def main():
n = int(input('Digite um número: '))
limite_inferior = int(input('Digite o limite inferior: '))
limite_superior = int(input('Digite o limite superior: '))
for i in range(limite_inferior, limite_superior):
if i % n == 0:
print(i)
main()
|
7b90331c67f20e1efa8efa15eb4a25a37cc02d53 | basu-sanjana1619/python_projects | /sum_of_numbers.py | 190 | 4.25 | 4 | #this program will calculate the sum of numbers till the specified value
def sum_of_numbers(val):
add = 0
for num in range(val):
add = add + num
return add
print(sum_of_numbers(10))
|
4bceac8beff559eb8487225d7e0663114c3189ca | nabeel-malik/my_python | /my_programs/lambda_function_with_filter().py | 868 | 4.4375 | 4 | #This program uses lambda function with filter() to find even numbers in a list
user_input = input('Enter the positive integers separated by commas(","): ')
user_input_list = user_input.split(",")
try:
user_input_list = [int(i) for i in user_input_list]
except ValueError:
print("Invalid entry. Please ensure th... |
34ee335437aae95dac5a0a8e3a0d3cbd8e930f0d | Andrew-Coxall-0934/ICS3U-Unit1-04-Python | /ICS3U-Unit1-O4.py | 270 | 4 | 4 | # !/usr/bin/env python 3
# Created by: Andrew Coxall
# Created on: Mar 31, 2020
# This is the area of a square with a length of 5 and a hight of 3 (cm)
"""
Your module description
"""
print("Perimeter is 5*2 + 3*2={}" .format(5*2 + 3*2))
print("Area is 5*3={} " .format(5*3)) |
2d67e61606225b846589948d6ae6d5a299223907 | Lehcs-py/guppe | /Seção_05/Exercício_26.py | 779 | 4 | 4 | print("""
26. Leia A distância em Km e A quantidade de litros de gasolina consumidos por um carro em percurso,
calcule o consumo em Km/l e escreva uma mensagem de acordo com A tabela abaixo:
Consumo : Km/l : Mensagem
menor que : 8 : Venda o carro!
entre : 8 e 14 : Econômico!
... |
1bf72a676dcb8b157f9b94038cfe1c978dbaa8f1 | ayangacann/hicheel4 | /Dasgaluud/2.py | 219 | 3.984375 | 4 | # Өгөгдсөн тоо 3т хуваагдах нь үнэн бол true үгүй бол false гэж хэвлэ.
# 3%3==0 6%3==0 9
# 4 5 7
n = int(input())
if n % 3 == 0:
print(True)
else:
print(False)
|
c4cceb68cdd2bf45e9cc91590bb9d4ef6f99876e | matthewdeanmartin/keno | /keno/player.py | 4,226 | 3.78125 | 4 | # coding=utf-8
"""
Represents a player with a particular strategy.
"""
from typing import Union, Tuple, List
from keno.game import Keno
from keno.strategy import Strategy
from keno.ticket import Ticket
from keno.ticket import TicketValidator
class Player(object):
"""
Person who plays keno until they lose too... |
cb8bca9124d34cdcb594757e9ca417c9e8c3d0e3 | Pincaptain/pybin | /src/services/file_service.py | 3,155 | 3.8125 | 4 | from abc import ABC, abstractmethod
from src.repositories.file_repository import IFileRepository
class IFileService(ABC):
"""
Abstract class for a file service containing the required
methods and their signatures.
If required this class can be extended to support a custom
implementation of the f... |
a31204bfd151f5cb3ff9ef9b10122c21551317cb | Zainab-Kalief/python_intro | /multiplicationTable.py | 217 | 3.875 | 4 | def multipleTable():
for value in range(1,13):
mult = 1
table = ''
while mult < 13:
table += ' ' + str(value * mult)
mult += 1
print table
multipleTable()
|
425bff3486782e094517e81106538ed934d2c829 | nagasrik/learnPython | /functions2.py | 1,886 | 3.703125 | 4 | #function object as a reference
def do_twice(f):
f()
f()
def do_four(f):
do_twice(f)
do_twice(f)
def define_row():
print '+ - - - -',
def define_column():
print '| ',
def grid_row():
define_row()
print '+'
def grid_column():
define_column()
print '|'
def single... |
c9c20bac00aaa7aded58be2194a496c1dbe97725 | slsefe/-algorithm015 | /Week_01/189_rotate_array.py | 1,025 | 3.71875 | 4 | """
leetcode 189 旋转数组
给定一个数组,将数组中的元素向右移动k个位置,其中k是非负数
"""
class Solution:
def rotate_1(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
# 1. 旋转k次,O(kn)
k = k % len(nums)
for i in range(k):
last = nums[-... |
f1af583bb26cb4c2e0e1410fd22c0bde76fe39e3 | gabriellaec/desoft-analise-exercicios | /backup/user_298/ch38_2020_10_01_00_00_34_728734.py | 151 | 3.546875 | 4 | def quantos_uns(num):
t = 0
w =0
a = str(num)
while t < len(a):
if a[t] == '1':
w += 1
t += 1
return w |
36d2c3ba3206d1083b338896708370b388e9cc78 | rogers228/Learn_python | /note/basic/03_判斷式與迴圈/test_while_01.py | 53 | 3.578125 | 4 | a = 1
while a <= 5:
print('a =',a)
a = a + 1
|
4da731fff004bf3f413a67d5a393198003210a5f | Gray-Tu/1A2B_demo | /DEMO/RandomAns.py | 424 | 3.578125 | 4 | RandAns = "9527"
OtherAns = "9487"
print(RandAns) # print out the "9527"
print(OtherAns) # print out the "9487"
# it will return False
print(RandAns == OtherAns) # compare "9527" and "9487"
print(RandAns == RandAns) # compare "9527" and "9487"
print("9527" == " 9527 ") # ?? Guess that, False
impo... |
f5ddedb28cb2e544e82b07b86b25596d206847e9 | korea7030/pythonwork | /Algorithm/n_queens.py | 833 | 3.5625 | 4 | # -*- coding: utf-8 -*-
def is_promising(k, col):
for row in range(1, k):
# level - row = col - x[level]
if col == x[row] or (abs(col - x[row]) == abs(k-row)):
return False
return True
def n_queens(k):
"""
:param k: tree의 level값
:return:
"""
global count
... |
caf9648a9501bf2b39ff6a3723905a38e8899ad7 | zhangruochi/leetcode | /977/Solution.py | 990 | 3.796875 | 4 | """
Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.
Example 1:
Input: [-4,-1,0,3,10]
Output: [0,1,9,16,100]
Example 2:
Input: [-7,-3,2,3,11]
Output: [4,9,9,49,121]
Note:
1 <= A.length <= 10000
-10000 <= A[i] <= 10... |
5f1ebaa4e435d42c128ea96d10f8c2ad2bf8b088 | kritika170/administration-setup | /admin.py | 1,071 | 3.84375 | 4 | import csv
def w(info_list):
csv_file=open("student_info","a")
writer=csv.writer(csv_file)
if csv_file.tell()==0:
writer.writerow(["name","roll.no"])
writer.writerow(info_list)
if __name__=="__main__":
condition=True
num=1
while condition:
student_i... |
ea66fa8a6bd5c6c202c4f84b944d3979abc9c8d0 | lutianming/leetcode | /construct_binary_tree_from_preorder_and_inorder_traversal.py | 695 | 3.5625 | 4 | from leetcode import TreeNode
class Solution:
# @param preorder, a list of integers
# @param inorder, a list of integers
# @return a tree node
def buildTree(self, preorder, inorder):
m = len(preorder)
n = len(inorder)
if m != n:
return None
if m == 0:
... |
03a0862460e739d3e00de3da832ea2b8810d0ded | aissaei/Complete_Solution | /src/p2.py | 845 | 3.65625 | 4 | # This file count the number of words on the file and write it
# on the text file. The result will be used by median_final.cpp
from __future__ import print_function
import glob
import os
path_=os.getcwd()
path_ = path_[:-4]
fout= open('median_interim.txt', 'w')
f=open("file_n.txt",'r')
myList = []
for line in f:
m... |
8180224f3336f5be9bd84edc31a18b8d86b57592 | basilwong/coding-problems | /misc/connect-four/board.py | 3,067 | 3.75 | 4 | BOARD_ROWS = 6
BOARD_COLS= 7
CONNECT_FOUR = 4
DIRECTIONS = (((0, 1), (0, -1)), ((1, 0), (-1, 0)), ((-1, 1), (1, -1)), ((-1, -1), (1, 1)))
PLAYER_1 = 1
PLAYER_2 = 2
EMPTY = 0
GAME_IS_ENDED = 3
class Board:
def __init__(self):
self._new_game()
def _new_game(self):
self.board = [[0] * BOARD_COLS... |
35ffe357773b53b538930d7345feae710427e4f1 | shankar7791/MI-10-DevOps | /Personel/Siddhesh/Assessment/Mar1/TestAns3.py | 171 | 3.890625 | 4 | #Given a list of numbers, return True if first and last number of a list is same.
list=[20,40,50,20]
if(list[0]==list[3]):
print("True")
else:
print("False")
|
8ab67abc7ecf1ade58e43ac26937983ee9b24f4a | EspejelKevin/crud_consola | /agenda_contactos.py | 2,281 | 3.8125 | 4 | class Agenda:
def __init__(self):
self.lista_contactos = []
def menu(self):
print("""
\tAgenda de contactos
1.- Crear contacto.
2.- Editar contacto.
3.- Eliminar contacto.
4.- Consultar contactos.
5.- Salir.
""")
opcion = int(input("Ingrese la opción deseada: "))
if... |
a45b38a401170107b9f925fb3edca0c036039ad6 | 2kindsofcs/exercise | /python exercise/viral-advertising.py | 711 | 3.734375 | 4 | # https://www.hackerrank.com/challenges/strange-advertising/problem
def viralAdvertising(n):
totalNumLike = [2]
totalNumLikeLen = len(totalNumLike)
if n <= totalNumLikeLen:
return totalNumLike[n-1]
for i in range(totalNumLikeLen-1, n-1):
totalNum = math.floor(totalNumLike[i] * 3 / 2)
... |
944e27d7ef0721e1ee4c0011ddc8333c78ce511c | tatiaris/tatiame-old | /coding_problems/project_euler/34.py | 322 | 3.71875 | 4 | from math import factorial
cns = []
limit = int(input('enter limit: '))
def is_special(n):
temp_sum = 0
for a in n:
temp_sum += factorial(int(a))
if temp_sum == int(n):
return True
return False
for i in range(10, limit):
if is_special(str(i)):
cns.append(i)
print(sum(cns)... |
cdeebecc19889d59670ebb9639f991fbb2c57510 | spandanasalian/Python | /exception handling.py | 268 | 3.78125 | 4 | result=None
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
try:
result=a/b
except Exception as e:
print("error in the code")
print(type(e))
print("-----------------------print------------------------")
print(result) |
723a79e1446b07f2bfc13db1bd6b7ff82d2ab579 | omdkhaleel/swayam-python | /thirdmax.py | 325 | 3.703125 | 4 | def thirdmax(l):
(mymax,mysecondmax,mythirdmax) = (0,0,0)
for i in range(len(l)):
if l[i] > mymax:
(mymax,mysecondmax,mythirdmax) = (l[i],mymax,mysecondmax)
elif l[i] > mysecondmax:
(mysecondmax,mythirdmax) = (l[i],mysecondmax)
elif l[i] > mythirdmax:
mythirdmax = l[i]
return(mythird... |
55a2186af990c0d31101896f12be798c9ed59a41 | Jashwanth-k/Data-Structures-and-Algorithms | /1.Recorsions - 1/print List in ascending order.py | 195 | 3.875 | 4 | def ascending(a):
for i in range(len(a)):
for j in range(len(a)):
if a[i] < a[j]:
a[i],a[j] = a[j],a[i]
a = [34,23,7,5,54,3]
ascending(a)
print(a) |
419167279153d0a997ee22a22349e695b6cf8ac4 | sdspikes/stanfordkarel | /problems/garden_karel.py | 695 | 3.546875 | 4 | """
File: garden_karel.py
----------------------------
When you finish writing it, GardenKarel should lay a fence of beepers
on the outer edge of the world it started in. For more in-depth problem
specification, refer to the assignment handout. GardenKarel should be
able to make a fence in any world that has at least 2... |
823330c576d59f68b535301c42e7f93dfc348f0a | gabrieleliasdev/python-cev | /ex015.py | 361 | 3.703125 | 4 | va = float(input('\nType the daily car rental amount:\n>>> R$ '))
km = float(input('\nType the value for Km driven:\n>>> R$ '))
r = float(input('\nHow many days rented?\n>>> '))
d = float(input('\nHow many Km did you drive?\n>>> '))
pag = (va * r) + (km * d)
print('\nYou rented for {} days and traveled {:.2f}km, y... |
ebff9937fff970365c3fa2b831777d006250ac1f | Aasthaengg/IBMdataset | /Python_codes/p02263/s648141413.py | 311 | 3.625 | 4 | operand = []
for x in raw_input().split():
if x.isdigit():
operand.append(int(x))
else:
a1 = operand.pop()
a2 = operand.pop()
if x == '+' :
operand.append(a2 + a1)
elif x == '-':
operand.append(a2 - a1)
elif x == '*':
operand.append(a2 * a1)
print operand.pop() |
6fca51e3f225c9ece22d1439ba29733659d532e7 | Left123456/p19085 | /ask13.py | 826 | 3.6875 | 4 | def luhn_checksum(card_number):
def digits_of(n):
return [int(d) for d in str(n)]
digits = digits_of(card_number)
odd_digits = digits[-1::-2]
even_digits = digits[-2::-2]
checksum = 0
checksum += sum(odd_digits)
for d in even_digits:
checksum += sum(digits_of(d*2))
... |
8fe18a518d0bd8d35126f535105ff41ce967b3f7 | yunakim2/Algorithm_Python | /백준/실습 1/baekjoon2523.py | 102 | 3.734375 | 4 | a = int(input())
for i in range(1,a+1) :
print("*"*i)
for i in range(a-1,0,-1) :
print("*"*i) |
7c4cbed72b3882c5d573e7643ad508b0c80f05a4 | zhenguo96/test1 | /Python基础笔记/8/代码/3.return.py | 626 | 4.1875 | 4 | # 函数不返回值,系统默认返回None
# def add(a,b):
# print(a + b)
# res = add(2,3)
# print(res)
# def add(a,b):
# # 返回值,只能有一个返回值
# # 结束函数调用
# return a + b
# print("hello")
# res = add(3,2)
# print(res)
# def add(a,b):
# if a < 0:
# return -a + b
# else:
# print("hello")
... |
1ddc1dd0fc539ddcc65ece48ebd147d332a8ba25 | Lazaro232/pythonRoadMap | /completePythonCourse/11_Web_Scraping/scrapingBooks/app.py | 878 | 3.796875 | 4 | # Site: https://books.toscrape.com/
# Programa que baixa um página de livros e retorna o livro de menor valor
import requests
from pages.books_page import BookPage
page_content = requests.get('https://books.toscrape.com/').content
page = BookPage(page_content)
# print(page)
for book in page.books:
print(book)
... |
3f633afe5dc836e79e9112d9ee8c417bd34a7799 | MakarVS/GeekBrains_Algorithms_Python | /Lesson_2/Check/Урок 2/zadanie2.py | 521 | 4.03125 | 4 | # Посчитать четные и нечетные цифры введенного натурального числа.
# Например, если введено число 34560, в нем 3 четные цифры (4, 6 и 0) и 2 нечетные (3 и 5).
x=int(input('Введите число: '))
itog=x
chet=nechet=0
while x>0:
if x%2 == 0:
chet += 1
else:
nechet += 1
x = x//10
print('{} четных ... |
8b840eaa11e15bb9d1338b12db85d06bb649dd9f | shahdharm/PythonBasics | /factorial.py | 160 | 4.1875 | 4 | def factorial(a,b):
num = int(input("enter the num:"))
factorial=1
for i in range(2,num+1):
product = product*1
print(factorial)
print() |
8191f8aa05ee7e839019eea29236479ad169e842 | ArchieDash/Python-Basics | /lists.py | 882 | 4.15625 | 4 | import time
def delayed_print(string):
print(string)
time.sleep(2)
def main():
desserts = ['ice cream', 'cookies']
desserts.sort()
delayed_print(f'Sorted list with alphabedical order: {desserts}')
delayed_print(f'The index of ice cream item is: {desserts.index("ice cream")}')
food = ... |
46b7f03cc26f71911810cff42d4be586441d6453 | dorisluvizute/Curso-Python-Udemy | /exercicio3.py | 369 | 3.953125 | 4 | cores = {
'vermelho': 'red',
'azul': 'blue',
'verde': 'green',
'amarelo': 'yellow',
'branco': 'white',
'preto': 'black'
}
cor = input('Digite uma cor para tradução: ').lower()
tradução = cores.get(cor, 'Esta cor não existe no dicionario.')
print(tradução)
# Função lower() transforma tudo oq ... |
7eebb70a2d986af391f9140dc7458172ea9a9578 | SNAPminions/snapcode | /merging-process/merge1005.py | 4,415 | 3.5 | 4 | import csv
import requests
import os
#ToDo
#if the person is already merged with a another 'prefix'+id, then add the 'new' id to the already existing dataset
#
##global Variables
#How to get rid of them?
i= 0
tempVar = ''
def consoleInput():
consoleInputID = raw_input('insert the number where the already existi... |
bf8e56759d6799a79f49edd38250e4954364b199 | vigneshwr/python | /math/math/angle.py | 274 | 4.375 | 4 | import math #importing math package
AB = int(raw_input()) #input the length of two sides
BC = int(raw_input())
print str(int(round(math.degrees(math.atan2(AB,BC)))))+'°' #finding the angle betweentwo sides by calculating the tan angle rounding off to integer
|
b829cc212a527faab2b5883a3cbf050fec2433d1 | Ankit-29/competitive_programming | /Strings/robotToOrigin.py | 1,170 | 3.921875 | 4 | '''
There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves,
judge if this robot ends up at (0, 0) after it completes its moves.The move sequence is represented by a
string, and the character moves[i] represents its ith move. Valid moves are R (right), L (left), U (up), ... |
1a223fca4bd747ca7401636ce0ec98f9c38642d6 | aslamsikder/Complete-Python-by-Aslam-Sikder | /Aslam_16_oop_grocery.py | 994 | 3.9375 | 4 | import random
import sys
import os
class Grocery:
__name = None
__quantity = 0
__price = 0
# Declaring constructor
def __init__(self, name, quantity, price):
self.__name = name
self.__quantity = quantity
self.__price = price
# Initializing all the setter & getter method... |
ec3725fc1c4481c245107d7d3bccc2ae9afc0018 | irissooa/Algorithm-with-Python | /JUNGOL/Beginner_Coder/J_2514_문자열찾기.py | 667 | 3.625 | 4 | '''
20-12-14 18:26-18:37
주어진 문자열, 연속 3개의 문자가 IOI이거나 KOI인 문자열이 각각 몇 개 있는지 찾는 프로그램
1. 문자열을 앞에 3개를 list로 초기값으로 word에 저장 후 IOI or KOI인지 확인
2. 그다음 수를 볼때 word의 앞글자 pop, 다음 문자 뒤에 append,해서 확인 반복
'''
words = list(input())
word = words[:3]
ioi,koi = 0,0
idx = 2
while True:
# print(''.join(word))
if ''.join(word) == 'IOI... |
3200a9d221cca6503ce3d48ec4064400b30284ac | yusufa84/PythonBaseCamp | /Assignments/OOPHomeAssignment.py | 676 | 4.0625 | 4 | import math
class Line(object):
def __init__(self,coord1,coord2):
self.coord1 = coord1
self.coord2 = coord2
def distance(self):
#You can unpack the tuple by writing x1,y1=self.coord1 and that would have made the code more readable.
dist = ((self.coord2[0]-self.coord1[0])**2) + (... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.