blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
a3d204581bd24365e6ebb3ce7fb1d750e795237f | tieje/holbertonschool-higher_level_programming | /0x0B-python-input_output/0-read_file.py | 240 | 4.1875 | 4 | #!/usr/bin/python3
"""This module reads a text file"""
def read_file(filename=""):
"""This method reads a file."""
with open(filename, mode="r", encoding="utf_8") as file:
for line in file:
print(line, end='')
| true |
32040098ac2f626214124dab1cc919b8aebd8eb9 | GaryGonzenbach/python-exercises | /control_structures_examples.py | 1,991 | 4.3125 | 4 | print('Good Morning Ada!')
i_like_coffee = True # switch to False to test else
if i_like_coffee:
print('I like coffee!')
else:
print('Ok - lets have some tea')
# ---
pizza_reference = input('What kind of pizza do you like?')
if pizza_reference == 'pineapple and hot sauce':
print('Wow - what a coincidence!... | true |
b27acfbc54aeae4b5741ed27fa849e09d9c8a46a | skyrydberg/LPTHW | /ex3/ex3.py | 1,251 | 4.25 | 4 | # Exercise 3: Numbers and Math
# I addressed Exercises 1 & 2 in the same post because they
# are trivial. This one gets its own post.
print "I will now count my chickens:"
# Note the order of operations holds here, a kind programmer
# would type this 25 + (30 / 6) for clarity, we divide 30 by 6
# and then add the res... | true |
618535ad2c3d769521c1a60f73b2e37f26ee5cc3 | GaddamMS/PythonMoshYT | /own_program_weather_notify_0.py | 1,481 | 4.4375 | 4 | '''Feature: Intimate user with precautions based on weather when going outside
Problem Statement: We should identify the weather and tell the user of necessary precautions
Solution:
1. We will ask the user for temperature
2. Based on the given temperature, we will intimate user with self - defined precautions
'''
... | true |
7b28907cfd5737677e3d0380f631272847cfe936 | monsybr11/FirstCodingAttempts | /textrealiser.py | 535 | 4.21875 | 4 | abc = input("Type any text in.\n")
abc = str(abc) # converting the input to a string in case of text and digits being used.
if abc.islower() is True:
print("the text is lowercase!")
if abc.isupper() is True:
print("the text is Uppercase!")
if abc.isupper() is False and abc.islower() is False and ... | true |
095c16d2e25fe3e5d076ea09bad8b18c0e0e140a | SastreSergio/Datacademy | /paper_scissors.py | 2,815 | 4.1875 | 4 | #A game of Scissors, paper and stone against the machine
import random
def choice_player2(): #Function with random for the other player, in this case: the machine
options = ['Scissors', 'Paper', 'Stone']
random_choice = random.choice(options)
return random_choice
def play(choice_player1, choice_player2):... | true |
f1217d5ddd3b8c780f5d08eda75bd31481cd6b38 | kissann/Lab1 | /five.py | 966 | 4.4375 | 4 | #Задача 5 Задано чотири точки паралелограма за допомогою координат його вершин.
# Визначити площу паралелограма та довжину його діагоналей. Результат округлити до тисячних.
print("Введите координаты первой точки:")
x1= input("x1 = ")
y1= input("y1 = ")
print("Введите координаты второй точки:")
x2= input("x2 = ")
y2= in... | false |
a141c79f05ee4dfe9eb04f36e7ce0e2ca59e8fc2 | tdounnyy/SampleCodes | /python/helloPython.py | 961 | 4.15625 | 4 | #!/usr/bin/python
print 'hello python'
print ''
print '#\/*\'?:"' # fuck the golden lian
print "what do you mean?"
print '''hey, son. what`s your name?
do \
i\
know # Hail the winterfell
you?
'''
i = 5
print i
print i+1
i=i+1
print i
string= '''Which family do you serve?
Long live the king!'''
print... | false |
27804af36166140fc6655be1c6fd1f60096f34ef | vickiedge/cp1404practicals | /prac_04/quick_picks.py | 584 | 4.125 | 4 | #relied heavily on solution for this exercise. Still not printing all quick picks
import random
MIN_NUMBER = 1
MAX_NUMBER = 45
NUMBER_PER_LINE = 6
number_of_quick_picks = int(input("How many quick picks? "))
for i in range(number_of_quick_picks):
quick_pick = []
for j in range(NUMBER_PER_LINE):
numbe... | true |
11ed3a0ab634d3fc1568dbfb38c9d9aff5aced21 | introprogramming/exercises | /exercises/fibonacci/fibonacci-iterative.py | 735 | 4.25 | 4 | '''An iterative version, perhaps more intuitive for beginners.'''
input = int(input("Enter a number: "))
def fibonacci_n(stop_after):
"""Iteratively searches for the N-th fibonacci number"""
if stop_after <= 0:
return 0
if stop_after <= 2:
return 1
prev = 1
curr = 1
count = 2... | true |
e6ca6a8207216df4ce34d79187e9e41e147ba4b8 | introprogramming/exercises | /exercises/talbas/convert.py | 657 | 4.1875 | 4 | #
# Decimal to binary (and back) converter
#
# Usage:
# python convert.py bin|dec 100
#
import sys
def dectobin(dec_string):
"""Convert a decimal string to binary string"""
bin_string = bin(int(dec_string))
return bin_string[2:]
def bintodec(bin_str):
"""Convert a binary string to decimal string"""
num = 0
in... | false |
e435dd76259d6ad09b57f30f5b8b3647f565b086 | shea7073/Algorithm_Practice | /phone_number.py | 495 | 4.28125 | 4 | # Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string
# of those numbers in the form of a phone number.
def create_phone_number(arr):
if len(arr) != 10:
return ValueError('Array Must be 10 digits long!')
for i in arr:
if i > 9 or i < 0:
... | true |
f6a6fe07b1678d57b8b3d600b2dfe9b84458313b | frclasso/CodeGurus_Python_mod1-turma1_2019 | /atividades/imc_cris.py | 1,218 | 4.15625 | 4 | #imc = peso / altura * altura
#input
#criar um menu com osparametros
print('Vamos calcular seu Indice de massa corporal!')
input('Digite Enter para comecar!')
altura = 0
peso = 0
while peso<=0:
peso = float(input('Por favor digite seu peso: '))
if peso<=0:
print('Digite um valor maior que 0!')
whi... | false |
dd7aa50d126ddab75b24da79f3b0ac1b0d61bcf3 | gy09/python-learning-repo | /PythonLearning/FunctionLearning/forLoop.py | 290 | 4.15625 | 4 | def upperConversion():
sentence = input("Enter the sentence to loop on:")
for word in sentence:
print(word.upper())
def listLoop():
friends = ["test1","test2","test3","test4"]
for friend in friends:
print(friend.upper())
upperConversion()
listLoop()
| true |
758b8bec6328bfb4e403b1ea4bd3e12ca235d0b8 | yxh13620601835/store | /day10/car.py | 2,671 | 4.4375 | 4 | '''
车类:
属性:车型号,车轮数,车身颜色,车重量,油箱存储大小 。
功能:跑(要求参数传入车的具体功能,比如越野,赛车)
创建:法拉利,宝马,铃木,五菱,拖拉机对象
'''
class Car:
__type=""
__wheelnum=0
__color=""
__weight=0.0
__fuelstorge=0.0
def setType(self,type):
self.__type=type
def getType(self):
return self.__type... | false |
c2853f4bd7682ed91b22dd8040e727299bff2b52 | vharmers/Kn0ckKn0ck | /Parsing/Readers/Reader.py | 1,416 | 4.1875 | 4 | import abc
class Reader:
"""
Abstract class which defines the minimal functionality of Readers. You will need to extend from tis class
if you want to create your own reader.
"""
def __init__(self):
pass
@abc.abstractmethod
def get_count(self):
"""
Gets ... | true |
0bb76f227b04593d109b4abf127f95aa5348c09f | jraulcr/curso-python | /practica_listas.py | 1,229 | 4.25 | 4 | miLista=["María", "Pepe", "Marta", "Antonio"]
#Accede a todos los elementos
print(miLista[:])
#Acceso por indice (Desde el primer lugar)
print(miLista[2])
#Acceso por subindice (Desde el último lugar)
print(miLista[-1])
#Acesso por porciones
print(miLista[1:3])
print(miLista[2:])
print(miLista[:2])
#Agrega nuevo elem... | false |
f2e3ddcbfedf9b3860590b28dbfd032e106e9390 | aayush2906/learning_curve | /for.py | 559 | 4.34375 | 4 | '''
You are given a number N, you need to print its multiplication table.
'''
{
#Initial Template for Python 3
//Position this line where user code will be pasted.
def main():
testcases=int(input()) #testcases
while(testcases>0):
numbah=int(input())
multiplicationTable(numbah)
print()
... | true |
a4e7ded1eac764352cb65888ba36ef4289bd6c4b | nathanesau/data_structures_and_algorithms | /_courses/cmpt225/lecture09/python/stack.py | 1,661 | 4.15625 | 4 | class Node:
def __init__(self, data):
self.data = data
self.prev = None
class StackLinkedList:
"""
linked list implementation of stack
- similar to singly linked list
"""
def __init__(self):
self.top = None
def push(self, data):
"""
add element to ... | true |
9a044231cb1d922651e6b3463e5f3696cf7b18af | nathanesau/data_structures_and_algorithms | /_courses/cmpt225/practice4-solution/question6.py | 892 | 4.1875 | 4 | """
write an algorithm that gets a tree and computes its
depth using iterative implementation.
"""
"""
write an algorithm that gets a tree and computes its size
using iterative implementation.
"""
from binary_tree import build_tree1, build_tree2, build_tree3
def get_depth(bt):
"""
use level-order iterative a... | true |
3875d9590a0a90962b5680329c571b9e300d4540 | Pranav2507/My-caption-project | /project 2.py | 398 | 4.125 | 4 | filename=input('Enter a filename: ')
index=0
for i in range(len(filename)):
if filename[i]=='.':
index=i
print(filename[index+1: ])
filename = input("Input the Filename: ")
f_extns = filename.split(".")
print ("The extension of the file is : " + repr(f_extns[-1]))
fn= input("Enter Filena... | true |
aba6611d825897b03b9d9c4a7adca8f2e6b66c69 | uniite/anagram_finder | /modules/util.py | 449 | 4.125 | 4 | import string
def remove_punctuation(word):
"""
Return the given word without any punctuation:
>>> remove_punctuation("that's cool")
'thatscool'
"""
return "".join([c for c in word if c in string.ascii_letters])
def save_anagram_sets(sets, output_file):
"""
Save the given list of a... | true |
5d8b5f6d8436b68596e79fd29672031d4e0fbd03 | kwstu/Algorithms-and-Data-Structures | /BubbleSort.py | 443 | 4.15625 | 4 | def bubble_sort(arr):
# Go over every element (arranged backwards)
for n in range(len(arr)-1,0,-1):
# For -1 each time beacuse each loop an elemnt will be set in position.
for k in range(n):
# Check with the rest of the unset elements if they are greater than one another if so, switch
... | true |
c608d17aeb079332cf51be22647352ce2abc5085 | titanlien/workshop | /task04/convert.py | 1,167 | 4.15625 | 4 | #!/usr/bin/env python3
import argparse
"""https://www.rapidtables.com/convert/number/how-number-to-roman-numerals.html"""
ROMAN_NUMERALS = [
(1000, 'M'),
(900, 'CM'),
(500, 'D'),
(400, 'CD'),
(100, 'C'),
(90, 'XC'),
(50, 'L'),
(40, 'XL'),
(10, 'X'),
(9, 'IX'),
(5, 'V'),
... | true |
06b8339073dff3c0e3207154c9a1277f63202956 | davidygp/Project_Euler | /python/prob4.py | 893 | 4.34375 | 4 | """
Problem 4:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
def find_max_palin_product() -> int:
"""
Find the largest palindrome made from the... | true |
dd37b3f9e28b6c26000a9c94f1883c647708b3ae | razvitesting/Automation-Testing | /mylist.py | 206 | 4.125 | 4 | mylist = []
mylist.append(1)
mylist.append(2)
mylist.append(3)
print(mylist[0]) # prints 1
print(mylist[1]) # prints 2
print(mylist[2]) # prints 3
# prints out 1,2,3
for x in mylist:
print(x) | true |
044be8776e8a959acbac43836290556e632b3e99 | milindukey/Python | /Beginners/control loop.py | 1,022 | 4.375 | 4 | largestNumber = -99999999
counter = 0
number = int(input("Enter a number or type -1 to end program: "))
while number != -1:
if number == -1:
continue
counter += 1
if number > largestNumber:
largestNumber = number
number = int(input("Enter a number or type -1 to end program: "))
if co... | true |
4b41f7f1a744e6820d77049da3443faadacaa9a6 | Abinaya3198/shivanya | /f4.py | 211 | 4.34375 | 4 | al = input("enter the character : ")
if((al >= 'a' and al <= 'z') or (al >= 'A' and al <= 'Z')):
print("The Given Character ", ch, "is an Alphabet")
elif(al == '?'):
print("no")
else:
print("not an alphabet")
| true |
5f12ff4b364897d99f9a9ac78243f1ad19907479 | jewellwk/sample-code | /Python/Cartesian Distance/Methods.py | 1,132 | 4.25 | 4 | #Compute the Cartesian distance between 2 points with coordinates (x1,y1) and (x2,y2) = sqrt((x2-x1)^2+(y2-y1)^2))
import math
def solveCart():
x1 = int(input("Enter a value for x1: "))
y1 = int(input("Enter a value for y1: "))
x2 = int(input("Enter a vlaue for x2: "))
y2 = int(input("Enter a value for y2: "))
ca... | false |
41801fad4b3a2693ff4dbf696e7e5fa6e86c9dfc | ignaciomgy/python | /Tests/LambdaYmapYfilter.py | 774 | 4.21875 | 4 | #MAP mapea una funcion definida sobre un conjunto de objetos
#FILTER aplica en una funcion sobre un conjunto y los filtra por la funcion aplicada
#ej defino las funciones a mapear y filtrar
def cuadrado(a):
return a**2
def pares(a):
return a%2==0
numeros = [1,2,3,4,5,6]
#pongo dentro de una lista el resultad... | false |
5fbc21600fc9ea53a5e16fa3a00389efecc8be91 | nitin-cherian/LifeLongLearning | /Web_Development_Python/RealPython/flask-blog/sql.py | 684 | 4.125 | 4 | # sql.py - Create a sqlite3 table and populate it with data
# import sqlite3 library
import sqlite3
# create a new database if the database already does not exist
with sqlite3.connect("blog.db") as connection:
# get a cursor object to execute sql commands
c = connection.cursor()
# create the table
... | true |
b70018a393d272324b542a0d6bc40ce0e1a5a23e | nitin-cherian/LifeLongLearning | /Python/Experiments/ITERATORS/Polyglot.Ninja/why_iterables.py | 494 | 4.75 | 5 | # why_iterables.py
print("""
Iterator behaves like an iterable in that it implements the __iter__ method. Then why do we need iterables?
When StopIteration is raised from an iterator, there is no way to iterator over the iterator again, because
iterator maintains the state and return self when iter is invoked on it. ... | true |
83b8306a533237034ce55d980ee49b44d9ba0f78 | nitin-cherian/LifeLongLearning | /Python/Experiments/ITERATORS/Polyglot.Ninja/iterators_should_be_iterable.py | 2,400 | 4.40625 | 4 | # iterators_should_be_iterable
print('''
According to the official doc:
*********
Iterators should implement the __iter__ method that returns the iterator object itself,
so every iterator is also iterable and may be used in most places where other iterables
are accepted.
*********
{code}
class HundredIterator:
... | true |
d0c3eee3504d0e0fb919e97c9396080bb70719b9 | indra-singh/Python | /prime_number.py | 350 | 4.125 | 4 | #Write a program to print if a number is a prime number *
n=int(input("Enter lower number :"))
m=int(input("Enter upper number :"))
print("Prime numbers between",n,"and",m,"are:")
for num in range(n,m+1):
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
els... | true |
d71afbf08a4088e3770dc46957e7b9e45a6d3e03 | aniGevorgyan/python | /math_util.py | 1,194 | 4.1875 | 4 | #!/usr/bin/python
# 1. Math simple actions
"""
:input a, b
:output: a+b, a-b, a*b, a/b
"""
def mathActions(a, b):
add = a + b
minus = a - b
mult = a * b
div = a / b
return ('Addition is ' + str(add), 'Subtraction is ' + str(minus),
'Multiplication ' + str(mult), 'Division is ' + str(div))
# 2. ... | false |
4c7173d644078932261cf2f33aa568baf85671f1 | imaaduddin/TreeHouse-Data-Structures-And-Algorithms | /recursion.py | 297 | 4.125 | 4 | # def sum(numbers):
# total = 0
# for number in numbers:
# total+= number
# return total
# print(sum([1, 2, 3, 4, 5]))
# Recursive Function
def sum(numbers):
if not numbers:
return 0
remaining_sum = sum(numbers[1:])
return numbers[0] + remaining_sum
print(sum([1, 2, 7, 9]))
| true |
88891cba26521787b2d7eeecd1f2e558baf8f0fd | orhanyagizer/Python-Code-Challange | /count_of_wovels_constants.py | 549 | 4.3125 | 4 | #Write a Python code that counts how many vowels and constants a string has that a user entered.
vowel_list = []
constant_list = []
word = input("Please enter a word: ").lower()
for i in word:
if i in set("aeiou"):
vowel_list.append(i)
count_vowel = len(vowel_list)
else:
constant_list.append(... | true |
541d39fe2f6ef9cc7f86284554fc10a7fe0d7678 | JamesMcPeek/Python-100-Days | /Day 2.py | 342 | 4.125 | 4 | print("Welcome to the tip calculator!")
billTotal = float(input("What is the total bill? "))
percTip = int(input("What percentage tip would you like to give? "))
people = int(input("How many people will split the bill? "))
results = round((billTotal * (1 + (percTip / 100))) / people,2)
print("Each person should pay: " ... | true |
caf58ea2197a68273d5e5a8a7c2b85925ed42bb4 | Lucas-JS/Python_GeekUni | /loop_for.py | 1,107 | 4.21875 | 4 | """
Loop for
Utilizamos loops para iterar sobre sequencias ou sobre valores iteráveis
Exemplos de iteráveis:
- String
nome = 'John Wayne'
- Lista
lista = [1, 3, 5, 7, 9]
- Range
numeros = range(1, 10)
"""
nome = 'John Wayne'
lista = [1, 3, 5, 7, 9]
numeros = range(1, 10)
# Exemp... | false |
7419e55dcfacf0eab400524d1fd3cc1cbe5f48c6 | srajamohan1989/aquaman | /StringSlicer.py | 392 | 4.59375 | 5 | #Given a string of odd length greater 7, return a string made of the
# middle three chars of a given String
def strslicer(str):
if(len(str)<=7):
print("Enter string with length greater than 7")
else:
middleindex= int(len(str)/2)
print(text[middleindex-1:middleindex+2])
text=in... | true |
2d2c2f7ea670a516a2716d73a92d986b8498325e | joshl26/tstcs_challenge_solutions | /chapter14_ex1.py | 1,456 | 4.34375 | 4 | # This question actually does not make much sense
# because it is impossible to make a binary tree with no
# leaf nodes! My mistake!
class BinaryTree():
def __init__(self, value):
self.key = value
self.left_child = None
self.right_child = None
def insert_left(self, value):
if s... | true |
8053fdd5fed3a656f5e52ae6e66af9a62976500d | jnyryan/rsa-encryption | /p8_is_prime.py | 965 | 4.375 | 4 | #!/usr/bin/env python
"""
Implement the following routine:
Boolean fermat(Integer, Integer)
such that fermat(x,t) will use Fermat's algorithm to determine if x is prime.
REMEMBER
Fermat's theorm asserts that if n is prime and 1<=a<=n, then a**n-1 is congruent to 1(mod n)
"""
import p5_expm
import random
def i... | true |
efa2dcde8d6fddbcbea0ce5b0defa790986396ef | martinpeck/broken-python | /mathsquiz/mathsquiz-step3.py | 1,822 | 4.15625 | 4 | import random
# this function will print a welcome message to the user
def welcome_message():
print("Hello! I'm going to ask you 10 maths questions.")
print("Let's see how many you can get right!")
# this function will ask a maths question and return the points awarded (1 or 0)
def ask_question(first_number, ... | true |
b66bf8a200e19fe87eb82eaf0667bca53f7fc8c3 | sumitsrv121/parctice2 | /Excercise3.py | 227 | 4.1875 | 4 | def reverse_string(arr):
new_list = []
for x in arr:
new_list.append(x[::-1])
return new_list
fruits = ['apple','mango','orange','pears','guava','pomegranate','raspberry pie']
print(reverse_string(fruits)) | true |
3d9abc8e44dccf5964b610e95be724b8964d2185 | helaluddin92/Python-Challanges | /how to find average N number in python.py | 283 | 4.25 | 4 | # How to find average N number in python
def avg_n(num):
total_sum = 0
for n in range(num):
number = int(input("Enter any number "))
total_sum += number
avg = total_sum / num
return avg
result = avg_n(int(input("How many number?")))
print(result)
| false |
f8adcc2bdd040963560c5fa96ae48e219b9afe0f | aditmulyatama/pertemuan-6 | /tuple.py | 868 | 4.46875 | 4 | # Tuple
# Tuple adalah struktur data kolektif sekuensial yang tidak dapat diubah bawaan python
# Tuple juga bisa menyimpan banyak tipe data yang berbeda dan mengizinkan duplikasi data
this_is_tuple = ("oke", 100, 9.0, "oke")
# print(this_is_tuple, " is type of ", type(this_is_tuple))
# Akses data di Tuple
# print("F... | false |
12dda19350218d4ad3b9a4bbae13a72101bd44a5 | Chithra-Lekha/pythonprogramming | /co5/co5-1.py | 346 | 4.40625 | 4 | # Write a python program to read a file line by line and store it into a list.
l = list()
f = open("program1.txt", "w")
n = int(input("Enter the number of lines:"))
for i in range(n):
f.write(input("Enter some text:")+"\n")
f.close()
f = open("program1.txt", "r")
for i in f:
print(i)
l.append(i[... | true |
04aea542b7903d07b756e8a7287b720f8938a414 | Chithra-Lekha/pythonprogramming | /co2-8.py | 335 | 4.28125 | 4 | list=[]
n=int(input("enter the number of words in the list:"))
for i in range(n):
x=input("enter the word:")
list.append(x)
print(list)
length=len(list[0])
temp=list[0]
for i in list:
if len(i) > length:
length=len(i)
temp=i
print("the longest word is of length",... | true |
29a2c2a520dfad83d106dddf1ce3d7039ac437c6 | dannymulligan/Project_Euler.net | /Prob_622/primes.py | 1,962 | 4.125 | 4 | #!/usr/bin/python
import time
############################################################
def calculate_primes(limit, prime_table, prime_list):
start_time = time.clock()
if (limit>len(prime_table)):
raise Exception("prime_table is too small ({} entries, need at least {})".format(len(prime_table), lim... | true |
771c6cc674e6299c842a3e388bca7cc0f2252bf1 | srinijadharani/DataStructuresLab | /02/02_c_delete_duplicate.py | 594 | 4.3125 | 4 | # 2c. Program to delete duplicate elements from an array
# import the array module
import array as arr
array1 = arr.array("i", [1, 3, 6, 6, 8, 1, 9, 4, 3, 0, 4])
# initial array
print("Initial array is:")
for a in array1:
print(a, end = ", ")
# function to delete duplicate elements
def delete_duplicate(a... | true |
1f81e477ec81fde2f1edcbf9a33c2a1580f8d8d6 | srinijadharani/DataStructuresLab | /10/10_queue_implementation.py | 746 | 4.15625 | 4 | class Queue(object):
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def enqueue(self, item):
self.items.insert(0, item)
def dequeue(self):
return self.items.pop()
def size(self):
return len(self.items)
def display... | false |
5a18eac0d8a069a3a7b38ce9281616e0027fc02c | srinijadharani/DataStructuresLab | /08/08_stack_implementation.py | 1,029 | 4.28125 | 4 | '''
08. Program to create a stack and perform various operations on it.
'''
class Stack(object):
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, items):
self.items.append(items)
def pop(self):
... | true |
f1c8c835ca5b6efbb1e31eafc5ee2a5dc77fde26 | mouayadd/TurtleArtDesign | /mydesignfunctions.py | 584 | 4.34375 | 4 | import turtle #brings in turtle
bob = turtle.Turtle() #gives turtle the name bob
def draw_star(size,color): #creates a function
bob.penup #pulls the pen up to make sure no lines are drawn when moving
bob.goto(10,15)
bob.pendown #drops the pen in order to start drawing again
angle=120
bo... | true |
a36f69ae0e11a20138a5232983d13af4660476dc | BabyNaNaWang/myPythonProgram | /列表排序.py | 722 | 4.25 | 4 | import random
#列表排序
nums = [1,34,5,90,80]
'''nums.sort(reverse = True)
print(nums)'''
nums.reverse()
print(nums)
newNums = [100,20,18,39,90]
#newNums.reverse() #倒置
#newNums.sort() #从小到大排序
newNums.sort(reverse = True) #从大到小排序
print(newNums)
#列表的常见操作
#1、添加 insert
names = ['he','she','his']
names.insert(0,'him')
print(... | false |
cafd46886bf1713a537458db19daa24dabd93bc5 | BabyNaNaWang/myPythonProgram | /列表循环.py | 343 | 4.125 | 4 | names = ['gaga','didi','gana']
'''print(names[0])
print(names[1])
print(names[2])
for x in names:
print(x)'''
#查询是否数字在列表内
findFlag = 0
insertName = input('请输入名字:')
for temp in names:
if temp == insertName:
findFlag = 1
break
if findFlag ==1 :
print('yes')
else:
print('no')
| false |
4b400c91a2d5c8c918c7af9c216fbd687c357751 | andreylrr/PythonDeveloperHW5 | /borndayforewer.py | 1,053 | 4.5 | 4 | """
МОДУЛЬ 2
Программа из 2-го дз
Сначала пользователь вводит год рождения Пушкина, когда отвечает верно вводит день рождения
Можно использовать свой вариант программы из предыдущего дз, мой вариант реализован ниже
Задание: переписать код используя как минимум 1 функцию
"""
def birth_year():
year = input('Ввведит... | false |
5edebd8cdbebcb9ae782c6d8571b7e15f41a8da1 | fm3ssias/python-exercices | /02_oddOrEven.py | 529 | 4.15625 | 4 | '''
Objetivo: Mostrar pro usuário se o numero inserido é par ou impar
Entrada: Um numero
Saida: Se é impar ou par
'''
numero = 1
while numero != 0 :
numero = int(input("Digite um numero (0 para sair): "))
if numero == 0:
break
divPorQuatro = str(numero)
if int(divPorQuatro[-2:])%4 == 0 or int... | false |
a1b9bf680534dbbfbc310a822deb14f1bb4e2dad | prataprc/gist | /py/loop.py | 657 | 4.65625 | 5 | #! /usr/bin/python
# Some examples using the looping constructs in python
a = ['cat', 'dog', 'elephant']
x = 10
print type(x)
for x in a :
print x, type(x), len(x)
b = 'hello \n world'
for x in b :
print x, type(x), len(x)
# Dangerous iteration on a mutable sequence (list)
# for x in a :
# a.insert(1,... | true |
a73736d32143141ee7a794e8dbee169441c640d1 | TungstenRain/Python-conditionals_and_recursion | /koch_curve.py | 1,357 | 4.4375 | 4 | """
This module contains code from
Think Python, 2nd Edition
by Allen Downey
http://thinkpython2.com
This is to complete the exercises in Chapter 5: Conditionals and Recursion in Think Python 2
Note: Although this is saved in a .py file, code was run on an interpreter to get results
No... | true |
553dac4289f659e451c03900b34c0ea558605567 | xxxxgrace/COMP1531-19T3 | /Labs/lab03/19T3-cs1531-lab03/timetable.py | 733 | 4.25 | 4 | # Author: @abara15 (GitHub)
from datetime import date, time, datetime
def timetable(dates, times):
'''
Generates a list of datetimes given a list of dates and a list of times. All possible combinations of date and time are contained within the result. The result is sorted in chronological order.
For examp... | true |
a1b96498860d27c397fb2713cda40c85ada6b51a | sabu0912/reto3 | /reto.py | 1,965 | 4.21875 | 4 | #CADA UNA DE LAS NOTAS
while True:
try:
nota1 = int(input("Ingresa la primera nota : "))
print(f"La primera nota es :", (nota1))
nota2 = int(input("Ingresa la segunda nota : "))
print(f"La segunda nota es :", (nota2))
nota3 = int(input("Ingresa la tercera nota : "))
print(f"La tercera... | false |
2323b6570606fb1b7ad155680f0d77cbeaf5dac2 | M01eg/algo_and_structures_python | /Lesson_1/3.py | 596 | 4.125 | 4 | '''
Урок 1
Задание 3
По введенным пользователем координатам двух точек вывести уравнение прямой
вида y=kx+b, проходящей через эти точки.
'''
X1 = float(input("Введите X1: "))
X2 = float(input("Введите X2: "))
Y1 = float(input("Введите Y1: "))
Y2 = float(input("Введите Y2: "))
K = (Y2 - Y1) / (X2 - X1)
B = Y2 - K * X2... | false |
30e901c77786c1803fa054cc36961361a43b68ca | Jenoe-Balote/ICS3U-Unit6-04-Python | /list_average.py | 1,558 | 4.28125 | 4 | #!/usr/bin/env python3
# Created by: Jenoe Balote
# Created on June 2021
# This program determines the average of a 2D list
# with limitations inputted by the user
import random
def calculate_average(number_list, rows, columns):
# This function calculates the average
# sum of numbers in list
total =... | true |
cfa3db9cd7599d1a15291c5d6c2f954ebc3080c6 | arpitdixit445/Leetcode-30-day-challenge | /Day_11__Diameter_of_Binary_Tree.py | 1,135 | 4.1875 | 4 | '''
Problem Statement -> Given a binary tree, you need to compute the length of the diameter of the
tree. The diameter of a binary tree is the length of the longest path
between any two nodes in a tree. This path may or may not pass through the root.
Examp... | true |
b95a6c6882907504cfa7442d906117bed63a04f8 | hkkmalinda/python_simple_calculator | /simple_python_calculator.py | 641 | 4.15625 | 4 | # define functions
def add(a,b):
result = a + b
print(f'{a} + {b} = {result}')
def sub(a,b):
result = a - b
print(f'{a} - {b} = {result}')
def mul(a,b):
result = a * b
print(f'{a} * {b} = {result}')
def div(a,b):
result = a / b
print(f'{a} / {b} = {result}')
#getting inputs
a = int(i... | true |
c43ebbe77c89e0e72019436179ee8fd22bdc2a50 | CeciFerrari16/Esercizi-Python-1 | /es31.py | 1,924 | 4.21875 | 4 | # Esercizio 31
'''
Fornisci la rappresentazione in binario di un numero decimale.
Dopo aver acquisito il valore del Numero da trasformare, si esegue la divisione del numero per 2
e si calcola quoziente e resto. Il resto è la prima cifra della rappresentazione binaria.
Si ripete il procedimento assegnando il quozien... | false |
df40f13d105229bd08bb69536e0a1c05a606acfa | Sudani-Coder/python | /Rock Paper Scissor Game/index.py | 2,249 | 4.5 | 4 | ## project11
# Rock - Paper - Scissor "Game"
import random
print(
"""
Winning Rules: \n
"Rock vs paper => paper wins" \n
"Rock vs scissor => Rock wins" \n
"paper vs scissor => scissor wins \n
"""
)
# Step 1: Conditions for the User
while True:
print("\nEnter Choice 1.Rock 2.Paper 3.Scisso... | false |
72080afb57f4c2e02c0a15b7a5ba49fe378cb50b | Sudani-Coder/python | /Silly sentences/silly.py | 1,050 | 4.15625 | 4 | import random
import words
def silly_string(nouns, verbs, templates):
# Choose a random template.
template = random.choice(templates)
# We'll append strings into this list for output.
output = []
# Keep track of where in the template string we are.
index = 0
# Add a while loop here.
... | true |
65cf2845d8c237a4b53f0d3091269a33557a57f2 | Sudani-Coder/python | /User Input/index.py | 286 | 4.125 | 4 | fName = input("\nwhat is your first name? ").strip().capitalize()
mName = input("\nwhat is your middle name? ").strip().capitalize()
lName = input("\nwhat is your last name? ").strip().capitalize()
print(f"\nHello World, My name is {fName:s} {mName:.1s} {lName:s}, Happy to see you.")
| true |
8a4892bb57e06dc99f908e82e6ea9adc470c0bb8 | Sudani-Coder/python | /Removing Vowels/index.py | 279 | 4.375 | 4 | ## Project: 2
# Removing Vowels
vowels = ("a", "e", "i", "o", "u")
message = input("Enter the message: ").lower()
new_message = ""
for letters in message:
if letters not in vowels:
new_message += letters
print("Message without vowels is : {} ".format(new_message)) | true |
77089197928b24182560f982d74cf2b2262987a9 | natp75/homework_4 | /homework_4/homework_4_3.py | 360 | 4.125 | 4 |
#Для чисел в пределах от 20 до 240 найти числа, кратные 20 или 21.
# Необходимо решить задание в одну строку.
#Подсказка: использовать функцию range() и генератор.
result = [x for x in range(20,240) if ((x % 20==0) or (x % 21==0))]
print(result) | false |
c0327f753e1cbd8d3bba93aa38b75a1d976e9056 | jcrock7723/Most-Common-Character---Python | /Pg368_#10_mod.py | 1,216 | 4.40625 | 4 | # Unit 8, pg368, #10
# This function displays the character that appears the most
# frequently in the sring. If several characters have the same
# highest frequency, it displays the first character with that frequency
def main():
count=[0]*26
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
index = 0
fr... | true |
7d19936ea344f55344b7e4a8e18e4efbf5e84938 | ceadoor/HacktoberFest-2020 | /Python/tints-GuessGame.py | 447 | 4.28125 | 4 | # PROGRAM-NAME : Guess Game
# By Tintu
# PROGRAM-CODE :
import random
def guess(val,x):
while ((val-x)!=0):
dif=val-x
if(dif>0):
print("Number is greater than guessed")
else:
print("Number is less than guessed")
x=int(input("Gues another number: "))
print("You guessed right!!!")
val=int(random.randra... | true |
64b7feefea06bb59afba2ebdb4598276479eb0cc | saravananprakash1997/Ranking-and-Rewarding-Project-using-Python-intermediate- | /Intermediate_Project.py | 1,878 | 4.21875 | 4 | #intermediate Python Project
#get the total marks of the students
#Rank them and highlight the top three
#Reward the top three with 1000$, 500$ and 250$ respectively
import operator
def student_details():
print()
number_of_students=int(input("Enter the number of students :"))
students_records={}
for x i... | true |
820621fd61547622d1e3208d595eeae3b2edd989 | eugurlubaylar/Python_Kod_Ornekleri | /Noktalama İşaretlerini kaldırma.py | 392 | 4.40625 | 4 | # Program to all punctuation from the string provided by the user
# define punctuation
punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
# take input from the user
my_str = input("Enter a string: ")
# remove punctuation from the string
no_punct = ""
for char in my_str:
if char not in punctuations:
no_pun... | true |
78ac7f08733f7501d3f4bdf3dfbe98c732cc25db | PatrickArthur/Python_Calculator | /python_calc.py | 954 | 4.125 | 4 | #Calculator in Python#
import math
print(" Weclome to Patrick Arthur's Calculator: V1")
print(" A) Add")
print(" B) Sub")
print(" C) Mul")
print(" D) Div")
choice = raw_input("Pick your choice: ")
if choice == "A":
print("add numbers!")
x= input("First Number: ")
y= input("Second Number: ")
... | false |
9a173033eab1402ceb4ee544aa9d5b55f683d3f6 | freeglader/python_repo | /automate_the_boring_stuff/ch3_functions/ch3_number_guessing_game.py | 2,274 | 4.3125 | 4 |
#TODO: The number guessing game will look something like the following:
#TODO: I am thinking of a number between 1 and 20. Take a guess. (Guess is too low, guess is too high)
#? My implementation, done before checking solution in the book:
import random
print('Let\'s play a game. I will pick a number between 1 and ... | true |
7d215d4ebde45fd672ee4c55e86a6e8f6fba0648 | Vivek-Muruganantham/Project-Euler | /Python Project Euler/Python Project Euler/Functions/PrimeNumber.py | 697 | 4.3125 | 4 | #Returns true if the number is prime else false
import math
def IsPrime(number):
# If number is 2, 3, 5 or 7, return IsPrime as true
if(number == 2 or number == 3 or number == 5 or number == 7):
return True
# If number is divisible by 2,3,5 or 7, return IsPrime as False
elif(number % 2 == 0 or n... | true |
0d31376a8bd4c7fbec9c225637fdfaded0f0f490 | pipo411/AT06_API_Testing | /ArielGonzales/python/session2/DaysInMonth.py | 699 | 4.15625 | 4 | def days_in_month(month):
months = {
"January": 31,
"February": 28,
"March": 31,
"April": 30,
"May": 31,
"June": 30,
"July": 31,
"August": 30,
"September": 31,
"October": 30,
"November": 31,
"December": 30
}
if (... | false |
c86e88ee54016d83cd5b25a0f1a58758d6c5e2ab | ezmiller/algorithms | /mergesort/python/mergesort.py | 988 | 4.21875 | 4 | # Merge sort
#
# How it works:
# 1. Divide the unsorted list into n sublists, each containing 1 element
# 2. Repeatedly merge sublists to produce new sorted sublists until there
# is only 1 sublist remaining. This will be the sorted list.
def merge(l, r):
# print('merge():: l => {} r => {}'.format(l,r))
... | true |
def7dc7dc7df68acab39702c78cba860f8f1970e | adeelnasimsyed/Interview-Prep | /countTriplets.py | 743 | 4.28125 | 4 | '''
In an array check how many triplets exist of a common ration R
example:
ratio: 4
[1,4,16,64]
triplets:
[1,4,16] and [4,16,64]
returns 2
method:
read array in reverse order
have two dicts, one for each number and one for each pair that meet criteria
if a num*ratio exists in dic that means we have a pair
if n... | true |
79ff9476ded6d3eb48bb8a98389a16c84b163510 | 1131057908/-1 | /函数.py | 2,624 | 4.125 | 4 | """
座右铭:将来的你一定会感激现在拼命的自己
@project:7-23
@author:Mr.Zhang
@file:函数.PY
@ide:PyCharm
@time:2018-07-23 09:05:17
"""
#函数:为什么使用函数?因为没有函数的编程只是在单纯的写代码逻辑,如果想重用代码逻辑,只能够copy一份代码。但是一旦使用函数,就可以将一些相同的代码逻辑封装起来,这样可以提高代码的重复使用率,提升开发效率。
#第一步:声明一个函数,在函数里面写逻辑代码
#第二步:调用函数,执行编写的逻辑代码
# print('今天是周一')
# print('明天是周二')
# print('后... | false |
2d1e425c878658733f1d32f2e5edcdbcc39e47fd | ericgreveson/projecteuler | /p_020_029/problem23.py | 888 | 4.1875 | 4 | from factor_tools import compute_factors
def main():
"""
Entry point
"""
# Compute set of all abundant numbers up to the limit we know all integers above can be
# expressed as a sum of two abundant numbers
sum_abundant_limit = 28123
abundant = {i for i in range(1, sum_abundant_limit) if sum... | true |
de1c37645d58898828ec4d4b1ec85588065cf75e | The-Kernel-Panic/HackerRank-Solutions | /Algorithms/Day of the Programmer.py | 1,241 | 4.375 | 4 | #Practice > Algorithms > Implementation > Day of the Programmer
#Julian -> after 1918 (leap year is divisible by 4)
#Gregorian -> from 1919
#During 1918 feb starts from 14.
#Jan + Mar + April + May + June + July + Aug = 215
def dayOfProgrammer(year):
if year < 1917:
if year % 4 == 0: #Leap Year
... | false |
159cdae23d6e3e19c73eb74eb39bdc8e42554574 | gavinmcguigan/gav_euler_challenge_100 | /Problem_59/XOR_Decryption.py | 2,417 | 4.1875 | 4 | from globs import *
"""
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 ... | true |
769836cb18a5f7bd6851f28792daebd0f561d5fb | aldzor/School-python-projects | /calculator.py | 1,397 | 4.15625 | 4 | # An even better calculator
import math
def asking():
loop = True
while loop == True:
givenNum = input("Give a number:")
try:
givenNum = int(givenNum)
return givenNum
loop = False
except Exception:
print("This input is invalid.")
def operation():
loop = True
while loop == True:
operation = in... | true |
c4d2f88ede5a3b373ce8e6912c70c71d9de7d863 | Jeffreyo3/cs-module-project-recursive-sorting | /src/sorting/sorting.py | 2,277 | 4.15625 | 4 | # TO-DO: complete the helper function below to merge 2 sorted arrays
def merge(arrA, arrB):
elements = len(arrA) + len(arrB)
# create a list with lenght
# equal to total incoming elemnts
merged_arr = [0] * elements
a_idx = 0 # keep track of current arrA index
b_idx = 0 # keep track of current a... | true |
9136d269ad920365c747a0fefcf3ad8e238e20c6 | nx6110a5100/Internshala-Python-Training | /while.py | 235 | 4.125 | 4 | day=0
sq=0
total=0
print('Enter number of quats each day')
while day<=6:
day=day+1
sq=int(input('Enter the number of quats on {} day '.format(day)))
total+=sq
avg=total/day
print('Average sqats is {} per day'.format(avg))
| true |
bfd58a191c030136732f08e61ab49a124178fdbd | roblivesinottawa/problem_solving | /weektwo/format_name.py | 754 | 4.5 | 4 | """Question 6
Complete the body of the format_name function.
This function receives the first_name and last_name parameters
and then returns a properly formatted string"""
def format_name(first_name, last_name):
# code goes here
string = ''
if first_name!= '' and last_name != '':
return f"Name: {last_name}, {... | true |
519141822d77e1cc19c19e2261c942a6fc95c94b | roblivesinottawa/problem_solving | /weektwo/fractional_part.py | 938 | 4.375 | 4 | """
Question 10
The fractional_part function divides the numerator by the denominator,
and returns just the fractional part (a number between 0 and 1).
Complete the body of the function so that it returns the right number.
Note: Since division by 0 produces an error, if the denominator is 0,
the function should retu... | true |
78279ce8c48f746121c66a5297a044dee410ef9c | NicholasBreazeale/NB-springboard-projects | /python-syntax/words.py | 288 | 4.1875 | 4 | def print_upper_words(wordList, must_start_with):
"""Print out a list of words if they start with a specific letter, each on separate lines, and all uppercase"""
for word in wordList:
for letter in must_start_with:
if word[0] == letter[0]:
print(word.upper())
break | true |
74b92ec02440aa5980ea1dff14115ce3603d60fc | mimikrija/ProjectEuler.py | /01.py | 616 | 4.34375 | 4 | # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
# The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
def is_multiple_of_any(num, divisors):
"returns if `num` is divisible by any of the `divisors`"
return any(num % diviso... | true |
31e121e4facd9b159492a8195ea4316317aa766d | brunnacroches/python-calculadora | /3.0CalculoDaApp.py | 1,422 | 4.375 | 4 |
#CALCULADORA DE PINTURA#
#Bem, agora pegando todos os dados do usario
# vamos fazer todos os calculos que faltam definir
# a litragem de tinta necessaria para fazer a nossa calculadora de pintura
#CALCULADORA DE PINTURA#
#1- REMOVER A EXPRESSAO DO PRINT E COLOCA-LA DENTRO DE UMA VARIAVEL
# VARIAVEL CHAMADA DE AREA ... | false |
acfa9d5fd8f1c22e0a15d8e26ef8882c8de07907 | jackparra253/pythonya | /ejercicio19.py | 515 | 4.15625 | 4 | #Confeccionar un programa que lea por teclado tres números enteros distintos y nos muestre el mayor
mensaje = "Ingrese un número "
numero_uno = int(input(mensaje))
numero_dos = int(input(mensaje))
numero_tres = int(input(mensaje))
if numero_uno > numero_dos and numero_uno > numero_tres:
print(numero_uno)
else:
... | false |
1bf86108fe73ed2004793ad957e6c0c631a3aa51 | keithsm/python-specialization | /Seventh_Assignment/input_read_upper.py | 409 | 4.625 | 5 | #Assignment 7.1
#Program that prompts for a file name, then opens that file and
#reads through the file, and print the contents of the file in upper case.
#Input and open the the file
fname = input ('Enter the name of the file: ')
file_contents = open (fname)
#Read the file contents
text = file_contents.read()
text =... | true |
af73c1e95044953a0fcf88f0bce2f3622a2dd110 | alandaleote/Algoritmos-II | /Aula01/atividade_aula01.py | 2,055 | 4.25 | 4 | '''
Construir um algoritmo que contenha 3 listas:
• Nomes de produtos
• Preços de cada produto
• Quantidades de cada produto
• Construir uma função para imprimir um dos produtos da lista e uma
função para retirar um dos produtos das listas
'''
nome_produto = []
preco_produto = []
quantidade_produto = []
def inserir_p... | false |
1708ba01af55f49a00f835d4872ce553a8a01cd1 | Goldenresolver/Functions-and-pizza | /happy 3 using write to a file.py | 876 | 4.125 | 4 | def happy():
return "Happy Birthday to you!|n"
# the magic of value returning functions is we have streamlined the
#program so that an entire verse is built in a single string expression.
# this line really illustrates the power and beauty of value returning functions.
# in this line we are calling happy() f... | true |
e47f4fbd7866bd272fae080bc44af55004c66ceb | leilalu/algorithm | /剑指offer/第一遍/stack&queue/59-2.队列的最大值.py | 943 | 4.125 | 4 | """
题目二:队列的最大值
请定义一个队列并实现函数max得到队列里的最大值,要求函数max、push_back和pop_front的时间复杂度都是O(1)
"""
class MaxQueue:
def __init__(self):
# python内置的deque的popleft 时间复杂度才是O(1),python数组的pop(0)的时间复杂度是O(n)
from collections import deque
self.data = deque() # 原始队列
self.max_data = deque() # 辅助队列
d... | false |
8ab7440e90e5d9527d973428e86a20cccf336aca | leilalu/algorithm | /剑指offer/第一遍/search/30-3.数组中数值和下标相等的元素.py | 1,522 | 4.125 | 4 | """
题目三:数组中数值和下标相等的元素
假设一个单调递增的数组里的每个元素都是整数并且是唯一的。请编程实现一个函数,找出数组中任意一个数值等于其下标的元素。
例如,在数组[-3,-1,1,3,5]中,数字3和它下标相等。
"""
class Solution1:
def GetNumberSameAsIndex(self, numbers):
"""
暴力法,顺序遍历数组
"""
# 检查无效输入
if not numbers:
return
for i in range(len(... | false |
03bdbf7857ae16c8d9d3a0112336abdd284aba82 | leilalu/algorithm | /剑指offer/第二遍/16.数值的整数次方.py | 1,485 | 4.21875 | 4 | """
题目描述
给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
保证base和exponent不同时为0
"""
class Solution1:
def Power(self, base, exponent):
""""
base = 0 exp = 0 0
base = 0 exp > 0 0
base = 0 exp < 0 倒数无意义
base > 0 exp > 0 累乘
base > 0 exp < 0 累乘 取倒数
base >... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.