blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
7897869a67893a3ea72027ae8911e80e9e1d8f6a | Moandh81/python-self-training | /datetime/7.py | 450 | 4.4375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to print yesterday, today, tomorrow
from datetime import datetime, date, time
today = datetime.today()
print("Today is " , today)
yesterday = today.timestamp() - 60*60*24
yesterday = date.fromtimestamp(yesterday)
print( "Yesterday is " ... | true |
cdf3abaafdf05f6cc6a164b72120b100c010fe28 | Moandh81/python-self-training | /sets/6.py | 256 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to create an intersection of sets.
set1 = {"apple", "banana", "cherry" , "strawberry"}
set2 = {"cherry", "ananas", "strawberry", "cocoa"}
set3 = set1.intersection(set2)
print(set3) | true |
f552ed71c41a45b8838d36ca289e6ded418370f5 | Moandh81/python-self-training | /tuple/12.py | 355 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to remove an item from a tuple.
mytuple = ("dog", "cat", "cow", "fox", "hen", "cock", "duck" ,"bull", "sheep")
myliste = []
txt = input("Please input a text : \n")
for element in mytuple:
if element != txt:
myliste.append(element)
myl... | false |
c05aca3c8637d78d9f31db8209ec7f3f1d6060cd | Moandh81/python-self-training | /functions/2.py | 360 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*
# Write a Python function to sum all the numbers in a list. Go to the editor
# Sample List : (8, 2, 3, 0, 7)
# Expected Output : 20
liste = [1,2,3,4,5]
def sumliste(liste):
sum = 0
for item in liste:
sum = sum + item
print("The sum of the numbers in the list ... | true |
4870640a39e9da3773c603ccb30b877b56c6c693 | J-Krisz/project_Euler | /Problem 4 - Largest palindrome product.py | 462 | 4.125 | 4 | # A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
# Find the largest palindrome made from the product of two 3-digit numbers.
def is_palindrome(n):
return str(n) == str(n)[::-1]
my_list = []
for n_1 in range(100, 1000):
for... | true |
4f05572563bd615a85bccc3d225f28b8a4ae36b5 | djeikyb/learnpythonthehardway | /ex19a.py | 1,298 | 4.125 | 4 | # write a comment above each line explaining
# define a function. eats counters for cheese and cracker boxen
# shits print statements
def cheese_and_crackers(cheese_count, boxes_of_crackers):
# print var as decimal
print "You have %d cheeses!" % cheese_count
# print var as decimal
pr... | true |
44142626c57508d50cf1977411479703657439fc | stjohn/csci127 | /errorsHex.py | 1,179 | 4.21875 | 4 | #CSci 127 Teaching Staff
#October 2017
#A program that converts hex numbers to decimal, but filled with errors...
Modified by: ADD YOUR NAME HERE
define convert(s):
""" Takes a hex string as input.
Returns decimal equivalent.
"""
total = 0
for c in s
total = total * 16
... | true |
7bb50d2132b47e415d67bd07dcdf4a82ce95fc16 | danilocamus/curso-em-video-python | /aula18a.py | 327 | 4.28125 | 4 | pessoas = [['Pedro', 25], ['Maria', 26], ['Jaqueline', 29]]
print(pessoas[1]) #mostra a lista de índice 1 que esta dentro da lista pessoas
print(pessoas[0][1]) #mostra o conteudo de índice 1 da lista de índice 0 que esta na lista pessoas
print(pessoas[0][0])
print(pessoas[1][1])
print(pessoas[2][0])
print(pessoas... | false |
7bfde9995154ed324c387c2c211583ee1e42cfe9 | cuihee/LearnPython | /Day01/c0108.py | 471 | 4.375 | 4 | """
字典的特点
字典的key和value是什么
新建一个字典
"""
# 字典
# 相对于列表,字典的key不仅仅是有序的下标
dict1 = {'one': "我的下标是 one", 2: "我的下标是 2"}
print(dict1['one']) # 输出键为 'one' 的值
print(dict1[2]) # 输出键为 2 的值
print('输出所有下标', type(dict1.keys()), dict1.keys())
# 另一种构建方式
dict2 = dict([(1, 2), ('2a', 3), ('3b', 'ff')])
print('第二种构建方式', dict2)
| false |
59412e27906d5aa3a7f435bfb4ab63d9ee5ed5a2 | RamrajSegur/Computer-Vision-Python | /OpenCV-Python/line.py | 1,046 | 4.125 | 4 | #Program to print a line on an image using opencv tools
import numpy as np
import cv2
# Create a grayscale image or color background of desired intensity
img = np.ones((480,520,3),np.uint8) #Creating a 3D array
b,g,r=cv2.split(img)#Splitting the color channels
img=cv2.merge((10*b,150*g,10*r))#Merging the color channels... | true |
dac4fea633910137cc60dc5c73d8558886877f09 | dennisSaadeddin/pythonDataStructures | /manual_queue/Queue.py | 2,121 | 4.15625 | 4 | from manual_queue.QueueElem import MyQueueElement
class MyQueue:
def __init__(self):
self.head = None
self.tail = None
self.is_empty = True
def enqueue(self, elem):
tmp = MyQueueElement(elem)
if self.head is None:
self.head = tmp
if self.tail is not... | false |
c954b3d5067de813172f46d1ce5b610a5adc6317 | LL-Pengfei/cpbook-code | /ch2/vector_arraylist.py | 421 | 4.125 | 4 | def main():
arr = [7, 7, 7] # Initial value [7, 7, 7]
print("arr[2] = {}".format(arr[2])) # 7
for i in range(3):
arr[i] = i;
print("arr[2] = {}".format(arr[2])) # 2
# arr[5] = 5; # index out of range error generated as index 5 does not exist
# uncomment the line above to see the error
arr.append... | true |
039e8c37b1c95e7659c109d2abbef9b697e7ca3d | xiaochenchen-PITT/CC150_Python | /Design_Patterns/Factory.py | 2,731 | 4.78125 | 5 | '''The essence of Factory Design Pattern is to "Define a factory creation
method(interface) for creating objects for different classes.
And the factory instance is to instantiate other class instances.
The Factory method lets a class defer instantiation to subclasses."
Key point of Factory Design Pattern is--
Only ... | true |
6ce064242cb40428e52917203518b1291ceeb0e5 | emetowinner/python-challenges | /Phase-1/Python Basic 2/Day-26.py | 2,807 | 4.5625 | 5 | '''
1. Write a Python program to count the number of arguments in a given function.
Sample Output:
0
1
2
3
4
1
2. Write a Python program to compute cumulative sum of numbers of a given list.
Note: Cumulative sum = sum of itself + all previous numbers in the said list.
Sample Output:
[10, 30, 60, 100, 150, 210, 217]
[1... | true |
48449d264326a4508b0f111d19a6f5832155485d | emetowinner/python-challenges | /Phase-1/Python Basic 2/Day-28.py | 2,740 | 4.375 | 4 | '''
1. Write a Python program to check whether two given circles (given center (x,y) and radius) are intersecting. Return true for intersecting otherwise false.
Sample Output:
True
False
2. Write a Python program to compute the digit distance between two integers.
The digit distance between two numbers is the absolute... | true |
6ece47524c7619b649fd02a684262c06eac17f53 | Megha2122000/python3 | /3.py | 361 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 19 15:30:29 2021
@author: Comp
"""
# Python program to print positive Numbers in a List
# list of numbers
list1 = [-12 , -7 , 5 ,64 , -14]
# iterating each number in list
for num in list1:
# checking condition
if n... | true |
ccad48e6c0098ebc9f19b8218034baada0a18a53 | sushrest/machine-learning-intro | /decisiontree.py | 1,455 | 4.4375 | 4 | # scikit-learn Machine Learning Library in python
# Environment Python Tensorflow
# Following example demonstrates a basic Machine Learning examples using
# Supervised Learning by making use of Decision Tree Classifier and its fit algorithm to predict whether the given
# features belong to Apple or Orange
from sklea... | true |
ccc3abda28abe8e4719c043e55fe47fe3e9f7b53 | fight741/DaVinciCode | /main.py | 435 | 4.15625 | 4 | import numpy as np
start = input("start from : ")
end = input("end with : ")
number = int(np.random.randint(int(start), int(end)+1))
g = int(input("Input your guess here : "))
while g != number:
if g > number:
print("The number is smaller")
g = int(input("Give another guess : "))
else:
... | true |
ce4538035bd10d46defe36ca39677409fad124a8 | AndresMontenegroArguello/UTC | /2020/Logica y Algoritmos/Tareas/Tarea 2/Extras/Python/Tarea 2.1 - Colones.py | 626 | 4.34375 | 4 | # Introducción
print("Logica y Algoritmos")
print("Andres Montenegro")
print("02/Febrero/2020")
print("Tarea 2.1")
print("Colones")
print("**********")
# Definición de variables
# Python es de tipado dinámico por lo que no es necesario declarar antes de asignar valor a las variables
# Ingreso de datos por el usuario
... | false |
8bb4ef10fa5bb4e81806cdb797e2a7d857854f37 | mbeliogl/simple_ciphers | /Caesar/caesar.py | 2,137 | 4.375 | 4 |
import sys
# using caesar cipher to encrypy a string
def caesarEncrypt(plainText, numShift):
alphabet = 'abcdefghijklmnopqrstuvwxyz '
key = []
cipherText = ''
plainText = plainText.lower()
# the for loop ensures we are looping around
for i in range(len(alphabet)):
if i + numShift >... | true |
4d969849727d7b049825d2dcf47db14b7dd16a67 | AndrewBowerman/example_projects | /Python/oopRectangle.py | 1,745 | 4.5625 | 5 | """ oopRectangle.py
intro to OOP by building a Rectangle class that demonstrates
inheritance and polymorphism.
"""
def main():
print ("Rectangle a:")
a = Rectangle(5, 7)
print ("area: {}".format(a.area))
print ("perimeter: {}".format(a.perimeter))
print ("")
print ("Rectan... | true |
6f7d33585fac28efdcbd848c65e489bb71044b0b | singhankur7/Python | /advanced loops.py | 2,306 | 4.375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 9 23:48:15 2019
@author: New
"""
"""
Python is easy: Homework assignment #6
Advanced Loops
"""
# for the maximum width(columns) and maximum height(rows) that my playing board can take
# This was achieved by trial and error
# Defining the function which... | true |
b6b9a578c524fa372d4adf93096d3a5c29b5c5d0 | sagarneeli/coding-challenges | /Linked List/evaluate_expression.py | 2,583 | 4.59375 | 5 | # Python3 program to evaluate a given
# expression where tokens are
# separated by space.
# Function to find precedence
# of operators.
def precedence(op):
if op == '+' or op == '-':
return 1
if op == '*' or op == '/':
return 2
return 0
# Function to perform arithmetic
# operations.
def applyOp(a, ... | true |
0a1a0f66af66feb4ee13899192bc64ef2d66f018 | sy-li/ICB_EX7 | /ex7_sli.py | 1,791 | 4.375 | 4 | # This script is for Exercise 7 by Shuyue Li
# Q1
import pandas as pd
def odd(df):
'''
This function is aimed to return the add rows of a pandas dataframe
df should be a pandas dataframe
'''
nrow = df.shape[0]
odds = pd.DataFrame()
for i in range(1,nrow):
if i%2 == 0:
... | true |
c24b76b40773bcde6356d5ba2f951cdd3eea5d94 | io-ma/Zed-Shaw-s-books | /lmpthw/ex4_args/sys_argv.py | 1,302 | 4.4375 | 4 | """
This is a program that encodes any text using the ROT13 cipher.
You need 2 files in the same dir with this script: text.txt and result.txt. Write your text in text.txt, run the script and you will get the encoded version in result.txt.
Usage:
sys_argv.py -i <text.txt> -o <result.txt>
"""
import sys, codecs
... | true |
e015f0925ccb831ef32e805bd81fff3db46668f6 | io-ma/Zed-Shaw-s-books | /lpthw/ex19/ex19_sd1.py | 1,485 | 4.34375 | 4 | # define a function called cheese_and_crackers that takes
# cheese_count and boxes_of_crackers as arguments
def cheese_and_crackers(cheese_count, boxes_of_crackers):
# prints a string that has cheese_count in it
print(f"You have {cheese_count} cheeses!")
# prints a string that has boxes_of_crackers in it
... | true |
a6da253639d8ca65b62444ec6bc60545c11d2501 | blakfeld/Data-Structures-and-Algoritms-Practice | /Python/general/binary_search_rotated_array.py | 1,661 | 4.34375 | 4 | #!/usr/bin/env python
"""
binary_search_rotated_array.py
Author: Corwin Brown <blakfeld@gmail.com>
"""
from __future__ import print_function
import sys
import utils
def binary_search(list_to_search, num_to_find):
"""
Perform a Binary Search on a rotated array of ints.
Args:
list_to_search (lis... | true |
c6b2dab45e102ae19dc887e97e296e5c90f68a51 | tocxu/program | /python/function_docstring.py | 264 | 4.34375 | 4 | def print_max(x,y):
'''Prints the maximum of two numbers.
The two values must be integers.'''
#convert to integers, if possible
x=int(x)
y=int(y)
if x>y:
print x, 'is maximum'
else:
print y,'is maximum'
print (3,5)
print_max(3,5)
print print_max.__doc__
| true |
0939ff340b6f0410cedac5b9966dc13d0e42269d | yaelh1995/AlumniPythonClass | /ex18.py | 592 | 4.15625 | 4 | '''def print_two(*args):
arg1, arg2 = args
print(f"arg1: {arg1}, arg2: {arg2}")
def print_two_again(arg1, arg2):
print(f"arg1: {arg1}, arg2: {arg2}"
def print_one(arg1):
print(f"arg1: {arg1}")
def print_none():
print("I got nothin'.")
print_two("Zed","Shaw")'''
'''def function(x, y, z):
ans... | false |
684c0c1dda56869fc93817a64f67acb1606107a2 | humbertoperdomo/practices | /python/PythonPlayground/PartI/Chapter02/draw_circle.py | 455 | 4.4375 | 4 | #!/usr/bin/python3
# draw_circle.py
"""Draw a circle
"""
import math
import turtle
def draw_circle_turtle(x, y, r):
"""Draw the circle using turtle
"""
# move to the start of circle
turtle.up()
turtle.setpos(x + r, y)
turtle.down()
# draw the circle
for i in range(0, 361, 1):
a... | false |
a4b203896d017258eb8d703b4afc92ce8d03df7c | humbertoperdomo/practices | /python/PythonCrashCourse/PartI/Chapter09/number_served.py | 1,550 | 4.15625 | 4 | #!e/urs/bn/python3
# restaurant.py
"""Class Restaurant"""
class Restaurant():
"""Class that represent a restaurant."""
def __init__(self, restaurant_name, cuisine_type):
"""Initialize restaurant_name and cuisine_type attributes."""
self.restaurant_name = restaurant_name
self.cuisine_typ... | true |
6824e7c7d9116fc808d6320f206dd5845e6b0ba5 | guguda1986/python100- | /例8.py | 351 | 4.1875 | 4 | #例8:输出99乘法表
for x in range(0,10):
for y in range(0,10):
if x==0:
if y==0:
print("*",end="\t")
else:
print(y,end="\t")
else:
if y==0:
print(x,end="\t")
else:
print(x*y,end="\t")... | false |
5d2c49f3e11cc346105c7fb02c59435e2b56af76 | Necmttn/learning | /python/algorithms-in-python/r-1/main/twenty.py | 790 | 4.25 | 4 | """
Python’s random module includes a function shuffle(data) that accepts a list of elements and randomly reorders the elements so that each possi- ble order occurs with equal probability. The random module includes a more basic function randint(a, b) that returns a uniformly random integer from a to b (including both ... | true |
d69ba19f1271f93a702fd8009c57a34a11122c6b | Necmttn/learning | /python/algorithms-in-python/r-1/main/sixteen.py | 684 | 4.21875 | 4 |
"""
In our implementation of the scale function (page25),the body of the loop executes the command data[j]= factor.
We have discussed that numeric types are immutable, and that use of the *= operator in this context causes the creation
of a new instance (not the mutation of an existing instance). How is it still poss... | true |
8cc73de7110d0300d84909f76d7cebb6f0e772e9 | tboy4all/Python-Files | /csv_exe.py | 684 | 4.1875 | 4 | #one that prints out all of the first and last names in the users.csv file
#one that prompts us to enter a first and last name and adds it to the users.csv file.
import csv
# Part 2
def print_names():
with open('users.csv') as file:
reader = csv.DictReader(file)
for row in reader:
pri... | true |
0fbfcaafa9794d32855c67db1117c3ec4d682864 | holomorphicsean/PyCharmProjectEuler | /euler9.py | 778 | 4.28125 | 4 | """A Pythagorean triplet is a set of three natural numbers,
a < b < c, for which,
a**2 + b**2 = c**2
For example, 3**2 + 4**2 = 9 + 16 = 2**5 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc."""
import time
import math
# We are going to just brute force this and ch... | true |
1dbf066eeb432496cb1cc5dec86d41f54eefd74f | Murali1125/Fellowship_programs | /DataStructurePrograms/2Darray_range(0,1000).py | 901 | 4.15625 | 4 |
"""--------------------------------------------------------------------
-->Take a range of 0 - 1000 Numbers and find the Prime numbers in that
--range. Store the prime numbers in a 2D Array, the first dimension
--represents the range 0-100, 100-200, and so on. While the second
--dimension represents the prime numbers ... | true |
ebfd35ab13d1b55fe3b78f1974a512a1dccb7a4d | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/921 Minimum Add to Make Parentheses Valid.py | 1,116 | 4.21875 | 4 | #!/usr/bin/python3
"""
Given a string S of '(' and ')' parentheses, we add the minimum number of
parentheses ( '(' or ')', and in any positions ) so that the resulting
parentheses string is valid.
Formally, a parentheses string is valid if and only if:
It is the empty string, or
It can be written as AB (A concatenate... | true |
3e60a45e7923bb72bece7ee0f705b2d6467ee4a6 | syurskyi/Python_Topics | /070_oop/001_classes/examples/The_Complete_Python_Course_l_Learn_Python_by_Doing/61. More about classes and objects.py | 1,239 | 4.5 | 4 | """
Object oriented programming is used to help conceptualise the interactions between objects.
I wanted to give you a couple more examples of classes, and try to answer a few frequent questions.
"""
class Movie:
def __init__(self, name, year):
self.name = name
self.year = year
"""
Parameter na... | true |
bbbd1d21e8e907c7353f2a1aee9c6c2984a4c255 | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/Algorithmic Problems in Python/binary_search.py | 986 | 4.3125 | 4 |
#we can achieve O(logN) but the array must be sorted
___ binary_search(array,item,left,right):
#base case for recursive function calls
#this is the search miss (array does not contain the item)
__ right < left:
r.. -1
#let's generate the middle item's index
middle left + (right-left)//2
print("Middle index... | true |
5fb93b463f49e0440570a02f3d1eea4cc91e8d0f | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/405 Convert a Number to Hexadecimal.py | 1,467 | 4.3125 | 4 | """
Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two's complement method is
used.
Note:
All letters in hexadecimal (a-f) must be in lowercase.
The hexadecimal string must not contain extra leading 0s. If the number is zero, it is represented by a single zero
character '0'; ... | true |
e415830c017fb802d0f55c1f525d59af43fe82b1 | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/838 Push Dominoes.py | 2,392 | 4.1875 | 4 | #!/usr/bin/python3
"""
There are N dominoes in a line, and we place each domino vertically upright.
In the beginning, we simultaneously push some of the dominoes either to the left
or to the right.
After each second, each domino that is falling to the left pushes the adjacent
domino on the left.
Similarly, the dom... | true |
cf7895c32a09b5ad12e8985b811797f8d3962c58 | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/590 N-ary Tree Postorder Traversal.py | 1,316 | 4.1875 | 4 | #!/usr/bin/python3
"""
Given an n-ary tree, return the postorder traversal of its nodes' values.
For example, given a 3-ary tree:
Return its postorder traversal as: [5,6,3,2,4,1].
Note:
Recursive solution is trivial, could you do it iteratively?
"""
# Definition for a Node.
c_ Node:
___ - , val, children
... | false |
56992da99dfce4fc45484256df0a63cb6f2d082a | syurskyi/Python_Topics | /045_functions/007_lambda/examples/004_Closures.py | 613 | 4.40625 | 4 | # -*- coding: utf-8 -*-
def outer_func(x):
y = 4
def inner_func(z):
print(f"x = {x}, y = {y}, z = {z}")
return x + y + z
return inner_func
for i in range(3):
closure = outer_func(i)
print(f"closure({i+5}) = {closure(i+5)}")
# Точно так же лямбда также может быть замыканием. ... | false |
d3e9bd61135b603f1f8b149781f49b88e49eb11f | syurskyi/Python_Topics | /030_control_flow/001_if/examples/Python 3 Most Nessesary/4.2. Listing 4.2. Check several conditions.py | 790 | 4.21875 | 4 | # -*- coding: utf-8 -*-
print("""Какой операционной системой вы пользуетесь?
1 — Windows 8
2 — Windows 7
3 — Windows Vista
4 — Windows XP
5 — Другая""")
os = input("Введите число, соответствующее ответу: ")
if os == "1":
print("Вы выбрали: Windows 8")
elif os == "2":
print("Вы выбрали: Windows 7")
elif os ==... | false |
e9e455eacdb596a36f52fee4dd8175aa37686023 | syurskyi/Python_Topics | /030_control_flow/example/Python-from-Zero-to-Hero/03-Коллеции, циклы, логика/11_ДЗ-1-2_solution.py | 259 | 4.125 | 4 | # 1
rows = int(input('Enter the number of rows'))
for x in range(rows):
print('*' * (x+1))
# 2
limit = int(input('Enter the limit'))
for x in range(limit):
if x % 2 == 0:
print(f'{x} is EVEN')
else
print(f'{x} is ODD')
| true |
d83552fae236deecb6b23fb25234bdf7ff6f26b9 | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/771 Jewels and Stones.py | 763 | 4.1875 | 4 | #!/usr/bin/python3
"""
You're given strings J representing the types of stones that are jewels, and S
representing the stones you have. Each character in S is a type of stone you
have. You want to know how many of the stones you have are also jewels.
The letters in J are guaranteed distinct, and all characters in J ... | true |
e9b7e415a19e4aae056651b649a4744fe88aba1b | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/693 Binary Number with Alternating Bits.py | 729 | 4.34375 | 4 | #!/usr/bin/python3
"""
Given a positive integer, check whether it has alternating bits: namely, if two
adjacent bits will always have different values.
Example 1:
Input: 5
Output: True
Explanation:
The binary representation of 5 is: 101
Example 2:
Input: 7
Output: False
Explanation:
The binary representation of 7 is: ... | true |
6c27ed30f7c0259092479eae4b54a924d55e3251 | syurskyi/Python_Topics | /045_functions/_examples/Python-from-Zero-to-Hero/04-Функции и модули/06-Decorators.py | 1,179 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
def hello_world():
print('Hello, world!')
hello_world()
# In[ ]:
hello2 = hello_world
hello2()
# In[ ]:
#return func from func
#pass in a func as an arg
# In[ ]:
def log_decorator(func):
def wrap():
print(f'Calling func {func}')
func(... | false |
550e085e7618bbc1b7046419f23a47587965a162 | syurskyi/Python_Topics | /070_oop/004_inheritance/examples/super/Python 3 super()/001_super function example.py | 1,476 | 4.78125 | 5 | # At first, just look at the following code we used in our Python Inheritance tutorial. In that example code,
# the superclass was Person and the subclass was Student. So the code is shown below.
class Person:
# initializing the variables
name = ""
age = 0
# defining constructor
def __init__(self,... | true |
67592f055428cf2fd1aefd14a535c9d855a5a881 | syurskyi/Python_Topics | /010_strings/_exercises/_templates/Python 3 Most Nessesary/6.3. Row operations.py | 2,523 | 4.15625 | 4 | # # -*- coding: utf-8 -*-
# f__ -f _______ p.... # for Python 2.7
#
# s = "Python"
# print(s[0], s[1], s[2], s[3], s[4], s[5])
# # ('P', 'y', 't', 'h', 'o', 'n')
#
#
# s = "Python"
# # s[10]
# """
# Traceback (most recent call last):
# File "<pyshell#90>", line 1, in <module>
# s[10]
# IndexError: string index ... | false |
eb10863faaab3eabc8f28a687d4d698567c8cea0 | syurskyi/Python_Topics | /125_algorithms/_examples/_algorithms_challenges/pybites/beginner/149/solution.py | 560 | 4.125 | 4 | words = ("It's almost Holidays and PyBites wishes You a "
"Merry Christmas and a Happy 2019").split()
def sort_words_case_insensitively(words):
"""Sort the provided word list ignoring case, and numbers last
(1995, 19ab = numbers / Happy, happy4you = strings, hence for
numbers you only n... | true |
167776832ada38867f57a79bd37cf80b5ef2ff70 | syurskyi/Python_Topics | /050_iterations_comprehension_generations/001_iterations_and_iteration_tool/examples/013_Copying an Iterator.py | 1,344 | 4.90625 | 5 | # "Copying" an Iterator
# Sometimes we may have an iterator that we want to use multiple times for some reason.
# As we saw, iterators get exhausted, so
# simply making multiple references to the same iterator will not work -
# they will just point to the same iterator object.
#
# What we would really like is a way to ... | true |
82432656d06b812015a3cb455c5c05085c762933 | syurskyi/Python_Topics | /125_algorithms/005_searching_and_sorting/_exercises/templates/02_Binary Search/4 Binary Search/Binary-Search-Recursive-Implementation-with-Print-Statements.py | 1,170 | 4.25 | 4 | # ___ binary_search data low high item
#
# print("\n===> Calling Binary Search")
# print("Lower bound:" ?
# print("Upper bound:" ?
#
# __ ? <_ ?
# middle _ ? + ?//2
# print("Middle index:" ?
# print("Item at middle index:" ?|?
# print("We are looking for:" ?
# pri... | false |
ff244299c6831f01e62b6e1ec05c777c9840c057 | syurskyi/Python_Topics | /125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/197/mday.py | 618 | 4.28125 | 4 | from datetime import date
def get_mothers_day_date(year):
"""Given the passed in year int, return the date Mother's Day
is celebrated assuming it's the 2nd Sunday of May."""
day_counter = 1
mothers_day = date(year, 5, day_counter)
sunday_count = 0
while sunday_count < 2:
if mothers_day.wee... | false |
0c8fc8a50961f4cd18c3b1bfe27baf3beb6e8cdc | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/leetCode/Array/SortArrayByParity.py | 889 | 4.125 | 4 | """
Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.
You may return any answer array that satisfies this condition.
Example 1:
Input: [3,1,2,4]
Output: [2,4,3,1]
The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be... | true |
9823abdc5913bf193054f16ca7a44b5d55f69d99 | syurskyi/Python_Topics | /070_oop/008_metaprogramming/examples/Expert Python Programming/properties_decorator.py | 1,167 | 4.53125 | 5 | """
"Properties" section example of writing properties using
`property` decorator
"""
class Rectangle:
def __init__(self, x1, y1, x2, y2):
self.x1, self.y1 = x1, y1
self.x2, self.y2 = x2, y2
@property
def width(self):
"""rectangle height measured from top"""
return self.x... | false |
fc8d7266535b1af6ba76aac70e15c867ee09d069 | syurskyi/Python_Topics | /125_algorithms/_examples/Python_Hand-on_Solve_200_Problems/Section 14 Array/array_longest_non_repeat_solution.py | 2,461 | 4.25 | 4 | # To add a new cell, type '# %%'
# To add a new markdown cell, type '# %% [markdown]'
# %%
# ---------------------------------------------------------------
# python best courses https://courses.tanpham.org/
# ---------------------------------------------------------------
# Challenge
# Given a string, find the length ... | true |
2bfd3d1c05de676850cd447ca2f9adab34335e98 | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/leetCode/String/SortCharactersByFrequency.py | 1,384 | 4.15625 | 4 | """
Given a string, sort it in decreasing order based on the frequency of characters.
Example 1:
Input:
"tree"
Output:
"eert"
Explanation:
'e' appears twice while 'r' and 't' both appear once.
So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid answer.
Example 2:
Input:
"cccaaa"
Output:
"... | true |
f6266f2a13c31a765420db79fdb8235f06487c5e | syurskyi/Python_Topics | /125_algorithms/_exercises/exercises/_algorithms_challenges/pybites/beginner/beginner-bite-208-find-the-number-pairs-summing-up-n.py | 1,075 | 4.34375 | 4 | '''
In this Bite you complete find_number_pairs which receives a list of numbers and returns all the pairs
that sum up N (default=10). Return this list of tuples from the function.
So in the most basic example if we pass in [2, 3, 5, 4, 6] it returns [(4, 6)] and if
we give it [9, 1, 3, 8, 7] it returns [(9, 1), (3, 7... | true |
69ad335243346001307df683f73d09e66a0e72d3 | syurskyi/Python_Topics | /095_os_and_sys/examples/realpython/018_Deleting Directories.py | 1,222 | 4.3125 | 4 | # The standard library offers the following functions for deleting directories:
#
# os.rmdir()
# pathlib.Path.rmdir()
# shutil.rmtree()
#
# To delete a single directory or folder, use os.rmdir() or pathlib.rmdir(). These two functions only work if the d
# irectory you’re trying to delete is empty. If the di... | true |
3ea4a2eeebbb4784a57accf7184350ed53c503ff | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/leetCode/Array/SortArrayByParityII.py | 968 | 4.21875 | 4 | """
Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even.
Sort the array so that whenever A[i] is odd, i is odd; and whenever A[i] is even, i is even.
You may return any answer array that satisfies this condition.
Example 1:
Input: [4,2,5,7]
Output: [4,5... | true |
a5ae2046a401cae347fe7a33ccf0c96ec51dcef5 | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/codeabbey/_Python_Problem_Solving-master/Palindrome.py | 474 | 4.25 | 4 | #The word or whole phrase which has the same sequence of letters in both directions is called a palindrome.
___ i __ r..(i..(i.. ))):
rev_str ''
s__ ''.j..(e ___ e __ i.. ).l.. __ e.islower
#here iam storing the string in the reverse form
___ j __ r..(l..(s__)-1,-1,-1
rev_str += s__[j]
#once... | false |
c2ed4a564cc754afbee699556ef3b5483dca28ed | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/pybites/intermediate/9_v2/palindrome.py | 1,427 | 4.15625 | 4 | # """A palindrome is a word, phrase, number, or other sequence of characters
# which reads the same backward as forward"""
# _______ __
# _______ u__.r..
# _______ __
#
# TMP __.g.. TMP /tmp
# DICTIONARY __.p...j..? dictionary_m_words.txt
# u__.r...u..
# 'https://bites-data.s3.us-east-2.amazonaws.com/dictionary_... | false |
0586551822d2c81be6473a3604a06b80f558c254 | syurskyi/Python_Topics | /120_design_patterns/016_iterator/examples/Iterator_003.py | 1,326 | 4.375 | 4 | #!/usr/bin/env python
# Written by: DGC
#==============================================================================
class ReverseIterator(object):
"""
Iterates the object given to it in reverse so it shows the difference.
"""
def __init__(self, iterable_object):
self.list = iterable_obje... | true |
14e23ea3e3de89813068797bce4742c01e62044d | syurskyi/Python_Topics | /045_functions/008_built_in_functions/reduce/_exercises/templates/002_Using Operator Functions.py | 829 | 4.28125 | 4 | # # python code to demonstrate working of reduce()
# # using operator functions
#
# # importing functools for reduce()
# ____ f..
#
# # importing operator for operator functions
# ____ o..
#
# # initializing list
# lis _ 1 3 5 6 2
#
# # using reduce to compute sum of list
# # using operator functions
# print ("The sum... | true |
048985656c8b9aa4fdd20d5f4485302a9059ebe2 | syurskyi/Python_Topics | /095_os_and_sys/examples/pathlib — Filesystem Paths as Objects/009_Deleting/001_pathlib_rmdir.py | 926 | 4.28125 | 4 | # There are two methods for removing things from the file system, depending on the type. To remove an empty directory, use rmdir().
# pathlib_rmdir.py
#
# import pathlib
#
# p = pathlib.Path('example_dir')
#
# print('Removing {}'.format(p))
# p.rmdir()
#
# A FileNotFoundError exception is raised if the post-conditions ... | true |
331eab5b8eafeadd1f9d83d27280117a4daea3b8 | syurskyi/Python_Topics | /012_lists/_exercises/Python 3 Most Nessesary/8.1. Listing 8.1. Create a shallow copy of the list.py | 1,202 | 4.1875 | 4 | # # -*- coding: utf-8 -*-
#
# x = [1, 2, 3, 4, 5] # Создали список
# # Создаем копию списка
# y = l.. ? # или с помощью среза: y = x[:]
# # или вызовом метода copy(): y = x.copy()
# print ?
# # [1, 2, 3, 4, 5]
# print(x i_ y) ... | false |
7f571f75e4cde471f37e78d7b6e3f64255c5e9dd | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/pybites/topics/String/8/test_rotate.py | 1,794 | 4.46875 | 4 | ____ rotate _______ rotate
___ test_small_rotate
... rotate('hello', 2) __ 'llohe'
... rotate('hello', -2) __ 'lohel'
___ test_bigger_rotation_of_positive_n
s__ 'bob and julian love pybites!'
e.. 'love pybites!bob and julian '
... rotate(s__, 15) __ e..
___ test_bigger_rotation_of_negative_n
... | false |
ce65f63521103a3b65819c8bdf7daaaf479a51ef | syurskyi/Python_Topics | /012_lists/_exercises/ITVDN Python Starter 2016/03-slicing.py | 822 | 4.4375 | 4 | # -*- coding: utf-8 -*-
# Можно получить группу элементов по их индексам.
# Эта операция называется срезом списка (list slicing).
# Создание списка чисел
my_list = [5, 7, 9, 1, 1, 2]
# Получение среза списка от нулевого (первого) элемента (включая его)
# до третьего (четвёртого) (не включая)
sub_list = my_list[0:3]
... | false |
a64c2c4481a7f03ccad171656f3430c81f4496db | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/pybites/intermediate/intermediate-bite-18-find-the-most-common-word.py | 2,185 | 4.25 | 4 | """
Write a function that returns the most common (non stop)word in this Harry Potter text.
Make sure you convert to lowercase, strip out non-alphanumeric characters and stopwords.
Your function should return a tuple of (most_common_word, frequency).
The template code already loads the Harry Potter text and list of s... | true |
d6457e1f59aa2e7f58e030cdc15209bc2e73432b | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/Recursion, Backtracking and Dynamic Programming in Python/Section 3 Search Algorithms/LinearSearch.py | 489 | 4.1875 | 4 |
___ linear_search(container, item
# the running time of this algorithms is O(N)
# USE LINEAR SEARCH IF THE DATA STRUCTURE IS UNORDERED !!!
___ index __ ra__(le_(container)):
__ container[index] __ item:
# if we find the item: we return the index of that item
r_ index
... | true |
ab0688242ee45e648ef23c6aea22c389a47fb746 | syurskyi/Python_Topics | /095_os_and_sys/_exercises/exercises/realpython/017_Deleting Files in Python.py | 2,381 | 4.28125 | 4 | # # To delete a single file, use pathlib.Path.unlink(), os.remove(). or os.unlink().
# # os.remove() and os.unlink() are semantically identical. To delete a file using os.remove(), do the following:
#
# ______ __
#
# data_file _ 'C:\\Users\\vuyisile\\Desktop\\Test\\data.txt'
# __.r.. ?
#
# # Deleting a file using os.un... | true |
b6e934cfc5af74841bd8c4a8f951220163ce6bb0 | syurskyi/Python_Topics | /125_algorithms/_examples/Learn_Python_by_solving_100_Coding_Challenges/Coding Challenge No. 92 - SortColours.py | 757 | 4.15625 | 4 | # Sort Colours
# Question: Given an array with n objects coloured red, white or blue, sort them so that objects of the same colour are adjacent, with the colours in the order red, white and blue.
# Here, we will use the integers 0, 1, and 2 to represent the colour red, white, and blue respectively.
# Note: You are not ... | true |
8b3ff422b9e6313a0af0302c628c4179f750d85e | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/227 Basic Calculator II py3.py | 2,303 | 4.21875 | 4 | #!/usr/bin/python3
"""
Implement a basic calculator to evaluate a simple expression string.
The expression string contains only non-negative integers, +, -, *, / operators
and empty spaces . The integer division should truncate toward zero.
Example 1:
Input: "3+2*2"
Output: 7
Example 2:
Input: " 3/2 "
Output: 1
Exa... | true |
58cf2e0e3efb0f44bce7b4ef7c203fc27a443842 | syurskyi/Python_Topics | /095_os_and_sys/examples/realpython/005_Listing All Files in a Directory.py | 2,565 | 4.375 | 4 | # This section will show you how to print out the names of files in a directory using os.listdir(), os.scandir(),
# and pathlib.Path(). To filter out directories and only list files from a directory listing produced by os.listdir(),
# use os.path:
#
import os
# List all files in a directory using os.listdir
basepath =... | true |
29313678d25756a660eef4638259ee18459be08c | syurskyi/Python_Topics | /125_algorithms/_examples/Practice_Python_by_Solving_100_Python_Problems/77.py | 219 | 4.125 | 4 | #Create a script that gets user's age and returns year of birth
from datetime import datetime
age = int(input("What's your age? "))
year_birth = datetime.now().year - age
print("You were born back in %s" % year_birth)
| true |
08eff574578ac91abce96916bc188833ac922619 | syurskyi/Python_Topics | /125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/intermediate-bite-3-word-values.py | 2,365 | 4.3125 | 4 | """
Calculate the dictionary word that would have the most value in Scrabble.
There are 3 tasks to complete for this Bite:
First write a function to read in the dictionary.txt file (= DICTIONARY constant),
returning a list of words (note that the words are separated by new lines).
Second write a function that receiv... | true |
dccee39c84fc8a8b20b0cb56c22b64111a294a7d | syurskyi/Python_Topics | /125_algorithms/_examples/_algorithms_challenges/pybites/topics/intro/intro-bite102-infinite-loop-input-continue-break.py | 1,151 | 4.15625 | 4 | VALID_COLORS = ['blue', 'yellow', 'red']
def my_print_colors():
"""Ask for color, lowercase it, check if 'quit' is entered, if so print
'bye' and break, next check if given color is in VALID_COLORS, if not,
continue, finally if that check passes, print the color"""
while True:
inp = inpu... | true |
b7bad63ce92b0c02cb75adfbd722b04af3be1127 | syurskyi/Python_Topics | /125_algorithms/_examples/Learn_Python_by_solving_100_Coding_Challenges/Coding Challenge No. 93 - SpiralMatrix.py | 1,543 | 4.15625 | 4 | # Spiral Matrix
# Question: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
# For example:
# Given the following matrix:
# [ [ 1, 2, 3 ],
# [ 4, 5, 6 ],
# [ 7, 8, 9 ] ]
# You should return [1,2,3,6,9,8,7,4,5].
# Solutions:
class Solution:
# @param matrix, a... | true |
1dde8cb11156223aecd6a4a81853f4045270155d | syurskyi/Python_Topics | /125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/299_v4/base_converter.py | 780 | 4.34375 | 4 | def digit_map(num):
"""maps numbers greater than a single digit to letters (UPPER)"""
return chr(num + 55) if num > 9 else str(num)
def convert(number: int, base: int = 2) -> str:
"""Converts an integer into any base between 2 and 36 inclusive
Args:
number (int): Integer to convert
bas... | true |
2320ff2a2f62a49a58ed296a3886563432f3132f | syurskyi/Python_Topics | /070_oop/004_inheritance/_exercises/templates/super/Python Super/002_ Single Inheritance.py | 2,396 | 4.28125 | 4 | # # Inheritance is the concept in object-oriented programming in which a class derives (or inherits) attributes
# # and behaviors from another class without needing to implement them again.
#
# # See the following program.
#
# # app.py
#
# c_ Rectangle
# __ - length width
# ? ?
# ? ?
#
# __ ar... | false |
961312152de7cdc52600dbbce3f98d379605f5a4 | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/pybites/intermediate/159/calculator.py | 724 | 4.125 | 4 | # _______ o..
#
# ___ simple_calculator calculation
# """Receives 'calculation' and returns the calculated result,
#
# Examples - input -> output:
# '2 * 3' -> 6
# '2 + 6' -> 8
#
# Support +, -, * and /, use "true" division (so 2/3 is .66
# rather than 0)
#
# Make sure you convert... | false |
dc8846f3e74b784dcee36049f2735d7dd2ae3c4d | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/581 Shortest Unsorted Continuous Subarray.py | 2,052 | 4.3125 | 4 | #!/usr/bin/python3
"""
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 sorted
in ascending order, too.
You need to find the shortest such subarray and output its length.
Example 1:
Input: [2, 6, 4, 8, 10, 9, 15]
Outp... | true |
7a183c9f407ec53a128bb57bfd6e5f0f9e10df7d | syurskyi/Python_Topics | /070_oop/008_metaprogramming/_exercises/templates/Abstract Classes in Python/a_004_Concrete Methods in Abstract Base Classes.py | 848 | 4.21875 | 4 | # # Concrete Methods in Abstract Base Classes :
# # Concrete classes contain only concrete (normal)methods whereas abstract class contains both concrete methods
# # as well as abstract methods. Concrete class provide an implementation of abstract methods, the abstract base class
# # can also provide an implementation b... | true |
98357c37192a91a3dc3afbe121908ae36db45019 | syurskyi/Python_Topics | /125_algorithms/_examples/Learn_Python_by_solving_100_Coding_Challenges/Coding Challenge No. 84 - ReverseInt.py | 382 | 4.15625 | 4 | # Reverse Integer
# Question: Reverse digits of an integer.
# Example1: x = 123, return 321
# Example2: x = -123, return -321.
# Solutions:
class Solution:
# @return an integer
def reverse(self, x):
if x<0:
sign = -1
else:
sign = 1
strx=str(abs(x))
r = s... | true |
c9481862292b011e70bf73b3d62078e3a0122ab7 | syurskyi/Python_Topics | /120_design_patterns/025_without_topic/examples/MonoState.py | 2,609 | 4.28125 | 4 | #!/usr/bin/env python
# Written by: DGC
# python imports
#==============================================================================
class MonoState(object):
__data = 5
@property
def data(self):
return self.__class__.__data
@data.setter
def data(self, value):
self.__class... | true |
dcd947e7c695994dce361540224d3b63d3bb4d7a | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/336 Palindrome Pairs.py | 2,980 | 4.125 | 4 | #!/usr/bin/python3
"""
Given a list of unique words, find all pairs of distinct indices (i, j) in the
given list, so that the concatenation of the two words, i.e. words[i] + words[j]
is a palindrome.
Example 1:
Input: ["abcd","dcba","lls","s","sssll"]
Output: [[0,1],[1,0],[3,2],[2,4]]
Explanation: The palindromes are... | false |
42ea23542608d894bf2c4c50394464b9d68d0eeb | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/769 Max Chunks To Make Sorted.py | 1,315 | 4.28125 | 4 | #!/usr/bin/python3
"""
Given an array arr that is a permutation of [0, 1, ..., arr.length - 1], we
split the array into some number of "chunks" (partitions), and individually sort
each chunk. After concatenating them, the result equals the sorted array.
What is the most number of chunks we could have made?
Example 1... | true |
0291f8953312c8c71a778cb5defd91ca5c24ef09 | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/AdvancedPython_OOP_with_Real_Words_Programs/App-6-Project-Calorie-Webapp/src/calorie.py | 564 | 4.125 | 4 | ____ temperature _____ Temperature
c_ Calorie:
"""Represents optimal calorie amount a person needs to take today"""
___ - weight, height, age, temperature):
weight weight
height height
age age
temperature temperature
___ calculate _
result 10 * weight + 6... | true |
23c0c2ee5b6165c16168522bf61bc190696b3161 | syurskyi/Python_Topics | /079_high_performance/examples/Writing High Performance Python/item_49.py | 1,819 | 4.15625 | 4 | import logging
from pprint import pprint
from sys import stdout as STDOUT
# Example 1
def palindrome(word):
"""Return True if the given word is a palindrome."""
return word == word[::-1]
assert palindrome('tacocat')
assert not palindrome('banana')
# Example 2
print(repr(palindrome.__doc__))
# Example 3
"... | true |
2f0cd45309945619d5e95e75abf7be9718989ddf | syurskyi/Python_Topics | /120_design_patterns/009_decorator/_exercises/templates/decorator_003.py | 1,334 | 4.1875 | 4 | # """Decorator pattern
#
# Decorator is a structural design pattern. It is used to extend (decorate) the
# functionality of a certain object at run-time, independently of other instances
# of the same class.
# The decorator pattern is an alternative to subclassing. Subclassing adds
# behavior at compile time, and the c... | true |
1e11e649770bc1016e7babd381ba315750367a03 | syurskyi/Python_Topics | /045_functions/008_built_in_functions/map/examples/006_Python map() with string.py | 2,072 | 4.375 | 4 | def to_upper_case(s):
return str(s).upper()
def print_iterator(it):
for x in it:
print(x, end=' ')
print('') # for new line
# map() with string
map_iterator = map(to_upper_case, 'abc')
print(type(map_iterator))
print_iterator(map_iterator)
# Output:
# <class 'map'>
# A B C
# Python map() with t... | false |
ee5aada9b9038f1262e4b8d07a2ad5bdeb8a076c | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/pybites/advanced/42/guess.py | 2,517 | 4.15625 | 4 | # _______ r__
# MAX_GUESSES 5
# START, END 1, 20
#
#
# ___ get_random_number
# """Get a random number between START and END, returns int"""
# r.. r__.r.. ?
#
#
# c_ Game
# """Number guess class, make it callable to initiate game"""
#
# ___ -
# """Init _guesses, _answer, _win to set(), get_random... | false |
1be54b84d0949dc683432acfc41b13cde9f570c1 | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/100_python_Best_practices_for_absolute_beginers/Project+99 How to calculate the Area and Perimeter of Right Angle Triangle.py | 276 | 4.1875 | 4 | _______ math
x float(input("Insert length of x: "))
y float(input("Insert length of y: "))
z math.sqrt((pow(x,2)+pow(y,2)))
Area (x*y)/2
Perimeter x+y+z
print("Area of right angled triangle = %.2f" % Area)
print("Perimeter of right angled triangle = %.2f" % Perimeter) | false |
b7e17d3710c68df3ebf3b937d389f40cf4257d7e | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/959 Regions Cut By Slashes.py | 2,876 | 4.1875 | 4 | #!/usr/bin/python3
"""
In a N x N grid composed of 1 x 1 squares, each 1 x 1 square consists of a /, \,
or blank space. These characters divide the square into contiguous regions.
(Note that backslash characters are escaped, so a \ is represented as "\\".)
Return the number of regions.
Example 1:
Input:
[
" /",... | true |
2901e2dbaab6f155dfd2d32feeed803ef2d07a5d | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/674 Longest Continuous Increasing Subsequence.py | 978 | 4.15625 | 4 | #!/usr/bin/python3
"""
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 subsequence, i... | true |
69accf57e5d5b8c3921c910a0f19e3b4def863dc | syurskyi/Python_Topics | /125_algorithms/_examples/_algorithms_challenges/pybites/topics/supplementary exercises/e0001-zip.py | 857 | 4.53125 | 5 | # zip(), lists, tuples
# list is a sequence type
# list can hold heterogenous elements
# list is mutable - can expand, shrink, elements can be modified
# list is iterable
# tuple is a sequence type
# tuple can hold heterogeneous data
# tuple is immutable
# tuple is iterable
# Test case 1 - when iterables are of equa... | true |
438cb7633c606ebafa831e5a24a8ceb3ae2ba851 | syurskyi/Python_Topics | /125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/intermediate-bite-272-find-common-words.py | 1,862 | 4.34375 | 4 | """
Given two sentences that each contains words in case insensitive way, you have to check the
common case insensitive words appearing in both sentences.
If there are duplicate words in the results, just choose one. The results should be
sorted by words length.
The sentences are presented as list of words. Example:
... | true |
ab296e2bb06b26e229bf476a06432826585dbbb5 | syurskyi/Python_Topics | /125_algorithms/_examples/Python_Hand-on_Solve_200_Problems/Section 4 Condition and Loop/2_dimensional_array_solution.py | 1,011 | 4.375 | 4 | # To add a new cell, type '# %%'
# To add a new markdown cell, type '# %% [markdown]'
# %%
# ---------------------------------------------------------------
# python best courses https://courses.tanpham.org/
# ---------------------------------------------------------------
# Write a Python program which takes two digit... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.