blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
840f4b5f3d7dbb11fd65e266fbff83561e4f729b | kancha-supriya/python_samples | /test2.py | 1,139 | 4.25 | 4 | """
Return true for palidrome
test with case sensitive and non case sensitive
EG : Madam
"""
import string
class Palindrome:
@staticmethod
def is_palindrome(word):
if word[::-1] == word:
return True
if word[::-1].lower() == word.lower():
return True
... | false |
a662d0ba108c778eabc880a98c81767894b9e31e | jon-rutledge/Notes-For-Dummies | /Python/ListsAndStrings.py | 1,198 | 4.1875 | 4 | #strings and lists
testList = list('Hello')
print(testList)
print(testList)
#strings are immutable data types, they cannot be modified
#if you need to modify a string value, you need to create a new string based the original
#References
#with one off variables you can do something like this
spam = 42
cheese = spam... | true |
3cdc151abf8b3d094b0efe4b833ffee6d05866e9 | nikhil-kamath/Scheduling | /DateTimeInput.py | 1,685 | 4.1875 | 4 | import datetime as dt
class DateTimeInput:
def __init__(self):
pass
def input_date(self) -> dt.date:
'''gets input from console and returns DATE object'''
goal_date_str = input("Enter a date at which our code should run: ").split()
if goal_date_str[0] == 'today':
re... | false |
d4a8bd4e8e212950b246d5b1a2dba83eb08c669e | mhipo1364/takh | /test.py | 1,008 | 4.1875 | 4 | __author__ = 'moefar'
def is_divisible(x, y):
"""
Check if x is divided by y
:param x: int
:param y: int
:return: bool
"""
if x % y == 0:
return True
def divisible_by_three(x):
"""
Returns proper string if x is divided by 3
:param x: int
:return: str/None
... | false |
34f8a256264e0da898d07b32d613371bc0fecde5 | SACHSTech/ics2o1-livehack-2-Kyle-Lue | /problem2.py | 1,066 | 4.5 | 4 | """
-------------------------------------------------------------------------------
Name: problem2.py
Purpose: Determine the sides of the traingle and determine if it is a triangle
Author: Lue.Kyle
Created: 23/02/2021
------------------------------------------------------------------------------
"""
#Input the le... | true |
5ba6cfe289b2cec8dd68df78d11253cbb7a5ec0c | ashutosh4336/python | /coreLanguage/ducktyping/lambda.py | 1,324 | 4.28125 | 4 | """
--> What is Lambda function ?
Lambda function are Namesless or Anonymous functions
'lambda' is not a function it is a keywork in python
--> Why they are Used.
One-Time-Use ==> Throw away function as they're only used Once
IO of other function ==> They're also passed as inputs or returned as outputs of other Hi... | true |
90b19ba814eb586ddae8d0b97068b71901a8627c | Satishchandra24/CTCI-Edition-6-Python3 | /chapter1/oneAway.py | 2,799 | 4.15625 | 4 | """There are three types of edits that can be performed on strings: insert a character,
remove a character, or replace a character. Given two strings, write a function to check if they are
one edit (or zero edits) away.
EXAMPLE
pale, ple-> true
pales, pale -> true
pale,bale-> true
pale,bake-> false"""
def oneAway(str1... | true |
bd897223c898fe68168a467fd41f7b1923bcf6ee | rwedema/master_ontwikkeling | /informatica_start/jupyter_notebooks/informatics01/WC_05/random_dna_template.py | 1,231 | 4.21875 | 4 | #!/usr/bin/env python3
#imports
import sys
import random
def calc_gc(seq):
#calculates the percentage of GC in the sequence
#finish this function yourself
pass
def generate_dna(len_dna):
#generates random DNA with GC percentage between 50 and 60%
#some comments removed. Write your own comments!... | true |
ea4d338b844b370f06bdfd9368fac0c1f154a8a7 | rwedema/master_ontwikkeling | /informatica_start/jupyter_notebooks/informatics01/WC_03/03_dna_convert_functions_solution.py | 1,748 | 4.15625 | 4 | #!/usr/bin/env python3
#solution for DNA convert
#imports
import sys
def is_valid_dna(seq):
#checks if all letters of seq are valid bases
valid_dna = "ATCG"
for base in seq:
if not base in valid_dna:
#the break statement is not needed anymore as return automatically breaks the loop.
... | true |
74d8061cc74328a6c65d08ff91ec679347bb76f3 | abaldeg/EjerciciosPython | /Simulacro Segundo Parcial Segundo Cuatrimestre Segundo ejercicio.py | 472 | 4.21875 | 4 | """2) Desarrollar una función recursiva que reciba un número binario y lo devuelva convertido
a base decimal. Creando una excepción o generando ValueError en caso de recibir un número que no es
binario o un número negativo con el mensaje aclaratorio correspondiente a cada error. Resolver utilizando
raise o assert."""
d... | false |
d2040f23880631d72fa1f90eca9374c012ac0db5 | abaldeg/EjerciciosPython | /PROGRAMACION I TP 2 EJ 7.py | 803 | 4.15625 | 4 | #Escribir una función que reciba una lista como parámetro y devuelva True si la lista
#está ordenada en forma ascendente o False en caso contrario. Por ejemplo,
#ordenada([1, 2, 3]) retorna True y ordenada(['b', 'a']) retorna False. Desarrollar
#además un programa para verificar el comportamiento de la función.
#Funci... | false |
e977567aa32b21b6b0a557963a5cd3a01982bca1 | boluwaji11/Py-HW | /HW4/HW4-5_Boluwaji.py | 674 | 4.5 | 4 | # This program calculates the factorial of nonnegative integer numbers
# Start
# Get the desired number from the user
# Use a repetition control to calculate the factorial
# End
# ==============================================================
print('Welcome!')
number = int(input('\nPlease enter the desired positiv... | true |
adf9d5898e666f01c6fb4e8c5a7976fe0242283f | boluwaji11/Py-HW | /HW3/HW3-4_Boluwaji.py | 1,191 | 4.4375 | 4 | # This program converts temperature in degrees Celsius to Fahrenheit.
# Start
# Get the temperature in celsius from the user
# Calculate the Fahrenheit equivalent of the inputted temperature
# Check the result
# If the result is more than 212F
# Display "Temperature is above boiling water temperature"
... | true |
0cd27f6603efb0bea65eb78aceff2e0ccb25a884 | boluwaji11/Py-HW | /HW5/HW5-3_Boluwaji.py | 1,712 | 4.1875 | 4 | # This program calculates dietary information
# Start
# Define main function
# In the main function,get fat and carbohydrate information from the user
# Pass fat to calories_fat and call it
# Pass carbohydrate to calories_carbs and call it
# Call calories_fat and calories_carbs in main
# Define the c... | true |
2eece337929e5f114a7a8a2e4dc0e33d4634906b | boluwaji11/Py-HW | /HW6/HW6-1-a_Boluwaji.py | 1,476 | 4.15625 | 4 | # This program saves different video running times for Kevin to the video_running_times.txt file.
# Start
# Define the main function
# Ask Kevin for the number of short videos he's working with
# Open a file to save the videos
# Enter the different times and write it to file
# Close the file
# Noti... | true |
fafcd54d9ca7df23aa71d59fa7dde85b0b153aee | JasoSalgado/python-problems | /first-week/first-exercises/problem_16.py | 836 | 4.34375 | 4 | """
Pedir el día, mes y año de una fecha e indicar si la fecha es correcta. Con meses de 28, 30 y 31 días. Sin años bisiestos.
"""
instructions = "***** Enter a valid date. For instance: dd/mm/yyyy *****"
print(instructions.center(50, "*"))
day = int(input("Write a day: \n"))
month = int(input("Write a month: \n"))
y... | false |
a35aa8b96d8fa8820556790e4ebb69552e569d5b | JasoSalgado/python-problems | /second-week/first-exercise-poo/account.py | 1,595 | 4.1875 | 4 | class Account():
def __init__(self, account_holder, amount):
self.__account_holder = input("Enter an account holder: \n")
self.__amount = float(input("Enter an amount: \n"))
@property
def account_holder(self):
return self.__account_holder
@property
... | false |
6a1288f7eb4c1d9934ec25f3b6d1c71451f58819 | JasoSalgado/python-problems | /first-week/first-exercises/problem_18.py | 787 | 4.125 | 4 | """
Ídem que el ej. 17, suponiendo que cada mes tiene un número distinto de días (suponer que febrero tiene siempre 28 días).
"""
instructions = "***** Enter a valid date. For instance: dd/mm/yyyy *****"
print(instructions.center(50, "*"))
day = int(input("Write a day: \n"))
month = int(input("Write a month: \n"))
ye... | false |
9f4e5d5c93d94f01f61e924974c34d869a5fa0b1 | piyush546/Machine-Learning-Bootcamp | /Basic Python programs/listreverse.py | 341 | 4.21875 | 4 | # -*- coding: utf-8 -*-
""" A program to demonstrate list content reversing and optimizing the reversing method of string """
# To take user name input in single command using split
name = input().split()
# to print the name string after reversing
name = name[::-1]
name = " ".join(name)
print(name)
# Input = piyu... | true |
68742eb158b913e6e9f3f85f80d669eef018fa2d | piyush546/Machine-Learning-Bootcamp | /Basic Python programs/style.py | 290 | 4.15625 | 4 | # -*- coding: utf-8 -*-
""" A program to use some str methods """
# variables to store strings to be styled
First_string = input("Enter the string:")
# To print the strings after styling
print(str.upper(First_string))
print(str.lower(First_string))
print(str.capitalize(First_string))
| true |
34b635354da1a433f5a0ebc96a481141bf48f1be | Neeraj-Chhabra/Class_practice | /task2.py | 454 | 4.125 | 4 | def square_root(a):
z=1
x=a/2
while(z==1):
y = (x + (a/x)) / 2
if (abs(y-x) < 0.0000001):
print(x)
z=2
return(x)
else:
x=y
# print("new value not final", x)
# print(y)
def test_square_root(a):
return(math.sqrt(a))
root=int(input("enter the number for the squareroot"))
import math
d=square_... | true |
30822abe9cc556240dca0da5ade9f60371c89676 | RayNieva/Python | /printTable.py | 2,165 | 4.4375 | 4 | #!/usr/bin/env python
"""Project Table Printer
Write a function named printTable() that takes a list of lists of strings and displays it in a well-organized table with each column right-justified. Assume that all the inner lists will contain the same number of strings. For example, the value could look like this:"""
... | true |
cd7ce1b61e2223f77e45a8ff3960dcf8114b40fa | european-54/python_algos_gb | /Урок 4. Практическое задание/task_3.py | 1,326 | 4.3125 | 4 | """
Задание 3.
Приведен код, формирующий из введенного числа
обратное по порядку входящих в него
цифр и вывести на экран.
Сделайте профилировку каждого алгоритма через cProfile и через timeit
Сделайте вывод, какая из трех реализаций эффективнее и почему
"""
def revers(enter_num, revers_num=0):
if enter_num == 0:
... | false |
e3d1598b8864ed8a3bd40b2e9f41894b5028c326 | nuneza6954/cti110 | /M4T4 P4HW2_ PoundsKilos _AliNunez.py | 951 | 4.3125 | 4 | # Program will display a table of pounds starting from 100 through 300
# (with a step value of 10) and their equivalent kilograms.
# The formula for converting pounds to kilograms is:
# kg= lb/2.2046
# Program will do a loop to display the table.
# 03-07-2019
# CTI-110 P4HW2 - Pounds to Kilos Table
# Ali Nunez... | true |
6c3e99015bf3c5a132b18f7d55dddf6b7e9952d5 | narasimhareddyprostack/Ramesh-CloudDevOps | /Python/Fours/Set/four.py | 208 | 4.40625 | 4 | s = {1,2,3}
s.update('hello')
print(s)
#The Python set update() method updates the set, adding items from other iterables.
'''
adding items form other iterable objects, such as list, set, dict, string
'''
| true |
ff61d43320ab6abbbd0c233a72d80420be6e8a7d | narasimhareddyprostack/Ramesh-CloudDevOps | /Python/Fours/Dict/Dict-Exe/seven.py | 289 | 4.15625 | 4 | '''
Create a new dictionary by extracting the following keys
from a below dictionary
keys = ["name", "salary"]
'''
sampleDict = {
"name": "Kelly",
"age":25,
"salary": 8000,
"city": "New york" }
keys = ["name", "salary"]
newDict = {k:sampleDict[k] for k in keys}
print(newDict) | false |
96be9ec136c4bd58d90e56a1f1b6b7e07a08f23a | djndl1/CSNotes | /algorithm/introAlgorithm/python-implementation/bubble_sort.py | 1,005 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import operator
def optimized_bubble_sort(arr, comp=operator.le):
if len(arr) < 2:
return arr
n = len(arr)
while n > 1:
next_n = 0
for i in range(1, n):
if not comp(arr[i-1], arr[i]): # if out of order, then swap
... | true |
99b71f3b737456b6916d801929159ba767e85a55 | TBobcat/Leetcode | /CountPrimes.py | 1,234 | 4.25 | 4 | def countPrimes( n):
"""
:type n: int
:rtype: int
"""
prime_list=is_prime(n)
# print(prime_list)
return len(prime_list)
def is_prime(n):
# based on Sieve of Eratosthenes
result = []
if n <=1 :
return []
# Create a boolean array "prime[0..n]" a... | true |
e19d001fa89e189159f02bc70314c4dbdc4ebe6f | pierredepascale/PyED | /src/pyed/fundamental.py | 2,376 | 4.15625 | 4 | #
# PyED -- an emacs like text editor in Python
#
# Copyright 2011 Pierre De Pascale (pierre.depascale _AT_ gmail.com)
#
from keymap import *
from mode import *
from command import *
from editor import *
FUNDAMENTAL_MAP = Keymap()
FUNDAMENTAL_MODE = Mode("Fundamental", "Fundamental mode", FUNDAMENTAL_MA... | false |
b4ab5c05860d95676bdc24b9813226002a49fc0f | fgarcialainez/RabbitMQ-Python-Tutorial | /rabbitmq/tutorial1/receive.py | 1,191 | 4.3125 | 4 | #!/usr/bin/env python
"""
In this part of the tutorial we'll write two small programs in Python; a producer (sender) that sends a single
message, and a consumer (receiver) that receives messages and prints them out. It's a "Hello World" of messaging.
https://www.rabbitmq.com/tutorials/tutorial-one-python.html
"""... | true |
a7b0001a9a204a24607419abd86197464487e184 | oskip/IB_Algorithms | /Merge.py | 1,152 | 4.1875 | 4 | # Given two sorted integer arrays A and B, merge B into A as one sorted array.
#
# Note: You have to modify the array A to contain the merge of A and B. Do not output anything in your code.
# TIP: C users, please malloc the result into a new array and return the result.
# If the number of elements initialized in A and... | true |
81afe70547b88e2216f90d93e901d89282ae7628 | oskip/IB_Algorithms | /RevListSample.py | 914 | 4.25 | 4 | # Reverse a linked list. Do it in-place and in one-pass.
#
# For example:
# Given 1->2->3->4->5->NULL,
#
# return 5->4->3->2->1->NULL.
#
# PROBLEM APPROACH :
#
# Complete solution code in the hints
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = ... | true |
9431f2f8c0c10c09878199baf743b0d1f3510781 | pr1malbyt3s/Py_Projects | /Advent_of_Code/2021/1_2021.py | 1,183 | 4.4375 | 4 | # AOC 2021 Day 1
import sys
# This function is used to read a file input from the command line. It returns the file contents as a list of lines.
def read_file() -> list:
if len(sys.argv) != 2:
print("Specify puzzle input file")
sys.exit(-1)
else:
# Open file at command line position 1:... | true |
abbda68a1e2777bae2bdc1ec1903232c81d7d42f | pr1malbyt3s/Py_Projects | /Runcode.ninja/Simple_Addition.py | 1,116 | 4.1875 | 4 | #!/usr/bin/env python3
# This script accepts an input file of mixed value pairs separated by lines.
# It check that each value pair can be added and if so, prints the corresponding sum.
import sys
from decimal import Decimal
# Create a master list of all number pairs.
numList = []
# Type check function to determine... | true |
dd49bbd3212bd1c77674f3b8f68ef134a6f7b253 | pr1malbyt3s/Py_Projects | /Runcode.ninja/Simple_Cipher.py | 579 | 4.28125 | 4 | #!/usr/bin/env python3
# This script is used to decode a special 'cipher'.
# The cipher pattern is each first word in a new sentence.
import sys
# Create a list to store each parsed first word from an input file.
message = []
with open(sys.argv[1], 'r') as f:
cipher = f.read()
# While reading file, split the file ... | true |
ac0ef21febfd8f26eeec7ae27c2bee55b35ab46f | pr1malbyt3s/Py_Projects | /Runcode.ninja/Third_Letter_Is_A_Charm.py | 946 | 4.21875 | 4 | #!/usr/bin/env python3
# This script accepts an input file containing words with misplaced letters.
# Conveniently, the misplaced letter is always from the third position in the word and is at the beginning.
import sys
# rotate function to perform letter rotation on a provided string.
# It first checks to ensure the... | true |
812a8a7dac1e22b1bdbd9e47f3c59113b303aa0c | seaboltthomas19/Monty-Hall-Problem | /monty-hall-sim.py | 1,111 | 4.1875 | 4 | import random
switch_was_correct = 0
no_switch_was_correct = 0
print("====================================" +
"\n" +
"*** Monty Hall Problem Simulator ***" +
"\n" +
"====================================")
print("Doors to choose from: ")
doors = int(input())
print("Iterations to r... | true |
d61a5fe6d5b68073a738d19b93e24a35695cc1d4 | luckymime28/Skyjam | /skyjam.py | 1,851 | 4.1875 | 4 | print("- If you need more info or you're confused type 'help'")
def help():
print("\n-So basically, this is my first exploit I ever created \n-My name is luckymime28, and this is my exploit skyjam.py \n-skyjam.py is a password combination maker and list creator \n-Simply follow the instructions on screen and you ... | true |
1c2ac0372cd46f24e4a6a18d3fb7808154166a31 | EthanCornish/AFPwork | /Chapter4-Functions-Tutorial#1.py | 759 | 4.125 | 4 |
# Function Tutorial
# Creating a main function
# In the main function print instructions and ask for a value
def main():
print('Hello')
print('This program will ask you for a temperature\nin fahrenheit.')
print('-----------------------------------------------------------')
value = int(input('Enter a ... | true |
5fc5f217581a224b9f22be8c91a204a7936a8885 | seanmortimer/udemy-python | /python-flask-APIs/functions.py | 856 | 4.1875 | 4 | def hello(name):
print(f'Heeyyy {name}')
hello('Sean ' * 5)
# Complete the function by making sure it returns 42. .
def return_42():
# Complete function here
return 42 # 'pass' just means "do nothing". Make sure to delete this!
# Create a function below, called my_function, that takes two arguments and... | true |
832adbc3d78e3496afb1bb180fc1e8ed42be1b76 | LiamWoodRoberts/HackerRank | /Anagrams.py | 741 | 4.125 | 4 | '''Solution to:
https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem
function finds the number of anagrams contained in a certain string'''
def substrings(word):
strings=[]
for l in range(1,len(word)):
sub = [word[i:i+l] for i in range(len(word)-l+1)]
strings.append(sub)
... | true |
4a0e8b5efeb37c0b538ed7b264f9a39ad9d67440 | Rockwell70/GP_Python210B_Winter_2019 | /examples/office_hours_code/class_inheritence.py | 953 | 4.15625 | 4 | class rectangle:
def __init__(self, width, length):
self.width = width
self.length = length
def area(self):
return self.width * self.length
def present_figure(self):
return f'This figure has a width of {self.width}, a length of {self.length} and an area of {self.area()}'
... | true |
77b412d9121baf177d930b1072f9870b7f7f6b79 | Rockwell70/GP_Python210B_Winter_2019 | /examples/office_hours_code/donor_models.py | 2,082 | 4.34375 | 4 | #!/bin/python3
'''
Sample implementation of a donor database using classes
'''
class Person:
'''
Attributes common to any person
'''
def __init__(self, donor_id, name, last_name):
self.donor_id = donor_id
self.name = name
self.last_name = last_name
class Donation:
'''
... | true |
38ce46230cc6f2c490b97ef27681975750f48ed7 | Rockwell70/GP_Python210B_Winter_2019 | /examples/office_hours_code/sunday_puzzle.py | 1,425 | 4.1875 | 4 | '''
From: https://www.npr.org/2019/01/20/686968039/sunday-puzzle-youre-halfway-there
This week's challenge: This challenge comes from listener Steve Baggish of Arlington, Mass.
Take the name of a classic song that became the signature song of the artist who performed it.
It has two words; five letters in the first, thr... | true |
7d85e7b88b3ba9ffce5d21164dcbba0fea78aa2c | petrarka/bmstu_tisd | /some files we do/1sem/2/dz2.py | 1,357 | 4.21875 | 4 | # Программа для вычисления квадратного уравнения
# Сангинов Азамат ИУ7-11Б
from math import sqrt
# a, b, c - коэфициенты уравнения
# d - дискриминант
# x - корень квадратного уравнения
print('Квадратное уравнение имеет вид: a*x^2 + b*x + c = 0')
a = float(input('Введите коэффициент ... | false |
eb3057689fc57e496ee0e3f64cf50ef1ef723fe1 | Cody-Hayes97/Sprint-Challenge--Algorithms | /recursive_count_th/count_th.py | 706 | 4.25 | 4 | '''
Your function should take in a single parameter (a string `word`)
Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters.
Your function must utilize recursion. It cannot contain any loops.
'''
def count_th(word):
# return zero if the ength of the word is less ... | true |
0a1bf196667cd63dc6f5fe840a88b74aa9593883 | RutujaWanjari/Python_Basics | /RenameFileNames/rename_filenames.py | 885 | 4.375 | 4 | # This program demonstrates how to access files from relative path.
# Also it changes alphanumeric file names to totally alphabetic names.
# To successfully run this program create a directory "AllFiles" and add multiple files with alphanumeric names.
from pathlib import Path
import os
# Path is a class from "pathlib... | true |
6d210d6f2ab4cad68112fd06c8704b62352f5d03 | DmitryVlaznev/leetcode | /296-reverse-linked-list.py | 1,871 | 4.21875 | 4 | # 206. Reverse Linked List
# Reverse a singly linked list.
# Example:
# Input: 1->2->3->4->5->NULL
# Output: 5->4->3->2->1->NULL
# Follow up:
# A linked list can be reversed either iteratively or recursively. Could
# you implement both?
# Definition for singly-linked list.
class ListNode:
def __init__(self, x)... | true |
020377082a10915fae20031ccf7b0dc1d6424a3b | DmitryVlaznev/leetcode | /328-odd-even-linked-list.py | 2,474 | 4.34375 | 4 | # 328. Odd Even Linked List
# Given a singly linked list, group all odd nodes together followed by
# the even nodes. Please note here we are talking about the node number
# and not the value in the nodes.
# You should try to do it in place. The program should run in O(1) space
# complexity and O(nodes) time complexit... | true |
f542f1f5c756600310e472c711f84dc787cefc2d | DmitryVlaznev/leetcode | /1329-sort-the-matrix-diagonally.py | 1,513 | 4.21875 | 4 | # 1329. Sort the Matrix Diagonally
# Medium
# A matrix diagonal is a diagonal line of cells starting from some cell
# in either the topmost row or leftmost column and going in the
# bottom-right direction until reaching the matrix's end. For example,
# the matrix diagonal starting from mat[2][0], where mat is a 6 x 3... | true |
c4d5b792263bd949ebe3b6bb5186121c8832307f | DmitryVlaznev/leetcode | /246-strobogrammatic-number.py | 1,077 | 4.15625 | 4 | # 246. Strobogrammatic Number
# Easy
# Given a string num which represents an integer, return true if num is
# a strobogrammatic number.
# A strobogrammatic number is a number that looks the same when rotated
# 180 degrees (looked at upside down).
# Example 1:
# Input: num = "69"
# Output: true
# Example 2:
# Inpu... | true |
2d94fb484758fb8e9d8c079a8cfa4d94fe03ebaf | DmitryVlaznev/leetcode | /702-search-in-a-sorted-array-of-unknown-size.py | 1,982 | 4.125 | 4 | # 702. Search in a Sorted Array of Unknown Size
# Given an integer array sorted in ascending order, write a function to
# search target in nums. If target exists, then return its index,
# otherwise return -1. However, the array size is unknown to you. You
# may only access the array using an ArrayReader interface, wh... | true |
aefd7af360fdf3d158e5be8fdf16a3deb939b6b9 | DmitryVlaznev/leetcode | /1423-maximum-points-you-can-obtain-from-cards.py | 2,553 | 4.125 | 4 | # 1423. Maximum Points You Can Obtain from Cards
# Medium
# There are several cards arranged in a row, and each card has an
# associated number of points The points are given in the integer array
# cardPoints.
# In one step, you can take one card from the beginning or from the end
# of the row. You have to take exac... | true |
284ec6e03f5edb54d8ba5903235f37a74a4d4b32 | DmitryVlaznev/leetcode | /902-numbers-at-most-n-given-digit-set.py | 1,719 | 4.21875 | 4 | # 902. Numbers At Most N Given Digit Set
# Hard
# Given an array of digits, you can write numbers using each digits[i]
# as many times as we want. For example, if digits = ['1','3','5'], we
# may write numbers such as '13', '551', and '1351315'.
# Return the number of positive integers that can be generated that ar... | true |
aa350a3b28ad670e494ba35e8865ad519ecb1f14 | DmitryVlaznev/leetcode | /701-insert-into-a-binary-search-tree.py | 2,224 | 4.1875 | 4 | # Insert into a Binary Search Tree
# You are given the root node of a binary search tree (BST) and a value
# to insert into the tree. Return the root node of the BST after the
# insertion. It is guaranteed that the new value does not exist in the
# original BST.
# Notice that there may exist multiple valid ways for t... | true |
665b37f3e85a2bdffac567069351cfb071b1322e | DmitryVlaznev/leetcode | /970-powerful-integers.py | 1,683 | 4.15625 | 4 | # 970. Powerful Integers
# Medium
# Given three integers x, y, and bound, return a list of all the
# powerful integers that have a value less than or equal to bound.
# An integer is powerful if it can be represented as x^i + y^j for some
# integers i >= 0 and j >= 0.
# You may return the answer in any order. In you... | true |
6ad55eb0f4b036b0c33b0f00dc24de6cd29714cb | DmitryVlaznev/leetcode | /116-populating-next-right-pointers-in-each-node.py | 2,141 | 4.125 | 4 | # 116. Populating Next Right Pointers in Each Node
# You are given a perfect binary tree where all leaves are on the same
# level, and every parent has two children. The binary tree has the
# following definition:
# struct Node {
# int val;
# Node *left;
# Node *right;
# Node *next;
# }
# Populate each next ... | true |
e4f730d10a30032bce93d1b61c55e741cde27889 | DmitryVlaznev/leetcode | /1704-determine-if-string-halves-are-alike.py | 1,730 | 4.15625 | 4 | # 1704. Determine if String Halves Are Alike
# Easy
# You are given a string s of even length. Split this string into two
# halves of equal lengths, and let a be the first half and b be the
# second half.
# Two strings are alike if they have the same number of vowels ('a',
# 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', '... | true |
9e0bd15c3f7a2e572618ffc85fdffde3d8579b0a | MicheSi/cs-bw-unit2 | /balanced_brackets.py | 2,142 | 4.125 | 4 | '''
Write function that take string as input. String can contain {}, [], (), ||
Function return boolean indicating whether or not string is balance
'''
table = { ')': '(', ']':'[', '}':'{' }
for _ in range(int(input())):
stack = []
for x in input():
if stack and table.get(x) == stack[-1]:
... | true |
c317269d86f21534edc00ce2e66e14e2e3b790bd | MicheSi/cs-bw-unit2 | /search_insert_position.py | 1,016 | 4.125 | 4 | '''
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You may assume no duplicates in the array.
Example 1:
Input: [1,3,5,6], 5
Output: 2
Example 2:
Input: [1,3,5,6], 2
Output: 1
Example 3:
Input: [1,3,5,6], 7
... | true |
88cf81dc127010d9bec8fd09d916a1ddeee26a8e | akimi-yano/algorithm-practice | /tutoring/mockClassmates/officehour_mock2.py | 819 | 4.28125 | 4 | # Valid Palindrome Removal
# Return true if the input is a palindrome, or can be a palindrome with no more than one character deletion.
# Zero characters can be added.
# Return false if the input is not a palindrome and removing any one character from it would not make it a palindrome.
# Must be done in constant space... | true |
2b0f70093994c026f521f5936967fcc887c74444 | akimi-yano/algorithm-practice | /lc/1870.MinimumSpeedToArriveOnTime.py | 2,783 | 4.21875 | 4 | # 1870. Minimum Speed to Arrive on Time
# Medium
# 152
# 49
# Add to List
# Share
# You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n trains in sequential order. You are also given an integer array dist of length n, wh... | true |
683bd029ec511e1c2868af454303d95065e93c23 | akimi-yano/algorithm-practice | /lc/438.FindAllAnagramsInAString.py | 1,687 | 4.25 | 4 | # 438. Find All Anagrams in a String
# Medium
# 6188
# 235
# Add to List
# Share
# Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order.
# An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typi... | true |
beda2c8b84bfa3be65e93edacf33c71c524f2718 | akimi-yano/algorithm-practice | /lc/isTreeSymmetric.py | 2,043 | 4.34375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
# 101. Symmetric Tree
# Easy
# Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
# For example, this binary tree... | true |
0f4bfcbc1f59afbb95c2a2d112b72e1f34c798d0 | akimi-yano/algorithm-practice | /lc/111.MinimumDepthOfBinaryTree.py | 2,149 | 4.125 | 4 | # 111. Minimum Depth of Binary Tree
# Easy
# 1823
# 759
# Add to List
# Share
# Given a binary tree, find its minimum depth.
# The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
# Note: A leaf is a node with no children.
# Example 1:
# Input: r... | true |
a770ed5446cb22606122f0d55488d58aff374679 | akimi-yano/algorithm-practice | /examOC/examWeek1.py | 2,868 | 4.15625 | 4 |
# Week1 Exam
# Complete the 'mergeArrays' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts following parameters:
# 1. INTEGER_ARRAY a
# 2. INTEGER_ARRAY b
# merge two sorted arrays
def mergeArrays(a, b):
ans = []
i = 0
k = 0
while len(a)>i and len(b... | true |
94d942c6bc11ceb1a8919f193e31a186f1a90658 | akimi-yano/algorithm-practice | /lc/154.FindMinimumInRotatedSortedAr.py | 2,593 | 4.15625 | 4 | # 154. Find Minimum in Rotated Sorted Array II
# Hard
# 2147
# 315
# Add to List
# Share
# Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become:
# [4,5,6,7,0,1,4] if it was rotated 4 times.
# [0,1,4,4,5,6,7] if it was ro... | true |
448467cb0445f9e81c67e1c29ff29d4545a47b88 | akimi-yano/algorithm-practice | /lc/UniquePaths.py | 2,518 | 4.40625 | 4 | # latice path unique path problems are different problems !
# difference :
# lattice path - counting the edges
# robot unique path - counting the boxes (so -1)
# also for lattice path,
# instead of doing this ----
# if m == 0 and n == 0:
# return 1
# elif m<0 or n<0:
# return 0
# you ... | true |
201e5eb0545be43fceece844312c43566b1e0818 | akimi-yano/algorithm-practice | /oc/328_Odd_Even_Linked_List.py | 2,239 | 4.1875 | 4 | # 328. Odd Even Linked List
'''
Given a singly linked list, group all odd nodes together
followed by the even nodes.
Please note here we are talking about the node number and
not the value in the nodes.
You should try to do it in place. The program should run in O(1)
space complexity and O(nodes) time complexity.... | true |
241ca9304d4b204bfa717ea366abdb73046e7547 | akimi-yano/algorithm-practice | /lc/1338.ReduceArraySizeToTheHalf.py | 1,686 | 4.15625 | 4 | # 1338. Reduce Array Size to The Half
# Medium
# 767
# 64
# Add to List
# Share
# Given an array arr. You can choose a set of integers and remove all the occurrences of these integers in the array.
# Return the minimum size of the set so that at least half of the integers of the array are removed.
# Example 1... | true |
323585745e2d7f83533a0c8b7273619c21b8ff2b | akimi-yano/algorithm-practice | /lc/1936.AddMinimumNumberOfRungs.py | 2,606 | 4.28125 | 4 | # 1936. Add Minimum Number of Rungs
# Medium
# 123
# 9
# Add to List
# Share
# You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung.
# You are also given an integer dist. You can only... | true |
a316b2d14a524e00985fd59c54d58595f3c2c4a7 | ARWA-ALraddadi/python-tutorial-for-beginners | /02-How to Use Pre-defined Functions Demos/2-random_numbers.py | 1,626 | 4.53125 | 5 | #---------------------------------------------------------------------
# Demonstration - Random Numbers
#
# The trivial demonstrations in this file show how the
# functions from the "random" module may produce a different
# result each time they're called
# Normally when we call a function with the same parameters
# ... | true |
15e88757e99a4285445e4641ff9e86df0c9ff134 | ARWA-ALraddadi/python-tutorial-for-beginners | /03-Workshop/Workshop-Solutions/fun_with_flags.py | 1,564 | 4.28125 | 4 | #--------------------------------------------------------------------
#
# Fun With Flags
#
# In the lecture demonstration program "stars and stripes" we saw
# how function definitions allowed us to reuse code that drew a
# star and a rectangle (stripe) multiple times to create a copy of
# the United States flag.
#
# As... | true |
de5d83e72f9e97e33665e635fd5099dcfb4bec07 | ARWA-ALraddadi/python-tutorial-for-beginners | /06-How to Create User Interfaces Demos/02-frustrating_button.py | 1,076 | 4.40625 | 4 | #----------------------------------------------------------------
#
# Frustrating button
#
# A very simple demonstration of a Graphical User Interface
# created using Tkinter. It creates a window with a label
# and a frustrating button that does nothing.
#
# Import the Tkinter functions
from tkinter import *
# Creat... | true |
d49423bc7fc93a65763555efc2a9e6aec0ccf1a1 | ARWA-ALraddadi/python-tutorial-for-beginners | /10-How to Stop Programs Crashing Demos/0-mars_lander_V5.py | 2,361 | 4.46875 | 4 | #--------------------------------------------------------------------#
#
# Mars lander example - Exception handling
#
# This simple program allows us to experiment with defensive
# programming, assertions and exception handling. It is based on
# a real-life example in which a software failure caused
# a Mars lander to ... | true |
15eaf7c1be83f2636e171211a049ceda21eb2fe5 | ARWA-ALraddadi/python-tutorial-for-beginners | /03-Workshop/Workshop-Solutions/olympic_rings.py | 2,327 | 4.5625 | 5 | #-------------------------------------------------------------------------
#
# Olympic Rings
#
# In this folder you will find a file "olympic_rings.pdf" which shows
# the flag used for the Olympics since 1920. Notice that this flag
# consists of five rings that differ only in their position and colour.
# If we wa... | true |
43aaf6575d5a423e006fbe4360972d2868e7a8ff | ARWA-ALraddadi/python-tutorial-for-beginners | /08-How to Find Things Demos/08-replacing_patterns.py | 2,598 | 4.3125 | 4 | ## Replacing patterns
##
## The small examples in this demonstration show how regular
## expressions with backreferences can be used to perform
## automatic modifications of text.
from re import sub
## This example shows how to "normalise" a data representation.
## A common problem at QUT is that student numbe... | true |
d69866a1cf193e6eed2cc8abfad5b9a5c6653777 | ARWA-ALraddadi/python-tutorial-for-beginners | /01-Workshop/Workshop-Solutions/cylinder_volume.py | 939 | 4.4375 | 4 | # Volume of a cylinder
#
# THE PROBLEM
#
# Assume the following values have already been entered into the
# Python interpreter, denoting the measurements of a cylindrical
# tank:
radius = 4 # metres
height = 10 # metres
# Also assume that we have imported the existential constant "pi"
# from the "math" library module... | true |
4a1039d67f5927daf41b2aa86fde4cf9d7ead6a8 | ARWA-ALraddadi/python-tutorial-for-beginners | /10-How to Stop Programs Crashing Demos/0-mars_lander_V0.py | 2,269 | 4.34375 | 4 | #--------------------------------------------------------------------#
#
# Mars lander example - No error handling
#
# This simple program allows us to experiment with defensive
# programming, assertions and exception handling. It is based on
# a real-life example in which a software failure caused
# a Mars lander to c... | true |
70d2912f7acbaa964fa09f0d17f11f96a5e3fb26 | ARWA-ALraddadi/python-tutorial-for-beginners | /05-How to Repeat Actions demos/09-uniqueness.py | 1,090 | 4.46875 | 4 | #--------------------------------------------------------------------#
#
# Uniqueness test
#
# As an example of exiting a loop early, here we develop a small
# program to determine whether or not all letters in some text
# are unique. It does so by keeping track of each letter seen and
# stopping as soon as it sees a l... | true |
101c4d993889264c4e592564584242cb96e85754 | ARWA-ALraddadi/python-tutorial-for-beginners | /12-How to do more than one thing Demos/B_scribbly_turtles.py | 1,501 | 4.71875 | 5 | #--------------------------------------------------------------------#
#
# Scribbly turtles
#
# As a simple example showing that we can create two independent
# Turtle objects, each with their own distinct state, here
# we create two cursors (turtles) that draw squiggly lines on the
# canvas separately.
#
# To develop ... | true |
0598e5896c2b92261ac342485f300d5b0af7c907 | ARWA-ALraddadi/python-tutorial-for-beginners | /09-Workshop/print_elements.py | 2,663 | 4.84375 | 5 | #---------------------------------------------------------
#
# Print a table of the elements
#
# In this exercise you will develop a Python program that
# accesses an SQLite database. We assume that you have
# already created a version of the Elements database using
# the a graphical user interface. You can do so by ... | true |
189cbe4c2f6cb9b263e5c6f7fba1571040478428 | ARWA-ALraddadi/python-tutorial-for-beginners | /08-How to Find Things Demos/01-wheres_Superman.py | 1,804 | 4.65625 | 5 | #---------------------------------------------------------------------
#
# Where's Superman?
#
# To illustrate how we can find simple patterns in a text file using
# Python's built-in "find" method, this demonstration searches for
# some patterns in an HTML file.
#
# Read the contents of the file as a single string
te... | true |
5c6f7af9847b7112297337f1dd5199f9ba6bb97e | ARWA-ALraddadi/python-tutorial-for-beginners | /04-How to Make Decisions Demos/15-un-nesting.py | 1,389 | 4.40625 | 4 | #---------------------------------------------------------------------
#
# "Un-nesting" some conditional statements
#
# There are usually multiple ways to express the
# same thing in program code. As an instructive
# exercise in using conditional statements, consider
# the code below which decides whether or not
# an ... | true |
3a2ad3460b8151fc7df5ae3232b315b6c5dc9cab | ARWA-ALraddadi/python-tutorial-for-beginners | /03-How to Create Reusable Code Demos/07-ref_transparency.py | 1,735 | 4.21875 | 4 | #---------------------------------------------------------------------
#
# Demonstration - Referential transparency
#
# The small examples in this file illustrate the meaning of
# "referentially transparent" function definitions. A
# function that is referentially transparent always does this
# same thing when given t... | true |
d8d0afeca8c35fdfa370f32af41f0ce66e670e58 | ARWA-ALraddadi/python-tutorial-for-beginners | /01-Workshop/Workshop-Questions/01_repair_cost.py | 854 | 4.21875 | 4 | # Total repair cost
#
# THE PROBLEM
#
# Assume the following values have already been entered into the
# Python interpreter, representing the vehicle repair costs in dollars
# from several suppliers following a motor accident, and the deposit
# paid for the work:
panel_beating = 1500
mechanics = 895
spray_painting = 5... | true |
072d4198ea1dea7962646af90a14f36fc72bbf81 | ARWA-ALraddadi/python-tutorial-for-beginners | /10-How to Stop Programs Crashing Demos/0-mars_lander_V1.py | 2,045 | 4.65625 | 5 | #--------------------------------------------------------------------#
#
# Mars lander example - Checking input validity
#
# This simple program allows us to experiment with defensive
# programming, assertions and exception handling. It is based on
# a real-life example in which a software failure caused
# a Mars lande... | true |
d4e19d058a7a7ea4f0d66467c19c15cfd3d510d9 | DiogoBispo/python | /funcao_duplicados.py | 1,575 | 4.28125 | 4 | """
-> é uma lista de listas de numeros inteiros
-> as listas internas tem o tamanho de 10 elementos
-> as listas internas contem numeros entre 1 a 10 e eles
podem ser duplicados
Exercicio
-> Crie uma função que controla o primeiro duplicado considerando
o segundo numero como a duplicação:
requisitos:
... | false |
3b1778872c9c7cf1a01f97d34413637fbd846720 | n1k-n1k/python-algorithms-and-data-structures--GB-interactive-2020 | /unit_01_algorithms_intro/hw/hw_01_5.py | 311 | 4.125 | 4 | """
Пользователь вводит номер буквы в алфавите.
Определить, какая это буква.
"""
letter_pos = int(input('Введите номер латинской буквы в алфавите: '))
print(f'Ваша буква: {chr(letter_pos + ord("a") - 1)}')
| false |
73febf1c1bf6a8d35dc50afbedd76b2df8bb2da4 | RohanNankani/Computer-Fundamentals-CS50 | /Python/mad_lib_theatre.py.py | 2,357 | 4.25 | 4 | # Author: Rohan Nankani
# Date: November 11, 2020
# Name of Program: MadLibTheater
# Purpose: To create a mad lib theater game which ask user for input, store their input using list, and print the story.
# Intializing the list
grammar = []
# List of prompts that describe the category of the next word
# to be substit... | true |
17856f57c910a767dfc433a16fbe31b365e3e870 | sp3arm4n/OpenSource-Python | /assignment_01/src/p10.py | 364 | 4.46875 | 4 | # step 1. asks the user for a temperature in Fahrenheit degrees and reads the number
number = float(input("please enter Fahrenheit temperature: "))
# step 2. computes the correspodning temperature in Celsius degrees
number = (number - 32.0) * 5.0 / 9.0
# step 3. prints out the temperature in the Celsius scale.
... | true |
45497bbe4e6c706c4f79e8be82bc586cc78331e3 | DarkCodeOrg/python-learning | /list.py | 288 | 4.21875 | 4 | #!/bin/python python3
""" creating an empty list and adding elements to it"""
list = []
list.append(200)
list.append("salad")
list.append("maths")
print(list)
print("this is your initial list")
new = input("Enter something new to the list: ")
list.append(new)
print(list)
| true |
192af36327e7984ba16c57dac945182bc92de21a | 2u6z3r0/automate-boaring-stuff-with-python | /inventory.py | 1,171 | 4.1875 | 4 | #!/usr/bin/python3
#chapter 5 exercise
stuff = {'gold coin': 42, 'rope': 1}
def displayInventory(stuff):
'''
:param stuff: It takes a dictionary of item name as key and its quantity as value
:return: Nothing, but it prints all items and respective quantity and total quantity(sum of all itmes qty)
'''
... | true |
a767fd70f5fedac106f3aca0b8b48b41d38a2a8e | NATHAN76543217/BtCp_D00 | /ex03/count.py | 1,005 | 4.28125 | 4 | import string
def text_analyzer(*text):
"""
This function counts the number of upper characters,
lower characters, punctuation and spaces in a given text.
"""
if len(text) > 1:
print("ERROR")
return
if len(text) == 0 or isinstance(text[0], str) == 0:
text = []
t... | true |
75e70e3300181dfb1dd71800fa0bc5d7ca4f2aa2 | valdialva/Topicos-1 | /Labs/Lab1.py | 1,610 | 4.1875 | 4 | #1. Create first name and add last name with join
print ("1")
n = "Alvaro"
print (n)
n = ''.join([n, " Valdivieso"])
print (n)
#2. convert tu uppercase
print ("2")
n = n.upper()
print (n)
#3. create list with n
print ("3")
l = list(n)
print (l)
print (len(l))
#4. create string from l
print ("4")
m = ''.join(l)
print... | false |
cf2553bafad225366a58d08ab9a8edc6b4daa9d2 | Ayush900/django-2 | /advcbv2/basic_app/templates/basic_app/pythdjango/oops.py | 807 | 4.40625 | 4 | #class keyword is used to create your own classes in python ,just like the sets,lists,tuples etc. .these classes are also known as objects and this type of programming involving the creation of your own classes or objects is known as object oriented programming or oops....#
class football_team: #Here the ... | true |
e98ba84add2519f4c3858cef105c6e5de54f57fb | jonathangriffiths/Euler | /Page1/SumPrimesBelowN.py | 612 | 4.15625 | 4 | __author__ = 'Jono'
from GetPrimeN import isPrime
#basic method to estimate how long it will take like this
def get_sum_primes_below_n(n):
sum=2
for i in range(3, n+1, 2):
if isPrime(i):
sum+=i
return sum
print get_sum_primes_below_n(2000000)
#note: Erastosthenes seive useful for ... | true |
af32475e446f1ddc7e65cb90040a567a21ac5d85 | tchaitanya2288/pyproject01 | /Simple if.py | 421 | 4.15625 | 4 | #1. The 1. if 2. if..else , 3. elif and 4. neasted elif
#1. IF Statement:
my_var=50
#50 < 100:
if my_var<100:
print(my_var,'is less then 100')
print ("We are out of the if statement")
#The if statement is used for conditional execution:
#if_stmt ::= "if" expression ":" suite
#(or)
my_var=50
if my_var<... | false |
6f5e0be8179eee4ea15eeb31baf53954cf803678 | tchaitanya2288/pyproject01 | /simple Elseif.py | 699 | 4.15625 | 4 | """
3. NESTED IF-ELSE STATEMENT :
>>> ord('A')
65
>>> ord("Z")
90
>>> ord('a')
97
>>> ord("z")
122
"""
char=input("Please enter any charcter : ")
if ord(char)>=65 and ord(char)<=90:
print ("You entered an upper case alphabet")
if char in ['A','E','I','O','U']:
print ("You entered A vowel.",char)
el... | false |
3dbaed02def20cc1c27d7ed07cce6be97942b78b | za-webdev/Python-practice | /score.py | 425 | 4.25 | 4 |
#function that generates ten scores between 60 and 100. Each time a score is generated,function displays what the grade is for a particular score.
def score_grade():
for x in range(1,11):
import random
x=(random.randint(60,100))
if x >60 and x<70:
z="D"
elif x>70 and x<80:
z="C"
elif x>80 and x<90:
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.