blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
fbc4ac57f264a917f6b57f50991be8360191af16 | euggrie/w3resources_python_exercises | /Strings/exercise14.py | 822 | 4.25 | 4 | ###############################
# #
# Exercise 14 #
# www.w3resource.com #
###############################
... | true |
e0d3ed27dd48792145a724db61e2ecb9ab9c66a6 | euggrie/w3resources_python_exercises | /Basic/exercise12.py | 794 | 4.25 | 4 | ###############################
# #
# Exercise 12 #
# www.w3resource.com #
###############################
... | true |
7e0c0e825e7db2e8d1f4d6690d5def4791b288b5 | euggrie/w3resources_python_exercises | /Strings/exercise10.py | 816 | 4.25 | 4 | ###############################
# #
# Exercise 10 #
# www.w3resource.com #
###############################
... | true |
0962e1e56e5f9eb01a86f2fdf8d34dac129c65f2 | euggrie/w3resources_python_exercises | /Strings/exercise11.py | 685 | 4.34375 | 4 | ###############################
# #
# Exercise 11 #
# www.w3resource.com #
###############################
... | true |
608e1f2ebe4482e6bffbd075df0b6f6725fd361c | nedssoft/Graphs | /projects/ancestor/ancestor.py | 1,823 | 4.125 | 4 |
from queue import Queue
from graph import Graph
def earliest_ancestor(ancestors, starting_node):
# Initialize a graph
graph = Graph()
# build a graph of the parents and children
# Iterate over ancestors' tuple (parent, child)
for parent, child in ancestors:
# check if the parent is not in... | true |
7094a2cb97ee65161af28d73c8610185cd91c752 | avin82/Python_foundation_with_data_structures | /swap_alternate.py | 1,095 | 4.59375 | 5 | # PROGRAM swap_alternate:
'''
Given an array of length N, swap every pair of alternate elements in the array.
You don't need to print or return anything, just change in the input array itself.
Input Format:
Line 1 : An Integer N i.e. size of array
Line 2 : N integers which are elements of the array, separated by spa... | true |
f3950dd5cf075f54278cd721781cceec557ac1fc | avin82/Python_foundation_with_data_structures | /bubble_sort.py | 1,020 | 4.5625 | 5 | # PROGRAM bubble_sort:
'''
Given a random integer array. Sort this array using bubble sort.
Change in the input array itself. You don't need to return or print elements.
Input format:
Line 1 : Integer N, Array Size
Line 2 : Array elements (separated by space)
Constraints :
1 <= N <= 10^3
Sample Input 1:
7
2 13 4 1 ... | true |
edfee79b2601268c1de74fbfbd9e40a7260451b4 | avin82/Python_foundation_with_data_structures | /array_intersection.py | 1,456 | 4.28125 | 4 | # PROGRAM array_intersection:
'''
Given two random integer arrays of size m and n, print their intersection. That is, print all the elements that are present in both the given arrays.
Input arrays can contain duplicate elements.
Note : Order of elements are not important
Input format:
Line 1 : Array 1 Size
Line 2 : ... | true |
9e7978f32832e2912c2136be6adb0de6c81f2ad3 | avin82/Python_foundation_with_data_structures | /find_reverse_of_num.py | 754 | 4.5 | 4 | # PROGRAM find_reverse_of_num:
'''
Write a program to generate the reverse of a given number N. Print the corresponding reverse number.
Input format:
Integer N
Constraints:
Time Limit: 1 second
Output format:
Corresponding reverse number
Sample Input 1:
1234
Sample Output 1:
4321
Sample Input 2:
1980
Sample Out... | true |
4611752ec19471a7bb892b4c32c689e2ae4f8977 | avin82/Python_foundation_with_data_structures | /check_num_in_array_recursive.py | 1,183 | 4.15625 | 4 | # PROGRAM check_num_in_array_recursive:
'''
Given an array of length N and an integer x, you need to find if x is present in the array or not. Return true or false.
Do this recursively.
Input Format:
Line 1 : An Integer N i.e. size of array
Line 2 : N integers which are elements of the array, separated by spaces
Lin... | true |
ec10db1087d697597551771bc74c157018212c46 | avin82/Python_foundation_with_data_structures | /largest_column_sum_2d_array.py | 1,204 | 4.125 | 4 | # PROGRAM largest_column_sum_2d_array:
'''
Find the column id of the column in a 2D array with largest sum of elements.
Note: Assume that all columns are of equal length.
Input Format:
Line 1: Two integers m and n (separated by space)
Line 2: Matrix elements of each row (separated by space)
Output Format:
Column id... | true |
2bd0589eef540f182bc9e1018e0d2294a2aba576 | avin82/Python_foundation_with_data_structures | /row_wise_sum_2d_array.py | 971 | 4.21875 | 4 | # PROGRAM row_wise_sum_2d_array:
'''
Given a 2D integer array of size M*N, find and print the sum of ith row elements separated by space.
Input Format:
Line 1 : Two integers M and N (separated by space)
Line 2 : Matrix elements of each row (separated by space)
Output Format:
Sum of every ith row elements (separated ... | true |
a8b5f7ee0be1f8e6e198857a2951b86d4eb20a19 | avin82/Python_foundation_with_data_structures | /rotate_array.py | 1,129 | 4.53125 | 5 | # PROGRAM rotate_array:
'''
Given a random integer array of size n, write a function that rotates the given array by d elements (towards left).
Change in the input array itself. You don't need to return or print elements.
Input format:
Line 1 : Integer n (Array Size)
Line 2 : Array elements (separated by space)
Line... | true |
6848e1f8170f7c654e3c39b3abc276a8b13d0cde | avin82/Python_foundation_with_data_structures | /print_1_to_n.py | 381 | 4.1875 | 4 | # PROGRAM print_1_to_n:
################
# Print Module #
################
def print_till_num():
num = int(input("Input number till which you want to print all numbers starting from 1: \n"))
count = 1
while count <= num:
# DO
print(count)
count = count + 1
# ENDWHILE;
# END print_till_num.
###############... | true |
4ff603e25d455dd4a034739c41b4e11bcc982449 | avin82/Python_foundation_with_data_structures | /print_even_between_1_to_n.py | 517 | 4.375 | 4 | # PROGRAM print_even_between_1_to_n:
#####################
# Print Even Module #
#####################
def print_even_till_num_inclusive():
num = int(input("Input number to print all the even numbers between 1 and the entered number both inclusive: \n"))
start = 1
while start <= num:
# DO
if start % 2 == 0:
... | true |
55b84355e66a06f831fc6d7b251f9d41aea28824 | avin82/Python_foundation_with_data_structures | /num_pattern_four.py | 738 | 4.34375 | 4 | # PROGRAM num_pattern_four:
'''
Print the following pattern for the given N number of rows.
Pattern for N = 4
1234
123
12
1
Input format:
Integer N (Total no. of rows)
Output format:
Pattern in N lines
Sample Input:
5
Sample Output:
12345
1234
123
12
1
'''
###############################
# Print Number Pattern ... | true |
5ae50bd68d0f3bb83b1d800afd6985f79c7a5ca3 | evanlamberson/Get-Programming-Python | /Unit 2/Lesson10Q1.py | 1,148 | 4.375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 1 11:49:04 2020
@author: evanlamberson
"""
### Lesson 10 Q10.1
# Write a program that initializes the string word = "echo", the empty tuple
# t = (), and the integer count = 3. Then, write a sequence of commands by
# using the commands you learn... | true |
23275c80bbc961da2e0a3ae055aef01dfd8aa970 | KitsuneNoctus/test_cases_apr15 | /problem_one.py | 1,508 | 4.28125 | 4 | '''
Determine if a word or phrase is an isogram.
An isogram (also known as a "nonpattern word") is a word or phrase without a
repeating letter, however spaces and hyphens are allowed to appear multiple times.
Examples of isograms:
lumberjacks
background
downstream
six-year-old
The word isograms, how... | true |
21a26951cef5a26ec8a74a8ab0c5a639b1c835a0 | ChiragPatelGit/PythonLearningProjects | /Numbers_Processor.py | 416 | 4.1875 | 4 | # Numbers Processor
line = input("Enter a line of numbers - separate them with spaces:")
strings = line.split()
total = 0
substr =''
# print("strings is: ", strings)
try:
for substr in strings:
total += float(substr)
if len(strings) <= 0:
print("There was nothing to total")
els... | true |
893a41c7e43a09215a51fd1e2f5e62b55d402d89 | sanatanghosh/python-programs | /basic/nestedifelse.py | 208 | 4.28125 | 4 | x =int(input("enter a number"))
if x>=0:
if x == 0:
print("the number is neither positive nor negative")
else:
print("the number is positive")
else:
print("the number is negative") | true |
75b4368dce79e4beebd0fd3771ac7bcaa1aadfbf | albertogeniola/Corso-Python-2019 | /Lecture 6/0. Simple adder.py | 365 | 4.125 | 4 | print("I am a nice adder. Please input two numbers and I will sum them")
addend_1 = input("First number:")
addend_2 = input("Second number:")
if not addend_1.isdigit() or not addend_2.isdigit():
print("Sorry: one of the inputs does not seem to be a valid integer number.")
else:
result = int(addend_1) + int(adde... | true |
a874557ed91313e3f4737e4c268e57053c771675 | AyanUpadhaya/Basic-Maths | /primenumber.py | 426 | 4.15625 | 4 | #Python Program to Find Prime Number using For Loop
#Any natural number that is not divisible by any other number except 1 and itself
#called Prime Number.
user_num=int(input("Enter a number:"))
def is_prime(num):
count=0
for i in range(2,(num//2+1)):
if num%i==0:
count+=1
break
if count==0 and num!=1:
... | true |
0418a7679705377379b20f6364f66a708b530126 | Kireetinayak/Python_programs | /Programs/Map/Find length.py | 404 | 4.25 | 4 | #The map() function applies a given function to each item of an iterable
def myfunc(n):
return len(n)
x = map(myfunc, ('apple', 'banana', 'cherry'))
print((list(x)))
def myfunc(a, b):
return a + b
x = map(myfunc, ('apple', 'banana', 'cherry'), ('orange', 'lemon', 'pineapple'))
print(list(x))
def myfunc(n):
... | true |
ec1a3f80df71a70088ab4833f709f0d842d43e8a | lalit97/DSA | /graph/topological-practice.py | 993 | 4.1875 | 4 | '''
https://www.youtube.com/watch?v=n_yl2a6n7nM
https://www.geeksforgeeks.org/topological-sorting/
https://practice.geeksforgeeks.org/problems/topological-sort/1
https://medium.com/@yasufumy/algorithm-depth-first-search-76928c065692
'''
def topoSort(n, graph):
visited = set()
stack = []
# given that no... | true |
c6f22a8617bdb7a869f72691c2b2902cb3daf719 | lgomezm/daily-coding-problem | /python/problem02.py | 640 | 4.15625 | 4 | # This problem was asked by Uber.
# Given an array of integers, return a new array such that each element
# at index i of the new array is the product of all the numbers in the
# original array except the one at i.
# For example, if our input was [1, 2, 3, 4, 5], the expected output
# would be [120, 60, 40, 30, 24].... | true |
2d5b885fd31a1e2761d76751b70ce097a49c59f7 | lgomezm/daily-coding-problem | /python/problem08.py | 1,412 | 4.28125 | 4 | # This problem was asked by Google.
# A unival tree (which stands for "universal value") is a tree where
# all nodes under it have the same value.
# Given the root to a binary tree, count the number of unival subtrees.
# For example, the following tree has 5 unival subtrees:
# 0
# / \
# 1 0
# / \
# 1 0
# ... | true |
e53d9addeb038d020ce876f0cf59e0c2aa8fe5df | vishalpatil0/Python-cwh- | /class in python.py | 845 | 4.21875 | 4 | #class is nothing but a template to store data
#object is the instance of the class by using object we can acces the elemnt of the class
class student:
no_of_leaves=9
pass #pass means nothing
vishal=student() #this is the way to create object in python
namrata=student()
print(f"memory location of object = ... | true |
0c052658817903571506e47e54de3ee109626501 | noelleirvin/PythonProblems | /Self-taught Programmer/Ch7/Ch7_challenges.py | 1,121 | 4.28125 | 4 | #CHAPTER 7
# 1. Print each item in the following list
listOfItems = ["The Walking Dead", "Entourage", "The Sopranos", "The Vampire Diaries"]
for show in listOfItems:
print(show)
# 2. Print all numbers from 25 to 50
# for i in range(25, 51):
# print(i)
# 3. Print each item in the list from the first challenge... | true |
f1468cee8de26ee04f98e0d0678ed42f69ce97a3 | dabideee13/exercises-python | /mod3_act3.py | 851 | 4.46875 | 4 | # mod3_act3.py
"""
Tasks
1. Write a word bank program.
2. The program will ask to enter a word.
3. The program will store the word in a list.
4. The program will ask if the user wants to try again. The user will
input Y/y if Yes and N/n if No.
5. If Yes, refer to step 2.
6. If No, display the total number of words... | true |
c42892dd50b96c6463b899870b52fd9ffb868bc0 | sagar412/Python-Crah-Course | /Chapter_8/greet.py | 533 | 4.1875 | 4 | # Program for greeter example using while loop, Chapter 8
def greet(first_name,last_name):
person = f"{first_name} {last_name}"
return person
while True:
print("Please enter your name and enter quit when you are done.")
f_name = input("\n Please enter your first name.")
if f_name == 'quit':
b... | true |
6e94da1bcafeb70de4cdaab83ae5f5281cdd3182 | rahulbhatia023/python | /08_Operators.py | 1,090 | 4.375 | 4 | # Arithmetic Operators
print(2 + 3)
# 5
print(9 - 8)
# 1
print(4 * 6)
# 24
print(8 / 4)
# 2.0
print(5 // 2)
# Floor Division (also called Integer Division) : Quotient when a is divided by b, rounded to the next smallest whole
# number
# 2
print(2 ** 3) # Exponentiation : a raised to the power of b
# 8
print(10 ... | true |
2cab37f6a7ea4fab967566286837d961b28a5a1a | MattAllen92/Data-Science-Basics | /Practice and Notes/The Self-Taught Programmer/Second Script.py | 2,479 | 4.21875 | 4 | # 1) Basic Functions
#def square(x, y=5):
# """
# Returns the square of the input
# :param x: int
# """
# return (x ** 2) + y
#
#print square(3)
#print square(4,2)
#print square.__doc__
#def str_to_float(x):
# try:
# return float(x)
# except:
# print("Cannot convert i... | true |
6066100934e59f803128f3415a1e9a25db9889cd | arahaanarya/PythonCrashCourse2ndEdition.6-1.Person.py | /Main.py | 472 | 4.40625 | 4 | # Use a dictionary to store information about a person
# you know. Store their first name, last name, age, and
# the city in which they live. You should have keys
# such as first_name, last_name, age, and city. Print
# each piece of information stored in your dictionary.
parents = {
"first_name": "Bruce",
"las... | true |
ad58c95139fd4a8c5da75c239dcbc5d38290312e | ShaneyMantri/Algorithms | /Binary Search/Minimum_Number_of_Days_to_Make_m_Bouquets.py | 2,421 | 4.15625 | 4 | """
Given an integer array bloomDay, an integer m and an integer k.
We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.
The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.
Return the minimum number ... | true |
7be9816c8fdb2e9c859b119dc729eb525b2e861f | danielbrenden/Learning-Python | /RemoveDuplicatesFromList.py | 290 | 4.34375 | 4 | # This program removes duplicates from a list of numbers via the append method and prints the result.
numbers = [2, 4, 5, 6, 5, 7, 8, 9, 9]
unique_numbers = []
for number in numbers:
if number not in unique_numbers:
unique_numbers.append(number)
print (unique_numbers)
| true |
f9b1a50f006459852fb2bc4314a8f23ba191b37b | bhavik89/CourseraPython | /CourseEra_Python/Rock_Paper_Scissors.py | 2,301 | 4.1875 | 4 | #Mini Project 2:
# Rock-paper-scissors-lizard-Spock program
# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
# library function random is imported to generate random numbe... | true |
001932fff07cf23900f82da599f858f4045951f1 | Shubhamrawat5/Python | /iterator-generator.py | 643 | 4.1875 | 4 | #ITERATOR : gives values one by one by next(iterator_object)
l=[6,4,7,9,0]
it = iter(l) #creating iterator object of list
print(next(it)) #next is function to go to next element
print(next(it))
for i in it: #loop with iterator object
print(i)
'''output:- (6 and 4 printed only once)
6
4
7
9
0
[Program finished]'''... | true |
f64f2cb09a7d6381ec1eb735d210f686d02eccb7 | decolnz/HS_higher_level_programming | /0x07-python-test_driven_development/4-print_square.py | 581 | 4.34375 | 4 | #!/usr/bin/python3
"""
print_square - prints a square with #
size: size of the square
"""
def print_square(size):
"""
Method to print a square
"""
error1 = "size must be an integer"
error2 = "size must be >= 0"
if not (isinstance(size, int)):
raise TypeError(error1)
if size < 0:
... | true |
eb2b3310bf51435dd8120f3d878bea9f1ac588e2 | vishal-1codes/python | /PYTHON LISTS_AND_DICTIONARIES/Maintaining_Order.py | 392 | 4.40625 | 4 | #In this code we find out index of any element
#using .index("name")
#also we insert element using index and value
#eg - animals.insert(2,"cobra")
animals = ["aardvark", "badger", "duck", "emu", "fennec fox"]
duck_index = animals.index("duck")# Use index() to find "duck"
# Your code here!
animals.insert(duck_index,"... | true |
1aadd3ce06ed65bb043a63c94fde435c90cd98e5 | vishal-1codes/python | /PRACTICE_MAKES_PERFECT/digit_sum.py | 436 | 4.1875 | 4 | #In below example we first get input as a string then we apply for loop for each element in that can be join with + and also convert string element to int then return total.
def digit_sum(n):
total = 0
string_n = str(n)
for char in string_n:
total += int(char)
return total
#Alternate Solution:
#def digit_... | true |
d829d4b8c7a6f701ce066d40df1ad2f870b78e88 | sachins0023/tarzanskills | /day-2.py | 1,929 | 4.5 | 4 | print("I will now count my chickens: ") #I will now count my chickens:
print("Hens", 25+30/6) #Hens 30.0
print("Roosters",100-25*3%4) #Roosters 97
print("Now I will count the eggs: ") #Now I will count the eggs:
print(3+2+1-5+4%2-1/4+6) #6.75
print("Is it true that 3+2<5-7?... | true |
1a28f0d4d473cf62088c578f425f40619ecf838c | wtakang/class_2 | /projects/alarm_clock/alarm_clock.py | 973 | 4.1875 | 4 | #!/home/tanyi/development/pythonclass/class_2/projects/alarm_clock/bin/python3
from time import sleep
from datetime import datetime
import winsound
def set_alarm():
print('your current time is:',datetime.now().strftime('%H:%M')) # print the current time to the user before the alarm
min = int(input("Enter... | true |
eba00dc827e5fdf4bd5098872802f18decbbdf7d | kennyestrellaworks/100-days-of-code-the-complete-python-pro-bootcamp-for-2021 | /Day 3/Day-3-4-Exercise- Pizza Order/day-3-4-exercise-pizza-order.py | 1,308 | 4.25 | 4 | # 🚨 Don't change the code below 👇
print("Welcome to Python Pizza Deliveries!")
size = input("What size pizza do you want? S, M, or L\n")
add_pepperoni = input("Do you want pepperoni? Y or N\n")
extra_cheese = input("Do you want extra cheese? Y or N\n")
# 🚨 Don't change the code above 👆
#Write your code below this ... | true |
a5f6ff9d546893c2b6552aaaddb324a1bf33b7d9 | kennyestrellaworks/100-days-of-code-the-complete-python-pro-bootcamp-for-2021 | /Day 4/Day-4-3-Exercise- Treasure Map/day-4-3-exercise-treasure-map.py | 781 | 4.28125 | 4 | # 🚨 Don't change the code below 👇
row1 = ["⬜️","⬜️","⬜️"]
row2 = ["⬜️","⬜️","⬜️"]
row3 = ["⬜️","⬜️","⬜️"]
map = [row1, row2, row3]
print(f"{row1}\n{row2}\n{row3}")
position = input("Where do you want to put the treasure?\n")
# 🚨 Don't change the code above 👆
#Write your code below this row 👇
empty = []
for x in ... | true |
7d92cd6287d39e641878f860c4b17b0b6d6c3048 | GarciaCS2/CSE | /GABRIELLA - GAMES/Beginner Programs/Gabriella - Hangperson, Shorter program (Beginner).py | 2,452 | 4.21875 | 4 | import random
setup = [0, 1, 2, 3]
counted_letters = [] # 0 = right_letter_count, 1 = guesses, 2 = doubles, 3 = letters_required
word_bank = ["cat", "edison", "donut", "zebra", "travel", "humor", "python", "computer", "number", "aerobic",
"math", "cow", "dog", "snow", "cake", "cough", "list", "binary", "c... | true |
f4433e3e99a94d3843f29b63463c1368bd85db17 | clash402/turtle-race | /main.py | 1,161 | 4.25 | 4 | from turtle import Turtle, Screen
import random
# PROPERTIES
screen = Screen()
screen.setup(width=500, height=400)
colors = ["red", "orange", "yellow", "green", "blue", "purple"]
random.shuffle(colors)
turtles = []
pos_y = -145
for color in colors:
turtle = Turtle("turtle")
turtle.shapesize(2)
turtle.c... | true |
53a5767fd1c27c87a91f94bfb7a42ae802ec4136 | Jacquelinediaznieto/PythonCourse | /final-project/final-project.py | 1,531 | 4.15625 | 4 | #Ask tJhe player name and store
player_name = input('What is your name? ')
#This is a list made up of questions and answers dictionaries
questions = [
{"question": "What is the capital of Germany? ",
"answer": "berlin"},
{"question": "What is the capital of Spain? ",
"answer": "madr... | true |
eaa246a72872b0f43a823f09db327c69202a9ad6 | sarkarChanchal105/Coding | /Leetcode/python/Medium/minimum-lines-to-represent-a-line-chart.py | 2,995 | 4.3125 | 4 | """
https://leetcode.com/problems/minimum-lines-to-represent-a-line-chart/
2280. Minimum Lines to Represent a Line Chart
Medium
185
368
Add to List
Share
You are given a 2D integer array stockPrices where stockPrices[i] = [dayi, pricei] indicates the price of the stock on day dayi is pricei. A line chart is create... | true |
7475f1052d034bb82d231b1bc45659bf391b9cc5 | sarkarChanchal105/Coding | /Leetcode/python/Easy/matrix-diagonal-sum.py | 1,521 | 4.40625 | 4 | """
https://leetcode.com/problems/matrix-diagonal-sum/submissions/
1572. Matrix Diagonal Sum
Easy
1204
22
Add to List
Share
Given a square matrix mat, return the sum of the matrix diagonals.
Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are no... | true |
09cf7d97cc71fa4aba589b07f418609f2a3cd354 | sarkarChanchal105/Coding | /Leetcode/python/Medium/validate-binary-search-tree.py | 1,552 | 4.1875 | 4 | """
https://leetcode.com/problems/validate-binary-search-tree/
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys less than the node's key.
The right subtree of a node contains only nodes with keys gre... | true |
50a0a350fb3aa861a4227044e5ac5e498847875a | Jokers01/Code_Wars | /8kyu/Beginner - Lost Without a Map.py | 391 | 4.1875 | 4 | """
Given and array of integers (x), return the array with each value doubled.
For example:
[1, 2, 3] --> [2, 4, 6]
For the beginner, try to use the map method - it comes in very handy quite a lot so is a good one to know.
"""
#answer
def maps(a):
return [ x * 2 for x in a ]
#or
def maps(a):
new_list = []... | true |
c59add8de30bcc385145236694d7ec330cf386d3 | KristofferFJ/PE | /problems/unsolved_problems/test_196_prime_triplets.py | 1,058 | 4.125 | 4 | import unittest
"""
Prime triplets
Build a triangle from all positive integers in the following way:
1
2 3
4 5 6
7 8 9 1011 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 2829 30 31 32 33 34 35 3637 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63 64 65 66
. . .
Each positive in... | true |
e3b20e979229a6f595e54a66003687e9e9de1ea3 | KristofferFJ/PE | /problems/unsolved_problems/test_309_integer_ladders.py | 873 | 4.1875 | 4 | import unittest
"""
Integer Ladders
In the classic "Crossing Ladders" problem, we are given the lengths x and y of two ladders resting on the opposite walls of a narrow, level street. We are also given the height h above the street where the two ladders cross and we are asked to find the width of the street (w).
Here... | true |
9058eb2ad8a06f152b4e292796b776bc132594af | KristofferFJ/PE | /problems/unsolved_problems/test_152_writing_1slash2_as_a_sum_of_inverse_squares.py | 854 | 4.3125 | 4 | import unittest
"""
Writing 1/2 as a sum of inverse squares
There are several ways to write the number 1/2 as a sum of inverse squares using distinct integers.
For instance, the numbers {2,3,4,5,7,12,15,20,28,35} can be used:
$$\begin{align}\dfrac{1}{2} &= \dfrac{1}{2^2} + \dfrac{1}{3^2} + \dfrac{1}{4^2} + \dfrac{1}{... | true |
0ff6187cf73b4e3ce59cea63123d4d5e5941bbac | KristofferFJ/PE | /problems/unsolved_problems/test_797_cyclogenic_polynomials.py | 928 | 4.15625 | 4 | import unittest
"""
Cyclogenic Polynomials
A monic polynomial is a single-variable polynomial in which the coefficient of highest degree is equal to 1.
Define $\mathcal{F}$ to be the set of all monic polynomials with integer coefficients (including the constant polynomial $p(x)=1$). A polynomial $p(x)\in\mathcal{F}$ ... | true |
ae296ed1c5ef3b45bc2997780d61aae7376ab3ee | KristofferFJ/PE | /problems/unsolved_problems/test_726_falling_bottles.py | 1,191 | 4.15625 | 4 | import unittest
"""
Falling bottles
Consider a stack of bottles of wine. There are $n$ layers in the stack with the top layer containing only one bottle and the bottom layer containing $n$ bottles. For $n=4$ the stack looks like the picture below.
The collapsing process happens every time a bottle is taken. A spac... | true |
75942c440659f556135d1b93074f464bd88cdc1b | KristofferFJ/PE | /problems/unsolved_problems/test_155_counting_capacitor_circuits.py | 1,148 | 4.21875 | 4 | import unittest
"""
Counting Capacitor Circuits
An electric circuit uses exclusively identical capacitors of the same value C.
The capacitors can be connected in series or in parallel to form sub-units, which can then be connected in series or in parallel with other capacitors or other sub-units to form larger sub-u... | true |
60ade4195efa8fbd6cce3ea80f0c9f512b711906 | KristofferFJ/PE | /problems/unsolved_problems/test_796_a_grand_shuffle.py | 790 | 4.125 | 4 | import unittest
"""
A Grand Shuffle
A standard $52$ card deck comprises thirteen ranks in four suits. However, modern decks have two additional Jokers, which neither have a suit nor a rank, for a total of $54$ cards. If we shuffle such a deck and draw cards without replacement, then we would need, on average, approxi... | true |
fd5834f002062fe02f75d86178696cd7886491c6 | KristofferFJ/PE | /problems/unsolved_problems/test_750_optimal_card_stacking.py | 930 | 4.1875 | 4 | import unittest
"""
Optimal Card Stacking
Card Stacking is a game on a computer starting with an array of $N$ cards labelled $1,2,\ldots,N$.
A stack of cards can be moved by dragging horizontally with the mouse to another stack but only when the resulting stack is in sequence. The goal of the game is to combine the ... | true |
3a6bc780036eba832c5c0d23bf007f45aaf47a57 | KristofferFJ/PE | /problems/archived_old_tries/test_059_xor_decryption.py | 2,606 | 4.28125 | 4 | # Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107.
# A modern encryption method is to take a text file, convert the bytes to ASCII, then XOR each byte ... | true |
7598bda86f1d88a5b10fb952862ccbe35f1336db | KristofferFJ/PE | /problems/unsolved_problems/test_066_diophantine_equation.py | 706 | 4.125 | 4 | import unittest
"""
Diophantine equation
Consider quadratic Diophantine equations of the form:
x2 – Dy2 = 1
For example, when D=13, the minimal solution in x is 6492 – 13×1802 = 1.
It can be assumed that there are no solutions in positive integers when D is square.
By finding minimal solutions in x for D = {2, 3, 5, ... | true |
1fa8ba3ddfd53d736b9699fce9c7e0ad2be30e7c | GeneKao/ita19-assignment | /02/task1.py | 767 | 4.21875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Task 1: Given two vectors, use the cross product to create a set of three orthonormal vectors.
"""
__author__ = "Gene Ting-Chun Kao"
__email__ = "kao@arch.ethz.ch"
__date__ = "29.10.2019"
def orthonormal_bases(u, v):
"""
Generate three base vectors from two ... | true |
7b419d44fa9686983dc3ebf2a9003b764d25e228 | nikadam/HangmanGamePython | /pythonGame.py | 1,938 | 4.15625 | 4 | import random
class HangmanGame(object):
words = ["guessing","apple","television","earphones",'mobile',
"apple","macbook","python","sunset",'sunrise','winter',
"opensource",'rainbow','computer','programming','science',
'python','datascience','mathematics','player','conditio... | true |
4b263f6d53b6a0a58611c8ef8765f309144b2454 | cami20/calculator-2 | /calculator.py | 2,907 | 4.28125 | 4 | """A prefix-notation calculator.
Using the arithmetic.py file from Calculator Part 1, create the
calculator program yourself in this file.
"""
from arithmetic import *
# Your code goes here
# No setup
# repeat forever:
while True:
# read input
input = raw_input("> ")
# tokenize input
input_string = i... | true |
f3f4eca9cee37f6e1906840c088e1576421a0911 | fatimaalheeh/python_stack | /_python/assignments/users_with_bank_account.py | 2,858 | 4.28125 | 4 | class BankAccount:
interest=1
rate=1
balance=0
def __init__(self, int_rate=1, balance=0):
self.rate=int_rate
self.balance=balance
def deposit(self, amount):
self.balance+=amount
def withdraw(self, amount):
self.balance-=amount
def display_account_info(self):
... | true |
4690cd9ff624a71728980ad40c60d686da8fd5c0 | shrenik77130/Repo5Batch22PythonWeb | /#3_Python_Complex_Programs/Program15.py | 241 | 4.25 | 4 | #WAP to input three digit number and print its reverse
no = int(input("Enter 3 Digit Number :")) #276 -> 27 -> 2
rem=no%10 #6
rev=rem
no=no//10
rem=no%10 #7
rev=rev*10+rem
no=no//10
rem=no%10 #2
rev=rev*10+rem
print("Reverse = ",rev)
| true |
3833d1646b0470f64f8258265681cb1d098d9e39 | shrenik77130/Repo5Batch22PythonWeb | /#3_Python_Complex_Programs/Program10.py | 256 | 4.125 | 4 | #WAP to input two numbers and perform Swapping
a=int(input("Enter value of a :"))
b=int(input("Enter value of b :"))
print(f"value of a = {a} and value of b = {b}")
t=a
a=b
b=t
print("After interchange")
print(f"value of a = {a} and value of b = {b}")
| true |
2b44364a2d8bac7c9ac95bafe580d55e2e209613 | paris3200/AdventOfCode | /code/Y2015/D05.py | 2,562 | 4.15625 | 4 | import re
import string
if __name__ != "__main__":
from Y2015 import utils
else:
import utils
def check_three_vowels(text: str) -> bool:
"""Checks if the input text has 3 or more vowels [aeiou]."""
result = re.search("^(.*[aeuio].*){3,}$", text)
if result:
return True
else:
r... | true |
5ad40813a589481b8afa46844746a3eb6e4c9da6 | jessicagamio/calculator | /calculator.py | 2,605 | 4.15625 | 4 | """Calculator
>>> calc("+ 1 2") # 1 + 2
3
>>> calc("* 2 + 1 2") # 2 * (1 + 2)
6
>>> calc("+ 9 * 2 3") # 9 + (2 * 3)
15
Let's make sure we have non-commutative operators working:
>>> calc("- 1 2") # 1 - 2
-1
>>> calc("- 9 * 2 3") # 9 - (2 * 3)
3
>>> calc("/ 6 - 4 ... | true |
2e655cc1d809c964b90f44f24d76126547ca0bba | Seabagel/Python-References | /3-working-with-strings/6-counting-all-the-votes-function.py | 1,110 | 4.28125 | 4 | # Create an empty dictionary for associating radish names
# with vote counts
counts = {}
# Create an empty list with the names of everyone who voted
voted = []
# Clean up (munge) a string so it's easy to match against other strings
def clean_string(s):
return s.strip().capitalize().replace(" "," ")
# Check if s... | true |
69b8ecf656173add61531024d7d8ed636e7f6f2b | maiwen/LeetCode | /Python/739. Daily Temperatures.py | 1,904 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on 2018/7/16 15:22
@author: vincent
Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.
For example, give... | true |
a8141241380818f22c3f8a0f6285a247e01d11ce | NRJ-Python/Learning_Python | /Ch3/dates_start.py | 923 | 4.5 | 4 | #
# Example file for working with date information
# (For Python 3.x, be sure to use the ExampleSnippets3.txt file)
from datetime import date
from datetime import time
from datetime import datetime
def main():
#Date Objects
#Get today's date from today() method from date class
today=date.today()
print("Today's date ... | true |
ff407d313085cd40426d61ffc481ffc44acb0f71 | srczhou/ProficientPython | /palindrome_linked_list.py | 2,355 | 4.21875 | 4 | #!/usr/bin/env python3
import sys
class ListNode:
def __init__(self, data=0, next_node=None):
self.data = data
self.next = next_node
#from reverse_linked_list_iterative import reverse_linked_list
def reverse_singly_list(L):
if not L:
return None
dummy_head = ListNode(0, L)
whil... | true |
4d3751389ef8147c17e6bb43da20015a41761864 | narnat/leetcode | /sort_list/sort_list.py | 2,728 | 4.15625 | 4 | #!/usr/bin/env python3
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
""" Regular recursive solution"""
def sortList(self, head: ListNode) -> ListNode:
if head is None or head.next is None:... | true |
a7198cf7640343771137bec333d57f8b777301b1 | Lyubov-smile/SEP | /Data/task24.py | 499 | 4.4375 | 4 | # 24. Write a Python program to print the elements of a given array.
Sample array : ["Ruby", 2.3, Time.now]
import sys
sv = (sys.version)
sv1 = sv[0:6]
print(sv)
print(sv1,"\n")
import datetime
import array
now = datetime.datetime.now()
dt = datetime.datetime.now().strftime("%H.%M")
print(dt, type(dt))
dt1 = floa... | true |
48f6dc47d99b3f3e679c12a02c44af0edc9885c7 | Lyubov-smile/SEP | /Statements_syntax/task23.py | 696 | 4.25 | 4 | # 23. Write a Python program to check whether a given value appears everywhere in a given array.
# A value is "everywhere" in an array if it presents for every pair of adjacent elements in the array.
n = int(input('Input the length of your array: '))
if n < 1:
print("The length of array can't be less than 1!")
ar... | true |
0ea8922947d6f6b578adf79034feb4af42f49620 | Lyubov-smile/SEP | /Statements_syntax/task14.py | 474 | 4.28125 | 4 | # 14. Write a Python program to check if a given array of integers contains 3 twice, or 5 twice.
n = int(input('Input the length of your array: '))
if n < 1:
print("The length of array can't be less than 1!")
arr = []
for i in range(n):
arr.append(int(input('Input an integer element of array: ')))
if arr.cou... | true |
29a7e843519581a67df4ac8a22a3c24512b17662 | Lyubov-smile/SEP | /Data/task04.py | 267 | 4.46875 | 4 | # 4. Write a Python program which accepts the radius of a circle from the user and compute the parameter and area.
r = float(input('Input the radius of a circle: '))
import math
p = 2 * r * math.pi
s = r ** 2 * math.pi
print('P=', p, sep='')
print('S=', s, sep='')
| true |
787360a936fa50633e29dac47347e9c49fb8a520 | Lyubov-smile/SEP | /Statements and syntax/task22.py | 360 | 4.375 | 4 | # 22. Write a Python program to check whether every element is a 3 or a 5 in a given array of integers.
arr = [3, 5, 3, 5, 3]
#[1, 3, 5, 2, 7, 5]
for i in range(len(arr)):
if arr[i] == 3 or arr[i] == 5:
i += 1
inf = 'Every element in array = 3 or 5'
else:
inf = 'Not every element in a... | true |
26100f9023f28861bcb35b8a5fbc20f26bcd15c4 | Lyubov-smile/SEP | /Statements_syntax/task17.py | 427 | 4.375 | 4 | # 17. Write a Python program to get the number of even integers in a given array.
n = int(input('Input the length of your array: '))
if n < 1:
print("The length of array can't be less than 1!")
arr = []
for i in range(n):
arr.append(int(input('Input an integer element of array: ')))
n = 0
for i in range(len(... | true |
a45b7b1ea7b5f9ab8d48c6507cd1d9c2f1d57f34 | Lyubov-smile/SEP | /Statements and syntax/task23.py | 425 | 4.21875 | 4 | # 23. Write a Python program to check whether a given value appears everywhere in a given array.
# A value is "everywhere" in an array if it presents for every pair of adjacent elements in the array.
arr = [1, 3, 5, 2, 7, 5]
value = 3
for i in range(len(arr)):
if arr[i] == 3:
i += 1
inf = 'Every e... | true |
62683c96cca30403c196eaf641b2e3e712cb1a1b | Max-Rider/basic-number-guessing-game | /number_guesser.py | 952 | 4.25 | 4 | # Maxwell Rider
# September 23 2020
# A very simple number guessing game where you guess a number between 1 and 100
# and the computer tells you if its too high or too low
# This is simply to help boost my python knowledge as I am very much a beginner as of writting this
from __future__ import print_function
... | true |
be28e73a27607679fa8b6a87bc7c8f7c44279367 | avielz/self.py_course_files | /self.py-unit6 lists/6.1.2.py | 579 | 4.28125 | 4 |
def shift_left(my_list):
"""Shift items in the list to the left.
:param my_list: the list with the items
:param last_item: will get the last item from my list
:type my_list: list
:type last_item: string
:return: The list with the items shifted to the left
:rtype: list
"""
last_item = my_... | true |
2cf335bf134fe8301e05aa9c60ef03d154be10ab | nicholasji/IS211_Assignment1 | /assignment1_part1.py | 1,098 | 4.21875 | 4 | #!usr/bin/env python
# -*- coding: utf-8 -*-
"""Week 1 Part 1"""
class ListDivideException(Exception):
"""Exception"""
def listDivide(numbers, divide=2):
"""Divisible by divide.
Args:
numbers(list): a list of numbers
divide(integer): a divisor integer default set to 2
Return... | true |
2e88aa71a50bec39e0c64b8466c2f5bc888b7340 | delacruzfranklyn93/Python--Challenge | /PyBank/Bank.py | 2,486 | 4.1875 | 4 | # import libraries
import os
import csv
# Declare the variable that you think you might be using
months = 0
net_total = 0
avg_change = []
greatest_increase = 0
greatest_decrease = 0
current = 0
past = 0
month_increase = ""
month_decrease = ""
# Read in the data into a list
csv_path = os.path.join( "Resources", "b... | true |
9fac2d1b600b43bb2e9842ca5028532f5b6feb1b | icimidemirag/GlobalAIHubPythonCourse | /Homeworks/HW1.py | 542 | 4.4375 | 4 | #Create two lists. The first list should consist of odd numbers. The second list is also of even numbers.
#Merge two lists. Multiply all values in the newlist by 2.
#Use the loop to print the data type of the all values in the new list.
#Question 1
oddList = [1,3,5,7,9]
evenList = [0,2,4,6,8]
oddList.extend(evenList)... | true |
c17b1ed61bb9753fcae4633bb059af8f5ffba1e1 | BhargavKadali39/Python_Data_Structure_Cheat_Sheet | /anti_duplicator_mk9000.py | 474 | 4.125 | 4 | List_1 = [1,1,1,2,3,4,4,4,5,5,6,6]
'''
# The old method
List_2 = []
for i in List_1:
if i not in List_2:
List_2.append(i)
print(List_2)
# Still this old method is faster than the other.
# Execution time is: 0.008489199999999975
# That much doesn't matter much,not in the case while working with big amount... | true |
9e10430c18dbdc82851fa9e58dacfb435b749b5e | Dillonso/bio-django | /ReverseComplement/process.py | 547 | 4.25 | 4 | # reverseComplement() function returns the revurse complement of a DNA sequence
def reverseComplement(stringInput):
# Reverse the input
string = stringInput[::-1].upper()
# define pairs dict
pairs = {
'A':'T', 'T':'A',
'G':'C', 'C':'G'
}
# Turn string into list
_list = list(string)
# Define a new emp... | true |
0f89dafea5460e09641fde03a3bba3f8571e4641 | arjunreddy-001/DSA_Python | /Algorithms/CountdownUsingRecursion.py | 294 | 4.25 | 4 | # use recursion to implement a countdown timer
def countdown(x):
if x == 0:
print("Done!")
return
else:
print(x, "...")
countdown(x - 1)
print("foo") # this code will execute after we reach the top of call stack
countdown(5)
| true |
ffbcd78e46dbb32c172ee980f837c5c32d3a118f | jkorstia/Intro2python | /population.py | 1,284 | 4.125 | 4 | # a program to calculate population size after a user specified time (in years)
# demographic rates are fixed, initial population size is 307357870 selfie taking quokkas
# This script is designed to model quokka populations! Use with other species at your own risk.
# ask user for number of years (inputs as string)
yr... | true |
673d177a709a5c019892d42b8579b12e6d13c790 | alexwolf22/Python-Code | /Cities QuickSort/quicksort.py | 1,203 | 4.34375 | 4 | #Alex Wolf
#Quicksort Lab
#functions that swaps two elements in a list based off indexs
def swap(the_list,x,y):
temp=the_list[x]
the_list[x]=the_list[y]
the_list[y]=temp
#partition function that partitions a list
def partition(the_list, p, r, compare_func):
pivot =the_list[r] #sets pivot to last ... | true |
60fab78905611616e336ccd8a320332099302905 | jjinho/rosalind | /merge_sort_two_arrays/main.py | 1,755 | 4.15625 | 4 | #!/usr/bin/python3
"""
Merge Sort Two Arrays
Given: A positive integer n <= 10^5 and a sorted array A[1..n] of integers
from -10^5 to 10^5, a positive integer m <= 10^5 and a sorted array B[1..m] of
integers from -10^5 to 10^5.
Return: A sorted array C[1..n+m] containing all the elements of A and B.
"""
def main():... | true |
d239f0a21759c9cc3275d87c740fca7a525a094c | jjinho/rosalind | /insertion_sort/main.py | 1,028 | 4.4375 | 4 | #!/usr/bin/python3
"""
Insertion Sort
Given: A positive ingeter n <= 10^3 and an array A[1..n] of integers.
Return: The number of swaps performed by insertion sort algorithm on A[1..n].
"""
def main():
n = 0 # number of integers in array A
array = []
# Parse in.txt
with open('./in.txt') as f:
... | true |
1df31164bee68d1f7a3d824d820f9be602797b3f | ziyang-zh/pythonds | /01_Introduction/01_03_input_and_output.py | 741 | 4.15625 | 4 | #input and output
#aName=input('Please enter your name: ')
aName="David"
print("Your name in all capitals is",aName.upper(),"and has length",len(aName))
#sradius=input("Please enter the radius of the circle ")
radius=2
radius=float(radius)
diameter=2*radius
print(diameter)
#format string
print("Hello")
print("Hello",... | true |
5cf1d1d96e8ea34205a206273b8e8eb7e1a466ca | prohodilmimo/turf | /packages/turf_helpers/index.py | 2,552 | 4.34375 | 4 | from numbers import Number
factors = {
"miles": 3960,
"nauticalmiles": 3441.145,
"degrees": 57.2957795,
"radians": 1,
"inches": 250905600,
"yards": 6969600,
"meters": 6373000,
"metres": 6373000,
"kilometers": ... | true |
7efe282d6ded5d17da05d420c71f7963be4dc419 | alexacanaan23/COSC101 | /hw03_starter/hw03_turtleword.py | 1,619 | 4.34375 | 4 | # ----------------------------------------------------------
# -------- HW 3: Part 3.1 ---------
# ----------------------------------------------------------
# ----------------------------------------------------------
# Please answer these questions after you have completed this
# program
# -... | true |
83c64368ab1d5b532f42d8a792f6e60c8b195f3c | AndriiSotnikov/py_fcsv | /fcsv.py | 462 | 4.28125 | 4 | """There is a CSV file containing data in this format: Product name, price, quantity
Calculate total cost for all products."""
import csv
def calc_price(filename: str, open_=open) -> float:
"""Multiply every second and third element in the row, and return the sum"""
with open_(filename, 'rt') as file:
... | true |
22815c71694d907bb322a2ef02f73bd2d617856d | newbieeashish/LeetCode_Algo | /3rd_30_questions/ConstructTheRectangle.py | 1,202 | 4.34375 | 4 | '''
For a web developer, it is very important to know how to design a
web page's size. So, given a specific rectangular web page’s area,
your job by now is to design a rectangular web page, whose length
L and width W satisfy the following requirements:
1. The area of the rectangular web page you designed must ... | true |
e0e976dd9ec32a240382544cb36bf2f42a59a0df | newbieeashish/LeetCode_Algo | /1st_100_questions/TransposeMatrix.py | 456 | 4.46875 | 4 | '''
Given a matrix A, return the transpose of A.
The transpose of a matrix is the matrix flipped over it's main diagonal,
switching the row and column indices of the matrix.
Example 1:
Input: [[1,2,3],[4,5,6],[7,8,9]]
Output: [[1,4,7],[2,5,8],[3,6,9]]
Example 2:
Input: [[1,2,3],[4,5,6]]
Output: [[1,4],[... | true |
884106b89d0e1bf8b34f22c55e53894f8b587191 | newbieeashish/LeetCode_Algo | /1st_100_questions/ShortestCompletingWord.py | 1,714 | 4.40625 | 4 | '''
Find the minimum length word from a given dictionary words, which has all the
letters from the string licensePlate. Such a word is said to complete the
given string licensePlate
Here, for letters we ignore case. For example, "P" on the licensePlate still
matches "p" on the word.
It is guaranteed an ans... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.