blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
43ccb8b12668d73c52ce2a05bf5084d97cf74ebf | mariascervino/basics | /Algoritimos/ChildrenHope.py | 987 | 4.1875 | 4 | # Fazer uma doação to o criança esperanca, incluindo a opcao de um valor escolhido pelo usuario
print ("------------------------------")
print (" WELCOME TO CHILDREN HOPE ")
print ("------------------------------")
print (" THANK YOU FOR DONATING! ")
print ("[1] to donate R$10")
print ("[2] to donate R$25")
pr... | false |
15dc717ca6ab36098948ad026d04c3095a1ddfcd | greenstripes4/CodeWars | /ipadress.py | 2,063 | 4.40625 | 4 | """
Task
An IP address contains four numbers(0-255) and separated by dots. It can be converted to a number by this way:
Given a string s represents a number or an IP address. Your task is to convert it to another representation(number to
IP address or IP address to number).
You can assume that all inputs are valid.
... | true |
9f77a05bef30a373aa6099a9b4ee181fc3d51b1e | greenstripes4/CodeWars | /DataReverse.py | 694 | 4.40625 | 4 | """
A stream of data is received and needs to be reversed.
Each segment is 8 bits long, meaning the order of these segments needs to be reversed, for example:
11111111 00000000 00001111 10101010
(byte1) (byte2) (byte3) (byte4)
should become:
10101010 00001111 00000000 11111111
(byte4) (byte3) (byte... | true |
0ad5b8175ba2ae7b9d4e563e6ecc1ad591232314 | greenstripes4/CodeWars | /digital_root.py | 522 | 4.21875 | 4 | """
A digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that
value has two digits, continue reducing in this way until a single-digit number is produced. This is only applicable to
the natural numbers.
Here's how it works:
digital_root(16)
=> 1 + 6
=> 7
"""
... | true |
06f8cd83c2cb510474d0788e473731b5cfc9b40e | carlos-hereee/Intro-Python-I | /src/05_lists.py | 858 | 4.1875 | 4 | # For the exercise, look up the methods and functions that are available for use
# with Python lists.
x = [1, 2, 3]
y = [8, 9, 10]
# For the following, DO NOT USE AN ASSIGNMENT (=).
# Change x so that it is [1, 2, 3, 4]
# YOUR CODE HERE
x.append(4)
print("\n Adds 4 to the end: ", x)
# Using y, change x so that it i... | true |
82d9cd4a618eb4d035049bf4570942c7ca1cbe43 | millerg09/python_lesson | /ex20.py | 1,914 | 4.1875 | 4 | # imports the `argv` module from sys
from sys import argv
# sets up the script name and input_file as script argument variables
script, input_file = argv
# creates the first function `print_all`, which accepts one input variable `f`
def print_all(f):
# the function is designed to use the read function with no ext... | true |
8c23df48951b0371225a507dffa4fb3198290d9d | utk09/BeginningPython | /2_Variables/2_variables.py | 534 | 4.15625 | 4 | # Variables are like Boxes. Their name remains the same, but values can be changed over the time.
number1 = 7
number2 = 4
print(number1 * number2) # insted of values, we now write variables here.
print(number1 - number2 * 3)
alpha = number1 / number2
beta = number1 // number2
print(type(alpha)) # Prints type of var... | true |
9297906d5a60f20b9081d2a280e5fc91646c1ec0 | utk09/BeginningPython | /8_MiniPrograms/14_Recursion.py | 1,215 | 4.375 | 4 | # We will find the sequence of Fibonacci Numbers using recursion.
# Recursive function is a function that calls itself, sort of like loop.
# Recursion works like loop but sometimes it makes more sense to use recursion than loop.
# You can convert any loop to recursion. ... Recursive function is called by some external ... | true |
62bd1fc8066ef085eee494f2d5277a7f68437f81 | cugis2019dc/cugis2019dc-Najarie | /Code Day_3.py | 2,818 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import plotly
dir(plotly)
print("My name is Najarie")
print("Hello how are you doing")
print(5*2)
print(5/2)
print(5-2)
print(5**2)
print((8/9)*3)
print("5*2")
def multiply(a,b):
multiply = a*b
print(mul... | true |
df639a127a816b127c320bfd00ed5b68b7d9ae27 | amahfouz/tweet-analyser | /count_freq.py | 784 | 4.21875 | 4 | '''
Counts word frequencies in a text file.
Words to be counted are read from a file.
'''
import codecs
import sys
import re
import time
def count_occurrences(f, w):
count = 0
for line in f:
index = 0
words = re.split(r'[\n\r\t-_ #]', line)
for word in words:
if (word == w):
count = count + 1
ret... | true |
5588d38839089141af8036a5f953c48640166fc1 | whyfzhou/intropython | /list.py | 1,895 | 4.3125 | 4 | # ---------------------------------------------------------------------
# 列表 list
li = [2, 4]
print('Repeating {} {} times: {}'.format(li, 3, li * 3)) # 重复三次
li.append(1) # 添加元素
li.append(3)
li.extend([10, 20]) # 扩展列表
print('The list: {}'.format(li))
print('List {} contains {} elements'.format(li, len(li)))
print(... | false |
ea4bb376bc5c3f27b6020fe3cbb8ec7b07183251 | erikgust2/OpenAI-Feedback-Testing | /dataset/Fahrenheit/Fahrenheit_functionality.py | 344 | 4.25 | 4 | def celsius():
fahrenheit = float(input("Enter a temperature in Fahrenheit: "))
celsius = ((fahrenheit - 32) * 5) / 9
print("The equivalent temperature in Celsius is", celsius)
if(celsius > 32):
print("It's hot!")
elif(celsius < 0):
print("It's cold!")
else:
print("It's ... | true |
705173744a8f66d1d65cf99066aad1e8831b7089 | erikgust2/OpenAI-Feedback-Testing | /dataset/AgeName/AgeName_syntax.py | 657 | 4.21875 | 4 | def greet_user():
# Get the user's name and age
name = input("What's your name? ")
age = int(input("How old are you? "))
# Print a greeting message with the user's name and age
print(f"Hello, {name}! You are {age} years old.")
# Check the user's age and print a message based on it
... | true |
a3e2f2ad2ea860a442caa073587ee156bc1a1f69 | MFTI-winter-20-21/DIVINA_2020 | /09 palindrom 2.0.py | 726 | 4.34375 | 4 | """
Пользователь за один инпут вводит вам разные слова
программа разделяет их на отдельные слова и проверяет, является ли слово палиндромом
Если является - выводит его нам
ВВЕДЕНО: шалаш, казак, ракета
ВЫВОД: шалаш, казак
"""
words = input("Введите слова: ").lower().split()
palindroms = []
for word in words:
... | false |
b17474f526fe2477e64276c73297618417b6c334 | Shriukan33/Skyjo | /src/cards.py | 1,460 | 4.15625 | 4 | from random import shuffle
class Deck:
"""
Deck class handles original deck building and drawing action.
"""
def __init__(self):
self.cards = [] # Deck is represented with a list of numbers from -2 to 12
self.minus_two = 5 # Number of minus two in build
self.zeroe... | true |
d823f2c91294dcc305f292d808f71707d95de09d | ntnshrm87/Python_Quest | /Prob6.py | 588 | 4.125 | 4 | # Prob 6
list_a = ['Raman', 'Bose', 'Bhatt', 'Modi']
# Case 1
print(list_a[10:])
# Case 2
try:
print(list_a[10])
except IndexError as e:
print("Error is: ", e)
# Case 3
print(list_a[:-10])
# Solution:
# []
# Error is: list index out of range
# []
# Reference:
# Its really a tricky one
# The problem is if... | true |
15734f950406d76a0c1e67dede382e095b0e1a34 | shokri-matin/Python_Basics_OOP | /05InputQutputImport.py | 622 | 4.25 | 4 | # Python Output Using print() function
print('This sentence is output to the screen')
# Output: This sentence is output to the screen
a = 5
print('The value of a is', a)
# Output: The value of a is 5
print(1,2,3,4)
# Output: 1 2 3 4
print(1,2,3,4,sep='*')
# Output: 1*2*3*4
print(1,2,3,4,sep='#',end='&')
# Output:... | true |
0449ecdfe040d45fc538696b97d0f7e0de6f106f | shokri-matin/Python_Basics_OOP | /17Files.py | 1,443 | 4.125 | 4 | # Hence, in Python, a file operation takes place in the following order.
# 1-Open a file
# 2-Read or write (perform operation)
# 3-Close the file
# f = open("test.txt") # open file in current directory
# f = open("C:/Python33/README.txt") # specifying full path
# f = open("test.txt") # equivalent to 'r' or '... | true |
4380065a6a07c72549544d4fe1cc38ee0d7fd623 | dmyerscough/codefights | /sumOfTwo.py | 728 | 4.25 | 4 | #!/usr/bin/env python
def sumOfTwo(a, b, v):
'''
You have two integer arrays, a and b, and an integer target value v.
Determine whether there is a pair of numbers, where one number is taken
from a and the other from b, that can be added together to get a sum of v.
Return true if such a pair exists... | true |
1eb28eb14c6dc0144de440ee62f1b560978a7f3c | shraddha136/python | /assn7.2.py | 1,116 | 4.625 | 5 | #7.2 Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form:
# X-DSPAM-Confidence: 0.8475
# Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output as shown below... | true |
085f1364d25c4bf0d60c3ae0f3c140c8bf2aa024 | Chewie23/PythonAlgo | /One-Offs/General/circle_problem.py | 1,334 | 4.34375 | 4 | """
prompt:
Given a point and a radius which designate a circle, return a random point
within that circle.
"""
#Fun math
#The solution is a fun formula. I am hesitant to delve further into this since
#I would never be required to derive the Pythagoreas formula and customize it
#to a circle. I mean, it's logic... | true |
1dd547f756e6e226c03f9caebc596c826c64480e | Chewie23/PythonAlgo | /Recursion/bubble_sort.py | 536 | 4.28125 | 4 | #Recursion bubble sort. If you though regular bubble sort was bad
#Remember, it's comparing two elements, and swapping. Then keep on going
#through until no more swapping
#Iteratively, we have a swapping bool, and a while loop
#Or we have outer for loop that will go through ALL of the array
def bubble(arr):
#Thi... | true |
c8ab267b2a2aa07725c50f09c7d74b7ceb855e34 | fuanruisu/Py | /listas.py | 544 | 4.1875 | 4 | # Nombre: listas.py
# Objetivo: muestra la funciòn de las listas en python
# Autor: alumnos de Mecatrònica
# Fecha: 27 de agosto de 2019
#crear lista vacía
lista = []
# agregamos elementos a la lista
lista.append("hola")
lista.append(False)
lista.append(23.13)
lista.append('c')
lista.append(23)
lista.append(-12)
... | false |
c5e7ae3880cb279a8837f51072056598c7c04c67 | mvkopp/pythagore_dates | /pythagore_dates.py | 1,991 | 4.5625 | 5 | def main():
"""
Main function that caluclate all Pythagore dates between two years (here between 2000 and 2100)
Params: /
"""
for y in range(10,3000):
for m in range(1,13):
dTotal = month_length(m,y)
for d in range(1,dTotal+1):
if is_pythagore(d,m,y):... | false |
9fc2d9c7597c35c254505f3a19e53ee17a9e2dca | DanielMelero/Search-engine | /ordsearch.py | 2,085 | 4.15625 | 4 | def linear(data, value):
"""Return the index of 'value' in 'data', or -1 if it does not occur"""
# Go through the data list from index 0 upwards
i = 0
# continue until value found or index outside valid range
while i < len(data) and data[i] != value:
# increase the index to go to the n... | true |
6b7c7ddae9d6d57e407648aedf281330bc7e69b9 | asset311/comp-sci-fundamentals | /strings/permutation_palindrome.py | 1,224 | 4.25 | 4 | '''
Check if any permutation of a string is a valid palindrome.
A brute force approach is to generate all permutations of the string = O(n!)
Then for each of those permutations to check if it is a palindrome = 0(n)
For the total time of O(n*n!) - that's extremely long.
A simple solution is to think about what a palin... | true |
a95868ce9c1ac1482b03c42db38b972225059858 | asset311/comp-sci-fundamentals | /arrays/permutations_list.py | 1,058 | 4.28125 | 4 | '''
Generate all permutations of a set
Permutation is an arrangement of objects in a specific order. Order of arrangement of object is very important.
The number of permutations on a set of n elements is given by n!.
Example
2! = 2*1 = 2 permutations of {1, 2}, namely {1, 2} and {2, 1}
3! = 3*2*1 = 6 permutations o... | true |
2199fc314341dea159789cdf6b0e899e38c0be4f | asset311/comp-sci-fundamentals | /queues/queue_using_stacks.py | 1,039 | 4.25 | 4 | '''
232. Implement Queue using Stacks
Implement the following operations of a queue using stacks.
push(x) -- Push element x to the back of queue.
pop() -- Removes the element from in front of queue.
peek() -- Get the front element.
empty() -- Return whether the queue is empty.
'''
class MyQueue:
def __init__... | false |
e6a2b110b16792d4de45200f61cb9bfb1be2e2e0 | Hansen-L/MIT-6.0001 | /ps4/test.py | 1,207 | 4.125 | 4 | import string
letter_to_number_dict={}
number_to_letter_dict={}
num = 1
shift = 2
#First make a dictionary that holds the default letter-number correspondence
for char in string.ascii_lowercase:
letter_to_number_dict[char] = num
number_to_letter_dict[num] = char
num = num + 1
for char in strin... | true |
126f12b64e6b63454b5843e73dc6dc87ed0e0e45 | akashgkrishnan/simpleProjects | /calc/app.py | 760 | 4.125 | 4 | from calc.actual_calc import ActualCalulator
repeat = 'y'
print('''
Enter the operation you are interested in :
1) Enter 1 for performing addition of 2 numbers
2) Enter 2 for performing subraction on 2 numbers
3) Enter 3 for perforiming multiplication on 2 numbers
4) Enter 4 for performing division on 2 numbers
5) Ente... | true |
1ebaa91a786113a75d78c6e9f46c0f02e3cd0787 | beyzabutun/Artificial-Intelligence | /MonteCarlo/mcs.py | 1,864 | 4.125 | 4 | #!/usr/bin/python3
import random
# Evaluate a state
# Monte Carlo search: randomly choose actions
def monteCarloTrial(player,state,stepsLeft):
if stepsLeft==0:
return state.value()
### Randomly choose one action, executes it to obtain
### a successor state, and continues simulation recursively
### from that s... | true |
46e72161442c45fa2a5e6dbc580bd86db5202a85 | EzraBC/CiscoSerialNumGrabber | /mytools.py | 1,581 | 4.375 | 4 | #!/usr/bin/env python
"""
INFO: This script contains functions for both getting input from a user, as
well as a special function for handling credentials (usernames/passwords) in a
secure and user-friendly way.
AUTHOR: zmw
DATE: 20170108 21:13 PST
"""
#Make script compatible with both Python2 and Python3.
from __fu... | true |
e794133843ab561393b55627675f3f419884527b | rembrandtqeinstein/learningPy | /pp_e_11.py | 342 | 4.125 | 4 | num = input("Enter a number to check if it's a prime: ")
try:
num = int(num)
except:
print("Not a number")
def prime(x):
div = range(1, x)
lis = [y for y in div if x % y == 0]
if len(lis) == 1:
print(x, "is a prime number")
else:
print(x, "is not a prime number, it's divisible ... | true |
327b2644b39d5364ca15d8eed74c8f2e7945902a | rembrandtqeinstein/learningPy | /coursera_test.py | 343 | 4.1875 | 4 | #import pandas as pd
hours = input("How many hours you work: ")
rate = input("How many you are payed per hour: ")
try:
hrs = float(hours)
fra = float(rate)
except:
print("That is not a number")
quit()
if hrs >= 40:
pay = 40 * fra
pay = pay + ((hrs - 40) * 1.5)
else:
pay = hrs * fra
print(p... | true |
9af4f4db42d1ee0ed61b0a8ab99ba76d7fbf803f | joshey-bit/Python_Projects | /2-D Game/alien.py | 1,544 | 4.15625 | 4 | '''
A program to create alien class
'''
import pygame
from pygame.sprite import Sprite
class Alien(Sprite):
'''A class to create an alien and draw it on the screen'''
def __init__(self,alien_settings,screen):
super().__init__()
self.alien_settings = alien_settings
self.screen... | true |
56f5016e2b78ae1611742dc99d3876c394095160 | JavierVaronBueno/python_3.x_Estructuras_Datos_Busquedas_Hilos | /Estructura Pila/Pila.py | 2,132 | 4.34375 | 4 | """
ESTRUCTURA DE DATO PILA:
Una pila es una lista ordenada o estructura de datos en el que el modo de acceso
a sus elementos es de tipo 'LIFO' (Last In First Out, Ultimo En Entrar es el Primero en Salir),
que permite almacenar datos.
Para el manejo de los datos se cuenta con dos operaciones basicas:
-Apilar(pu... | false |
2dbbd238faafed78e70b6a51c7c173eb917087b0 | JavierVaronBueno/python_3.x_Estructuras_Datos_Busquedas_Hilos | /02_ordenamientoSeleccion.py | 899 | 4.34375 | 4 | """
METODO ORDENAMIENTO POR SELECCION:
Es un algoritmo que consiste en ordenar los elementos de manera acedendente o descendente
PASOS:
-Busca el dato mas pequeño de la lista
-Intercambiarlo por el actual
-Seguir buscando el dato mas pequeño de la lista
-Intercambiarlo por el actual
-Esto se repetira sucecivamen... | false |
d2e486d034b40bf3820b402361fc59aabb09dd4b | SValeriey/PySL | /0014_Class3.py | 2,192 | 4.34375 | 4 | # 继承
# 一个类继承另一个类时,子类获得父类的所有属性和方法,子类可以定义自己的属性和方法
class Car:
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year
self.odometer_reading = 0
def get_descriptive_name(self):
long_name = str(self.year) + ' ' + self.make + ' ' +... | false |
92c0d35d31f7727ac542ad1d5661a15e4e2bc64c | ChengzhangBai/Python | /LAB10/task2.py | 700 | 4.5 | 4 | # Write a python program that prompts the user for the name of .csv file
# then reads and displays each line of the file as a Python list.
# Test your program on the 2 csv files that you generated in Task 1.
fileName = input('Please input "boy" or "girl" to open a file: ')
if fileName == "" or fileName not in('boy'... | true |
acd4218bb27771db82a4796d8dd21479cf3cab5c | humblefo0l/PyAlgo | /DP/MaximumProductSubarray.py | 1,261 | 4.1875 | 4 | """
Maximum Product Subarray
Medium
11755
362
Add to List
Share
Given an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return the product.
The test cases are generated so that the answer will fit in a 32-bit integer.
A subarray is a contiguous subseque... | true |
cecc70dbe060dcdfd840322a2bb44a649b751ecc | humblefo0l/PyAlgo | /Recursion/Permutation.py | 478 | 4.21875 | 4 | """
46. Permutations
Medium
Add to List
Share
Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
Example 1:
Input: nums = [1,2,3]
Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
Example 2:
Input: nums = [0,1]
Output: [[0,1],[1,0]]
Exa... | true |
ffeb082d317527637ee17b7dd36c0c4f7f11ea40 | trieuchinh/DynamicProgramming | /howSum.py | 1,063 | 4.21875 | 4 | '''
Write a function called "howSum(targetSum, number)" that takes in a targetSum and an array of numbers as arguments.
The function should return an array containing any combination of elements that add
up to exactly the targetSum. If there is no combination that adds to the targetSum, then return null.
If th... | true |
c95bc18ced7fafa924d4c59a8402f14fb1d178c8 | Philipotieno/Grokking-Algorithms | /02_selection_sort.py | 658 | 4.15625 | 4 | # Find the smallest valuein an array
def findSmallest(arr):
# Store the smalest value
smallest = arr[0]
# Store the smallest index of the smallest value
smallest_index = 0
for i in range(1, len(arr)):
if arr[i] < smallest:
smallest = arr[i]
smallest_index= i
retur... | true |
5f7e437af4b36a47030cc7d25357dfd100bc128d | Kallshem/iterators | /exercises/generators.py | 2,783 | 4.125 | 4 | """Övningar på generators"""
from math import sqrt
def cubes(x=0):
"""Implementera en generator som skapar en serie med kuber (i ** 3).
Talserien utgår från de positiva heltalen: 1, 2, 3, 4, 5, 6, ...
Talserien som skapas börjar således: 1, 8, 27, 64, 125, 216, ...
Talserien ska inte ha något slut.
... | false |
b3bb07853979e7dfec06b2d6c75e0c2ece5e250d | plankobostjan/practice-python | /06StringLists | 238 | 4.3125 | 4 | #!/usr/bin/python
word = str(input("Enter a word: "))
rev = word[::-1]
print word + " reversed is written as: " + rev
if word == rev:
print "Word you've enetered is a palidnrome."
else:
print "Word you've enetered is not a palidnrome."
| true |
6c4ba4568fe819c4401605d5080b4c885a542773 | venkataramadurgaprasad/Python | /Python-For-Everybody/Programming For Everybody(Getting Started With Python)/Week-5/Assignment_3.1.py | 690 | 4.3125 | 4 |
'''
3.1 Write a program to prompt the user for hours and rate per hour using input
to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times
the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of
10.50 per hour to test the program (the pay should be 498.75). You sho... | true |
ffe435dc3d49254e68777112b99d531f75b982b0 | nagasaimanoj/Python-Trails | /Basics/Basic_Programs/matrix_iter.py | 490 | 4.3125 | 4 | matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
print("row-wise")
for i in range(3):
for j in range(3):
print(matrix[i][j])
print("col-wise")
for j in range(3):
for i in range(3):
print(matrix[i][j])
print("skipping a row")
for i in range(3):
if i == 1:
continue
for j... | false |
c0eeee6004b9acb0f8e6dfd61edde5a3b80e5a1d | kaustubhvkhairnar/PythonPrograms | /Lambda Functions/Assignment2.py | 339 | 4.3125 | 4 | #2.Write a program which contains one lambda function which accepts two parameters and return
#its multiplication.
def main():
value1 = input("Enter number1 : ")
value2 = input("Enter number2 : ")
ret=fp(value1,value2);
print(ret)
fp=lambda no1,no2 : int(no1)*int(no2);
if __name__=="__main... | true |
3abedfd55165751b0cfb93e6b2f291113af556cf | kaustubhvkhairnar/PythonPrograms | /Object Orientation/Assignment3.py | 1,761 | 4.59375 | 5 | #3. Write a program which contains one class named as Arithmetic.
#Arithmetic class contains three instance variables as Value1 ,Value2.
#Inside init method initialise all instance variables to 0.
#There are three instance methods inside class as Accept(), Addition(), Subtraction(), Multiplication(), Division(... | true |
952f16d1be7dcf93fbf5afd931546da2e11b027e | kaustubhvkhairnar/PythonPrograms | /Object Orientation/Assignment5.py | 1,806 | 4.34375 | 4 | #5. Write a program which contains one class named as BankAccount.
#BankAccount class contains two instance variables as Name & Amount.
#That class contains one class variable as ROI which is initialise to 10.5.
#Inside init method initialise all name and amount variables by accepting the values from user.
#There a... | true |
a1999438dca6b16a76dec892d29ce8da066b731b | Eunaosei24788/lista3 | /oi7.py | 288 | 4.15625 | 4 | print("Esse programa serve para desenhar um quadrado em #")
lado = int(input("Insira o número de cada lado: "))
while lado <= 0:
print("insira apenas números positivos")
lado = int(input("Insira o número de cada lado: "))
for quadrado in range(lado):
print(" # "*lado)
| false |
bc5c6752015df561abe9e8d67a7120398eb893d0 | NatTerpilowska/DailyChallengeSolutions | /Daily3.py | 218 | 4.21875 | 4 | min = int(input("Enter the lowest number: "))
max = int(input("Enter the highest number: "))
print("Even numbers from %d to %d are: " % (min, max))
for i in range(min, max+1):
if(i%2==0):
print(i, end=" ") | true |
9f9c815d3a02685db5cf792468f0c96eea59a16f | penguincookies/GWSSComputerScience | /Python/AcidRain.py | 880 | 4.125 | 4 | # comments use pound
ACID_THRESHOLD = 6.4
ALKALINE_THRESHOLD = 7.4
print("This program will take the pH of a body of water and")
print("determine if it's habitable to the fish living there.")
print()
pH = eval(input("Enter the water's pH: "))
# instead of "else if", Python uses "elif
# Python also relies on colons ... | true |
251c1e495dc417088b243b50369e2d68e20aaa81 | hikarocarvalho/Blue_Module_01 | /exercicios_Aulas/Codelab_Saturday_Study_Class/26-06-2021/exercicio01.py | 1,904 | 4.1875 | 4 | #01 - Crie um programa que gerencie o aproveitamento de um jogador de futebol.O
# programa vai ler o nome do jogador e quantas partidas ele jogou. Depois vai ler a
# quantidade de gols feitos em cada partida. No final, tudo isso será guardado em um
# dicionário, incluindo o total de gols feitos durante o campeonato.
#... | false |
75ef83f749abf57e09d9d174459d2d3833dacbe3 | hikarocarvalho/Blue_Module_01 | /exercicios_Aulas/Aula_14/ex06.py | 610 | 4.1875 | 4 | #Escreva uma função que, dado um número nota representando a nota de um estudante,
#converte o valor de nota para um conceito (A, B, C, D, E e F)
#perform the conversion
def convertNote(note):
if note >8.9:
return "A"
elif note >6.9:
return "B"
elif note >4.9:
return "C"
elif no... | false |
bcd517d5144f761cee2ce9993dbaeff2dea939fe | AbhijitEZ/PythonProgramming | /Beginner/ClassDemo.py | 1,997 | 4.1875 | 4 | from abc import ABC, abstractmethod
class Car:
default_value = "All remain same" # static
def __init__(self, wheels_count=2):
self.wheels_count = wheels_count # property
def __str__(self):
# default function is when calling print
return(f"This is default print")
def __eq__... | true |
3d1ab6dfd6a8555720824f71c4cf794825000aed | mogubess/python_test | /nyumon/6chapter/68Property.py | 461 | 4.15625 | 4 | '''
Property
'''
class Duck():
def __init__(self, inputName):
self.hiddenName = inputName
def getName(self):
print('inside the getter')
return self.hiddenName
def setName(self, inputName):
print('inside the setter')
self.hiddenName = inputName
#変数のGetterとSetterを... | false |
d459fd0fab2c9cb4ae601dea2a57363828d70632 | theinsanetramp/AnkiAutomation | /genSentenceDB.py | 2,925 | 4.125 | 4 | import sqlite3
from sqlite3 import Error
import csv
def create_connection(db_file):
""" create a database connection to a SQLite database """
try:
conn = sqlite3.connect(db_file)
return conn
except Error as e:
print(e)
return None
def create_table(conn, create_table_sql):
... | true |
bbabed6baee00637d9459da02a4339440ea8799a | avieshel/python_is_easy | /fizz_buzz.py | 2,606 | 4.34375 | 4 | def is_divisible_by_5(number):
return number % 5 == 0
def is_divisible_by_3(number):
return number % 3 == 0
def is_prime(number):
for divisor in range (2, number):
if (number % divisor == 0):
return False
return True
'''
A Prime number has exactly two divisors 1 and itself.
To chec... | true |
d888bdf090097a515dbc7815e75ab5cb5f42344d | anubhav-shukla/Learnpyhton | /finbonacci.py | 431 | 4.21875 | 4 | # here we write a program for fibonacci series
def fibonacci_seq(n):
a=0
b=1
if n==1:
print (a)
elif n==2:
print(b)
else:
print(a,b,end=" ")
for i in range(n-2):
c=a+b #c==1
a=b #a==1
b=c #b==1 It is called swappi... | false |
5fbbabee18776cc21049d33131e117c5f32db22a | anubhav-shukla/Learnpyhton | /guessing.py | 520 | 4.1875 | 4 | # it is while loop program
# python guessing.py
print("It is a guessing game")
import random
random_number =random.randrange(1,10)
guess=int(input("what could be tthe Number? "))
correct=False
print(random_number)
while not correct:
if guess==random_number:
print("congrats you got it")
corr... | true |
0afb2f0b115724f3440cf755d094fe68e6597ee2 | anubhav-shukla/Learnpyhton | /some_method.py | 452 | 4.15625 | 4 | # here we learn some useful method
#python some_method.py
fruits=['mango','orange','apple','apple']
# print(fruits.count('apple')) # 2
# fruits.sort() it gives an sorted array
# print(sorted(fruits)) #it just use for print or temporary sorting
# fruits.clear() # it gives you an empty list
fruit1=fr... | true |
3c0c943512655eed6dc6e8ee92420cc6ba2f4e79 | anubhav-shukla/Learnpyhton | /list_comprehension.py | 1,054 | 4.625 | 5 | # most powerful topic in python
# list comprehension
# python list_comprehension.py
# today we create a list with the help o list comprehension
# create a list of squares from 1 to 10
# it is a simple way to create a list square
# square=[]
# for i in range(1,11):
# square.append(i**2)
# print(s... | true |
b8d1ff3381a518f89f764c2b26d1b687c3be7824 | anubhav-shukla/Learnpyhton | /chapter5_exe3.py | 256 | 4.34375 | 4 | # here we take input as list and reverse each element
# python chapter5_exe3.py
def reverse_all(l):
reverse=[]
for i in l:
reverse.append(i[::-1])
return reverse
listj=['mango','apple','banana']
print(reverse_all(listj))
| true |
718cb952f0b24a475eee0b032ec687a8dfc0157c | anubhav-shukla/Learnpyhton | /add.py | 487 | 4.3125 | 4 | # here we learn how to add two list and items
# python add.py
# cancatenation
fruits=['mango','orange','apple']
fruits1=['banana','grapes']
fruit=fruits+fruits1
# print(fruit) print all in single list
# using extend method
# exetnd
fruits.extend(fruits1)
print(fruits)
# it is doing same work
# appe... | true |
b6ae26fd8a595771abaf2e25b551685f8f5bd307 | anubhav-shukla/Learnpyhton | /gen_comprehension.py | 355 | 4.125 | 4 | # use generator comprehension
# it is a generator comprehension
square=(i**2 for i in range(1,11))
s=square
for i in s:
print(i)
for i in s:
print(i)
for i in s:
print(i)
# you can also use next but remove above code
# print(next(s))
# use () for generator comprehension
# hope i... | false |
ef4c42f4cab534e847afc7d0cbddc586797edc0f | anubhav-shukla/Learnpyhton | /check_empty_or_not.py | 318 | 4.375 | 4 | # here we see check empty or not
# important
#python check_empty_or_not.py
# name="Golu" it print not empty
# name='' it show empty
# here you can use it
name =input('Enter your name: ')
# name='India'
if name:
print('your name is '+name)
else:
print("You did't enter your name") | true |
7805a27b5f2e6ca6cd329c82b5242c6b6668cdda | shuxinzhang/nltk-learning | /exercises/Chapter 02/02-23.py | 1,631 | 4.28125 | 4 | # -*- coding: utf-8 -*-
import matplotlib
matplotlib.use('TkAgg')
import nltk
import math
'''
★ Zipf's Law:
Let f(w) be the frequency of a word w in free text. Suppose that
all the words of a text are ranked according to their frequency,
with the most frequent word first. Zipf's law states that the
frequency of a word... | true |
73762233b5fc0d1de3d02a74fde9ae76b7a71cd3 | jonathancox1/Python104-medium | /leetspeek.py | 759 | 4.21875 | 4 | #convert user input to 'leetspeak'
# A -> 4
# E -> 3
# G -> 6
# I -> 1
# O -> 0
# S -> 5
# T -> 7
#ask user for input
input = str(input("Give me your text: "))
user_input = input.upper()
#define function to check which letter is a leet letter
def convert(a):
if a == 'A':
return '4'
elif a == 'E':
... | true |
4898a3847fde7a21d295238a02391ac968351e7b | yamonc/bigData_course | /base_python/0127/yuanzu.py | 816 | 4.1875 | 4 | # 元组:元组与列表类似也是一种容器数据类型,可以用一个变量(对象)来存储多个数据,
# 不同之处在于元组的元素不能修改,在前面的代码中我们已经不止一次使用过元组了。顾名思义,
# 我们把多个元素组合到一起就形成了一个元组,所以它和列表一样可以保存多条数据。
t = ('yamon', 24, True, '河北邯郸')
print(t)
# 获取元组内的内容
print(t[0])
for i in t:
print(i)
# 重新赋值
t = ('陈亚萌' ,24 ,True , '天津')
print(t)
# 将元组转化为列表:
person = list(t)
print(person)
# 利用列表修改元素,元组... | false |
102d1dacc8b140fb06aa890ad6d866b02a0cfae5 | barney1538/CTI110 | /P2T1_BarneyHazel.py | 446 | 4.28125 | 4 | #Write a program that ask the user to enter projected total sales then will display the profit that'll be made from that amount.
#February 20th, 2020
#CTI-110 P2T1-Sales Prediction
#Hazel Barney
#Get the projected total sales.
total_sales = float(input('Enter the projected sales: '))
#Calculate the profit as 23... | true |
24074952dc46122d645ee137a840ae05483e7f1e | tgo93/nug | /nug.py | 1,491 | 4.40625 | 4 | """
nug.py - A simple (and silly) calculator that, given a height in feet and inches
Tells you how many chicken nuggets tall you are
Inspired by https://www.reddit.com/r/CasualConversation/comments/ao63rv/im_approximately_39_chicken_nuggets_tall/
on /r/CasualConversation
tgo93
"""
import re
def main():
playAgain... | false |
5b9ce39e7cadfa5a8c91d2f37701345f0e97f366 | fernandalozano/-AprendiendoPython | /Conversiones.py | 529 | 4.125 | 4 | # Se declara la variable str con 4 dígitos
numero= "1234"
# Se muestra el tipo de variable
# el type no es un str, es un dato type
print(type(numero))
# La cadena se convierte a su equivalente int
numero=int(numero)
# Se muestra como cambió el tipo pero se usa la misma variable
print(type(numero))
# Se declara... | false |
72e9820a494760fc8146df05992c5f4684442a04 | abhijit-mitra/Competitive_Programming | /7_pythagorean_triplet.py | 1,070 | 4.25 | 4 | '''
Is pythagorean triplet exist in the given array.
Pythagorean triplet means: a^2 + b^2 = c^2. a,b,c could be any elemnt in array.
for array = [3,1,4,5,6], one combination is present i.e: 3^2 + 4^2 = 5^2
Optimum solution is having time complexity of n^2.
**Trick**
1/Sort the given array. [1,3,4,5,6]
2/Iterate and mut... | true |
60a6eb1505bb2788859387d4af931ae036e0de1f | Edmartt/canbesplitted | /tests/test_basic.py | 1,816 | 4.125 | 4 | import unittest
from code.backend_algorithm import Splitter
class BasicTestCase(unittest.TestCase):
"""Contiene los metodos para las pruebas unitarias."""
def setUp(self):
self.splitter = Splitter()
self.empty = [] # empty array for testing empty array result==0
self.array = [1, 3, 3... | true |
6776f5e9be955e1f39672fa52979fa11e606856b | rfdickerson/cs241-data-structures | /A6/app/astar/priorityqueue.py | 1,591 | 4.3125 | 4 | import math
def parentindex( curindex):
return (curindex - 1) // 2
def leftchild( i ):
return i*2 + 1
class PriorityQueue ( object ):
""" A priority queue implemented by a list heap
You can insert any datatype that is comparable into the heap. The lowest
value element is kept at the root of the ... | true |
324731e01eddde2390c9fef2645ec76ca9eca3d5 | Rim-El-Ballouli/Python-Crash-Course | /solutions/chapter4/ex_4_10.py | 305 | 4.3125 | 4 | cubes = [number**3 for number in range(1, 10)]
for cube in cubes:
print(cube)
print('The first three items in the list are:')
print(cubes[:3])
print('Three items from the middle of the list are:')
print(cubes[len(cubes)//2:])
print('The last three items in the list are')
print(cubes[-3:])
| true |
534baa4384cb36ce87d60bc82c428bd7a876f532 | Rim-El-Ballouli/Python-Crash-Course | /solutions/chapter4/ex_4_11.py | 455 | 4.28125 | 4 | pizza_names = ["Cheese", "Vegetarian", 'Hawaiian', "Peperoni"]
for pizza_name in pizza_names:
print('I like ' + pizza_name + 'pizza')
print('I really like pizza!')
friend_pizzas = pizza_names[:]
pizza_names.append('Barbecue')
friend_pizzas.append('Honey Mustard')
print('My friend’s favorite pizzas are:... | true |
dfc48b4f6feadae7923fc0dfd795258492d4f5ed | soundestmammal/machineLearning | /bootcamp/flow.py | 1,915 | 4.125 | 4 | # -*- coding: utf-8 -*-
if 3>2:
print('This is true')
hungry = True
if hungry:
print('feed me')
else:
print('Not now, im full')
loc = 'Bank'
if loc == 'Auto Shop':
print('Cars are cool!')
elif loc == "Bank":
print("You are at the bank")
else:
print('I do not know much.')
name = 'Sammy'... | true |
41988de645aae080c0fc964cc7656acca922f431 | soundestmammal/machineLearning | /bootcamp/oop.py | 970 | 4.40625 | 4 | # This is part one of learning about how objects work in Python.
# Python is a class based language. This is different that other languages such as javascript.
# How to define a class?
class car:
pass
car = Vehicle()
print(car)
# Here car is an object (or instance) of the class Vehicle
#Vehicle class has 4 attrib... | true |
145b40261b3506d9605fff2a67e135b9e5fc4b6a | soundestmammal/machineLearning | /bootcamp/lists.py | 626 | 4.15625 | 4 | # -*- coding: utf-8 -*-
# Lists general version of sequence
my_list = [1,2,3]
# Lists can hold different object types
new_list = ['string', 23, 1.2, 'o']
len(my_list)
# Indexing and Slicing
my_list = ['one', 'two', 'three', 4, 5]
# my_list[0] returns 'one'
#my_list[1:] returns 'two' , 'three', 4, 5
my_list[:3]
'hel... | true |
592052a96d70f124fe17a0248b4df1f93ada8a14 | yarik335/GeekPy | /HT_1/task6.py | 412 | 4.375 | 4 | # 6. Write a script to check whether a specified value is contained in a group of
# values.
# Test Data :
# 3 -> [1, 5, 8, 3] : True
# -1 -> (1, 5, 8, 3) : False
def Check(mylist,v):
return print (v in mylist)
myList1 = [1, 5, 8, 3]
myList2 = (1, 5, 8, 3)
value = int(input("en... | true |
66a9a58b8ee04c9a903a6eaacb7c3b7d2c394807 | pramilagm/coding_dojo | /python/random_problems/decorator.py | 970 | 4.3125 | 4 | # Decorators are a way to dynamically alter the functionality of your functions. So for example, if you wanted to log information when a function is run, you could use a decorator to add this functionality without modifying the source code of your original function.
def decorator_function(original_function):
def... | true |
6e71070883296d0f4fa69456eb390a2a788114e1 | mrmoore6/Module2 | /main/camper_age_input.py | 463 | 4.1875 | 4 | """
Program: camper_age_input.py
Author: Michael Moore
Last date modified: 9/5/2020
The purpose of this program is to convert years into months.
"""
from main import constants
def convert_to_months(year):
months = year * constants.MONTHS
return(months)
if __name__ == '__main__':
age_in_years = int(in... | true |
57e01f83db8e55704098bd6fe9910bbcf0643cd3 | struppj/pbj-practice | /pbj.py | 1,366 | 4.21875 | 4 | #goal 1
peanut_butter = 1
jelly = 1
bread = 7
if peanut_butter == 1 and jelly == 1 and bread >=2:
print "I can make exactly one sandwich"
if peanut_butter < 1 or jelly < 1 or bread <=1:
print "No sandwich for me"
#goal 2
peanut_butter = 4
jelly = 6
bread = 9
if bread >= 2 and peanut_butter >= 1 a... | true |
6b8b4085784cded514229f7744463d282b03563e | K-Roberts/codewars | /Greed Is Good.py | 1,492 | 4.34375 | 4 | '''
Created on Nov 13, 2018
@author: kroberts
PROBLEM STATEMENT:
Greed is a dice game played with five six-sided dice. Your mission, should you
choose to accept it, is to score a throw according to these rules. You will always
be given an array with five six-sided dice values.
Three 1's => 1000 points
Three 6's... | true |
4fd336444011052fc5280b737aab042cfb0ecd1c | jcjessica/Python | /test.py | 738 | 4.25 | 4 | # program that prints out a table with integers from decimal 0 to 255, it's hex number, and the character corresponding to the unicode with UTF-8 encoding
# using a loop
#for x in range(0, 256):
# print('{0:d} {0:#04x} {0:c}'.format(x))
# using list comprehension
#ll = [('{0:d} {0:#04x} {0:c}'.format(x)) for x... | true |
37003d9f0f7ebeba14500e2f9e9d0c535e3c7b04 | hacksman/learn_python | /call/calll_demo.py | 2,664 | 4.21875 | 4 | #!/usr/bin/env python
# coding:utf-8
# @Time :11/17/18 10:30
"""
📋 --->>> 控制台输出(ter)
🤔 --->>> 解析(thi)
📢 --->>> 说明(exp)
🌰 --->>> 例子(exa)
------>>> 分割线(sep)
materials:
# Python __call__ special method practical example
1. https://stackoverflow.com/questions/5824881/python-ca... | false |
5aec73356d0c740bcc4550dcbacb369edac7d333 | theTransponster/Problem-Solving- | /Python/FindSubString.py | 1,562 | 4.1875 | 4 | #This script find a certain substring within a string, and counts how many times it appears
def count_substring(string, sub_string):
aux = 0
for i in range(0, len(string), len(sub_string)-1):
#print(i)
if (i + len(sub_string) - 1 ) < len(string):
if i > 0:
if i +... | false |
7e39ffe21c7c929daa5a7e52806206c839427ea8 | NamJueun/Algorithms-with-Data-Structure-using-Python | /chap2/리스트스캔/list2.py | 370 | 4.21875 | 4 | ## 리스트 스캔 2 : 인덱스와 원소를 짝지어 enumerate() 함수로 반복해서 꺼냅니다.
# 리스트의 모든 원소를 enumerate() 함수로 스캔 ➞ enumerate() 함수는 인덱스와 원소를 짝지어 튜플로 꺼내는 내장 함수
x = ['John', 'George', 'Paul', 'Ringo']
for i, name in enumerate(x):
print(f'x[{i}] = {name}')
| false |
4c05f6717795444de47d9c1f73332924cb41eb67 | BradleyMidd/learnwithbrad | /calc.py | 499 | 4.3125 | 4 | # Basic Calculator
action = True
while action:
num1 = int(input("Type a number: "))
info = input("Do you want to add, subtract, multiply or divide? \nType [+], [-], [*] or [/]: ")
num2 = int(input("Type a second number: "))
if info == "+":
print(num1 + num2)
elif info == "-":
prin... | true |
eeadea36a30f7259237e2a1b35219f6bba1d2b1e | ginajoerger/Intro-to-Computer-Programming | /Homework 0/exercise2.py | 524 | 4.28125 | 4 | # HOMEWORK 0 - EXERCISE 2
# Filename: 'exercise2.py'
#
# In this file, you should write a program that:
# 1) Asks the user for a number
# 2) Prints 'odd' or 'even' depending on the number's parity
#
# Example1:
# *INPUT FROM THE USER
# Enter a number: 17
# *PRINTED OUTPUT
# odd
#
# Example2:
# *INPUT ... | true |
fa53d19d965f3f5ca2e14ff0bbb84e1841fedce7 | DenisVargas/PhytonRoadToMaster | /Tutorial/ListComprehensions.py | 991 | 4.21875 | 4 | #Source: https://www.learnpython.org/en/List_Comprehensions
#List Comprenhensions permite crear una nueva lista utilizando una linea mas fácil de enteder.
#Example of program
# sentence = "the quick brown fox jumps over the lazy dog"
# words = sentence.split()
# word_lengths = []
# for word in words:
# if word !... | false |
24acebf08c5a78d24db1fd06a3943e4b9f9e23a3 | NayoungBae/algorithm | /week_3/08_queue.py | 1,518 | 4.15625 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Queue:
def __init__(self):
self.head = None
self.tail = None
def enqueue(self, value):
new_node = Node(value) # 새 노드 생성
if self.is_empty(): # head 또는 tail이 비었는지 안 비었는지에 따라 예외처리
... | false |
cf7107f26f2531a68e5a23c9ffa51090d1d1be7b | NayoungBae/algorithm | /week_2/03_add_node_linked_list_nayoung.py | 1,567 | 4.15625 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self, data):
self.head = Node(data)
def append(self, data):
if self.head is None:
self.head = Node(data)
return
current_node = self.head
... | true |
338ae906f91e5ab7dd8a9f7df31384bb894ba409 | kukaiN/Sudoku_solver | /sudoku_checker.py | 1,787 | 4.125 | 4 |
def num_in_row(board, row_number, col):
""" returns a list of values that are on the same row"""
return list({board[row_number][i] for i in range(len(board)) if col != i } - set([0]))
def num_in_column(board, column_number, row):
""" returns a list of values that are on the same column"""
return list(... | true |
397ac1c9fe38ca7a4352d42e0da2e1c0e794c2b9 | grayreaper/pythonProgrammingTextbook | /futval.py | 1,131 | 4.125 | 4 | # futval.py
# A program to compute the value of an investment
# carried 10 years into the future
###This is not working properly!!
###This is not working properly!!
###This is not working properly!!
###This is not working properly!!
###This is not working properly!!
###This is not working properly!!
###T... | true |
a3ed36e4bdedfb614019876ac85e1071883a9625 | grayreaper/pythonProgrammingTextbook | /feetToMilesConvert.py | 333 | 4.25 | 4 | # feetToMilesConvert.py
# This program converts feet to miles
# BY: Gray Reaper
def main():
print("This Program converts a distance in feet to miles")
feet = eval(input("Enter the distance in feet: "))
miles = feet / 5280
print("The distance in miles is", miles)
input("Press ENTER to e... | true |
c3560cced795faf82745f4beeea0e21cf802aa51 | WenJuing/scrapy-douBan | /study/dog.py | 1,336 | 4.15625 | 4 | '''一个关于狗的类'''
class Dog():
'''一只可爱的小狗'''
def __init__(self, name, age): # 使用类时自动运行,接收参数并返回实例
self.name = name
self.age = age
def sit(self):
'''坐下命令'''
print(self.name.title(), "is now sitting!")
def describe_dog(self):
'''输出小狗信息'''
print("Dog's name ... | false |
6b2d62a961fbc59098767452676fe067a3e6755b | WenJuing/scrapy-douBan | /C3-ComPythonScript/3.5-inheritClass.py | 1,246 | 4.375 | 4 | # 演示新类的继承
class Spider(object):
'''蜘蛛子,最原始的蜘蛛形态'''
eyes = 4
legs = 8
weight = 0.02
iq = '低下'
def __init__(self):
'''初始化'''
self.name = '蜘蛛子'
self.show()
def show(self):
print("我叫%s" % self.name)
print("我有%d个眼睛和%d条腿,体重为%.2f,智力%s" % (self.eyes, self.l... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.