blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
6413f86569da08a37374f72a6c330b1fd67ff02e | DayGitH/Python-Challenges | /DailyProgrammer/DP20170705B.py | 896 | 4.21875 | 4 | """
[2017-07-05] Challenge #322 [Intermediate] Largest Palindrome
https://www.reddit.com/r/dailyprogrammer/comments/6ldv3m/20170705_challenge_322_intermediate_largest/
# Description
Write a program that, given an integer input n, prints the largest integer that is a palindrome and has two factors
both of string lengt... | true |
9843b352194d21f8a67d7de52ba0b2c59c27bc2f | DayGitH/Python-Challenges | /DailyProgrammer/DP20160916C.py | 2,259 | 4.25 | 4 | """
[2016-09-16] Challenge #283 [Hard] Guarding the Coast
https://www.reddit.com/r/dailyprogrammer/comments/5320ey/20160916_challenge_283_hard_guarding_the_coast/
# Description
Imagine you're in charge of the coast guard for your island nation, but you're on a budget. You have to minimize how
many boats, helicopters ... | true |
78237d17e529cdd02fe42dd409c705b22e255eb8 | DayGitH/Python-Challenges | /DailyProgrammer/20120403B.py | 1,081 | 4.46875 | 4 | """
Imagine you are given a function flip() that returns a random bit (0 or 1 with equal probability). Write a program that
uses flip to generate a random number in the range 0...N-1 such that each of the N numbers is generated with equal
probability. For instance, if your program is run with N = 6, then it will genera... | true |
0b541c06a55954a41a1cf02de616696c28d9abf8 | DayGitH/Python-Challenges | /DailyProgrammer/DP20121023B.py | 1,571 | 4.1875 | 4 | """
[10/23/2012] Challenge #106 [Intermediate] (Jugs)
https://www.reddit.com/r/dailyprogrammer/comments/11xjfd/10232012_challenge_106_intermediate_jugs/
There exists a problem for which you must get exactly 4 gallons of liquid, using only a 3 gallon jug and a 5 gallon
jug. You must fill, empty, and/or transfer liquid... | true |
b268c2242ac7769abf8155f8299f3222452c706c | DayGitH/Python-Challenges | /DailyProgrammer/DP20120702A.py | 1,509 | 4.28125 | 4 | """
Before I get to today's problem, I'd just like to give a warm welcome to our two new moderators, nooodl and Steve132! We
decided to appoint two new moderators instead of just one, because rya11111 has decided to a bit of a break for a while.
I'd like to thank everyone who applied to be moderators, there were lots ... | true |
08e590ff030b1b2a50b3a0caadd086f4def3630c | DayGitH/Python-Challenges | /DailyProgrammer/20120611B.py | 2,005 | 4.40625 | 4 | """
You can use the reverse(N, A) procedure defined in today's easy problem [20120611A] to completely sort a list. For
instance, if we wanted to sort the list [2,5,4,3,1], you could execute the following series of reversals:
A = [2, 5, 4, 3, 1]
reverse(2, A) (A = [5, 2, 4, 3, 1])
reverse(5, A) (A = [1, 3,... | true |
8be851749005732519c82b72d3b7796187b59edc | DayGitH/Python-Challenges | /DailyProgrammer/DP20160408C.py | 2,212 | 4.15625 | 4 | """
[2016-04-08] Challenge #261 [Hard] magic square dominoes
https://www.reddit.com/r/dailyprogrammer/comments/4dwk7b/20160408_challenge_261_hard_magic_square_dominoes/
# Description
An NxN magic square is an NxN grid of the numbers 1 through N^2 such that each row, column, and major diagonal adds up
to M = N(N^(2)+1... | true |
0b0a585867ad3f4081fb6734d314797ad4dfe6e3 | DayGitH/Python-Challenges | /DailyProgrammer/20120310A.py | 363 | 4.1875 | 4 | """
Write a program that will compare two lists, and append any elements in the second list that doesn't exist in the first.
input: ["a","b","c",1,4,], ["a", "x", 34, "4"]
output: ["a", "b", "c",1,4,"x",34, "4"]
"""
inp1 = ["a","b","c",1,4,]
inp2 = ["a", "x", 34, "4"]
final = inp1[:]
for a in inp2:
if a not in f... | true |
cedde37647701d970cc14b091dd084966a18d480 | DayGitH/Python-Challenges | /DailyProgrammer/DP20120808A.py | 1,026 | 4.1875 | 4 | """
[8/8/2012] Challenge #86 [easy] (run-length encoding)
https://www.reddit.com/r/dailyprogrammer/comments/xxbbo/882012_challenge_86_easy_runlength_encoding/
Run-Length encoding is a simple form of compression that detects 'runs' of repeated instances of a symbol in a string
and compresses them to a list of pairs of... | true |
679d823627f1fc41e7027d234a4ae51b9ba3868d | DayGitH/Python-Challenges | /ProjectEuler/pr0019.py | 1,393 | 4.15625 | 4 | """
You are given the following information, but you may prefer to do some research for yourself.
* 1 Jan 1900 was a Monday.
* Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on le... | true |
dca128ba4183ba191a980e31fbe857280b70450f | DayGitH/Python-Challenges | /DailyProgrammer/20120331A.py | 502 | 4.125 | 4 | """
A very basic challenge:
In this challenge, the
input is are : 3 numbers as arguments
output: the sum of the squares of the two larger numbers.
Your task is to write the indicated challenge.
"""
"""
NOTE: This script requires three input arguments!!!
"""
import sys
arguments = len(sys.argv)
if arguments != 4:
... | true |
ff0d12abcd0f3b346d1da0bb9b0ac5aa0c25f473 | DayGitH/Python-Challenges | /DailyProgrammer/20120216C.py | 975 | 4.125 | 4 | '''
Write a program that will take coordinates, and tell you the corresponding number in pascals triangle. For example:
Input: 1, 1
output:1
input: 4, 2
output: 3
input: 1, 19
output: error/nonexistent/whatever
the format should be "line number, integer number"
for extra credit, add a function to simply print the trian... | true |
e468767ef3ec92629303e5c294e393f29ae6ee83 | DayGitH/Python-Challenges | /DailyProgrammer/20120218A.py | 906 | 4.34375 | 4 | '''
The exercise today asks you to validate a telephone number, as if written on an input form. Telephone numbers can be
written as ten digits, or with dashes, spaces, or dots between the three segments, or with the area code parenthesized;
both the area code and any white space between segments are optional.
Thus, al... | true |
f8ce35aa7a18e0b7a6febbd227e0b7a16f2fd832 | DayGitH/Python-Challenges | /DailyProgrammer/DP20120629B.py | 1,232 | 4.25 | 4 | """
Implement the hyperoperator [http://en.wikipedia.org/wiki/Hyperoperation#Definition] as a function hyper(n, a, b), for
non-negative integers n, a, b.
hyper(1, a, b) = a + b, hyper(2, a, b) = a * b, hyper(3, a, b) = a ^ b, etc.
Bonus points for efficient implementations.
thanks to noodl for the challenge at /... | true |
db322807d137276219ecaab479af539fe4088cb5 | DayGitH/Python-Challenges | /DailyProgrammer/DP20170619A.py | 1,147 | 4.125 | 4 | """
[2017-06-19] Challenge #320 [Easy] Spiral Ascension
https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/
# Description
The user enters a number. Make a spiral that begins with 1 and starts from the top left, going towards the right, and
ends with the square of tha... | true |
dea6624c859356ed196474cbb7f746f5d5b44dd8 | DayGitH/Python-Challenges | /DailyProgrammer/DP20120808C.py | 1,199 | 4.1875 | 4 | """
[8/8/2012] Challenge #86 [difficult] (2-SAT)
https://www.reddit.com/r/dailyprogrammer/comments/xx970/882012_challenge_86_difficult_2sat/
Boolean Satisfiability problems are problems where we wish to find solutions to boolean equations such as
(x_1 or not x_3) and (x_2 or x_3) and (x_1 or not x_2) = true
Thes... | true |
35a0fdd29e629a3e4bd1e795d6a7de6805243aaa | DayGitH/Python-Challenges | /DailyProgrammer/20120219A.py | 491 | 4.4375 | 4 | '''
The program should take three arguments. The first will be a day, the second will be month, and the third will be year.
Then, your program should compute the day of the week that date will fall on.
'''
import datetime
day_list = {0: 'Monday', 1: 'Tuesday', 2: 'Wednesday', 3: 'Thursday', 4: 'Friday', 5: 'Saturday'... | true |
ea8e85c489477c5736dbbaa83c565228543da9e4 | seesiva/ML | /lpthw/newnumerals.py | 1,169 | 4.65625 | 5 |
"""
Your Informatics teacher at school likes coming up with new ways to help you understand the material.
When you started studying numeral systems, he introduced his own numeral system,
which he's convinced will help clarify things. His numeral system has base 26, and
its digits are represented by English capital le... | true |
5514cb1b4588c60ba18477693747381d99b2073f | seesiva/ML | /lpthw/ex20.py | 777 | 4.28125 | 4 | """
Given a string, , of length that is indexed from to , print its even-indexed and odd-indexed characters as space-separated strings on a single line (see the Sample below for more detail).
Note: is considered to be an even index.
"""
import sys
if __name__=="__main__":
string_list=[]
T=int(raw_input())
... | true |
9958b0569eea52042d347d1e977137d3fff8ffc8 | seesiva/ML | /lpthw/euclids.py | 357 | 4.125 | 4 | """
Compute the greatest common divisor of two non-negative integers p and q as follows: If q is 0, the answer is p.
If not, divide p by q and take the remainder r. The answer is the greatest common divisor of q and r.
"""
def gcd(p,q):
if q==0:
return p
else:
r=p % q
return r
if __na... | true |
953469d38c6689be6f48986e855b6b3c6881aa56 | seesiva/ML | /lpthw/ex9.py | 698 | 4.21875 | 4 | """
Higher Order Functions
HoF:Function as a return value
"""
def add_two_nums(x,y):
return x+y
def add_three_nums(x,y,z):
return x+y+z
def get_appropriate_function(num_len):
if num_len==3:
return add_three_nums
else:
return add_two_nums
if __name__=="__main__":
args = [1,2,3]
... | true |
db8b5a361d085137634b19777ef97db2ab4db46d | TatianaKudryavtseva/python_algoritm | /lesson 3_2.py | 735 | 4.15625 | 4 | # Во втором массиве сохранить индексы четных элементов первого массива.
# Например, если дан массив со значениями 8, 3, 15, 6, 4, 2,
# второй массив надо заполнить значениями 0, 3, 4, 5,
# (индексация начинается с нуля), т.к. именно в этих позициях первого массива стоят четные числа.
import random
SIZE = 10
MIN_ITEM ... | false |
ca138f087a7cdadb84ea054df8fff44596fc265d | AdishiSood/The-Joy-of-Computing-using-Python | /Week 4/Factorial.py | 285 | 4.28125 | 4 | """
Given an integer number n, you have to print the factorial of this number.
Input Format:
A number n.
Output Format:
Print the factorial of n.
Example:
Input:
4
Output:
24
"""
k = int(input())
fac = 1
for i in range(1,k+1):
if(k==0):
break
fac=fac*i
print(fac)
| true |
76651f9226b584f4a7a0dfe0f1ceeb338ba0e2ae | AdishiSood/The-Joy-of-Computing-using-Python | /Week 12/Sentence.py | 807 | 4.21875 | 4 | """
Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalised.
Input Format:
The first line of the input contains a number n which represents the number of line.
From second line there are statements which has to be converted. Each statement co... | true |
82401ab5f1d228c0312819a08859994363fdce4f | AdishiSood/The-Joy-of-Computing-using-Python | /Week 9/First and Last.py | 470 | 4.21875 | 4 | """
Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.
Input Format:
The first line of the input contains the String S.
Output Format:
The first line of the output contains the modified string.... | true |
39adbf633463303ae3395d0f67a349497f293c68 | rohanaggarwal7997/Studies | /Python new/finding most frequent words in a list.py | 337 | 4.125 | 4 | from collections import Counter
text='''
dfkjskjefisej tjeistj isejt isejt iseotjeis tiset iesjt iejtes
est isjti esties hesiuhea iurhaur aurhuawh ruahwruawhra u
njra awurhwauirh uawirhuwar huawrh uawrhuaw
ajiawj eiwhaeiaowhe awhewai hiawe
'''
words=text.split()
counter=Counter(words)
print(counter.most_common(3)) ... | false |
e588bbb9899fa27aa4ee92fc9825a38ee626259e | kildarejoe1/CourseWork_Lotery_App | /app.py | 1,859 | 4.15625 | 4 | #Udemy Course Work - Lottery App
#Import the random class
import random
def menu():
"""Controlling method that
1. Ask players for numbers
2. Calculate the lottery numbers
3. Print out the winnings
"""
players_numbers = get_players_numbers()
lottery_numbers = create_lottery_numbers()
if... | true |
d35658055b36c894a01b375bb333ae11236ffbfa | fabricio24530/ListaPythonBrasil | /EstruturaDeDecisao08.py | 411 | 4.1875 | 4 | '''Faça um programa que pergunte o preço de três produtos e informe qual produto você deve comprar, sabendo que a
decisão é sempre pelo mais barato.'''
lista = list()
for i in range(3):
produto = float(input(f'Informe o preço do {i + 1}º produto: '))
lista.append(produto)
menor = min(lista)
posicao = lista.i... | false |
8d4ede1972573ed6ea89c68ec89ee4ec7e928f55 | fabricio24530/ListaPythonBrasil | /EstruturaSequencial09.py | 306 | 4.1875 | 4 | '''Faça um Programa que peça a temperatura em graus Farenheit, transforme e mostre a temperatura em graus Celsius.
C = (5 * (F-32) / 9).'''
temp_f = float(input('Informe a temperatura em graus Farenheit: '))
temp_c = (5 * (temp_f-32) / 9)
print(f'A temperatura {temp_f}°F equivale a {temp_c:.2f}°C')
| false |
6f96e9df955a926865d9dcdbc2e4231762536507 | fabricio24530/ListaPythonBrasil | /EstruturaDeRepeticao07.py | 234 | 4.3125 | 4 | '''Faça um programa que leia 5 números e informe o maior número.'''
lista = list()
for i in range(5):
num = float(input(f'Informe o {i+1}º numero: '))
lista.append(num)
print(f'O maior valor digitado foi: {max(lista)}') | false |
5b6b1da23f3ce3c77688148546276ca171cb0300 | xxxfly/PythonStudy | /ProjectBaseTest1/python核心编程/02-高级3-元类/02-元类.py | 769 | 4.34375 | 4 | #-*- coding:utf-8 -*-
#元类
# # --类也是对象,就是一组用来描述如何生成一个对象的代码段
# class Person(object):
# num=0
# print('--person--test--') #会直接被执行,说明此时python解释器已经创建了这个类
# def __init__(self):
# self.name='a'
# print(100)
# print('hello')
# print(Person)
# class Person():
# pass
# p1=Person()
# print(type(p1))
... | false |
4508f1a2a2db060764a3ccf1fcf01a56704031aa | xxxfly/PythonStudy | /ProjectBaseTest1/算法与数据结构/03-排序/06-归并排序.py | 1,019 | 4.125 | 4 | #encoding:utf-8
def mergeSort(orgList):
"""递归排序"""
n=len(orgList)
if n<=1:
return orgList
middle=n//2
#left_li 采用归并排序后形成新的有序列表
left_li=mergeSort(orgList[:middle])
#right_li 采用归并排序后形成新的有序列表
right_li=mergeSort(orgList[middle:])
#将两个有序的子序列合并成一个整体
# merage(left_li,right_li)... | false |
88e0893f2afce21f3eae1cf65e1cef3a833f09b2 | outcoldman/codeinterview003 | /2013/cracking/01-02.py | 426 | 4.15625 | 4 | # coding=utf8
# Write code to reverse a C-Style String. (C-String means that "abcd" is represented as five characters, including the null character.)
def reverse_string(str):
buffer = list(str)
length = len(buffer)
for i in xrange(length / 2):
t = buffer[i]
buffer[i] = str[length - i - 1]
... | true |
c73a54771e27fb298a73d595b5d925514f68e6cc | prashantchanne12/Leetcode | /find the first k missing positive numbers.py | 1,383 | 4.125 | 4 | '''
Given an unsorted array containing numbers and a number ‘k’, find the first ‘k’ missing positive numbers in the array.
Example 1:
Input: [3, -1, 4, 5, 5], k=3
Output: [1, 2, 6]
Explanation: The smallest missing positive numbers are 1, 2 and 6.
Example 2:
Input: [2, 3, 4], k=3
Output: [1, 5, 6]
Explanation: The s... | true |
5718a2011b7dcd969516e4c3f2b24b2cebfa713b | prashantchanne12/Leetcode | /reverse linked list.py | 1,355 | 4.3125 | 4 | '''
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?
'''
# Solution 1
class Solution(object):
def reverseList(self, head):
prev = None
current = he... | true |
d57e3c988f5311a9198d2d8bcd415c58ebb837d6 | prashantchanne12/Leetcode | /daily tempratures.py | 923 | 4.1875 | 4 | '''
Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.
Example 1:
Input: temper... | true |
20801f067b8f3b6248285c98c759bf60ef833c5f | prashantchanne12/Leetcode | /backspace string compare - stack.py | 1,839 | 4.1875 | 4 | '''
Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.
Note that after backspacing an empty text, the text will continue empty.
Example 1:
Input: S = "ab#c", T = "ad#c"
Output: true
Explanation: Both S and T become "ac".
Example 2:
Input: ... | true |
4cc773965da12e433077f96090bdeea04579534a | prashantchanne12/Leetcode | /pascal triangle II.py | 688 | 4.1875 | 4 | '''
Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:
Example 1:
Input: rowIndex = 3
Output: [1,3,3,1]
Example 2:
Input: rowIndex = 0
Output: [1]
'''
class Solution(object):
de... | true |
5efbfb64f054e7cbcd77aa0f55599835c48b4d0d | prashantchanne12/Leetcode | /bitonic array maximum.py | 998 | 4.34375 | 4 | '''
Find the maximum value in a given Bitonic array. An array is considered bitonic if it is monotonically increasing and then monotonically decreasing. Monotonically increasing or decreasing means that for any index i in the array arr[i] != arr[i+1].
Example 1:
Input: [1, 3, 8, 12, 4, 2]
Output: 12
Explanation: The ... | true |
c8ce6f1d1f34106357210c7361c2471bea783240 | prashantchanne12/Leetcode | /smallest missing positive number.py | 712 | 4.21875 | 4 | '''
Given an unsorted array containing numbers, find the smallest missing positive number in it.
Example 1:
Input: [-3, 1, 5, 4, 2]
Output: 3
Explanation: The smallest missing positive number is '3'
Example 2:
Input: [3, -2, 0, 1, 2]
Output: 4
Example 3:
Input: [3, 2, 5, 1]
Output: 4
'''
def find_missing_positive... | true |
1811fedf3317e61f5fa1f70b1669b47cae04716d | prashantchanne12/Leetcode | /validate binary search tree.py | 1,294 | 4.125 | 4 |
import math
'''
Given the root of a binary tree, determine if it is a valid binary search tree (BST).
A valid 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 greater than the node's key.
Both the l... | true |
0423ec8f68bdbea0933002ff792eaaf73b0026e5 | prashantchanne12/Leetcode | /merge intervals.py | 1,718 | 4.375 | 4 | '''
Given a list of intervals, merge all the overlapping intervals to produce a list that has only mutually exclusive intervals.
Example 1:
Intervals: [[1,4], [2,5], [7,9]]
Output: [[1,5], [7,9]]
Explanation: Since the first two intervals [1,4] and [2,5] overlap, we merged them into
one [1,5].
Example 2:
Input: in... | true |
30c022b03d26825d5edcce633de3b490123772eb | prashantchanne12/Leetcode | /valid pallindrome.py | 698 | 4.21875 | 4 | '''
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
Note: For the purpose of this problem, we define empty string as valid palindrome.
Example 1:
Input: "A man, a plan, a canal: Panama"
Output: true
Example 2:
Input: "race a car"
Output: false
'''
import... | true |
04774b08d79956c826dd25ece5d12f3aea56922b | sgpl/project_euler | /1_solution.py | 586 | 4.28125 | 4 | #!/usr/bin/python 2.7
# If we list all the natural numbers
# below 10 that are multiples of 3 or 5,
# we get 3, 5, 6 and 9.
# The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5
# below 1000.
counter = 0
terminating_condition = 1000
sum_of_multiples = 0
while counter < terminating_c... | true |
60140c55c6e6b002931c8fe16280ce14bed7186c | iamsabhoho/PythonProgramming | /Q1-3/MasteringFunctions/PrintingMenu.py | 713 | 4.21875 | 4 | #Write a function for printing menus in the terminal.
#The input is a list of options, and the output is the option selected by the user.
print('The options are: ')
#list = input()
#menu = ['Meat','Chicken','Fish']
menu = []
print(menu)
print()
def options(menu):
menu = input('Please enter the options: ')
for... | true |
c7c547252f8deb024b850f43dea0e73c3e8d849f | iamsabhoho/PythonProgramming | /Q1-3/WUP#7/Driving.py | 1,121 | 4.375 | 4 | #You are driving a little too fast, and a police officer stops you. Write an script that computes the result as “no ticket”, “small ticket”, and “big ticket”. If speed is 60 or less, the result is “no ticket”. If speed is between 61 and 80 inclusive, the result is “small ticket”. If speed is 81 or more, the result is “... | true |
dbece212a7cbf94c2bc33dc0b26dee6c0933cb81 | ATLS1300/pc04-generative-section11-sydney-green | /PC04_GenArt.py | 2,373 | 4.1875 | 4 | """
Created on Thu Sep 15 11:39:56 2020
PC04 start code
@author: Sydney Green
This code creates two circle patterns from two seperate turtles.
This is different than my pseudocode as I struggled bringing that to life but I was
able to make something I liked so much more. Turtle 1 is a larger circle with larger
cirlce... | true |
5e4da675ae102831a30af49576b89c665f7ed89c | nelvinpoulose999/Pythonfiles | /practice_prgms/factorial.py | 222 | 4.21875 | 4 | num=int(input('enter the number'))
factorial=1
if num<0:
print('no should be positive')
elif num==0:
print('the number is 1')
else:
for i in range (1,num+1):
factorial=factorial*i
print(factorial)
| true |
9bfc470a0656f879c729e2963675c71f00c06d02 | mercury9181/data_structure_using_python | /factorial.py | 269 | 4.28125 | 4 | def factorial_using_recursion(n):
if n==0:
return 1
else:
return n * factorial_using_recursion(n-1)
number = int(input('enter the number: '))
result = factorial_using_recursion(number)
print("factorial of "+ str(number)+ " = " + str(result))
| false |
85263ed8c3d2b28a3502e947024e1c9aaafaec39 | ShreyasJothish/ML-Precourse | /precourse.py | 1,771 | 4.25 | 4 | # Machine Learning/Data Science Precourse Work
# ###
# LAMBDA SCHOOL
# ###
# MIT LICENSE
# ###
# Free example function definition
# This function passes one of the 11 tests contained inside of test.py. Write the rest, defined in README.md, here, and execute python test.py to test. Passing this precourse work will gre... | true |
74bb9bf1887acf303204fa2f16bafefa9ad937f2 | amarelopiupiu/python-exercicios | /ex65.py | 665 | 4.21875 | 4 | # Crie um programa que leia uma frase qualquer e diga se ela é um palíndromo, desconsiderando os espaços. Exemplos de palíndromos:
# APÓS A SOPA, A SACADA DA CASA, A TORRE DA DERROTA, O LOBO AMA O BOLO, ANOTARAM A DATA DA MARATONA. (palíndromo é uma palavra que se lê igual de trás para frente e de frente para trás).
f... | false |
770699d93c01420aea23fd0a6e9386a015fc0686 | amarelopiupiu/python-exercicios | /ex28.py | 273 | 4.125 | 4 | # Importando apenas uma funcionalidade da biblioteca - peça a raiz quadrada de um número e arredonde ele para cima.
from math import sqrt, ceil
n = float(input('Digite um número para ver a sua raiz quadrada: '))
print('A raiz quadrada de {} é {}' .format(n, sqrt(n)))
| false |
10902336348620c8a9163eed06e0ced058bdbc6d | amarelopiupiu/python-exercicios | /ex47.py | 740 | 4.25 | 4 | # Escreva um programa em Python que leia um número inteiro qualquer e peça para o usuário escolher qual será a base de conversão: 1 para binário, 2 para octal e 3 para hexadecimal. (se você coloca 3 aspas, é possível adicionar mais linhas no print).
n = int(input('Digite um número inteiro: '))
bases = int(input('''
Es... | false |
29775912584cbf014fe4a2820dd8a5694c9dc7d1 | jossrc/LearningPython | /D012_Scope/project.py | 803 | 4.15625 | 4 | import random
random_number = random.randint(1, 100)
# GUESS THE NUMBER
attempts = {
"easy": 10,
"hard": 5
}
print("Welcome to the Number Guessing Game!")
print("I'm thinking of a number between 1 and 100")
difficulty = input("Choose a difficulty. Type 'easy' or 'hard': ")
attempts_remaining = attempts[dif... | true |
8a9d266866367fb2769f200cfc1ba1553084a2d8 | jossrc/LearningPython | /D024_Files/main.py | 1,100 | 4.34375 | 4 | # LEER ARCHIVO
"""
FORMA 01 :
Para leer un archivo se debe seguir una secuencia de pasos:
1. Abrir el archivo : Uso de la función open().
2. Leer el archivo : Uso del método read().
3. Cerrar el archivo : Uso del método close().
"""
file = open("my_file.txt")
contents = file.read(... | false |
35eb7b4f8ce9723f9452d06ffd91c6c0db2dd9fe | kiyokosaito/Collatz | /collatz.py | 480 | 4.34375 | 4 | # The number we will perform the Collatz opperation on.
n = int(input ("Enter a positive integer : "))
# Keep looping until we reach 1.
# Note : this assumes the Collatz congecture is true.
while n != 1:
# Print the current value of n.
print (n)
#chech if n is even.
if n % 2 == 0:
#If n is eve... | true |
d41db68df8a2d22a19518c8a5e6af49d2a29a29e | Selvaganapathi06/Python | /day4/Day4.py | 452 | 4.34375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
#List Reverse
cars = ["bmw", "audi", "toyota", "benz"]
cars.reverse()
print(cars)
# In[3]:
#list sort and reverse
cars = ["bmw", "audi", "toyota", "benz"]
cars.sort()
print(cars)
cars.reverse()
print(cars)
# In[4]:
#creating empty list
a = []
print("created empt... | false |
bb40d33e9bf091ae3be7652cc60fa12d80c27b71 | Selvaganapathi06/Python | /day3/Day3.py | 700 | 4.25 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
#sample list and print
bicycles = ["trek", "redline","hero"]
print(bicycles)
# In[2]:
#accessing first element in the list
print(bicycles[0])
# In[4]:
#Apply title()
print(bicycles[0].title())
# In[5]:
#replace element values
bicycles[0] = "Honda"
print(bic... | true |
edb0162e3d1c5b0582c9305da3fe9aff1d9a317b | surajbarailee/PythonExercise | /python_topics/generators.py | 2,369 | 4.53125 | 5 | """
Retur:. A function that returns a value is called once. The return statement returns a value and exits the function altogether.
Yield: A function that yields values, is called repeatedly. The yield statement pauses the execution of a function and returns a value. When called again, the function continues execution... | true |
b03282cb9349e6bbad73609dcfe369287d6fa6e6 | surajbarailee/PythonExercise | /python_topics/strings.py | 973 | 4.375 | 4 | """
Strings in python
"""
string = "Hello*World!"
"""
H e l l o * W o r l d !
0 1 2 3 4 5 6 7 8 9 10 11
-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
"""
print(string[2:]) # get every element from second index
print(string[-2:]) # get every element from -2
print(stri... | false |
711895f2590aa58911073abb4914d25ae9320548 | AyeChanKoGH/Small-code- | /DrawPyV1.py | 1,686 | 4.46875 | 4 | """
get screen and drawing shape with python turtle
#To draw line, press "l" key and click first end point and second end point
#To draw circle, press "c" key and click the center point and click the quarent point
#To draw Rectangle, press "r" key and click 1st end point and second end point
#To clean the screen, press... | true |
fa085d5bace6c4496c002a929a41548604227ebb | kimit956/MyRepo | /Simple Math.py | 402 | 4.125 | 4 |
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
sum1 = num1 + num2
diff1 = num1 - num2
prod1 = num1 * num2
try:
divide1 = num1 / num2
except ZeroDivisionError:
num2 = int(input("Cannot divide by 0. Please enter a different number: "))
divide1 = num1 / num2
print(... | true |
ad0e3a2b253ccb2b869fe21dbe25ccfd0320a582 | NweHlaing/Python_Learning_Udemy_Course | /Section_20_Advanced_Python_obj_datastructures/advanced_list.py | 936 | 4.28125 | 4 | list1 = [1,2,3]
#append
list1.append(4)
print("list after appand..",list1)
#count
count = list1.count(10)
count1 = list1.count(2)
print("list count..",count)
print("list count 1..",count1)
#append and extend
x = [1, 2, 3]
x.append([4, 5])
print("append...",x)
x = [1, 2, 3]
x.extend([4, 5])
print(... | false |
c20743ca806704d3cbdb98cb3bed95e4ebf7af61 | DeeCoob/hello_python | /_manual/format.py | 1,163 | 4.125 | 4 | # форматирование строки в стиле C s – форматная строка, x 1 …x n – значения
# s % x
# s % (x 1 , x 2 , …, x n )
# return Python has 002 quote types.
print("%(language)s has %(number)03d quote types." % {'language': "Python", "number": 2})
# '#' The value conversion will use the “alternate form” (where defined be... | true |
dcd0873f0dbf3884fea27940dd7ca07bc9f2f902 | DeeCoob/hello_python | /_starter/03_elif.py | 266 | 4.125 | 4 | x = float(input("Enter x: "))
if 0 < x < 10:
print("Value is in range")
y = x ** 2 + 2 * x - 3
if y < 0:
print("y = ", y, "; y is negative")
elif y > 0:
print("y = ", y, "; y is positive")
else:
print("y = 0")
| false |
558c51cde6f1a6992bc7202b5b2cfbbd93e514f6 | DeeCoob/hello_python | /_tceh_lection/05_constructors.py | 688 | 4.28125 | 4 | # Constructor is called when new instance is create
class TestClass:
def __init__(self):
print('Constructor is called')
print('Self is the object itself', self)
print()
t = TestClass()
t1 = TestClass()
# Constructor can have parameters
class Table:
def __init__(self, numbers_of_leg... | true |
d0922c3a88c57e9badfab0b28cc0294eb85eaefd | DeeCoob/hello_python | /_practic/starter_04_loop_factorial.py | 405 | 4.3125 | 4 | # Факториалом числа n называется число 𝑛!=1∙2∙3∙…∙𝑛.
# Создайте программу, которая вычисляет факториал введённого пользователем числа.
while True:
n = int(input("Enter n: "))
f = 1
for i in range(n):
f = f * (i + 1)
print("Factorial from n is", f)
| false |
a34c861f7c41768a76883e7e6f59c7149f106f36 | vikramriyer/FCS | /rotate_image.py | 419 | 4.125 | 4 | #!/usr/bin/python
init_list = [[1,2,3],[4,5,6],[7,8,9]]
def rotate_matrix(matrix):
'''Algo:
First: take transpose of the matrix
Second: interchange row 0 and row 2
'''
matrix = zip(*matrix)
return swap_rows(matrix)
def swap_rows(matrix):
print matrix
row0, row2 = matrix[0], matrix[2]
matrix[0] = ro... | true |
ddbc01b74befc3cb94f28d9f0c23ea1392e7eadb | Rkhwong/RHK_CODEWARS | /Fundamentals - Python/Arrays/Convert an array of strings to array of numbers.py | 618 | 4.1875 | 4 | # https://www.codewars.com/kata/5783d8f3202c0e486c001d23
"""Oh no!
Some really funny web dev gave you a sequence of numbers from his API response as an sequence of strings!
You need to cast the whole array to the correct type.
Create the function that takes as a parameter a sequence of numbers represented as strings... | true |
d4b2fb6a0358c339c0e5dd7b85962a6ff00bd298 | maczoe/python_cardio | /convertidor.py | 921 | 4.21875 | 4 |
def convert_km_to_miles(km):
return km * 0.621371
def convert_miles_to_km(miles):
return miles * 1.609344;
def main():
print("Bienvenido a convertidor.py")
seleccion = 0;
while seleccion!=3:
print("----MENU----")
print("1. Millas a kilometros")
print("2. Kil... | false |
8c8861259b03ed4f89574f56a3fff922b05619fa | drazovicfilip/Firecode | /Problems/firecode4_fibonacci.py | 1,182 | 4.1875 | 4 | """ The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it.
Write a recursive method fib(n) that returns the nth Fibonacci number. n is 0 indexed, which means that in the sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ..., n == 0 ... | true |
833b170674ce129a25e3efbea133eae6c903cb1b | qzylinux/Python | /generator.py | 216 | 4.15625 | 4 | #generator 返回当前值,并计算下一个值
def mygenerator(max):
a,b,n=0,1,0
while n<max:
yield b
a,b=b,a+b
n=n+1
return 'done'
f=mygenerator(10)
print('mygenerator(10):',f)
for x in f:
print(x) | false |
ac5fb09501c10e94d3f0c3149967aa2dc28d46ab | pranjal2203/Python_Programs | /recursive fibonacci.py | 518 | 4.5 | 4 | #program to print fibonacci series using recursion
#recursive function for generating fibonacci series
def FibRecursion(n):
if n <= 1:
return n
else:
return(FibRecursion(n-1) + FibRecursion(n-2))
#input from the users
no = int(input("Enter the terms: "))
#checking if the... | true |
2049e82aa7a5a24f4f9bdf39393b2aba2b1faa6a | kipland-m/PythonPathway | /FactorialRecursion.py | 764 | 4.21875 | 4 | # This program is a part of my program series that I will be using to nail Python as a whole.
# Assuming given parameter is greater than or equal to 1 | Or just 0.
def Factorial(n):
if (n >= 1):
return n * Factorial(n-1)
else:
return 1
# Function Fibonacci will take "n" as parameter, in whic... | true |
e32e692b073d079bb59aa2ed83460f8f3ff8802d | mukeshmithrakumar/PythonUtils | /PythonMasterclass/Exercise2.py | 1,362 | 4.5625 | 5 | """
Create a program that takes an IP address entered at the keyboard
and prints out the number of segments it contains, and the length of each segment.
An IP address consists of 4 numbers, separated from each other with a full stop. But
your program should just count however many are entered
Examples of the input you... | true |
0512db35031316c393b4571c8dca11b0a411b22a | kramin343/test_2 | /first.py | 428 | 4.28125 | 4 | largest = None
smallest = None
while True:
num1 = input("Enter a number: ")
try:
num = float(num1)
except:
print('Invalid input')
continue
if num == "done" :
break
if largest == none:
largest = num
smallest = num
if largest < num:
largest ... | true |
0ca502687d92d2e25228cf70a6cc1fe8499ae045 | victormaiam/python_studies | /conditions.py | 1,111 | 4.15625 | 4 | is_hot = False
is_cold = False
if is_hot:
print("It`s a hot day.")
print ("Drink plenty of water.")
elif is_cold:
print("It`s a cold day.")
print("Wear warm clothes.")
else:
print("It`s a lovely day.")
print("Enjoy your day.")
tem_credito = False
preco = 1000000
preco1 = preco * 0.10
preco2 ... | false |
3e7950446a092a65ef871c98e64e9820a6e637a5 | victormaiam/python_studies | /exercise1_4.py | 399 | 4.3125 | 4 | ''''
Write a function that returns the sum of multiples of 3 and 5 between 0 and limit (parameter). For example, if limit is 20, it should return the sum of 3, 5, 6, 9, 10, 12, 15, 18, 20.
'''
def calcula_soma(limite):
soma = 0
for i in range(0, limite + 1):
if i%3 == 0 or i%5 == 0:
soma =... | true |
28d5915b71c0f0ce0266c6169d724582b0d3963c | ranju117/cegtask | /7.py | 286 | 4.21875 | 4 | #tuple
tuple1 = ('python', 'ruby','c','java')
list1 = ['python','ruby','c','java']
print tuple1
print list1
# Let's include windows in the list and it works!
list1[1] = "windows"
list1[2]="Python"
print list1
# Windows does not work here!
tuple1[1] = "windows"
print tuple1 | true |
2293c26f5ae1fdf5417ce4033829cc36c80cff00 | furkanaygur/Codewars-Examples | /RemoveTheParantheses.py | 754 | 4.4375 | 4 | '''
Remove the parentheses
In this kata you are given a string for example:
"example(unwanted thing)example"
Your task is to remove everything inside the parentheses as well as the parentheses themselves.
The example above would return:
"exampleexample"
Notes
Other than parentheses only letters and spaces... | true |
d7eb20ba3f3a7b3b858265fb5dc87aea3939d909 | furkanaygur/Codewars-Examples | /MatrixAddition.py | 1,056 | 4.15625 | 4 | '''
Write a function that accepts two square matrices (N x N two dimensional arrays), and return the sum of the two. Both matrices being passed into the function will be of size N x N (square), containing only integers.
How to sum two matrices:
Take each cell [n][m] from the first matrix, and add it with the sam... | true |
a8477323029366675ff8de5169e40fbc701ffe0a | furkanaygur/Codewars-Examples | /SplitStrings.py | 844 | 4.28125 | 4 | '''
Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_').
Examples:
solution('abc') # should return ['ab', 'c_']
solution('abcdef') # shou... | true |
ad213ac20a71fb84dfa39d4ad5375110c6f6281b | furkanaygur/Codewars-Examples | /Snail.py | 2,004 | 4.3125 | 4 | '''
Snail Sort
Given an n x n array, return the array elements arranged from outermost elements to the middle element, traveling clockwise.
array = [[1,2,3],
[4,5,6],
[7,8,9]]
snail(array) #=> [1,2,3,6,9,8,7,4,5]
For better understanding, please follow the numbers of the next array consecutiv... | true |
4e5453723e9224120e84b3f6713af9aa84c647a6 | FA0AE/Mision-03 | /Boletos.py | 1,510 | 4.15625 | 4 | # Autor: Francisco Ariel Arenas Enciso
# Actividad : Cálculo del total a pagar de boletos dependiendo de su clase
'''
Función que recibe los datos de entrada de la función main (número de boletos) como parametros, los alamcena en
variables y realiza las operaciones artimeticas necesarias para devolver datos de sa... | false |
0d644ab18e56d13805766663cc0fb4bf7fd20840 | reeha-parkar/python | /dunder_magic_methods.py | 1,006 | 4.15625 | 4 | import inspect
'''x = [1, 2, 3]
y = [4, 5]
print(type(x)) # Output: <class 'list'>
# Whatever we make it print, it follows a certain pattern
# Which means that there is some class related method that works uunder the hood to give a certain output
'''
# Let's make our own data type:
class Person:
def __init__(self... | true |
bdee03756772c0848b3a27bf3c309e3523205975 | reeha-parkar/python | /classmethod_and_staticmethod.py | 1,109 | 4.1875 | 4 | # class methods and static method:
# class method is a method in the class whcih takes te class name as a parameter, requires class instances
# static method is a method which can be directly called without creating an instance of the class
class Dog:
dogs = []
def __init__(self, name):
self.name = nam... | true |
0232446325b58ecb878807316e3007eff77940fe | lalitp20/Python-Projects | /Self Study/Basic Scripts/IF_STATEMENT.py | 213 | 4.34375 | 4 | # Example for Python If Statement
number = int(input(" Please Enter any integer Value: "))
if number >= 1:
print(" You Have Entered Positive Integer ")
else:
print(" You Have Entered Negative Integer ")
| true |
c0597e939d13b6fdecd2e374868a4547128ee79a | lalitp20/Python-Projects | /Self Study/Basic Scripts/String Indexing_1.py | 377 | 4.125 | 4 | x = (11, 21, 31, 41, 51, 61, 71, 81, 91)
# Positive Indexing
print(x[0])
print(x[3])
print(x[6])
print('=======\n')
# Negative Indexing
print(x[-1])
print(x[-5])
print(x[-7])
print('=======\n')
# Accessing Nested Tuple Items
Mixed_Tuple = ((1, 2, 3), [4, 5, 6], 'Lalit')
print(Mixed_Tuple[0][0])
print(Mixed_Tuple[... | false |
b203678db14a642b6da0446d34aa0223a7010718 | lalitp20/Python-Projects | /Self Study/Basic Scripts/For_ELSE Statement.py | 263 | 4.25 | 4 | number = int(input(" Please Enter any integer below 100: "))
for i in range(0, 100):
if number == i:
print(" User entered Value is within the Range (Below 100)")
break
else:
print(" User entered Value is Outside the Range (Above 100)")
| true |
7b70d150000739cb2e83695b2908f09c6e1e13bf | hfyeomans/python-100days-class | /day_13_debugging/debugging fizzbuzz.py | 1,094 | 4.15625 | 4 | # # Orginal code to debug
# for number in range(1, 101):
# if number % 3 == 0 or number % 5 == 0:
# print("FizzBuzz")
# if number % 3 == 0:
# print("Fizz")
# if number % 5 == 0:
# print("Buzz")
# else:
# print([number])
for number in range(1, 101):
if number % 3 == 0 and number % 5 == 0: #... | true |
5bf7b52e8961a49b3667ae1731295ae1719a0900 | aishtel/Prep | /solutions_to_recursive_problems/geometric_progression.py | 655 | 4.34375 | 4 | # Geometric progression using recursion
# starting term = a = 1
# factor = r = a2/a1
# Find the nth term - 8th term
# 1, 3, 9, 27, ...
def geo_sequence(a, r, n):
if r == 0 or r == 1:
raise Exception("Sequence is not geometric")
if n < 1:
raise Exception("n should be >= 1")
if a == 0:
... | true |
f5dab06d3a74c77757d299124fbe8bcabbfa3c07 | aishtel/Prep | /solutions_to_recursive_problems/factorial_recursive.py | 465 | 4.5 | 4 | # Return the factorial of a given number using recursive method.
# Example:
# n = 6
# fact = 6*5*4*3*2*1 = 720
def factorial(n):
if n < 0:
raise Exception("n should be >= 0")
elif n == 0:
return 1
elif n == 1:
return 1
else:
return n * factorial(n - 1)
print "The fac... | true |
d5d66badeefb003f0d8356f94586ed89d869fc5e | Andrew-Callan/linux_academy_python | /age | 248 | 4.15625 | 4 | #!/usr/bin/env python3.7
name = input("What is your name? ")
birthdate = input("What is your birthday? ")
age = int(input("How old are you? "))
print(f"{name} was born on {birthdate}")
print(f"Half your age is {age/2}")
print(f"Fuck you {name}")
| true |
1c84b38bb37582851c05603793f51697860ac906 | Wyuchen/python_hardway | /48.py | 929 | 4.125 | 4 | #/usr/bin/python
#encoding=utf8
#笨方法学python-第四十八题
#目的:编辑出一个能够扫描出用户输入的字,并标注是那种类型的程序
#定义初始化的数据:
Direction=['Direction','north','south','east','west']
Verb=['Verb','go','stop','kill','eat']
Adjective=['Adjective','the','in','of','from','at','it']
Noun=['Noun','door','bear','pricess','cabine']
print '用户可以输入的词有:'
print Dir... | false |
e5de3dc1d18e6f517f24b58851dd96d88b007999 | Wyuchen/python_hardway | /29.py | 484 | 4.28125 | 4 | #!/usr/bin/python
#coding=utf-8
#笨办法学 Python-第二十九题
#条件判断语句if
people=20
cats=30
dogs=15
if people < cats:
print 'too many cats!too little people'
if people > cats:
print 'too many people,too little cats'
if people < dogs:
print 'the world is drooled on'
if people > dogs:
print 'the world is dry'
dogs+=... | true |
3e7b21d4fc0b9776ec7990f6aff7e5ae7abe7d1c | dianeGH/working-on-python | /menu/main.py | 1,100 | 4.53125 | 5 | #Write a program that allows user to enter their favourite starter, main course, dessert and drink. Concatenate these and output a message which says – “Your favourite meal is .........with a glass of....”
def function_1():
user_name = input("Hi there, what's your name? \n")
#print ("Nice to meet you " + user_name + "... | true |
09b28c6215e30d68fe17becca9b4495559ccb9de | dianeGH/working-on-python | /depreciation/main.py | 349 | 4.28125 | 4 | #A motorbike costs £2000 and loses 10% of its value every year. Using a loop, print the value of the bike every following year until it falls below £1000.
print("Today, Jim bought a motorbike for £2000.00")
year = 1
cost = 2000
while cost >1000:
print("At the end of year ",year,", Jim's bike is worth £", cost)
... | true |
5361bceaf8f580c2855c45a3396525a7a326bffa | shubhneetkumar/python-lab | /anagram,py.py | 203 | 4.15625 | 4 | #anagram string
s1 = input("Enter first string:")
s2 = input("Enter second string:")
if(sorted(s1) == sorted(s2)):
print("string are anagram")
else:
print("strings are not anagram")
| true |
c69eda975eaa6a5d7da163d458845a1e4a9e3366 | iloveyii/tut-python | /loop.py | 259 | 4.15625 | 4 | # For loop
fruits = ['banana', 'orange', 'banana', 'orange', 'grapes', 'banana']
print('For loop:')
for fruit in fruits:
print(fruit)
# While loop
count = len(fruits)
print('While loop')
while count > 0:
print(count, fruits[count-1])
count -= 1
| true |
ee5f15707242184f822ab27a6e05f93b3c296344 | thiagocosta-dev/Gerador_senha_simples | /senha_para_filas.py | 806 | 4.125 | 4 | # AUTOR: Thiago Costa Pereira
# Email: thiago.devpython@gmail.com
print('=-' * 20)
print('-- GERADOR DE SENHA --'.center(40))
print('=-' * 20)
senhas_comuns = [0]
senhas_pref = [0]
while True:
print()
print('--' * 20)
print('[1] SENHA COMUM')
print('[2] SENHA PREFERENCIAL')
print('[3] SAIR')
... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.