blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
f2b06363eb7bf486e5d397ffbf4c68f88ba6c5bc
Xiangyaojun/Algorithms
/栈和队列/用栈实现队列.py
1,886
4.125
4
# coding:utf-8 ''' leetcode 224 题目:使用栈实现队列的下列操作: push(x) -- 将一个元素放入队列的尾部。 pop() -- 从队列首部移除元素。 peek() -- 返回队列首部的元素。 empty() -- 返回队列是否为空。 示例: MyQueue queue = new MyQueue(); queue.push(1); queue.push(2); queue.peek(); // 返回 1 queue.pop(); // 返回 1 queue.empty(); // 返回 false 说明: 你只能使用标准的栈操作 -- 也就是只有 push to top, p...
false
8678b04cd9e28847b30d4b8ec7fe3f9aaddc1708
rohan8594/DS-Algos
/leetcode/medium/Arrays and Strings/ReverseWordsInAString.py
1,076
4.3125
4
# Given an input string, reverse the string word by word. # Example 1: # Input: "the sky is blue" # Output: "blue is sky the" # Example 2: # Input: " hello world! " # Output: "world! hello" # Example 3: # Input: "a good example" # Output: "example good a" # Note: # A word is defined as a sequence of non-space...
true
634119cf7cb1a5d461e0a320ac79151f217e00fd
rohan8594/DS-Algos
/leetcode/easy/Arrays and Strings/UniqueCharachters.py
476
4.25
4
# Given a string,determine if it is comprised of all unique characters. For example, # the string 'abcde' has all unique characters and should return True. The string 'aabcde' # contains duplicate characters and should return false. def uniqueChars(s): seen = set() for i in range(len(s)): if s[i] not...
true
bce31c7854e9835b1a697eb2a0604d78664c0bda
mrDurandall/Python-Basics-Course
/Lesson_3/Lesson-3_HW_Task-1.py
1,184
4.125
4
# Задание 1 - Функция деления. print('Задание 4 - Функция деления.') def divide(): """Функция деления двух чисел для вводимых чисел используется формат float, т.к. пользователь может ввести не только целые числа. также при вводе каждого числа проверям, точно ли пользователь ввел числа, а не другой ...
false
a2510d4c072bbae473cee9ea22e27c081bd97a4c
MVGasior/Udemy_training
/We_Wy/reading_input.py
1,536
4.3125
4
# This program is a 1# lesson of In_Ou Udemy # Author: Mateusz Gąsior # filename = input("Enter filename: ") # print("The file name is: %s" % filename) file_size = int(input("Enter the max file size (MB): ")) print("The max size is %d" % file_size) print("Size in KB is %d" % (file_size * 1024)) pri...
true
e8967361e05174dcd4cd64751213ecf91ce88814
pynic-dot/Python-code-practice
/Objects and Data Structures Assessment Test.py
955
4.28125
4
# Print out 'e' using indexing s = 'Hello' print(s[1]) # Reverse the string print(s[::-1]) # Two method to produce letter 'o' print(s[4]) print(s[-1]) # Lists Build list [0,0,0] in two different way s = [] for i in range(3): s.append(0) print(s) print([0, 0, 0]) print([0]*3) # Reassign 'hello' in this nested l...
false
c6fd9774176663a75853ab33bd9ac42c5573f65f
ursu1964/Libro2-python
/Cap2/Programa 2_9.py
1,576
4.125
4
# -*- coding: utf-8 -*- """ @author: guardati Problema 2.9 """ def aparece_dos_veces(palabra): """ Determina si todas las letras de la palabra están exactamente 2 veces. Parámetro: palabra: de tipo str. Regresa: True si la palabra cumple la condición y False en caso contrario. ...
false
7af831e19af6f8fd26a5e83ae00c391ff9bfcd15
ursu1964/Libro2-python
/Cap1/Ejemplo 1_2.py
1,392
4.1875
4
# -*- coding: utf-8 -*- """ @author: guardati Ejemplo 1_2 Operaciones con listas. """ dias_laborables = ["lunes", "martes", "miércoles", "jueves", "viernes"] colores_primarios = ['rojo', 'verde', 'azul'] precios = [205.30, 107.18, 25, 450, 310.89, 170.23, 340] # ============================================...
false
d1af7d34089b172801b7bef550955595791f2422
yujie-hao/python_basics
/datatypes/type_conversion_and_casting.py
1,689
4.75
5
# ================================================== """ https://www.programiz.com/python-programming/type-conversion-and-casting Key Points to Remember 1. Type Conversion is the conversion of object from one data type to another data type. 2. Implicit Type Conversion is automatically performed by the Python interpret...
true
1eb815e71e54a98630a1c89715a1a59edabaf461
yujie-hao/python_basics
/objects/class_and_object.py
2,060
4.53125
5
# A class is a blueprint for the object class Parrot: # docstring: a brief description about the class. """This is a Parrot class""" # class attribute species = "bird" # constructor def __init__(self, name, age): # instance attribute self.name = name self.age = age ...
true
48fd47973debe27fdf06e7d9335a92e5a5e7eb4e
DagmarMpheio/ExercicioComListasPython
/ExerciciosListas10.py
387
4.125
4
#Faa um programa que crie uma matriz aleatoriamente. O tamanho da matriz deve ser informado pelo usurio. import random print("\t\t Matriz") mat=[] lin=int(input("Digite o numero de linhas: ")) col=int(input("Digite o numero de colunas: ")) for i in range(lin): val=[] for j in range(col): val.ap...
false
867fcce1d6992bf8108ff0f7232acce9dcbefd3d
rozmeloz/PY
/dz2/task4-1.py
591
4.34375
4
""" 1. Запросить у пользователя его возраст и определить, кем он является: ребенком (0–2), подростком (12–18), взрослым (18_60) или пенсионером (60– ...). """ W = int(input('Введите Ваш возвраст:')) if W < 12: print ('Ребенок') elif 12 <= W <=18: print ('Подросток') elif 18 < W < 60: print ("Взрослый") eli...
false
efbc69732c249969b406b3a7071010c998d59297
SandyHoffmann/ListasPythonAlgoritmos
/Lista 3/SH-PCRG-AER-Alg-03-Ex-05.py
1,054
4.15625
4
#Pedindo mês e fazendo com q ele sempre fique no formato minusculo. mes = input("Qual o mês? ").lower() #Checando os meses para printar o tanto de dias. if mes == "janeiro": print(f'O mês de {mes} tem 31 dias.') elif mes == "fevereiro": print(f'O mês de {mes} tem 28 ou 29 dias.') elif mes == "março": print(...
false
6a9980954beb1a423130f6eb65c83a2a4ec8a1b7
lekakeny/Python-for-Dummies
/file_operations.py
1,762
4.46875
4
""" File operation involves 1. opening the file 2. read or write the file 3. close file Here we are learning how to read and write files. I learnt how to read and write long time ago! How could I be learning now? Anyway, kwani ni kesho? """ f = open('text.txt', 'w', encoding='utf8') # open the file called...
true
ed5cb135e00272635753e85b0a7d8d859dea1e0d
lekakeny/Python-for-Dummies
/generator_and_decorators.py
2,132
4.59375
5
""" Generators are functions that return a lazy iterator lazy iterators do not store their contents in memory, unlike lists generators generate elements/values when you iterate over it It is lazy because it will not calculate the element until when we want to use the element """ "Use isinstance function to check if an ...
true
8488ee8f09498521c1cc3054147370b793a35fe1
xs2tariqrasheed/python_exercises
/integer_float.py
722
4.1875
4
_ = print # NOTE: don't compare floating number with == # A better way to compare floating point numbers is to assume that two # numbers are equal if the difference between them is less than ε , where ε is a # small number. # In practice, the numbers can be compared as follows ( ε = 10 − 9 ) # if abs(a - b) < 1e-9: # ...
true
6af88b90a7d58c79ee0e192212d0893c168bf45e
BinYuOnCa/DS-Algo
/CH2/stevenli/HW1/pycode/NumpyDemo.py
1,454
4.25
4
import numpy as np # Generate some random data data = np.random.randn(2, 3) print("first random data: ", data) # data * 10 data = data * 10 print("Data times 10: ", data) # try np shape print("Data shape: ", data.shape) # Print data value's type print("Data types:", data.dtype) # Create a new ndarray data_forarray...
true
ea4dd28662cd52fb13147661624fa28381cd0433
dery96/challenges
/zero_name_generator.py
909
4.21875
4
from random import randint as RANDOM ''' Generates Words it meant to be character name generator ''' letters = 'abcdefghijklmnoprstuvwyz' len_letters = len(letters) - 1 syllabes = ['mon', 'fay', 'shi', 'fag', 'blarg', 'rash', 'izen'] def Generate_Word(word_len=15, word=''): '''This function generate Words (Rand...
false
416500cec0887721d8eb35ace2b89bc8d208a247
qasimriaz002/LeranOOPFall2020
/qasim.py
555
4.34375
4
from typing import List def count_evens(values: List[List[int]]) -> List[int]: """Return a list of counts of even numbers in each of the inner lists of values. # >>> count_evens([[10, 20, 30]]) [3] # >>> count_evens([[1, 2], [3], [4, 5, 6]]) [1, 0, 2] """ evenList = [] for sublist...
true
ad3a6c22485fece625f45f894962d548960b00b0
qasimriaz002/LeranOOPFall2020
/Labs/Lab_1/Lab_1_part_3.py
1,323
4.53125
5
# Here we will use the dictionaries with the list # We will create the record of 5 students in the different 5 dictionaries # Then we will add all of the these three dictionaries in the list containing the record of all student # Creating the dictionaries stdDict_1 = {"name": "Bilal", "age": 21, "rollno": "BSDS-001-20...
true
c2bf6604b053c51f040365c80ccdb95d3dae9fba
domsqas-git/Python
/vscode/myGame.py
1,044
4.21875
4
print("Bim Bum Bam!!") name = input("What's your name? ").upper() age = int(input("What's your age? ")) print("Hello", name, "you are", age, "years hold.") points = 10 if age >= 18: print("Hooray!! You can play!!") wants_to_play = input("Do you want to play? ").lower() if wants_to_play == "yes": ...
true
04c9bfd9367c43b47f01ba345ba94a7a9ac61129
Nilutpal-Gogoi/LeetCode-Python-Solutions
/Array/Easy/674_LongestContinuousIncreasingSubsequence.py
856
4.21875
4
# Given an unsorted array of integers, find the length of longest continuous # increasing subsequence(Subarray). # Example 1: # Input: [1,3,5,4,7] # Output: 3 # Explanation: The longest continuous increasing subsequence is [1,3,5], its length # is 3. Even though [1,3,5,7] is also an increasing subseque...
true
05365bc5a7afac8cb90b1078393aec87ec1867b4
Nilutpal-Gogoi/LeetCode-Python-Solutions
/Array/Easy/349_IntersectionOfTwoArrays.py
986
4.21875
4
# Given two arrays, write a function to compute their intersection. # Example 1: # Input: nums1 = [1,2,2,1], nums2 = [2,2] # Output: [2] # Example 2: # Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] # Output: [9,4] # Note: # Each element in the result must be unique. # The result can be in any order. # -----...
true
8b9c0aac40b97452fc35f19f49f191bc161e90b9
Nilutpal-Gogoi/LeetCode-Python-Solutions
/LinkedList/Easy/21_MergeTwoSortedLists.py
1,184
4.21875
4
# Merge two sorted linked lists and return it as a new sorted list. The new list should # be made by splicing together the nodes of the first two lists. # Example: # Input: 1->2->4, 1->3->4 # Output: 1->1->2->3->4->4 # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None)...
true
14e28eb677d53cd4e5b6931b2036c0de647f68a3
pol9111/algorithms
/二叉树/二叉树_建树.py
2,117
4.15625
4
from collections import deque import unittest class Node: """二叉树的节点类""" def __init__(self, elem=-1, lchild=None, rchild=None): # 一个节点实例具有三个属性: 值, 左子节点, 右子节点 self.elem = elem # 准备存入的数据 self.lchild = lchild self.rchild = rchild class Tree: """二叉树类""" def __init__(self): ...
false
2ff343c91342b32581d3726eb92c6570eb4c049e
forgoroe/python-misc
/5 listOverLap.py
1,102
4.3125
4
""" ake two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] and write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your program works on two lists of diffe...
true
1e138a3770218338f66b78f14945e0508c1041a4
forgoroe/python-misc
/3 listLessThan.py
912
4.375
4
""" Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a program that prints out all the elements of the list that are less than 5. Extras: Instead of printing the elements one by one, make a new list that has all the elements less than 5 from this list in it and print out t...
true
7c57689eac501ab4bc6da1e8c17a5c7abe1dd58b
forgoroe/python-misc
/14 removeListDuplicates.py
771
4.21875
4
""" Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates. Extras: Write two different functions to do this - one using a loop and constructing a list, and another using sets. Go back and do Exercise 5 using sets, and write the s...
true
c45559cbf2cd3491aa031ec9116ba6d2478dace9
notontilt09/Intro-Python-I
/src/prime.py
294
4.125
4
import math x = input("Enter a number, I'll let you know if it's prime:") def isPrime(num): if num < 2: return False for i in range(2, math.ceil(math.sqrt(num))): if num % i == 0: return False return True if isPrime(int(x)): print('Prime') else: print('Not prime')
true
4d343fedf8584b93d3835f74851898c2bbff0e8c
Tanner-Jones/Crypto_Examples
/Encryption.py
696
4.15625
4
from cryptography.fernet import Fernet # Let's begin by showing an example of what encryption looks like # This is an example random key. If you run the file again # you will notice the key is different each time key = Fernet.generate_key() print(key) # Fernet is just a symmetric encryption implementation ...
true
d337dff4b4895be03919604f2b501f5cda598fb0
jonaskas/Programa-o
/7_colecoes-master/G_set2.py
637
4.15625
4
""" Sets - Allow operations based on set theory. """ set1 = {'a', 'b', 'c', 'a', 'd', 'e', 'f'} set2 = set("aaaabcd") print() print("intersection:", set1 & set2) # same as print(set1.intersection(set2)) print("union:", set1 | set2) # same as print(set1.union(set2)) print("diference: ", set1 - set2) # same as print(s...
false
4b772bd2b3e80c5efb292bfedf7e74908aae1d7a
jonaskas/Programa-o
/7_colecoes-master/C_mutability2.py
489
4.15625
4
""" Mutability - Python is strongly object-oriented in the sense that everything is an object including numbers, strings and functions - Immutable objects: int, float, decimal, complex, bool, string, tuple, range, frozenset, bytes - Mutable objects: list, dict, set, bytearray,user-defined classes """ def print...
true
3939d09d42684a7b934c5d81820cb8153b8c4b29
jonaskas/Programa-o
/7_colecoes-master/C_mutability4.py
684
4.3125
4
""" Mutability - Python is strongly object-oriented in the sense that everything is an object including numbers, strings and functions - Immutable objects: int, float, decimal, complex, bool, string, tuple, range, frozenset, bytes - Mutable objects: list, dict, set, bytearray,user-defined classes """ def print...
true
62fb02699f26a16e7c18ba5d70b234068c05b0ee
jonaskas/Programa-o
/7_colecoes-master/C_mutability3.py
474
4.125
4
""" Mutability - Python is strongly object-oriented in the sense that everything is an object including numbers, strings and functions - Immutable objects: int, float, decimal, complex, bool, string, tuple, range, frozenset, bytes - Mutable objects: list, dict, set, bytearray,user-defined classes """ def print...
true
74494d848957c254dea03530e1cabe13b1b399b1
Jithin2002/pythonprojects
/List/element found.py
384
4.125
4
lst=[2,3,4,5,6,7,8] num=int(input("enter a number")) flag=0 for i in lst: if(i==num): flag=1 break else: flag=0 if(flag>0): print("element found") else: print("not found") #this program is caled linear search # we have to search everytime wheather element is thereor not # drawbac...
true
321f1e726d75e4f7013074163ce7cfeab25dbeb8
sunglassman/U3_L11
/Lesson11/problem3/problem3.py
253
4.1875
4
print('-' * 60) print('I am EvenOrOdd Bot') print() number = input('Type a number: ') number = int(number) if number == even: print('Your number is even. ') else: print('Your number is odd. ') print('Thank you for using the app! ') print('-' * 60)
true
ee0e317f118463d348f2a765fd161bb689ddc11e
swikot/Python3
/ListComprehension.py
2,162
4.15625
4
__author__ = 'snow' # List comprehension is an elegant # way to define and create # list in Python Celsius = [39.2, 36.5, 37.3, 37.8] Far=[((float(9)/5)*x + 32) for x in Celsius] print("far values",Far) odd_number=[x for x in range(1,11) if x%2] print("odd number is: ",odd_number) even_number=[x for x in range(1,11)...
false
1056aa97f9bd6fe7024e8b17dcbfb4e48a40e82e
swikot/Python3
/MaxFunction.py
518
4.1875
4
__author__ = 'snow' # x = eval(input("1st Number: ")) # y = eval(input("2nd Number: ")) # z = eval(input("3rd Number: ")) # # # maximum=max((x,y,z)) # mximum2=maximum # print("maximum=" +str(maximum)) # print("maxumum2=",mximum2) # print() number_of_values = int(input("How many values? ")) maximum = float(input("Va...
false
639de603bbf4502f07acfdfe29d6e048c4a89076
rjtshrm/altan-task
/task2.py
926
4.125
4
# Algorithm (Merge Intervals) # - Sort the interval by first element # - Append the first interval to stack # - For next interval check if it overlaps with the top interval in stack, if yes merge them def merge_intervals(intervals): # Sort interval by first element sort_intervals_first_elem = sorted(intervals...
true
132b54c3b4587e500e050d6be5cfadc4488f5da5
briantsnyder/Lutron-Coding-Competiton-2018
/move_maker.py
1,946
4.4375
4
"""This class is the main class that should be modified to make moves in order to play the game. """ class MoveMaker: def __init__(self): """This class is initialized when the program first runs. All variables stored in this class will persist across moves. Do any initialization of data y...
true
c7363294a807a273dce1204c1c6b0a2b167590ee
nathancmoore/code-katas
/growing_plant/plant.py
528
4.34375
4
"""Return the number of days for a plant to grow to a certain height. #1 Best Practices Solution by Giacomo Sorbi from math import ceil; growing_plant=lambda u,d,h: max([ceil((h-u)/(u-d)),0])+1 """ def growing_plant(up_speed, down_speed, desired_height): """Return the number of days for a plant to grow to a ce...
true
d0f59bf4520f993c32505a7b3406d786a76befa9
PaviLee/yapa-python
/in-class-code/CW22.py
482
4.25
4
# Key = Name # Value = Age # First way to make a dictionary object database = {} database["Frank"] = 21 database["Mary"] = 7 database["John"] = 10 print(database) # Second way to make a dictionary object database2 = { "Frank": 21, "Mary": 7, "Jill": 10 } print(database2) for name, age in database2.item...
true
832439c69ddbcbeb4b2ad961e7427b760306fb92
Th0rt/LeetCode
/how-many-numbers-are-smaller-than-the-current-number.py
999
4.125
4
# https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/ import unittest from typing import List class Solution: def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: length = len(nums) temp = sorted(nums) mapping = {} for i in range(lengt...
true
9f0d9d5ee1f94937f54a70330e70f5c3b5dc0358
JoeD1991/Quantum
/Joe_Problem_1.py
361
4.3125
4
""" If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ myList = set() N5 = 1000//5 N3 = 1000//3+1 for i in range(1,N3): myList.add(3*i) if i<N5: myList.a...
true
53684088e0af3d314c602a4c58439b76faf161cb
NGPHAN310707/C4TB13
/season6/validpasswordstourheart.py
212
4.125
4
while True: txt = input("Enter your password?") print(txt) if txt.isalpha() or len(txt)<=8 or txt.isdigit: print(txt,"is a name") break else: print("please don't")
true
144a61b43eab0992d60e4b0e8146734ed53347d0
JitinKansal/My-DS-code
/tree_imlementation.py
1,048
4.1875
4
# Creating a new node for the binary tree. class BinaryTree(): def __init__(self, data): self.data = data self.left = None self.right = None # Inorder traversal of the tree (using recurssion.) def inorder(root): if root: inorder(root.left) print(root.data,...
true
be4af81f42222bb4cb60937d036fc6f91b6fea67
a421101046/-python
/ex45.py
1,024
4.5
4
# -- coding: utf-8 -- # 习题 45: 对象、类、以及从属关系 # 针对类和对象 "is_a" 讨论两个类的共同点 “has_a”指 两个类无共同点,仅仅供互相参照 # is_a class Animal(object): pass class Dog(Animal): def __init_(self, name): # has_a self.name = name # is_a class Cat(Animal): def __init__(self, name): # has_a self.name = name # is_a class Person(obje...
false
4b6e6e0c460c8a3bd09e60009cac823ab52fed4b
yangrencong/pythonstudy
/3.0/copy.py
389
4.125
4
My_foods =['pizza','falafel','carrot','cake'] Friend_foods =My_foods[:] My_foods.append('cannoli') Friend_foods.append('ice cream') print('my favorate foods are:') print(My_foods) print("\nmy friend's favorate food are: ") print(Friend_foods) print('the first three items in list are:') food1=My_foods[0:3] print(food...
false
86a9f9654568017337b9f306ebd4a8eea326b535
YaohuiZeng/Leetcode
/152_maximum_product_subarray.py
1,446
4.28125
4
""" Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest product = 6. """ """ Q: (1) could have 0, and negative (2) input contains at least one number (3) all in...
true
d5ac5a0d89985b6525988e21ed9fe17a44fb4caa
YaohuiZeng/Leetcode
/280_wiggly_sort.py
1,227
4.21875
4
""" Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... For example, given nums = [3, 5, 2, 1, 6, 4], one possible answer is [1, 6, 2, 5, 3, 4]. """ """ 1. use python in-place sort() 2. one pass: compare current and next, if not the right order, swap. This wo...
true
6aea488ab45998317d8a8d5e180d539e5721873e
ariModlin/IdTech-Summer
/MAC.py
518
4.125
4
# finds the MAC of a message using two different keys and a prime number message = "blah blahs" key1 = 15 key2 = 20 prime_num = 19 def find_mac(): message_num = 0 for i in range(len(message)): # takes each letter of the message and finds its ASCII counterpart num = ord(message[i]) # adds each ASCII nu...
true
6fe51f731f777d02022852d1428ce069f0594cf4
ariModlin/IdTech-Summer
/one time pad.py
1,867
4.21875
4
alphabet = "abcdefghijklmnopqrstuvwxyz" message = input("input message you want to encrypt: ") key = input("input key you want to encrypt the message with: ") message_array = [] key_array = [] encrypted_numbers = [] decrypted_message = "" def convert_message(): for i in range(len(message)): # takes...
true
ada99ffe37296e78bbaa7d804092a495be47c1ba
dineshj20/pythonBasicCode
/palindrome.py
890
4.25
4
#this program is about Palindrome #Palindrom is something who have the same result if reversed for e.g. " MOM " #how do we know whether the given string or number is palindrome number = 0 reverse = 0 temp = 0 number = int(input("Please Enter the number to Check whether it is a palidrome : ")) print(number) temp = numbe...
true
6c5ee3e9cb85a24940a9238981b7f6fbf9ec1696
MichealPro/sudoku
/create_sudoku.py
2,158
4.375
4
import random import itertools from copy import deepcopy # This function is used to make a board def make_board(m=3): numbers = list(range(1, m ** 2 + 1)) board = None while board is None: board = attempt_board(m, numbers) return board # This function is used to generate a full board def at...
true
f605c356950e7e609d3e57c92169775cf4ed497a
sssvip/LeetCode
/python/num003.py
1,303
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-09-28 22:25:36 # @Author : David:admin@dxscx.com) # @Link : http://blog.dxscx.com # @Version : 1.0 """ Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the ...
true
89db6d170e6eb265a1db962fead41646aaed6f9f
sssvip/LeetCode
/python/num581.py
1,606
4.21875
4
#!/usr/bin/env python # encoding: utf-8 """ @version: v1.0 @author: David @contact: tangwei@newrank.cn @file: num581.py @time: 2017/11/7 20:29 @description: Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be s...
true
bee25d157f354404981db25e5912e87f21e1bb10
GeginV/Iterations-Python
/practice (17).py
769
4.1875
4
list_ = [-5, 2, 4, 8, 12, -7, 5] # Объявим переменную, в которой будем хранить индекс отрицательного элемента index_negative = None for i, value in enumerate(list_): if value < 0: print("Отрицательное число: ", value) index_negative = i # перезаписываем значение индекса print("Новы...
false
b2df25d12178483143cbb6fcceaba3e2220b2b4b
eludom/snippits
/python/exercises/python/QuickSort.py
2,607
4.125
4
# -*- coding: utf-8 -*- """ This class implements qucksort on arrays. See https://en.wikipedia.org/wiki/Quicksort # algorithm quicksort(A, lo, hi) is# # if lo < hi then # p := partition(A, lo, hi) # quicksort(A, lo, p – 1) # quicksort(A, p + 1, hi) # # algorithm parti...
false
009cdcd897a882a10ba8424fa34b1f4906e2a3ae
stenen19/hw1.py
/hw1.py
2,251
4.25
4
from math import sqrt def greeting(): capture = input("What's your name? ") print("Hello %s " % capture) def number(): number = input("enter any real number ") numberint = int(number) print("Your number is", numberint ) def average(): first = input("enter your first number ") firstint = fl...
false
89fa015cb0842c4e402b99284b3f2f6ebf46e0a4
cmcg513/app-sec-assgn01-p2
/mramdass/fib.py
1,531
4.21875
4
# -*- coding: utf-8 -*- """ Munieshwar (Kevin) Ramdass Professor Justin Cappos CS-UY 4753 14 September 2015 Compute up to the ith Fibonacci number """ def fib(ith): # BAD IMPLEMENTATION if ith == 0: return 0 elif ith == 1: return 1 else: return...
false
7e608dbf5c0d15627d9272e73afc33f69b37dfc5
prabuinet/mit-intro-cs-py
/python_basics.py
926
4.21875
4
# -*- coding: utf-8 -*- #Scalar objects in python: 5 #int 2.5 #float True #bool None #NoneType type(5) type(3.2) type(False) type(None) #Type Cast float(5) int(2.5) # operators on ints and floats i = 5 j = 2 i + j # sum i - j # difference i * j # product i / j # ...
false
047983b82b4d26b73b2afe14859b5253cce17263
erisaran/cosc150
/Lab 05/Divisibleby3.py
285
4.4375
4
def is_divisible_by_3(x): if x % 3 == 0: print x,"is divisible by 3." else: print "This number is not divisible by 3." def is_divisible_by_5(y): if y%5==0: print y,"is divisible by 5." else: print y,"is not divisble by 5."
false
d576f4074bb56baf51b82b9bf525db46c494f312
CarlaCCP/EstudosPython
/Python/aula4_elif.py
302
4.40625
4
numero = int(input("Digite um número: ")) if numero%3 ==0: print("Numero divisivel por 3") else: if numero%5 ==0: print("Numero divisivel por 5") if numero%3 ==0: print("Numero divisivel por 3") elif numero%5 ==0: print("Numero divisivel por 5")
false
09eb0f8acf255d4471a41a56a50bccf24ed4c91c
MissBolin/CSE-Period3
/tax calc.py
230
4.15625
4
# Tax Calculator cost = float(input("What is the cost of this item? ")) state = input("What state? ") tax = 0 if state == "CA": tax = cost * .08 print("Your item costs ${:.2f}, with ${:.2f} in tax.".format(cost+tax, tax))
true
b9884eae05e9518e3ec889dd5280a8cea7c3c1d7
gandastik/365Challenge
/365Challenge/insertElementes.py
382
4.125
4
#Jan 24, 2021 - insert a elements according to the list of indices from typing import List def createTargetArray(nums: List[int], index: List[int]) -> List[int]: ret = [] for i in range(len(nums)): ret.insert(index[i], nums[i]) return ret lst = [int(x) for x in input().split()] index = [int(x) ...
true
20644bc6631d5eb8e555b1e2e61d1e0e6273bd00
gandastik/365Challenge
/365Challenge/matrixDiagonalSum.py
762
4.21875
4
#37. Feb 6, 2021 - Given a square matrix mat, return the sum of the matrix diagonals. # Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal. from typing import List def diagonalSum(mat: List[List[int]]) -> int: ...
true
fb5ac6e49d0c5724362a41e2b004286e6a11478d
gandastik/365Challenge
/365Challenge/if-else.py
409
4.34375
4
# Jan 6, 2021 -if n is odd print Weird, n is even and inbetween 2 and 5 print Not Weird, # n is even and inbetween 5 and 20 print Weird, n is even and greater than 20 print Not Weird n = int(input()) if(n % 2 != 0): print("Weird") elif(n % 2 == 0 and n > 2 and n <= 5): print("Not Weird") elif(n % 2 == 0 and n ...
false
9fdedda65ec74a7ac9d9ab1510dcc1b63adf502d
ovidubya/Coursework
/Python/Programs/assign5part1.py
560
4.46875
4
def find_longest_word(wordList): print("The list of words entered is:") print(wordList) result = "" i = 0 while(i < len(wordList)): # iterates over the list to find the first biggest word if(len(result) < len(wordList[i])): result = wordList[i] i = i + 1 print("") ...
true
6d3693dc72b467e593b511e79bea1a1b6f6d1392
mcmxl22/Python-doodles
/fun/weird.py
355
4.125
4
#!/usr/bin/env python3 """ weird version 1.1 Python 3.7 """ def is_weird(): """Is a number odd or even?""" while True: pick_number = int(input("Pick a number: ")) if pick_number % 2 == 0: print("Not Weird!") else: print("Weird!") if __name...
false
a5201821c6cd15088a4b1a4d604531bbcca68c69
mlrice/DSC510_Intro_to_Programming_Python
/fiber_optic_discount.py
1,297
4.34375
4
# DSC510 # 4.1 Programming Assignment # Author Michelle Rice # 09/27/20 # The purpose of this program is to estimate the cost of fiber optic # installation including a bulk discount from decimal import Decimal print('Hello. Thank you for visiting our site, we look forward to serving you.' '\nPlease provide some...
true
65293fcbfb356d2f045eff563083e2b751e61326
martinkalanda/code-avengers-stuff
/wage calculaor.py
297
4.40625
4
#Create variables hourly_rate = int(input("what is your hourly rate")) hours_worked = int(input("how many hours have you worked per week")) #Calculate wages based on hourly_rate and hours_worked wages = hourly_rate * hours_worked print("your wages are ${} per week" .format(wages))
true
d1c8e6df0c2a44e543b879dcfcee89a2f77557ba
NishadKumar/interview-prep
/dailybyte/strings/longest_substring_between_characters.py
1,874
4.21875
4
# Given a string, s, return the length of the longest substring between two characters that are equal. # Note: s will only contain lowercase alphabetical characters. # Ex: Given the following string s # s = "bbccb", return 3 ("bcc" is length 3). # Ex: Given the following string s # s = "abb", return 0. # Approach: #...
true
649fb09854bb5c385e3eaff27302436741f09e4f
NishadKumar/interview-prep
/leetcode/1197_minimum_knight_moves/minimum_knight_moves.py
2,147
4.125
4
# In an infinite chess board with coordinates from -infinity to +infinity, you have a knight at square [0, 0]. # A knight has 8 possible moves it can make. Each move is two squares in a cardinal direction, then one square in an orthogonal direction. # Return the minimum number of steps needed to move the knight to the ...
true
8cf3e9b82cd34fcd4c65339fdafb439476c7c64d
Masrt200/WoC2k19
/enc/substitution_enc.py
996
4.125
4
#substitution cipher encryptor... def substitute(plaintext): plaintext=plaintext.upper() _alphabet_='ABCDEFGHIJKLMNOPQRSTUVWXYZ' _alphabet_new_='' keyword=input('Enter Keyword:') keyword=(keyword.strip()).upper() key_list=[] for x in keyword: ct=1 for y in key_l...
false
8488da7cb5989c2785a81faf81d9ac7a849c5b0d
Marcus-Mosley/ICS3U-Unit4-02-Python
/product.py
1,153
4.65625
5
#!/usr/bin/env python3 # Created by Marcus A. Mosley # Created on October 2020 # This program finds the product of all natural numbers preceding the # number inputted by the user (a.k.a. Factorial) def main(): # This function finds the product of all natural numbers preceding the # number inputted by...
true
845d6abc11a2f6eae857c0bae2e466c0fdc757b5
Ajaymagar/notes
/python/app.py
2,055
4.28125
4
#optional parameter tutorial ''' def func(word, freq=3): op = word*freq ajay = func('ajay') #print(ajay) ''' #static methods ''' class person(object): population = 50 #class variable def __init__(self,name ,age): # Constructor methods self.name = name self.age = age @classmethod...
false
e979a01341447f6f2e566b82c92515d3b1eaadc0
goriver/skinfosec
/DAY04/03_lambda.py
2,461
4.1875
4
# 람다 # • 기능을매개변수로전달하는코드를더효율적으로작성 def increase(value,original): return original+value original_list = [10,20,30,40,50] print("before",original_list) for index, value in enumerate(original_list): original_list[index] = increase(5, value) print("after ",original_list) """ # map : function을 매개변수로 받음 # filter :...
false
e7958f906c313378efd5815b81b70b4f5c45c65e
robbyhecht/Python-Data-Structures-edX
/CH9/exercise1.py
776
4.15625
4
# Write a program that reads the words inwords.txtand stores them askeys in a dictionary. It doesn’t matter what the values are. Then youcan use theinoperator as a fast way to check whether a string is in thedictionary. from collections import defaultdict f = input("Enter file name: ") try: content = open(f) exce...
true
ac07705a2cea96a51f696c5f942adc2ee6e9796f
cosmos-sajal/ds_algo
/sliding_pattern/smallest_subarray.py
1,478
4.125
4
# https://www.educative.io/courses/grokking-the-coding-interview/7XMlMEQPnnQ def get_sum_between_ptr(sum_array, i, j): if i == 0: return sum_array[j] else: return sum_array[j] - sum_array[i - 1] def get_smallest_subarray_size(size, ptr1, ptr2): if size > (ptr2 - ptr1 + 1): return...
false
566a23e9b7633a9ce17062fad16cb1088e33e155
TareqJudehGithub/Ardit_Sulce_Udemy
/Python_Mega/sec14_Numpy/numpy_practice.py
886
4.1875
4
""" Numpy - Numpy is a fundamental package for scientific computing with Python. - Official page: https://numpy.org/ - Numpy comes installed with Pandas library. """ import numpy # .arange(int) created a new array with the specified int number. n = numpy.arange(27) print(n) print(type(n)) print(len(n)) print(...
true
fdb85dd88220653054dc4127e2273885515a9c53
TareqJudehGithub/Ardit_Sulce_Udemy
/Python_Mega/sec6_Basics_Proc_User_Input/string_formatting.py
653
4.125
4
""" String formatting in Python - More on: https://pyformat.info/ """ def greet_user(): name = input('What is your name? ') # this is the a string formatting method introduced in Python 2 return "Hello, %s!" %name.title() # using format() return "Hello, {}!".format(name.title) ...
true
ebdfab2cb3cc75734d4d514005ffbb2bef50fa67
TareqJudehGithub/Ardit_Sulce_Udemy
/Python_Mega/sec8_build_prog/input_problem.py
1,092
4.25
4
import re # Write a program, that asks the user for input(s), until # the user types \end # user inputs should not include any symbols. # return all user outputs def inputs_problem(): inputs = list() inputs_str = str() interrogatives = ('how', 'what', 'why', 'where') input_validator = re.co...
true
a8a7b3d0a42ddd22c88073c4df721292e0dfca76
crampon231/ALDS
/ALDS1_1/ALDS1_1_C.py
420
4.15625
4
# -*- coding: utf-8 -*- import math def isPrime(x): if x == 2: return True if x < 2 or x % 2 == 0: return False for i in range(3, int(math.sqrt(x)) + 1): if x % i == 0: return False return True if __name__ == '__main__': n = int(input()) cnt = 0 for ...
false
a855b847eb732f4e7af1ee18c11d1c6d24e24aa3
satfail/Python
/03_PrimerProyecto/app.py
1,619
4.375
4
""" --Peliculas 'a' añadir, 'l' list, 'f' buscar y 'q' salir Tareas: -Menu -Añadir -Listar -Buscar -Salir """ peliculas = [] def add_movie(): name = input("Nombre de pelicula : ") director = input("Nombre de director : ") año = input("Año de pelicula : ") pelicula = { 'nombre' : name, ...
false
567699b665fd5b526c33e31e090ac3ab1ef8c77e
fan-tian0/happy-journey
/day02.py
1,529
4.21875
4
#print()的用法 #1、用法 print('hello world') name = '小小' print(name) #2、用法:print(name,age,gender) age = 18 gender = 'boy' #3、用法print(value,value,value,...sep = ' ' ,end = '\n') print(name,age,gender) #sep(separation:分割)默认的分割是空格 print(name,age,gender,sep='_')#sep='&' sep = '%' #print()后面默认跟两个sep(分割)空格,end(换行)\n ...
false
f13e841d3a8ef2d2e46bd958811aa53409350686
niyatigulati/Calculator.py
/calc.py
524
4.125
4
def calc(choice, x, y): if (choice == 1): add(x, y) elif (choice == 2): sub(x, y) elif (choice == 3): mul(x,y) elif (choice == 2): div(x,y) # the below functions must display the output for the given arithmetic # TODO def add(a, b): pass def sub(a, b): pass ...
true
7482d942e97a74847cbcdccf6e4809450238e845
greenfox-velox/bizkanta
/week-04/day-03/08.py
523
4.1875
4
# create a 300x300 canvas. # create a square drawing function that takes 2 parameters: # the x and y coordinates of the square's top left corner # and draws a 50x50 square from that point. # draw 3 squares with that function. from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.p...
true
a35413038dc25063fa1bda9bf93a868010510ce9
greenfox-velox/bizkanta
/week-03/day-02/functions/39.py
250
4.1875
4
names = ['Zakarias', 'Hans', 'Otto', 'Ole'] # create a function that returns the shortest string # from a list def shortest_str(list): short = list[0] for i in list: if len(i) < len(short): short = i return short print(shortest_str(names))
true
0c1cedbaa3a31450caae59fd00de54f21f2da412
greenfox-velox/bizkanta
/week-04/day-04/09.py
329
4.125
4
# 9. Given a string, compute recursively a new string where all the # adjacent chars are now separated by a "*". def separated_chars_with_stars(string): if len(string) < 2: return string[0] else: return string[0] + '*' + separated_chars_with_stars(string[1:]) print(separated_chars_with_stars('...
true
055b1173cbe0bc9a383f8863016bdf26b1285a00
choogiesaur/codebits
/data-structures/py-trie.py
1,350
4.21875
4
# Implement a version of a Trie where words are terminated with '*' # Efficient space complexity vs hashtable # Acceptable time complexity. O(Key_Length) for insert/find # Handle edge cases: # - Empty String # - Contains non alphabet characters (numbers or symbols) # - Case sensitivity class StarTrie: # Each node ...
true
406bbf1479e8c0bf119b566e4aab895ecdbc01e8
choogiesaur/codebits
/data-structures/py-stack.py
1,319
4.28125
4
### A Python implementation of a Stack data structure class PyStack: # Internal class for items in stack class StackNode: def __init__(self, val = 0, child = None): self.val = val self.child = child # Check if stack has items def is_empty(self): return self.size() == 0 # Get number of items in stack ...
true
7513472d24d6090efd5a3c9def621a59b41405ab
jchavez2/COEN-144-Computer-Graphics
/Jason_C_Assigment1/assignment1P2.py
1,936
4.21875
4
#Author: Jason Chavez #File: assignment1P2.py #Description: This file rasters a circle using Bresenham's algorithm. #This is taken a step further by not only rastering the circle but also filling the circle #The file is saved as an image and displayed using the computers perfered photo drawing software. from PIL imp...
true
dc9d95ec63607bec79a790a0e0e898bebe9998bc
nisarggurjar/ITE_JUNE
/ListIndex.py
559
4.1875
4
# Accessing List Of Items li = ["a", 'b', 'c', 'd', 'e', 'f', 'g'] # index print(li[2]) # Slicing print(li[2:5]) # <LIST_NAME>[starting_index : ending_index] ==> ending_index = index(last_value) + 1 # stepping (Index Difference) print(li[::2]) # <LIST_NAME>[starting_index : ending_index : index_difference] # N...
true
330ffa3c0f75a1fae5d7af3d0597ccb7d1286de1
nisarggurjar/ITE_JUNE
/ConditionalStatements.py
2,228
4.21875
4
# if # if else # elif ''' rain = False # if --> single condition if rain == True: print("I will take a leave") # if else if rain == True: print("I will take a leave") else: print("I will go to office") # if else sunny = False if rain: print("I will take a leave") elif sunny: print("I will go...
false
a714402ef8921b97870d62f24222575ba39fc5cb
Wakarende/chat
/app/main/helpers.py
1,230
4.1875
4
def first(iterable, default = None, condition = lambda x: True): """ Returns the first item in the `iterable` that satisfies the `condition`. If the condition is not given, returns the first item of the iterable. If the `default` argument is given and the iterable is empty, or if it has no items matching ...
true
cb8a0d965ca2b62c8b50e54621e50f524366727d
tcaserza/coding-practice
/daily_coding_problem_20.py
1,003
4.125
4
# Given two singly linked lists that intersect at some point, find the intersecting node. The lists are non-cyclical. # # For example, given A = 3 -> 7 -> 8 -> 10 and B = 99 -> 1 -> 8 -> 10, return the node with value 8. # # In this example, assume nodes with the same value are the exact same node objects. # # Do this ...
true
3b5e97f33277ee345b584501f9495e4f38c0b0e6
tcaserza/coding-practice
/daily_coding_problem_12.py
882
4.375
4
# There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. # Given N, write a function that returns the number of unique ways you can climb the staircase. # The order of the steps matters. # # For example, if N is 4, then there are 5 unique ways: # # 1, 1, 1, 1 # 2, 1, 1 # 1, 2, 1 # 1,...
true
4fbb7f1164e0e80689ac64a1f3a34d7e5c6f2f5b
tcaserza/coding-practice
/daily_coding_problem_18.py
702
4.1875
4
# Given an array of integers and a number k, where 1 <= k <= length of the array, compute the maximum values of # each subarray of length k. # # For example, given array = [10, 5, 2, 7, 8, 7] and k = 3, we should get: [10, 7, 8, 8], since: # # 10 = max(10, 5, 2) # 7 = max(5, 2, 7) # 8 = max(2, 7, 8) # 8 = max(7, 8, 7) ...
true
1f76f9b05ec4a73c36583154bc431bd3746f659e
cseharshit/Registration_Form_Tkinter
/registration_form.py
2,786
4.28125
4
''' This program demonstrates the use of Tkinter library. This is a simple registration form that stores the entries in an sqlite3 database Author: Harshit Jain ''' from tkinter import * import sqlite3 #root is the root of the Tkinter widget root = Tk() #geometry is used to set the dimensions of the window root.geom...
true
0a121ab2cf53f4696a7ec57311ff0017549023ea
khushboo2243/Object-Oriented-Python
/Python_OOP_1.py
1,850
4.46875
4
#classes aallows logially grouping of data and functions in a way that's easy to resue #and also to build upon if need be. #data and functions asscoaited with a specific class are called attributes and methods #mathods-> a function associated with class class Employee: #each employee will have specific attributes...
true