blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
d389a579ea1360932b5af127018b9b35e66ecc3b | paluchasz/Python_challenges | /interview_practice_hackerank/Arrays/Minimum_Swaps.py | 2,389 | 4.21875 | 4 | '''Find minimum number of swaps in an array of n elements. The idea is that the min
number of swaps is the sum from 1 to number of cycles of (cycle_size - 1). E.g
for [2,4,5,1,3] we have 2 cycles one between 5 and 3 which is size 2 and requires 1 swap
and one between 2 4 and 1 which is of size 3 and requires 2 swaps. S... | true |
cba55fed10f53f69c2860cf020507a736827532e | paluchasz/Python_challenges | /interview_practice_hackerank/Warm_up_problems/Counting_Valleys.py | 961 | 4.28125 | 4 | '''This program has a series of Ds and Us, we start at sea level and end at sea level, we
want to find the number of valleys, ie number of times we go below sea level (and back to 0)'''
import math
import os
import random
import re
import sys
# Complete the countingValleys function below.
def countingValleys(n, s):
... | true |
3608c44ab2d527502b864be1e13af76a126a55f7 | ekaterinaYashkina/simulated_annealing_PMLDL | /Task2/utils.py | 1,659 | 4.15625 | 4 | import math
from geopy.distance import lonlat, distance
"""
Calculates the distance between the two nodes using euclidean formula
neighbours - list of tuples, nodes coordinates
first, second - indices of elements in neighbours list, between which the distance should be computed
"""
def euclidean_dist(first, second... | true |
8aa19aece7c856c53348b9f18a895d8a6999f2bc | Lynch08/MyWorkpands | /Code/Labs/LabWk4/isEven.py | 249 | 4.1875 | 4 | # Author: Enda Lynch
# tell the user if they input an odd or even number
number = int(input("Enter an integer:"))
if (number % 2) == 0 :
print ("{} is an even number" . format(number))
else:
print ("{} is not an even number" . format(number))
| true |
38400be20795cf6cbdb634a9e6ad55ee7c719f8d | Lynch08/MyWorkpands | /Code/Labs/LabWk4/guess3.py | 568 | 4.25 | 4 | # generates random number for user to guess
# Author: Enda Lynch
# import random module and set limit between 1 and 100
import random
numberToGuess = random.randint(0,100)
#string for user
guess = int(input("Please guess the number between 1 and 100:"))
##'while' sets loop and 'if' and 'else' give prompts
while gue... | true |
2618d88acba70b47d7b374bcd1864ab3eeed50cf | Lynch08/MyWorkpands | /Code/Labs/LabWk3/div.py | 347 | 4.125 | 4 | #Author: Enda Lynch
# Division programme with remainder
#enter values using inputs to devide on integer by another
X = int(input('Enter number: '))
Y = int(input('Divided by: '))
# '//' gives divides the integers and '%' gives the remainder
B = X//Y
C = X%Y
#display work
print("{} divided by {} is equal to {} rema... | true |
7a2ed190c3d27d635a021014ee974f3873516d16 | tparackal/Test-Code | /test.py | 202 | 4.21875 | 4 | def numType(x):
a = "none"
if x < 0:
a = "negative"
if x > 0:
a = "positive"
if x == 0:
a = "zero"
return a
num = input("Enter a number: ")
result = numType(num)
print("Number is " + result) | false |
a4b94d07c019eba3b5d741dd14ebd0b478b107a5 | CptObviouse-School-Work/SDEV220 | /module3/6.5.py | 354 | 4.21875 | 4 | '''
Jesse Duncan
SDEV 220
Programming Assignment: 6.5
Due June 17, 2018
'''
def displaySortedNumbers(num1, num2, num3):
numbers = [num1, num2, num3]
numbers.sort()
print("The sorted numbers are " + str(numbers[0]), str(numbers[1]), str(numbers[2]))
num1, num2, num3 = eval(input("Enter three numbers: "))
... | true |
bb90ab5f1e40dee795f826f8831d1c7b9b23555b | CptObviouse-School-Work/SDEV220 | /module2/3.4.py | 216 | 4.1875 | 4 | '''
Jesse Duncan
SDEV 220
Exercise 3.4
Due June 10, 2018
'''
import math
side = eval(input("Enter the side: "))
area = (5 * (side * side)) / (4 * math.tan(math.pi / 5))
print("The area of the pentagon is " + str(area))
| false |
2e225d616432eabeddd4a1913cbc82b7013f7fd2 | CptObviouse-School-Work/SDEV220 | /module2/4.15.py | 1,400 | 4.125 | 4 | '''
Jesse Duncan
SDEV 220
Exercise 4.15 Game: Lottery
Due June 10, 2018
'''
import random
# Generate a lottery number
lottery = random.randint(0, 999)
# Prompt the user to enter a guess
guess = eval(input("Enter your lottery pick (three digits): "))
#Get digits from lottery
removeLastDigit = lottery // 10
firstDigit... | true |
6b406d1ea76d8a30b1a3dd315eb2656335d1b2fe | Leoads99/Programing-Language---II | /ex1.1.py | 2,605 | 4.1875 | 4 | """
Ex 01 -
Preencha uma lista com 10 números digitados pelo usuário e exiba:
a - O maior número da lista
b - O menor número da lista
c - a média dos números contidos na lista
d - todos os números menores do que a média calculada no item anterior
cont = 0
lista = []
while cont <10:
numeros = int(input('Digi... | false |
b92050a43e7859e3fa58a04e7e72b5b98982e740 | hibfnv/Python-learning | /func_parm.py | 311 | 4.125 | 4 | #!/usr/bin/python
# -*- coding:utf-8 -*-
# Author: Eason
def str(var1,*vartuple):
print var1
for var in vartuple:
print var
print "=" * 20
print "输出定义的变量:"
print "=" * 20
str(10)
print "=" * 20
print "输出所有未定义的变量:"
print "=" * 20
str(20,30,40)
print "=" * 20 | false |
e02be49d885d049f820771a4cd6ee1b3c045453d | lsrichert/LearnPython | /ex3.py | 2,909 | 4.65625 | 5 | # + plus does addition
# - minus does subtraction
# / slash does division
# * asterisk does multiplication
# % percent is the modulus; this is the remainder after dividing one number
# into another i.e. 3 % 2 is 1 because 2 goes into 3 once with 1 left over
# < less-than
# > greater-than
# <= less-than-equal
# >= great... | true |
a0aff6ea7d696b27594019f2bc9207ef5f875291 | jaindinkar/PoC-1-RiceUniversity-Sols | /Homework1/Q10-sol.py | 2,161 | 4.25 | 4 | class BankAccount:
""" Class definition modeling the behavior of a simple bank account """
def __init__(self, initial_balance):
"""Creates an account with the given balance."""
self.balance = initial_balance
self.fees = 0
def deposit(self, amount):
"""Deposits the amount in... | true |
36c7857bf6cb4087456e70307643515040ae8352 | phoenix14113/TheaterProject2 | /main.py | 2,029 | 4.3125 | 4 |
import functions
theater = functions.createTheater(False)
NumberOfColumns = len(theater)
NumberOfRows = len(theater[0])
while True:
# print the menu
print("\n\n\n\n")
print("This is the menus.\nEnter the number for the option you would like.\n")
print("1. Print theater layout.")
print("2. Purch... | true |
516d0656dc657d042ea1deddc24439531bca95ef | AlexDimitro0v/Gaussian-Distributions-Package | /distributions/example_code.py | 2,751 | 4.15625 | 4 | from distributions.gaussian_distribution import Gaussian
from distributions.binomial_distribution import Binomial
def main_gaussian():
# initialize two gaussian distributions
gaussian_one = Gaussian(25, 3)
gaussian_two = Gaussian(30, 4)
# initialize a third gaussian distribution reading in a data fil... | false |
429b4627202ef18b85b7d088f8972f984d4f872a | NelsonJyostna/Array | /Array_12.py | 1,250 | 4.15625 | 4 | #python array Documentation
#https://docs.python.org/3.1/library/array.html
#See these videos
#https://www.youtube.com/watch?v=6a39OjkCN5I
#https://www.youtube.com/watch?v=phRshQSU-xAar
#import array as ar
#from array import *
#h=ar.array('i',[1,6,5,8,9])
#print(h)
from array import *
h=array('i',[1,6... | true |
2b5afb0c23f01c5cd78462e373b86c2985bc0b81 | tarunna01/Prime-number-check | /Prime number check.py | 271 | 4.15625 | 4 | num = int(input("Enter the number to check for prime"))
mod_counter = 0
for i in range(2, num):
if num % i == 0:
mod_counter += 1
if mod_counter != 0:
print("The given number is not a prime number")
else:
print("The given number is a prime number")
| true |
bfd09644dc48fca95bbcb7cc513c6345be15d1b4 | judegarcia30/cvx_python101 | /02_integer_float.py | 910 | 4.40625 | 4 | # Integers are whole numbers
# Floats are decimal numbers
num = 3
num_float = 3.14
print(type(num))
print(type(num_float))
# Arithmetic Operators
# Addition: 3 + 2
# Subtraction: 3 - 2
# Multiplication: 3 * 2
# Division: 3 / 2
# Floor Division: 3 // 2
# Exponent: 3 ** 2
# Modulus: ... | true |
0e3f7d61c853088014a4c90cca82f09e08b7fc6a | Aphinith/Python101 | /dataTypes/loops.py | 469 | 4.59375 | 5 | # example of for loop
item_list = [1, 2, 3, 4, 5]
# for item in item_list:
# print(item)
# example of while loop
i = 1
# while i < 5:
# print('This is the value of i: {}'.format(i))
# i = i +
# examples of using range
first_range = list(range(0,10))
# print(first_range)
# for x in range(0,20):
# print('test... | true |
f0ec0a36fef58a10d02dae1cb042a156cc0248b2 | zakaleiliffe/IFB104 | /Week Work/Week 3/IFB104-Lecture03-Demos/01-stars_and_stripes.py | 2,566 | 4.3125 | 4 | #---------------------------------------------------------------------
#
# Star and stripes - Demo of functions and modules
#
# To demonstrate how functions can be used to structure code
# and avoid duplication, this program draws the United States
# flag. The U.S. flag has many duplicated elements -
# the repeated st... | true |
f2ed50358ac9a0e776a08353f5fcb47e43c33416 | zakaleiliffe/IFB104 | /Week Work/week 10/BUilding IT/Questions/2-alert_print_date.py | 2,393 | 4.59375 | 5 | #---------------------------------------------------------
#
# Alert date printer
#
# The following function accepts three positive
# numbers, expected to denote a day, month and year, and
# prints them as a date in the usual format.
#
# However, this function can be misused by providing
# numbers that don't form a val... | true |
281669198fd194e77dc2380c416d6ffb32d76c68 | zakaleiliffe/IFB104 | /Week Work/Week 4/Building IT Systems/IFB104-Lecture04-Demos/5-keyboard_input.py | 781 | 4.3125 | 4 | # Keyboard input
#
# This short demo highlights the difference between Python's raw_input
# and input functions. Just run this file and respond to the prompts.
text = raw_input('Enter some alphabetic text: ')
print 'You entered "' + text + '" which is of type', type(text)
print
number = raw_input('Enter a number: ')
... | true |
4c51cbab748aa26bdab3322a4427a9b097672e6b | zakaleiliffe/IFB104 | /Week Work/WEEK 6/Building IT systems/Week06-Questions/1-line_numbering.py | 1,893 | 4.46875 | 4 | #----------------------------------------------------------------
#
# Line numbering
#
# Define a function which accepts one argument, the name of a
# text file and prints the contents of that file line by line.
# Each line must be preceded by the line number. For instance,
# the file 'joke.txt' will be printed as fol... | true |
0ebc0fa0ed1b48382ef36c87f6aab350e3f02636 | zakaleiliffe/IFB104 | /Week Work/week 2/Building IT systems/demo week 2/IFB104-Lecture02-Demos/3-draw_Pacman.py | 1,257 | 4.4375 | 4 | #---------------------------------------------------------------------
#
# Demonstration - Draw Pacman
#
# As an introduction to drawing using Turtle graphics, here we'll
# draw a picture of the pioneering computer games character, Pacman.
# (Why Pacman? Because he's easy to draw!)
#
# Observation: To keep the code sho... | true |
05bd4cd46abc7ac340def95d084dde7f997d65e0 | zakaleiliffe/IFB104 | /Week Work/week 2/Building IT systems/week 2 quetions/Week02-questions/Done/3_random_min_and_max.py | 2,344 | 4.4375 | 4 | #------------------------------------------------------------------------#
#
# Minimum and Maximum Random Numbers
#
# In this week's exercises we are using several pre-defined
# functions, as well as character strings and lists. As a simple
# exercise with lists, here you will implement a small program which
# generat... | true |
1fd51daff7b2075a7371b380abddb323ea3cba72 | zakaleiliffe/IFB104 | /Week Work/Week 3/Week03-questions/DONE/3_stars_and_stripes_reused.py | 1,891 | 4.3125 | 4 | #--------------------------------------------------------------------
#
# Stars and stripes reused
#
# In the lecture demonstration program "stars and stripes" we saw
# how function definitions allowed us to reuse code that drew a
# star and a rectangle (stripe) multiple times to create a copy of
# the United States fl... | true |
689cb7e9c11aedc04d083eadf29b2a1a5521bf10 | anantkaushik/algoexpert | /Binary-Search.py | 581 | 4.1875 | 4 | """
Problem Link: https://www.algoexpert.io/questions/Binary%20Search
Write a function that takes in a sorted array of integers as well as a target integer. The function should use the Binary Search algorithm
to find if the target number is contained in the array and should return its index if it is, otherwise -1.
""... | true |
95b94e2744fae0f5fc3554f57aa514f980bdbd17 | anantkaushik/algoexpert | /Two-Number-Sum.py | 718 | 4.25 | 4 | """
Problem Link: https://www.algoexpert.io/questions/Two%20Number%20Sum
Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum.
If any two numbers in the input array sum up to the target sum, the function should return them in an array, in sorted order.
If no ... | true |
975c387e56c0e68da27fd859c9908f1169307442 | Freddy875/Python | /Numeros/Numeros.py | 1,531 | 4.59375 | 5 | '''
Existen 3 tipos numeircos en Python
int
float
complex
'''
x =1
y = 2.8
z = 1j
print(type(x))
print(type(y))
print(type(z))
#Enteros
print("Enteros")
'''
Los entrsos son todo numero positivo
o negativo sin decimales
de longitud indefinida
'''
x = 1
y = 123456789
z = -987654321
print(x)
print(type(x))
print(y... | false |
4b3cd2a324ba26d888e2fdf7506cb9250a2508da | Freddy875/Python | /Listas/Acceso_A_Las_Listas.py | 585 | 4.21875 | 4 | #Acceso a la listas
estalista =["manzana","bananas","cereza"]
print(estalista[1])
#Indice negativo
print(estalista[-1])
#Rango de index
estalista =["manzana","bananas","cereza","naranja","kiwi","limon","melon","mango"]
print(estalista[2:5])
print(estalista[:4])
#Esto devuelve los valores del indice 0 al indice 4
... | false |
f5ba637446b4eab8b78d6529a44764d05a7af847 | Freddy875/Python | /Operadores/OperadoresAritmeticos.py | 541 | 4.125 | 4 | '''
Operadores son usados para desempenio de operaciones con valores y variables
'''
#Operadores artimeticos
x = 5
y = 3
#Suma
print("Suma")
print(x + y)
#Resta
print("Resta")
print(x - y)
#Multiplicacion
print("Multipliacion")
print(x*y)
#Division
x = 12
y = 3
print("Division")
print(x/y)
#Modulos
x = 5
y = 2 ... | false |
26777d3a822041c22fb7f861b63766dd18a223dd | Freddy875/Python | /Introduccion/Pilas(conListas).py | 509 | 4.1875 | 4 | #Pilas
#Las pilas pueden emularse con Listas
#Las pilas son una estructura de datos
#de tipo LIFO (Last In-First Out)
pila = [1,2,3]
print(f"La pila inicila {pila}")
#Agregar elementos por el final de la pila
pila.append(4)
pila.append(5)
print(f"La pila despues de agregar dos valores {pila}")
#Sacar elementos... | false |
3b94901914ba40d20a29f0b89b2c6e8b42bf2e8a | garimasilewar03/Python_Task | /9.py | 976 | 4.4375 | 4 | '''Write a program such that it asks users to “guess the lucky number”. If the correct number is guessed the program stops, otherwise it
continues forever.
number = input("Guess the lucky number ")
while 1:
print ("That is not the lucky number")
number = input("Guess the lucky number ")
Modify the... | true |
5ed47bc2085e9808de61264f362a1d16e8eb78bc | softicer-67/ALGORITMS | /Lesson_7/2.py | 695 | 4.15625 | 4 | '''
2. Отсортируйте по возрастанию методом слияния одномерный вещественный массив, заданный случайными числами
на промежутке [0; 50). Выведите на экран исходный и отсортированный массивы.
'''
from random import randint
def sort(array):
res = []
new_arr = arr[:]
for _ in range(len(new_arr)):
mini ... | false |
b16fa5b82118b0d71e48b7aaa274e22d65dd0585 | softicer-67/ALGORITMS | /Lesson_1/3.py | 609 | 4.21875 | 4 | """
3. По введенным пользователем координатам двух точек вывести уравнение прямой вида y=kx+b, проходящей через эти точки.
"""
print('Координаты точки A(x1,y1): ')
x1 = int(input('\tx1 = '))
y1 = int(input('\ty1 = '))
print('Координаты точки B(x2,y2): ')
x2 = int(input('\tx2 = '))
y2 = int(input('\ty2 = '))
print('У... | false |
20c30cbcea1a137a4416ac0fd5eb41056b50b6d9 | margarineHound/sorting-algorithms | /reverse_string.py | 576 | 4.125 | 4 | def reverse_string(word, word_new):
if len(word) > 0:
word_new.append(word[-1])
reverse_string(word[:-1], word_new)
return ''.join(word_new)
def reverse_string_loop(word, word_new):
for i in range(len(word)):
word_new.append(word[-(i+1)])
return ''.join(word_new)
def main():
... | false |
46981ad4de6e8a408302f80921a8290999cc512b | markstali/atividade-terminal-git | /code13.05.py | 2,854 | 4.25 | 4 | #01 - Dada a lista L = [5, 7, 2, 9, 4, 1, 3], escreva um programa que imprima as seguintes informações:
# a) tamanho da lista.
# b) maior valor da lista.
# c) menor valor da lista.
# d) soma de todos os elementos da lista.
# e) lista em ordem crescente.
# f) lista em ordem decrescente.
""" L = [5, 7, 2, 9, 4, 1, 3]
... | false |
34f88b64105e960ae15d83589f7f808497d3e6e3 | Dansultan/python_fundamentals-master | /04_conditionals_loops/04_07_search.py | 358 | 4.28125 | 4 | '''
Receive a number between 0 and 1,000,000,000 from the user.
Use while loop to find the number - when the number is found exit the loop and print the number to the console.
'''
number = int(input("Please choose a number between 1 and 1,000,000 : "))
i = 0
while i <= 1000000:
i+=1
if i == number:
... | true |
05f89d81c140e24536a8370a3a9ba5faa6a0d2f1 | Dansultan/python_fundamentals-master | /04_conditionals_loops/04_01_divisible.py | 362 | 4.5 | 4 | '''
Write a program that takes a number between 1 and 1,000,000,000
from the user and determines whether it is divisible by 3 using an if statement.
Print the result.
'''
number = int(input("Please enter a number between 1 and 1,000,000,000 :"))
if number%3 == 0:
print("Your number is divisible by 3")
else:
... | true |
2430c5d0ad1b3c340be21963928f26b576552196 | acecoder93/python_exercises | /Week1/Day5/PhoneBook_App.py | 2,024 | 4.40625 | 4 | # Phone Book App
print ('Welcome to the latest version of hthe Electronic Phone Book')
print ('Please see the list below of all of the options that are available.')
print ('''Electronic Phone Book
---------------------
1. Look up an Entry
2. Set an entry
3. Delete an entry
4. L... | true |
926a60d1843e0e1161b64521cbd91c5808fec66d | ivaneyvieira/pythonJango | /testeIF.py | 219 | 4.21875 | 4 | #!/usr/bin/env python3
num = int(input("Digite um número: "))
if num % 2 == 0:
print("Eh par")
else:
print("Eh impar")
if num % 2 == 0:
print("Eh um número par")
else:
print("Eh um número impar")
| false |
76384fcd407b5d010b9bb56bac5f23c71aa45a0d | chloe-wong/leetcodechallenges | /088_Merge_Sorted_Array.py | 1,281 | 4.28125 | 4 | """
You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively.
Merge nums1 and nums2 into a single array sorted in non-decreasing order.
The final sorted array should not be returned by the function, ... | true |
a5bfc3163002084e274f971292f7fd5fe51916b6 | sardar1023/myPyGround | /OOP_impl.py | 2,227 | 4.53125 | 5 | #Python is amazing language. You can also implement OOPs concepts through python
#Resource: https://www.programiz.com/python-programming/object-oriented-programming
####Creat a class object and method####
class Parrot:
species = "bird"
def __init__(self,name,age):
self.name = name
self.age =... | true |
99962d1c4eba31c6cc61e686fa475dc46c87699f | praveenkumarjc/tarzanskills | /loops.py | 250 | 4.125 | 4 | x=0
while x<=10:
print('x is currently',x)
print('x is still less than 10')
x=x+1
if x==8:
print('breaking because x==8')
break
else:
print('continuing....................................')
continue | true |
6996d908c879d262226ff1601ba70f714c861714 | Olb/python_call_analysis | /Task2.py | 2,634 | 4.15625 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 2: Which telephone number spent the ... | true |
59858e66eb9e86f1503fe9afb90d1186226a569a | richardmanasseh/hort503 | /lpthw/ex4.py | 1,427 | 4.40625 | 4 | # Ex 4: Variables and Names
# Variables are "words" that hold a value
FRUIT = peach #
# The operand to the left of the = operator (FRUIT) is the name of the variable
# The operand to the right (peach) is the value stored in the variable.
# A variable is similar to the memory functionality found in most calc... | true |
6c3532589b88192fd0ff2b029cb0f9fd631aaf22 | richardmanasseh/hort503 | /lpthw/ex7.py | 940 | 4.1875 | 4 | # More Printing & Formatting
print("Mary had a little lamp.")
print("Its fleece was white as {}. ".format('snow'))
print("And everywhere that Mary went.")
print("." * 10) # Prints string (".") ten times
# By default python’s print() function ends with a newline, because it comes with a parameter called ‘end’.
# By def... | true |
9fed24a2a440c14883e062c59ea8d402a52e772c | richardmanasseh/hort503 | /lpthw/ex29.py | 2,422 | 4.25 | 4 | # What If
# At the end of each working day,the balance of a bank account is considered...
# IF the account is overdrawn, charges are applied to the account.
# So we ask the question: is the account overdrawn? Yes (=True) or No (=False)
# Algorithm:
# Step 1 Define your problem: we apply charges to a bank accoun... | true |
75bb09a361e33624f85c545e37210a78639f9d1b | richardmanasseh/hort503 | /Assignments/lpthw/Assignment02/ex13.py | 987 | 4.125 | 4 | from sys import argv
script, first, second, third = argv
# module sys is not imported, rather just argv has been imported as a variable.
# Python modules can get access to code from another module by importing the file/function using import
# sys = system library, contains some of the commands one needs in order to ... | true |
2a303f20dfe2844ea99580423d4e18af81d6c5ee | richardmanasseh/hort503 | /Assignments/lpthw/Assignment02/ex7.py | 968 | 4.3125 | 4 | print("Mary had a little lamp.")
print("Its fleece was white as {}. ".format('snow'))
print("And everywhere that Mary went.")
print("." * 10) # what'd that do? Prints string ten times
# By default python’s print() function ends with a newline.
# # Python’s print() function comes with a parameter called ‘end’. By defau... | true |
a18a42ff4815c6954e5c4cdf8ea1a172f7d16cd4 | richardmanasseh/hort503 | /Assignments/Assignment04/ex21.py | 1,115 | 4.34375 | 4 | # Functions Can Return Something
# The print() function writes, i.e., "prints", a string in the console.
# The return statement causes your function to exit and hand back a value to its caller.
def add(a, b): # this (add) function is called with two parameters: a and b
print(f"ADDING {a} + {b}") # we print what our... | true |
eaba342178fd0cd9efd60ed6816a213412396edf | richardmanasseh/hort503 | /lpthw/ex33.py | 1,525 | 4.3125 | 4 | # While-Loops
# The while loop tells the computer to do something as long as the condition is met
# it's construct consists of a block of code and a condition.
# It works like this: " while this is true, do this "
i = 1 # intially i =1
while i <= 10: # loop condition, interpreter first checks if this condtion is tru... | true |
57a0315522093751af054ca900fbd16c4ab30f8b | shruti310gautam/python-programming | /function.py | 291 | 4.25 | 4 | #You are given the year, and you have to write a function to check if the year is leap or not.
def is_leap(year):
leap = False
if (year%4 == 0 and year%100 != 0) or (year%400 == 0) :
leap = True
return leap
#Sample Input=1990
#Sample Output=False
| true |
f485c5a58c0774d0ef5ec230ebf62361849d7a3f | wgatharia/csci131 | /5-loops/exercise_3.2.py | 411 | 4.40625 | 4 | """
File: exercise_3.2.py
Author: William Gatharia
This code demonstrates using a while loop.
"""
#loop and print numbers from 1 to 10 using a while loop
number = 1
while True:
print(number)
#increment number
#short hand for increasing number by 1
#number += 1
number = number + 1
#... | true |
7a9673f15d019e3d98f5f4584ceec3f3d496a2f3 | rosmoke/DCU-Projects | /bucketlist/bl-binary-to-decimal.py | 359 | 4.125 | 4 | import sys
binary = sys.argv[1]
i = len(binary) # here we set the counter to how many numbers we have
power = 0
result = 0
while i > 0: # here we set the counter to do something i times
result += int(binary[i-1]) * 2 ** power # we convert each number to decimal
i = i - 1
power = power + 1 # now we increase the powe... | false |
08ef8f971812f815cf41a5b56050eb3bfeaf3917 | abdullaheemss/abdullaheemss | /My ML Projects/Data Visualization Exercises/01 - Understanding plotting.py | 626 | 4.125 | 4 | # ---------------------------------------------------------
# Understand basics of Plotting
# ---------------------------------------------------------
# Import pyplot from matplotlib
import matplotlib.pyplot as plt
# Create data to plot
x_days = [1,2,3,4,5]
y_price1 = [9,9.5,10.1,10,12]
y_price2 = [11,12,... | true |
ab8f166f68cb1bb13fa24aa3fe0d140809f6f5bf | webclinic017/data-pipeline | /linearRegression/lrSalesPredictionOnAddData.py | 1,026 | 4.375 | 4 | # https://towardsdatascience.com/introduction-to-linear-regression-in-python-c12a072bedf0
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import statsmodels.formula.api as smf
# Import and display first five rows of advertising dataset
advert = pd.read_csv('advertising.csv')
print(advert.h... | true |
310d5545758fc462c4269353a15beb122762f660 | sven-walser/Python-test | /selbstprojekte/namensbewerter.py | 479 | 4.125 | 4 | #!/usr/bin/env python3
print("Sag mir wie du heisst dann bewerte ich deinen Namen")
name = input("Dein Name: ")
name = name.lower()
if name == "sven":
print("so ein schöner Name")
elif name == "claudio":
print("Das ist der schlechteste Name den ich je gehört habe")
elif name == "simon":
print("wow du warst also ... | false |
a12f8edb0fda9985d3739772c338b45f6ae9ad7c | AngeloESFM/All_programs | /raiz_cuadrada.py | 231 | 4.125 | 4 | import math
num1 = input("inserte número para sacarle raiz cuadrada:")
num1 = float(num1)
print(math.sqrt(num1))
def raiz_c(n):
num1 = 0
while num1 * num1 <= n:
num1 += 0.00001
return num1
print(raiz_c(num1))
| false |
3f7e8cbe8ec1617d5125b361167de964b513998d | AngeloESFM/All_programs | /listas_o_vectores2.py | 588 | 4.375 | 4 | # 26 Listas
# Sirven para tener elementos guardadados entre corchetes como vectores
# Colección de elementos, las listas están ordenadas y son mutables
frutas = ["Naranja", "Manzana", "Banana", "Kiwi", "Mandarina", "Uva"]
# 0 1 2 3 4 5
# Imprime toda la lista
pri... | false |
e84d6844fa2d7c63fa300054a797152dffe3b322 | adarsh161994/python | /part 2.py | 811 | 4.40625 | 4 | # Addition of strings
# stri = "My name is"
# name = " Adarsh"
# print(stri + name)
# How to make temp
# name1 = "ADARSH"
# name2 = "YASH"
# temp = "This is {} and {} is my best friend".format(name1, name2)
# print(temp)
# Now introducing 'f' string It is also doing same thing which we have done above.
# ITS also... | true |
af26e1489a9ae2956c4c8163c57d88282ef4e239 | Urielglb/Curso-Python-Raccoons | /clase2/listas.py | 1,956 | 4.21875 | 4 | #Declarando listas
vacio = []#Lista vacia, se le puede meter elementos despues
supermercado =["Lechuga","Crema","Pan"]#Lista de strings
edades = [10,45,60]#lista de numeros
mixto = ["Lechuga",10,4.5,"Pan"]#Lista de varios tipos de dato, no se recomienda mezclar datos
#Accediendo a la lista
print(edades[0])#Primer eleme... | false |
c0ece596323cfcd837849a7fa5513a2daad6ddd2 | Renato-moura/PrgBancoFatec | /prgBancoEx1_3.py | 278 | 4.28125 | 4 | #3 Escreva um programa que calcula e mostra a rea de um crculo, uma vez que o usurioinforme o raio. Use math.pi para obter um valor aproximado de pi. (Use import math antes).
import math
raio = float(input("digite o raio: "))
area = math.pi * (raio ** 2)
print(area) | false |
95451780778a80ba364d857addb9e23ac67b856f | spradeepv/dive-into-python | /hackerrank/domain/artificial_intelligence/bot_building/bot_saves_princess.py | 2,769 | 4.3125 | 4 | """
Princess Peach is trapped in one of the four corners of a square grid. You
are in the center of the grid and can move one step at a time in any of the
four directions. Can you rescue the princess?
Input format
The first line contains an odd integer N (3 <= N < 100) denoting the size of
the grid. This is followed ... | true |
ccfe895e27c01f03f8a277528d35f306d89e56ea | spradeepv/dive-into-python | /hackerrank/domain/artificial_intelligence/bot_building/bot_clean_large.py | 2,103 | 4.40625 | 4 | """
In this challenge, you must program the behaviour of a robot.
The robot is positionned in a cell in a grid G of size H*W. Your task is
to move the robot through it in order to clean every "dirty" cells.
Input Format
The first line contians the position x and y of the robot.
The next line contains the height H a... | true |
7c54a3e4de30e706ff577367a5ed608d93b6233f | spradeepv/dive-into-python | /hackerrank/domain/python/sets/intro_mickey.py | 975 | 4.40625 | 4 | """
Task
Now, lets use our knowledge of Sets and help 'Mickey'.
Ms. Gabriel Williams is a botany professor at District College. One day, she asked her student 'Mickey' to compute an average of all the plants with distinct heights in her greenhouse.
Formula used:
Average=SumofDistinctHeightsTotalNumberofDistinctHeigh... | true |
3e09c61d5a62a3e00412522aa5e0895402696f87 | spradeepv/dive-into-python | /hackerrank/domain/python/built_in/any_or_all.py | 1,386 | 4.3125 | 4 | """
any()
This expression returns True if any element of the iterable is true.
If the iterable is empty, it will return False.
Code
----
any([1>0,1==0,1<0])
True
any([1<0,2<1,3<2])
False
all()
This expression returns True if all of the elements of the iterable are
true. If the iterable is empty, it will return Tr... | true |
abc4b59db59660232c5ee767870f41b686fe526b | spradeepv/dive-into-python | /hackerrank/domain/python/numpy/min_max.py | 1,838 | 4.5625 | 5 | """
Problem Statement
min
The tool min returns the minimum value along a given axis.
import numpy
my_array = numpy.array([[2, 5],
[3, 7],
[1, 3],
[4, 0]])
print numpy.min(my_array, axis = 0) #Output : [1 0]
print numpy.min(my_array, ax... | true |
7c5c86da342258cbe51310f7ef859ec7e25dc73c | spradeepv/dive-into-python | /hackerrank/domain/python/regex/validating-named-email.py | 1,589 | 4.4375 | 4 | """
Problem Statement
You are given N names and email addresses. Your task is to print the names
and email addresses if they are valid.
A valid email address follows the rules below:
- Email must have three basic components: username @ website name . extension.
- The username can contain: alphanumeric characters, -,.... | true |
33e672ec8d42bf4f655a9eb08d406108b041f025 | zuzanadostalova/The-Python-Bible-Udemy | /6_Section_Conditional_logic.py | 667 | 4.28125 | 4 | # 30. lesson - Future lesson overview
# 31. lesson - Booleans
# Boolean is not created through typing its value - we get it from doing logical comparison
print(2<3)
# Output: True
print(2>3)
# Output: False
print(type(2<3))
# Output: <class 'bool'>
# print(2 = 3)
# Output: Error - cannot assign to literal
print(2 ... | true |
0caac48689854309f5e867a07cd148287a9a376e | zuzanadostalova/The-Python-Bible-Udemy | /8_Section_For_loops.py | 1,918 | 4.46875 | 4 | # 50. lesson - For loops
# most useful loops
# "for" loops - variable (key) - changing on each cycle of the loop
# and iterable (students.keys()) - made up from elements
# In each cycle, the variable becomes the next value in the iterable
# operation on each value
# range function - set up number, create number iterabl... | true |
1ef901e075f7b922099badb7e1a62ea826317a21 | gidpfeffer/CS270_python_bootcamp | /2-Conditionals/2_adv.py | 866 | 4.21875 | 4 | """
cd into this directory
run using: python 2_adv.py
"""
a = 10
if a < 10:
print("a is less than 10")
elif a > 10:
print("a is greater than 10")
else:
print("a is 10")
# also could do
if a == 10:
print("a is 10")
# or
if a is 10:
print("a is 10")
# is checks for object equality where == does value equality
#... | true |
8a96f25f94b5f008c11075e2667f8b34ae850f04 | gidpfeffer/CS270_python_bootcamp | /4-Functions/2_optional_args.py | 979 | 4.3125 | 4 | """
cd into this directory
run using: python 2_optional_args.py
"""
def printName(firstName, lastName=""):
print("Hi, " + firstName + lastName)
# uses default lastname
printName("Gideon")
# uses passed in lastname
printName("Gideon", " Pfeffer")
def printNameWithAge(firstName, lastName="", age=25):
print("Hi, " ... | true |
17404714d2acef85fed4768120996bb9e9ff86c5 | bhvya1505/Cryptography | /Stream Ciphers/Caesar/caesar.py | 371 | 4.125 | 4 | plaintext = raw_input("Enter your plaintext: ")
key = input("Enter the key: ")
ciphertext = ""
small = "abcdefghijklmnopqrstuvwxyz"
capital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in plaintext:
if i in small:
ciphertext += small[(small.index(i)+key)%26]
elif i in capital:
ciphertext += capital[(capital.index(i)+ke... | false |
07f33784f2e4962b190adc616d93048cac1f33ff | todorovventsi/Software-Engineering | /Programming-Fundamentals-with-Python/functions-exercises/03. Characters in Range.py | 424 | 4.1875 | 4 | def print_chars_in_between(char1, char2):
result = ""
if ord(char1) > ord(char2):
for char in range(ord(char2) + 1, ord(char1)):
result += chr(char) + " "
else:
for char in range(ord(char1) + 1, ord(char2)):
result += chr(char) + " "
return result
first_char = i... | true |
ad772b77b29d2c780c2361ed6041b3b8c63c0259 | todorovventsi/Software-Engineering | /Python-Advanced-2021/05.Functions-advanced-E/04.Negative_vs_positive.py | 444 | 4.15625 | 4 | def compare_negatives_with_positives(nums):
positives = sum(filter(lambda x: x > 0, nums))
negatives = sum(filter(lambda x: x < 0, nums))
print(negatives)
print(positives)
if positives > abs(negatives):
return "The positives are stronger than the negatives"
return "The negatives are stro... | true |
da1aec1428db680418a45e7b717b8c06639d5f70 | todorovventsi/Software-Engineering | /Programming-Fundamentals-with-Python/functions-lab/01. Grades.py | 437 | 4.21875 | 4 | def convert_grade_to_text_grade(grade_as_num):
if 2 <= grade_as_num <= 2.99:
return "Fail"
elif 3 <= grade_as_num <= 3.49:
return "Poor"
elif 3.50 <= grade_as_num <= 4.49:
return "Good"
elif 4.50 <= grade_as_num <= 5.49:
return "Very Good"
elif 5.50 <= grade_as_num <=... | false |
c1436658b05474f63d7b99cf949878a9e63b5c35 | keurfonluu/My-Daily-Dose-of-Python | /Solutions/42-look-and-say-sequence.py | 844 | 4.125 | 4 | #%% [markdown]
# A look-and-say sequence is defined as the integer sequence beginning with a single digit in which the next term is obtained by describing the previous term. An example is easier to understand:
#
# Each consecutive value describes the prior value.
# ```
# 1 #
# 11 # one 1's
# 21 # two 1's
#... | true |
104cf3da661d2a8b84736b8312876bdcc912126c | jugshaurya/Learn-Python | /2-Programs-including-Datastructure-Python/5 - Stack/balanceParenthesis.py | 1,003 | 4.21875 | 4 | '''
Balanced Paranthesis
Given a string expression, check if brackets present in the expression are balanced or not. Brackets are balanced if the bracket which opens last, closes first.
You need to return true if it is balanced, false otherwise.
Sample Input 1 :
{ a + [ b+ (c + d)] + (e + f) }
Sample Output 1 :
true
S... | true |
67601147a8b88309baf61fdc1f5f81a769b8dc0c | solomonbolleddu/LetsUpgrade--Python | /LU Python Es Day-4 assignment.py | 1,471 | 4.4375 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Assignment - 4 Day - 4
# 1) write a program to find all the occurences of the substring in the given string along with the index value
# I have used list comprehension + startswith() to find the occurences ***
# In[2]:
a=input("Enter The String\n")
b=input("Enter The Subs... | true |
eb64252481f0ed81477e05e82455d7109655f57f | decareano/python_repo_2019 | /else_if_testing.py | 408 | 4.25 | 4 | people = 30
cars = 40
buses = 15
if cars > people:
print("we should take the cars.")
elif cars < people:
print("we should not take the cars")
else:
print("dont know what to do")
if buses > cars:
print("too many buses")
elif buses < cars:
print("maybe we can take the buses")
else:
print("still cannot decide")
i... | true |
87c9cd1d601d04d104fe23ef0b4e7c1fe18c0c69 | Devil-ReaperL/Trash | /1010/study3/字典.py | 1,238 | 4.34375 | 4 | # 字典: key唯一值 : 若出现重复 前者key对应的值发生改变
# key 唯一 value 随意
#{key1:value1,key2:value,...}
students = {
"name":"张奇",
"age":27,
"sex":"male",
"height":"1.8",
"name":"王齐",
"腰围":27,
}
print(len(students))
for i,j in students.items():
print(i,j)
print(students.items(),type(students.ite... | false |
428d6588af61c4b558a5f6f73187dd27043d3805 | Kulsoom-Mateen/Python-programs | /Calculator.py | 907 | 4.21875 | 4 | num1 = int(input("Enter 1st number : "))
num2 = int(input("Enter 2nd number : "))
operand = input("Enter Operator : ")
if operand == "+":
result = num1 + num2
print(result)
elif operand == "-":
result = num1 - num2
print(result)
elif operand == "*":
result = num1 * num2
print(result)
elif operan... | false |
a0087d82fea425ad005c58521416c1b0b82910ad | Kulsoom-Mateen/Python-programs | /dictionary.py | 1,771 | 4.3125 | 4 | #student=['James',123456789,'ABC','Jones']
# dictionary is represented by curly brackets , every value should be comma separated
student={ #Name,Cell no etc are keys
'Name': 'James',
'Cell Number': 123456789,
#'Cell no.':[123,456] here cell no is list inside a dictionary bcz some students can ... | false |
6945f73ee0dd66db503ab0bab31999861cd1c192 | Kulsoom-Mateen/Python-programs | /even_odd.py | 268 | 4.1875 | 4 | '''number=int(input("Enter any number : "))
if number % 2 == 0:
print(str(number) +" is even number")
else:
print(str(number) +" is odd number")'''
num=int(input("Enter any number : "))
if num%2==0:
print("Number is even")
else:
print("Number is odd") | false |
79f4733b669473de0a81c2b90fce55c4d965fcb1 | Kulsoom-Mateen/Python-programs | /abstract_method.py | 608 | 4.15625 | 4 | class Book():
def __init__(self,title,author):
self.title=title
self.author=author
# @abstractmethod
def display(): pass
class MyBook(Book):
def __init__(self,title,author,price):
self.title=title
self.author=author
self.price=price
def display(self):
... | true |
e9649cb521f4196efde0276015cf6dd313084475 | JordanSiem/File_Manipulation_Python | /ExtractAllZipFolders.py | 1,640 | 4.34375 | 4 | import os
import zipfile
print("This executable is used to extract documents from zip folders. A new folder will be created with the zip folder "
"name + 1. This program will process through the folder structure and unzip all zip folders in subdirectories.")
print("")
print("Instructions:")
print("-First,... | true |
2dc01f62020a8487c74a689ba41d48c55914f913 | davidkellis/py2rb | /tests/basic/for_in2.py | 539 | 4.375 | 4 | # iterating over a list
print('-- list --')
a = [1,2,3,4,5]
for x in a:
print(x)
# iterating over a tuple
print('-- tuple --')
a = ('cats','dogs','squirrels')
for x in a:
print(x)
# iterating over a dictionary
# sort order in python is undefined, so need to sort the results
# explictly before comparing output... | true |
daecf43082ccdca104974cb6299a019c74572610 | LukeO1/HackerRankCode | /CrackingTheCodingInterview/MergeSortCountingInversions.py | 1,699 | 4.125 | 4 | #!/bin/python3
"""Count the number of inversions (swaps when A[i] > B[j]) while doing merge sort."""
import sys
#Use global variable to count number of inversions
count = 0
def countInversions(arr):
global count
split(arr)
return count
def split(arr):
#If arr has more than one element, then split
... | true |
b25c2afc65fc0e03da050bf3362a5cf04474214a | t-christian/Python-practice-projects | /characterInput.py | 2,249 | 4.34375 | 4 | # From http://www.practicepython.org/
# Create a program that asks the user to enter their name and their age.
# Print out a message addressed to them that tells them the year that they will turn 100 years old.
# Stupid library to actually get the date
# TODO: figure out how to properly use datetime
import datetime
#... | true |
7c9ec57ae7dc314826604b9eb864413053023db8 | githubflub/data-structures-and-algorithms | /heap_sort.py | 2,167 | 4.34375 | 4 | ''' 1. Create an unsorted list
2. print the unsorted list
2. sort the list
3. print the sorted list
'''
def main():
myList = [4, 3, 1, 0, 5, 2, 6, 3, 3, 1, 6]
print("HeapSort")
print(" in: " + str(myList))
# sort list
myList = heapSort(myList)
print("out: " + str(myList))
def he... | true |
e9e50f5f8f47e36df2d4e5eb562d4adf3f9f061b | Pavan7411/Revising_python | /mf.py | 1,880 | 4.25 | 4 |
def line_without_moving():
import turtle
turtle.forward(20)
turtle.backward(20)
def star_arm():
import turtle
line_without_moving()
turtle.right(360 / 5)
def hexagon():
import turtle #import turtle module for the below code to make sense
x=50 #length of polyg... | true |
83b109bf6219348908a8f0e43b2fab2f69348b4e | Pavan7411/Revising_python | /Loop_7.py | 519 | 4.625 | 5 | import turtle #import turtle module for the below code to make sense
turtle.shape("turtle") #changing the shape of the turtle from arrow to turtle
x=10 #size of circle
n=40 #n sided regular polygon
th = 360/n #th is the external angle made by sides
... | true |
73a12e7f11ed70feddd44a4cc22a0129dbf2980d | Pavan7411/Revising_python | /Loop_6.py | 395 | 4.40625 | 4 | import turtle #import turtle module for the below code to make sense
turtle.shape("turtle") #changing the shape of the turtle from arrow to turtle
x=40 #size of square
for j in range(36): #for loop for drawing multiple squares
for i in range(4): #for loop for drawing a squ... | true |
5c88f3c0963bc2ecfa8e0c550567a9d43c018dd1 | spencer-mcguire/Sprint-Challenge--Algorithms | /recursive_count_th/count_th.py | 1,118 | 4.34375 | 4 | '''
Your function should take in a single parameter (a string `word`)
Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters.
Your function must utilize recursion. It cannot contain any loops.
'''
def count_th(word):
# return how many times 'th' exists in a give... | true |
92b4f6d127a5ab6bd50f08c4c3d7b9c4ed1cc868 | ldorourke/CS-UY-1114 | /O'Rourke_Lucas_Polynomials.py | 1,647 | 4.15625 | 4 | '''
Lucas O'Rourke
Takes a second degree polynomial and prints out its roots
'''
import math
a = int(input("Please enter value of a: "))
b = int(input("Please enter value of b: "))
c = int(input("Please enter value of c: "))
if a is 0 and b is 0 and c is 0:
print("The equation has infinite infinite number of solut... | true |
3bd5debd4340abed6b750f405ac83326a3f0a76c | evgenytihonov/Basic_Python | /Lesson_5/Tihonov_Evgeny_dz_5.2.py | 219 | 4.125 | 4 | def odd_num():
upper = 1 + int(input('До какого числа считать нечетные числа? '))
lower = 1
for i in range(lower, upper):
if i % 2:
print(i)
odd_num()
| false |
a2180fb2c112c0f1914f9be93e6cd07c9834a261 | titoeb/python-desing-patterns | /python_design_patterns/factories/abstract_factory.py | 2,253 | 4.53125 | 5 | """The abstract Factory
The abstract factory is a pattern that is can be applied when the object creation becomes too convoluted.
It pushes the object creation in a seperate class."""
from __future__ import annotations
from enum import Enum
from abc import ABC
# The abstract base class.
class HotDrink(ABC):
def c... | true |
ff7730e47b6d173de3f0c0cf175c543311b149fd | ppesh/SoftUni-Python-Developer | /Python-OOP/02-Classes-and-Instances/02-Circle.py | 467 | 4.3125 | 4 | # 02. Circle
class Circle:
pi = 3.14
def __init__(self, radius):
self.radius = radius
def set_radius(self, new_radius):
self.radius = new_radius
def get_area(self):
area = self.pi * self.radius * self.radius
return area
def get_circumference(self):
circumference = 2 * self.pi * self.radius
... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.