blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
701af849fc555f9c802f3d3f60c16569455d8bd6 | Vantom16/security_system | /security.py | 1,058 | 4.21875 | 4 | #Creating our Security System
# Code output is displayed in command line
#First we create a list of known users
known_users = ["Alice", "Jane", "David", "Paul", "Eli", "Isme"]
while True:
print("Hi! My name is Joe")
name =input("What is your name?: ").strip().capitalize()
#Computer will compare name ... | true |
031291a9602fdc584e02649768b0ef0d9fa3d1c4 | valievav/Python_programs | /Practice_exercises/training/mini_tasks.py | 2,730 | 4.1875 | 4 | # Related read
# https://realpython.com/python-coding-interview-tips/#select-the-right-built-in-function-for-the-job
# https://docs.python.org/3/library/functions.html#built-in-functions
section_sep = ''
# EVEN numbers
x = [11,1,3,4,5,6,8,9,10,1,3]
even_only = [i for i in x if i %2==0]
print(even_only)
print(section... | true |
9717caa2c2fccc161cd400a18bad6574237374be | valievav/Python_programs | /Practice_exercises/reverse_word_order.py | 917 | 4.375 | 4 | # https://www.practicepython.org/exercise/2014/05/21/15-reverse-word-order.html
# Write a program that asks the user for a long string containing multiple words.
# Print back to the user the same string, except with the words in backwards order.
# For example 'My name is Michele' -> 'Michele is name My'
def reverse_w... | true |
893b5f5f5268d728a7b3474e0289bcd57961e512 | adonis-lau/Python3Demo | /bid/adonis/lau/one/def.py | 2,743 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def my_abs(x):
if not isinstance(x, (int, float)):
raise TypeError('bad operand type')
if x > 0:
return x
else:
return -x
print(my_abs(-99))
a = abs
print(a(-88))
# 如果什么也不想坐,可以使用pass
def my_pass():
pass
import math
# 函数返回多个... | false |
70808716d0d3ae632945a34ffc58c57326666ce6 | tmetz/ITP195 | /notes/ch4.py | 2,233 | 4.1875 | 4 | import math
import string
#my_utf = ord("h") # Returns integer (ordinal) UTF-8 value of char
#my_utf_ch = chr(121) # Returns UTF-8 char
#print(my_utf, my_utf_ch)
my_str = "This is a test of a string"
#print(my_str[:8]) # Print from beginning to 7th char. Does not print the 8th character!!!
# Extended slicing:
# [sta... | true |
28b8a10bc86eb1393dfb88d0d0192c4c4a2a2e18 | tmetz/ITP195 | /Homework/stack.py | 1,332 | 4.25 | 4 | """
Tammy Metz
ITP 195 - Topics In Python
HW 4 - due April 9, 2018
Create a python module called "stack" that has methods for popping, pushing, and returning
the top of the stack
"""
class Stack(object):
def __init__(self, stack_as_list):
self.stack = stack_as_list
def is_empty(self):
if le... | true |
ed02008cb439f9c84cbbc1aa022fa87f9465e1e4 | Spookyturbo/PythonCourse | /Week2/Lab3/guessNumber-ariedlinger.py | 855 | 4.28125 | 4 | #Guess My Number
#Andrew Riedlinger
#January 24th, 2019
#
#The computer picks a random number between 1 and 100
#The player tries to guess it and the computer lets
#the player know if the guess is too high, too low
#or right on the money
import random
print("\tWelcome to 'Guess My Number'!")
print("\nI'm thinking of ... | true |
6072136ab86ea5de52eaaf5ae8c75e2af47f3d20 | tgoel5884/twoc-python | /Day6/Program5.py | 605 | 4.1875 | 4 | import math
def isPerfectSquare(x):
s = int(math.sqrt(x))
if s*s == x:
return True
def isFibonacci(n):
# n is Fibinacci if one of 5*n*n + 4 or 5*n*n - 4 or both
return isPerfectSquare(5 * (n*n) + 4) or isPerfectSquare(5 * (n*n) - 4)
n = int(input("Enter length: "))
arr = []
for i in ... | false |
94d88ae01f38050fa8f03842be24da5a3f860ab1 | tgoel5884/twoc-python | /Day4/program2.py | 542 | 4.3125 | 4 | a = int(input("Enter the no of tuples you want to add in the list: "))
b = int(input("Enter the no of elements you want to add in each tuple: "))
List = []
for i in range(a):
print("Enter the elements in Tuple", i + 1)
Tuple = []
for j in range(b):
Tuple.append(int(input("Enter the element: "... | true |
ba9e575719e21c20983bbb2a9ef8187246cdb3fd | a-abramow/MDawsonlessons | /lessons/Chapter 06/6_08.py | 1,520 | 4.28125 | 4 | # Доступ отовсюду
# Демонстрирует работу с глобальным переменными
def read_global():
print("В области видимости функции read_global() значение value равно", value)
def shadow_global():
value = -10
print("В области видимости функции shadow_global() значение value равно", value)
def change_global():
... | false |
48bd30e53c5ccd161965c7133d4a378de01e80d1 | a-abramow/MDawsonlessons | /lessons/Chapter 05/Homework_01.py | 512 | 4.34375 | 4 | # Создайте программу, которая будет выводить список слов в случайном порядке.На экране должны печататься без
# повторений все слова из представленного списка.
import random
words = ["run", "fast", "bill", "apple", "dog", "cat"]
print('Эти слова в случайном порядке:')
while words:
word = random.choice(words)
... | false |
036a2c05ee302c3bb0dd70f6445c8b4f7f2fec6b | kaukas14/python-shit | /ex32.py | 1,073 | 4.46875 | 4 | the_count = [1, 2, 3, 4, 5]
fruits = ['apples','oranges','pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
# this first kind of for loop goes throught a list
for number in the_count:
print(f"This is count {number}")
# same as above
for fruit in fruits:
print(f"A fruit of type: {fruit}"... | false |
9cfc335ffe0c53f298a637da72223abb916829c6 | Fin-Syn/Python-Beginings | /first_list.py | 1,249 | 4.59375 | 5 | days_of_week = ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat']
print (days_of_week [2])
#Changes element in the list
days_of_week [0] = 'Sunday'
print (days_of_week)
#Slices the list, but formats is as stated in the list
print (days_of_week [2:5])
#Example nested list, when printing needs to call ... | true |
c92c03f694a6c07a2b699102edd11edeb7e49ec2 | ZhangJiaQ/everything | /Python/Algorithm/LintCode/30. Insert Interval.py | 1,944 | 4.21875 | 4 | """
Definition of Interval.
class Interval(object):
def __init__(self, start, end):
self.start = start
self.end = end
30. Insert Interval
中文English
Given a non-overlapping interval list which is sorted by start point.
Insert a new interval into it, make sure the list is sti... | false |
edc76b2b6c2a2926e3a4f9529829661fe5eb2669 | Stashare/Bc13_Day2 | /missingnumber.py | 558 | 4.21875 | 4 | """MissingNumber"""
def find_missing(a,b):
temparr=[] #an array that stores missing numbers temporarily during the loop
#and it is assigned to outputarr.
outputarr=[0] #output the final result
#loop to check whether there is missing numbers
for i in b:
if i not in a:
... | true |
cf8a2e180a9866c3a980ebfec8424562bb0ab65f | santosh2alp/hellow-world | /exp.py | 1,091 | 4.21875 | 4 | #!/usr/bin/python3
# First python program
def printMassage():
print("The Quick Brown Fox Jumps Over The Lazy Dog!")
if __name__ == "__main__":
printMassage()
# Arithemetic Oprators
'''
num1 = 10
num2 = 20
print ("Num1 + Num2 =",num1+num2)
print ("Num1 - Num2 =",num1-num2)
print ("Num1 * Num2 =",num1*num2)
pri... | false |
2d5778d4a29476d3da4731d3b4bf523c16ed842e | cglima/maratona-data-science | /semana01/laboratorio/ex2.7/ex2.7c.py | 862 | 4.34375 | 4 | """Programa que escolhe o mais barato dentre 5 produtos
Faça um programa que pergunte o preço de 5 produtos e
informe qual produto você deve comprar, sabendo que a decisão é sempre
pelo mais barato.
3. Uma lista bidimensional com preço e nome
"""
#pergunte o preço de 5 produtos
produtos = [
["computador", 0 ],
... | false |
5387a36e27d9425e0699db07d3d5aa6d3d3d205a | juffaz/module4 | /task10.py | 1,002 | 4.21875 | 4 | print('Задача 10. Максимальное число (по желанию)')
# Пользователь вводит три числа.
# Напишите программу,
# которая выводит на экран максимальное из этих трёх чисел (все числа разные).
# Можно использовать дополнительные переменные, если нужно
first_dig = int(input("Введите первое число: "))
second_dig = int(input(... | false |
5307cc0e8ef1eef508357f5217d98d5e1dce0fb6 | katiavega/CS1100_S03 | /Ejercicio05.py | 2,121 | 4.15625 | 4 | print ("Ingrese fecha de nacimiento:")
dia = int(input("Ingrese dia:"))
mes = int(input("Ingrese mes:"))
anio = int(input("Ingrese año:"))
if anio % 2 == 0: # Es año PAR
if mes>=1 and mes<=3: # Ene,Feb ó Mar
if dia % 2 ==0: #Día PAR
print("Tu piedra preciosa es: ", "Rubí")
else: ... | false |
c8b0db36c366681ec0245f0441a2ab8e25d59e82 | chelseacx/CP1404 | /Practicals/workshop 4/calculating_bmi.py | 587 | 4.15625 | 4 |
def get_float_value(variable_name, measurement_unit):
while True:
try:
float_value = float(input("Please enter your {} in {}: ".format(variable_name, measurement_unit)))
break
except ValueError:
print("Invalid value!")
return float_value
print("Body-mass-i... | true |
30584f415728ad4df70f03004cff68c03823dd9f | ElielLaynes/Curso_Python3_Mundo1_Fundamentos | /Mundo1_Fundamentos/Aula07_Operadores_Aritméticos/DESAFIOS/desafio009.py | 721 | 4.15625 | 4 | # Faça um programa que leia um número inteiro qualquer e mostre na tela a sua tabuada.
num = int(input('Digite um Número: '))
print('=' * 30)
print('A Tabuada de {} é:'.format(num))
print('=' * 30)
print('{} x 0 = {:^5}'.format(num, num * 0))
print('{} x 1 = {:^5}'.format(num, num * 1))
print('{} x 2 = {:^5}'.fo... | false |
e8bf766cb61490a70fbc298c790b0aadcaf2b1de | Mrklata/Junior | /tuples.py | 766 | 4.15625 | 4 |
def tuple_checker(a, b):
unique_a = set(a) - set(b)
unique_b = set(b) - set(a)
if a == b:
return 'tuples are equal'
if unique_b != unique_a:
return f'tuples are not equal and the unique values are a: {unique_a}, b: {unique_b}'
else:
return 'tuples are not equal but have t... | true |
a8df3d657504d3ab7c0c7e69ffbc484702bab7d2 | wenzhifeifeidetutu/pythonWork | /pythonCrashcourseExerciseAnswer/p179.py | 435 | 4.125 | 4 | #p179
try:
number1 = int(input("please input first number "))
number2 = int(input("please input second number "))
except ValueError:
print("you should input number !")
else:
print(str(number1 + number2) )
while True:
try:
number1 = int(input("please input first number "))
number2 = int(input("please input s... | false |
63ee2a4321f54f09e2c06cccb689b017ad090a6a | MythiliPriyaVL/PySelenium | /venv/ProgramCode/34-ModuleItertools.py | 573 | 4.46875 | 4 | """
Define a function even_or_odd, which takes an integer as input and returns the string even and odd,
if the given number is even and odd respectively.
Categorise the numbers of list n = [10, 14, 16, 22, 9, 3 , 37] into two groups namely even and odd based on above defined function.
Hint : Use groupby method of itert... | true |
a81870d539a8fd5de0f7c7514a04bcfd87532f6f | MythiliPriyaVL/PySelenium | /venv/ProgramCode/31.2-TimeDelta.py | 1,244 | 4.28125 | 4 | #Example file for timedelta
from datetime import datetime
from datetime import date
from datetime import time
from datetime import timedelta
def main():
# basic timedelta
print(timedelta(days=365, hours=5, minutes=1))
#Today's date
now = datetime.now()
print("Today is: ", str(now))
#Today's d... | true |
6505d7aa96966839827ac72822be80332f018413 | MythiliPriyaVL/PySelenium | /venv/ProgramCode/11-PrimeNumbers.py | 668 | 4.25 | 4 | #5. Print prime numbers below a given number.
#Get input from the User and print whether the value is Prime or Not
numberInput = int(input("Enter any number, I can print the Prime Numbers below that :"))
#Validating the Input value
if (numberInput == 1 or numberInput == 2 ):
print("There is no Prime Number below "... | true |
9c76c25e8e7d552cf7a53ce4dc4ee341963dd20d | MythiliPriyaVL/PySelenium | /venv/ProgramCode/31.1-DateTimeFormatting.py | 817 | 4.375 | 4 | #Example file for Date Formatting
from datetime import datetime
def main():
now=datetime.now()
### DATE FORMATTING ###
print(now.strftime("Current year is: %Y")) #Current year is: 2020
# %y/%Y - Year, %a/%A - Weekday, %b/%B - month, %d - day of month
print(now.strftime("%a, %d %B, %y")) #Thu, 27 ... | false |
a6c3a5848f1f16bddcf0f65e0927b6cc7d396eb3 | MythiliPriyaVL/PySelenium | /venv/ProgramCode/05-LoginCheck.py | 740 | 4.15625 | 4 | """
Login Testing:
1. User Name and Password are hardcoded in the program
2. User should enter right combination of values to login
3. User can try upto 3 times and the program stops after that.
"""
#Hardcoded User Name and Password values
uN1 = "newUser"
uP1 = "09876"
#Looping for 3 maximum attempts
for x in range(3... | true |
1deb4d6cf623e49cff90450de4087c1c5433b18a | demetredevidze/edge-final-project | /final.py | 1,377 | 4.28125 | 4 | # day_1_game.py
# [Demetre Devidze]
import random
rules = "Rules are simple! You get 5 chances to guess a random integer between 0 and 30. "
hint1 = "PS, 5 tries is definitely enough! If you play smart you will be able to win the game every single time!"
hint2 = "Think about the powers of 2. Two to the power of fiv... | true |
26c9f7e383cce71cde211cd35562d951f7c64c54 | RAJARANJITH1999/Python-Programs | /even.py | 214 | 4.1875 | 4 | value=int(input("enter the value to check whether even or odd"))
if(value%2==0):
print(value,"is a even number")
else:
print(value,"is odd number")
print("vaule have been checked successfully")
| true |
9285ac69e4170b19d8cf59a5e202d3368933d978 | RAJARANJITH1999/Python-Programs | /bitodec.py | 474 | 4.15625 | 4 | n=int(input("enter the binary number (1's and 0's)"))
base=1
decimal=0
binary=n
while(n>0):
rem=n%10
decimal=decimal+rem*base
n=n//10
base=base*2
n1=int(input("enter the decimal number to convert into binary"))
base2=1
bi=0
dec=n1
while(n1>0):
rem1=n1%2
bi=bi+rem1*base2
n1=n1... | false |
2d2147a5e19328d03bb6105bc77f569881ccfced | RAJARANJITH1999/Python-Programs | /shirt.py | 880 | 4.125 | 4 | white=['M','L']
blue=['M','S']
available=False
print("*****search for your color shirt and size it*****")
color=input("enter your shirt color")
if(color.lower()=='white'):
size=input("enter your size")
if((size.upper() in white)):
print("available")
available=True
else:
print("unavailable"... | true |
7346df8393977718803fbe9c33ab377afb56a2c9 | wengellen/cs36 | /searchRotatedSortedArray.py | 554 | 4.1875 | 4 | # Given an integer array nums sorted in ascending order, and an integer target.
#
# Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
#
# You should search for target in nums and if found return its index, otherwise return -1.
#
# Example 1:
# Inp... | true |
0d7662fc3a197bb8d5fb992726c99597bd2a410c | wengellen/cs36 | /linkedListPatterns.py | 859 | 4.125 | 4 | class LinkedListNode:
def __init__(self, value):
self.value = value
self.next = None
self.prev = None
x = LinkedListNode('X')
y = LinkedListNode('Y')
z = LinkedListNode('Z')
x.next = y
y.next = z
y.prev = x
z.prev = y
def print_ll_reverse(tail):
current = tail
while current is n... | true |
b743ffa0b4a76bceb5b53afb58b2e3b2106652e9 | tsoutonglang/gwc-summer-2017 | /your-grave.py | 2,059 | 4.1875 | 4 | start = '''
You wake up strapped to a chair at the bottom of a grave. Your arms are tied behind your back, and your feet are tied to the chair.
You look up and see the Riddler standing over you with a shovel in his hand.
"You have to play my games to live. It's game over once you get a riddle wrong.
Get all three right... | true |
8d57d7804f802324d3a2a23bda49bb553f82b463 | manas-mukherjee/MLTools | /src/tutorials/fluentpython/2-Vector.py | 816 | 4.28125 | 4 | #Example 1-2 is a Vector class implementing the operations just described, through the use of the special methods __repr__, __abs__, __add__ and __mul__.
from math import hypot
class Vector:
"""docstring for Vector."""
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def __repr__(self):... | false |
1c30b6fff4469000460b9518314899e67004f706 | manas-mukherjee/MLTools | /src/tutorials/fluentpython/function_as_objects/TestFunction.py | 2,833 | 4.15625 | 4 | ##############################################
# Treating a Function Like an Object #
##############################################
# Example 5-1
print('\nExample 5-1\n------------\n')
def factorial(n):
'''Returns n factorial'''
return 1 if n<2 else n * factorial(n-1)
print(factorial(42))
print(fact... | true |
19f26e9acaab20e6ca4c43ab04797cafa9fb6f0f | Sciencethebird/Python | /Numpy/arrange and linspace.py | 686 | 4.125 | 4 |
import matplotlib.pyplot as plt
import numpy as np
import math
# arange and linespace both output np array
# arange: x1 form [0, 10) increase by 1
x1 = np.arange(0,10,0.1)
print(x1)
# linespace: x2 belongs to [10, 2] with twenty dots
x2 = np.linspace(10,2,50)
print('numpy array is converted to a python list \n', l... | true |
3ec05fbcb0a83872f6dc2454482e07aca2e52229 | zanda8893/Student-Robotics | /.unused/code.py | 2,586 | 4.1875 | 4 | import time
import random
"""
this is a rough first attempt which shouldn't work
"""
class move():
"""
the general movement methods for the robot
they are programmed here for easy access and to
make it easier when implementing new ideas
# TODO: add proper moter commands for starting and stoping to robit ... | true |
3b05334d87578f06dbdae53128873bf77f512ef4 | ccbrantley/Python_3.30 | /Decision Structures and Boolean Logic/Brantley_U3_14.py | 645 | 4.21875 | 4 | weight = 0
height = 0
print('This progam will calculatey your BMI(Body Mass Index).')
weight = int(input('Please enter in your weight using a measurement of pounds.'))
height = int(input('Please enter in your height using a measurement of inches.'))
BMI = weight * 703/height**2
if 18.5 <= BMI <= 25:
print('Y... | true |
5f5b691d7740a9bb38c7a28cbda880cc6ed2aed6 | ccbrantley/Python_3.30 | /Repetition Structure/Brantley_U4_8.py | 285 | 4.375 | 4 | number = 0
number_sum = 0
print('Enter positive numbers to sum them together and enter a negative number to stop.')
while number >= 0:
number = float(input('Enter number: '))
if number >= 0:
number_sum += number
print('The sum is:', format(number_sum, ',.2f'))
| true |
7edaaf88bdc2d0df04c503d28f817a286775bd25 | Mike1514/python_project | /max num, min num, etc.py | 631 | 4.1875 | 4 | #Напишите программу, которая получает на вход три целых числа, по одному числу в строке,
# и выводит на консоль в три строки сначала максимальное, потом минимальное, после чего оставшееся число.
f = int (input())
s = int (input())
t = int (input())
a = max(f, s, t)
b = min(f, s, t)
print(a)
print(b)
if a == f and b ==... | false |
7f395f81d1c25a4eb0a5ca406328745dff758ded | whereislima/python-syntax | /words.py | 373 | 4.40625 | 4 | def print_upper_words(words, first_letter):
"""
print out each word in all uppercase
only print words that start with h or y
"""
for word in words:
if word[0] == "h" or word[0] == "y":
print(word.upper())
# this should print "HELLO", "HEY", "YO", and "YES"
print_upper_words(... | false |
2bb3801d508611d068f14d575a80a368c7252c3c | Jeremyljm/new | /05-高级数据类型/hm_20_字符串切片演练.py | 593 | 4.21875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
num_str = "abcdefghi"
# 截取2-5位置的字符串
print(num_str[2:6])
# 截取2-末尾位置的字符串
print(num_str[2:])
# 截取从开始-5位置的字符串
print(num_str[0:6])
# 截取完整的字符串
print(num_str[:])
# 从开始位置,每隔一个字符截取字符串
print(num_str[::2])
# 从索引1开始,每隔一个取一个
print(num_str[1::2])
# 截取从2-末尾 -1的字符串
print(num_str[2:... | false |
449f7ce26696cd4804d5e7796a5d724d9b9c34b8 | ashishaaron346/MONTHLY_TASKS_PROJECT | /March_2019_Task2/Beginner_Python_Projects_2/proj13DiceRoll.py | 1,520 | 4.125 | 4 | #!/usr/bin/env python3
# proj13DiceRoll.py - r/BeginnerProjects #13
# https://www.reddit.com/r/beginnerprojects/comments/1j50e7/project_dice_rolling_simulator/
import random, time
# Loop until keyboard interrupt
while True:
try:
# Prompt until a positive integer is input for num of sides
while True:
try:
... | true |
72a2dea947e7c91504ad5fa81a035c5c34454128 | ashishaaron346/MONTHLY_TASKS_PROJECT | /March_2019_Task1/Beginner_Python_Projects_1/proj02Magic8Ball.py | 1,135 | 4.15625 | 4 | #!/usr/bin/env python3
# proj02Magic8Ball.py - r/BeginnerProjects #2
# https://www.reddit.com/r/beginnerprojects/comments/29aqox/project_magic_8_ball/
import time, random
responses = ["Nah.",
"Get out of here.",
"Could be, who knows man.",
"Yes",
"Technically your odds aren't zero, but realistically...",
"Maybe.... | true |
04bb9b3d91d0f91b5c9f8b66a9ff301af2983553 | daorejuela1/holbertonschool-higher_level_programming | /0x06-python-classes/100-singly_linked_list.py | 2,165 | 4.15625 | 4 | #!/usr/bin/python3
"""linked list docstrings.
This module demonstrates how to use a linked list with classes.
"""
class Node():
"""This class defines a memory space"""
def __init__(self, data, next_node=None):
""" corroboares data is int and next node is valid"""
if type(data) is not int:
... | true |
99b2b7fa1180a5ed800908c4e3e925d19c1f502e | xx-m-h-u-xx/Scientific-Computing-with-AI-TensorFlow-Keras | /GuessNumber.py | 562 | 4.125 | 4 | # Guess the number game.
# GuessNumber.py
import random
num_guesses = 0
user_name = input("Hi: What is your name? ")
number = random.randint(1,20)
print("Welcome, {}! Guess number between 1 and 20.".format(user_name))
while num_guesses < 6:
guess = int(input("Take a guess?"))
num_guesses += 1
... | true |
e666d86c38fda89d2434f80db29c44a386020118 | fanzou2020/Parsing | /driver.py | 1,106 | 4.25 | 4 | import parser
import truth_table
inputStr = input('Please enter the proposition:\n')
result = parser.parse(inputStr)
variables = result["variables"]
case = input('1. Given the truth value of variables.\n2. Generate truth table\n')
if case == '1':
print("The variables are: ", end='')
print(variables)
s = ... | true |
40b995a19b4b4b77e16f9b248dd7e0079514b5cf | JordonZ90/LeapYear | /LeapYear.py | 242 | 4.28125 | 4 | def leap_year():
year = int(input("Please enter the year "))
if (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)):
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
leap_year()
| false |
ab534206a4e2293ccf0d1d774aa6d698ddabc870 | andersonLoyola/python-repo | /book/exerciseOne.py | 634 | 4.25 | 4 | # Write a program that asks the user to enter a integer and prints two integers, root and pwr, such that 0 < pwr < 6 amd root**pwr is equals to the integer entered by the user
number = int(input("Write some number: "))
auxNumber = 1
found = False
while auxNumber < number and found == False:
auxPower=0
while auxNum... | true |
6f1f06ca37ee63633a8b568afd7c15571a019222 | marjorienorm/learning_python | /words.py | 1,414 | 4.21875 | 4 | """Retrieve and print words for a url.
usage:
python words.py <URL>
"""
import sys
from urllib.request import urlopen
def fetch_words(url):
"""Fetch a list of words form a url.
Args:
url: The URL of a UTF-8 text document.
Returns:
A list of strings containing the words from the do... | true |
01a55d99f9fbf4b98ec18322393f396480d59f34 | Saberg118/CS100 | /Tuition_calculator.py | 397 | 4.125 | 4 | # This program will display the projected semester tuition for the next 5
# years if tuition increases by 3%
# Initialize
tuition = 8000
# Make a table
print('Years \t\t Tuition')
print('___________________________')
#for loop
for year in range(1,6):
# Calculate tuition
tuition *= 1.03
#... | true |
404845e4a4a0225a1c712014a3a2730f378e287e | Saberg118/CS100 | /budget_calculator_using for loop.py | 1,082 | 4.28125 | 4 | # This program keeps the running total of the expenses of the user
# and it will give the feedback wither or not the user stayed on
# their proposed budget or if they were over or under it.
total = 0.0 # initialize the accumulator
# Get the budget amount from the user
budget = float(input('Enter your budget ... | true |
8ec079ba4cb5f0388a539f1963ad8f6b6e039a79 | Saberg118/CS100 | /Ocean_level.py | 312 | 4.3125 | 4 | # This program displays the Ocean level
# through years 0 through 25
print('Years \t\t Ocean levels')
print('___________________________')
Ocean_level = 0
for year in range(1,26,1):
Ocean_level += 1.6
print(format(year, '.2f'),'\t\t',format(Ocean_level,'.2f'), 'millimeters')
| false |
71b3cd139efaa07ca2bd48ed3e81ffbafb2af00b | Saberg118/CS100 | /classroom_percentage.py | 858 | 4.1875 | 4 | # This program calculate the percentage of males and females
# in a given class.
# Get the number of girl in the class.
girls = int(input('How many females are in the class? '))
# Get the number of boys in the class.
boys = int(input('How many males are in the class? '))
# Calculate the number of students i... | true |
6e11cba06075706d9d8eae9678aaafe941fdb039 | cifpfbmoll/practica-3-python-AlfonsLorente | /src/Ex7.py | 1,336 | 4.46875 | 4 | #!/usr/bin/env python3
#encoding: windows-1252
#Pida al usuario tres nmero que sern el da, mes y ao. Comprueba que la fecha introducida es vlida. Por ejemplo:
#32/01/2017->Fecha incorrecta
#29/02/2017->Fecha incorrecta
#30/09/2017->Fecha correcta.
import sys
if __name__ == "__main__":
#declare the variables
... | true |
68436256894092a0eae4cb852624edd04e53baa5 | avholloway/100DaysOfCode | /day9.py | 2,573 | 4.28125 | 4 | programming_dictionary = {
"Bug": "An error in a program that prevents the program from running as expected.",
"Function": "A piece of code that you can easily call over and over again."
}
# 9.1 - grading
# -----------------------------------------------------------
def one():
student_scores = {
"Harr... | true |
3ae0882b38387b25a66b1cf72c98595d2c539b54 | dinphy/python-base-case | /03_函数编程_上/04_返回值.py | 1,136 | 4.5625 | 5 | """
返回值: 函数执行之后. 会给调用方一个结果. 这个结果就是返回值
关于return:
函数只要执行到了return. 函数就会立即停止并返回内容. 函数内的return的后续的代码不会执行
1. 如果函数内没有return , 此时外界收到的是None
2. 如果写了return
1. 只写了return, 后面不跟数据, 此时接收到的依然是None -> 相当于break
2. return 值 , 此时表示函数有一个返回值, 外界能够收到一个数据 -> 用的最多
3. return... | false |
794fb4af68bf0683eab6ce717a4de1cf955f007b | russunazar/-.-1- | /number 3.py | 459 | 4.21875 | 4 | x = float(input("перша цифра: "))
y = float(input("друга цифра: "))
operation = input("Operation: ")
result = None
if operation == "+":
result = x + y
if operation == "-":
result = x - y
if operation == "*":
result = x * y
if operation == "/":
result = x / y
else:... | true |
8e4f94063b10e42d4877fcf11afaaccc00217437 | itsmehaanh/nguyenhaanh-c4e34 | /Session4/homework/bai4.py | 987 | 4.25 | 4 | print ('''If x = 8, then what is 4(x+3)?
1. 35
2.36
3.40
4.44''')
question = {
"If x = 8, then what is 4(x+3)?" : {
"1" : 35,
"2" : 36,
"3" : 40,
"4" : 44,}
}
answer = input("Your code:")
if answer == "3":
print("Bingo!")
else:
print(":(")
print('''Estimate this answer (ex... | true |
5df4cabafe46b6606f8712dcd94f62a9bd08c680 | hakim-DJZ/HF-Python | /Chapter2/nester/hakim_nester.py | 688 | 4.5 | 4 | """Example module from chapter 2, Head First Python. The module allows
you to print nested lists, by use of recursion. It's named the nester.py
module, which provides the print_lol() frunction to print nested lists."""
def print_lol(the_list, indent = False, level=0):
"""For each item, check if it's a list; if ... | true |
b68dbecaada6712ac96438e48a88e462196ceee8 | in-tandem/matplotlib_leaning | /simple_graph.py | 484 | 4.125 | 4 |
## i am going to plot using simple lists of data
## i am going to label x and y axis
## i am going to add color
## i am adding title to the graph
import matplotlib.pyplot as plot
print('i am going to draw a simple graph')
x_axis = [10, 20, 30, 40, 66, 89]
y_axis = [2.2, 1.1, 0, 3, -9, 99]
plot.plot(x_axis,y_axis, c... | true |
b59d922c989315e331dc682a37a9d48f8bd41ef0 | odeyale2016/Pirple_assignment | /card2.py | 1,038 | 4.1875 | 4 | from random import randint, choice
def jack_chooses_a_card(suits: dict):
"""
Program for Card Game
"""
print(str(randint(1,13)) + " of " + str(choice(suits)))
def check_help():
# Instructions for the help
multiline_str = """Welcome to Pick a Card Game.
To play the game, follow the instructi... | true |
801d9ab6b31011ff1783ec489e3d150c5c79f44a | rlowrance/re-local-linear | /x.py | 2,216 | 4.15625 | 4 | '''examples for numpy and pandas'''
import numpy as np
import pandas as pd
# 1D numpy arrays
v = np.array([1, 2, 3], dtype=np.float64) # also: np.int64
v.shape # tuple of array dimensions
v.ndim # number of dimensions
v.size # number of elements
for elem in np.nditer(v): # read-only iteration
pass
for elem... | true |
b5df893cc27a870952f800153e355c44610c2cca | jemg2030/Retos-Python-CheckIO | /INITIATION/IsEven.py | 1,082 | 4.34375 | 4 | '''
Check if the given number is even or not. Your function should return True if the number is even, and
False if the number is odd.
Input: An integer.
Output: Bool.
Example:
assert is_even(2) == True
assert is_even(5) == False
assert is_even(0) == True
How it’s used: (math is used everywhere)
Precondition: given... | false |
72e53cf5497ee8a69bde468b3d2ad05374978e4a | jemg2030/Retos-Python-CheckIO | /INCINERATOR/OOP4AddingMethods.py | 2,031 | 4.4375 | 4 | """
4.1. Add the working_engine class attribute inside the Car class and assign it a value of False.
4.2. Add a start_engine method to the Car class, that displays the message "Engine has started"
and changes the working_engine value of the instance of class to True.
4.3. Add a stop_engine method to the Car class, th... | false |
758aea129a19502aeacd16c4a89319a1da897513 | jemg2030/Retos-Python-CheckIO | /HOME/EvenTheLast.py | 2,110 | 4.125 | 4 | '''
You are given an array of integers. You should find the sum of the integers with even indexes (0th, 2nd, 4th...). Then
multiply this summed number and the final element of the array together. Don't forget that the first element has an
index of 0.
For an empty array, the result will always be 0 (zero).
Input: A lis... | true |
2614ae144faef13ad3271bf311531cbd671b395e | jemg2030/Retos-Python-CheckIO | /SCIENTIFIC_EXPEDITION/AbsoluteSorting.py | 2,639 | 4.78125 | 5 | '''
Let's try some sorting. Here is an array with the specific rules.
The array (a list) has various numbers. You should sort it, but sort it by absolute value in ascending order.
For example, the sequence (-20, -5, 10, 15) will be sorted like so: (-5, 10, 15, -20). Your function should
return the sorted list or tuple... | true |
ba08876c2201f7ad0783e6df4cc5f16999370969 | jemg2030/Retos-Python-CheckIO | /ICE_BASE/NotInOrder.py | 1,885 | 4.28125 | 4 | """
You are given a list of integers. Your function should return the number of elements, which
are not at their places as if the list would be sorted ascending. For example, for the sequence
[1, 1, 4, 2, 1, 3] the result is 3, since elements at indexes 2, 4, 5 (remember about 0-based
indexing in Python) are not at the... | false |
0b1e36b6d8953235cd853e1827a28ebbc62f5883 | jemg2030/Retos-Python-CheckIO | /O_REILLY/SumOfDigits.py | 1,522 | 4.3125 | 4 | '''
The task in this mission is as follows:
You are given an integer. If it consists of one digit, simply return its value. If it consists of two or more
digits - add them until the number contains only one digit and return it.
Input: A int.
Output: A int.
Example:
assert sum_digits(38) == 2
assert sum_digits(0) ==... | false |
5f47280efff7921b548de8f213f7e6a07b4138b1 | jemg2030/Retos-Python-CheckIO | /HOME/BiggerPrice.py | 2,824 | 4.40625 | 4 | '''
You have a list with all available products in a store. The data is represented as a list of dicts
Your mission here is to find the most expensive products in the list. The number of products we are
looking for will be given as the first argument and the list of all products as the second argument.
Input: int and... | true |
483f162dabdd2310a400cadb2abc8ad26faeac62 | Chi10ya/UDEMY_SeleniumWithPython | /Sec8_ClassesObjectOrientedPrg.py | 2,934 | 4.8125 | 5 | """
8: Classes - Object Oriented Programming
45: Understanding objects / classes
46: Create your own object
47: Create your own methods
48: Inheritance
49: Method Overriding
50: Practice exercise with solution
"""
# 45: Understanding objects / classes
# 46: Create your own object
class myCla... | true |
4bf52edd8b443fde14901d5522921ac8f599679f | stanisbilly/misc_coding_challenges | /decompress.py | 1,981 | 4.1875 | 4 | '''
Decompress a compressed string, formatted as <number>[<string>]. The decompressed string
should be <string> written <number> times.
Example input: 3[abc]4[ab]c
Example output: abcabcabcababababc
Number can have more than one digit. For example, 10[a] is allowed, and just means aaaaaaaaaa
One repetition can occ... | true |
b26f56ad13ac9c603fe51fe969c4ee54b81b4687 | bermec/challenges | /challenges_complete/challenge182_easydev10.py | 2,146 | 4.4375 | 4 | '''
(Easy): The Column Conundrum
Text formatting is big business. Every day we read information in one of several formats.
Scientific publications often have their text split into two columns, like this.
Websites are often bearing one major column and a sidebar column, such as Reddit itself.
Newspapers very often hav... | true |
bbc20d6705ef01287e574deca25e2e6c1497b87e | bermec/challenges | /challenge75_easy.py | 2,182 | 4.125 | 4 | '''
Everyone on this subreddit is probably somewhat familiar with the C programming language.
Today, all of our challenges are C themed! Don't worry, that doesn't mean that you have
to solve the challenge in C, you can use whatever language you want.
You are going to write a home-work helper tool for high-school stude... | true |
f40424fe68b14466ea96ab54d934bf3795c312a1 | nnicha123/Python-tutorial | /cofee/coffee1.py | 266 | 4.125 | 4 | print('Write how many cups of coffee you will need:')
cups = input()
print(f'For {cups} cups of coffee you will need:')
water = 200 * int(cups)
milk = 50 * int(cups)
beans = 15 * int(cups)
print(f'''{water} ml of water
{milk} ml of milk
{beans} g of coffee beans''') | false |
f11d708155799e063007143742985ddc376c4d01 | AvneetHD/little_projects | /Time Converter.py | 524 | 4.28125 | 4 | def minutes_to_seconds(x):
x = int(x)
x = x * 60
print('{} seconds.'.format(x))
def hours_to_seconds(x):
x = int(x)
x = (x * 60) * 60
print('{} seconds'.format(x))
direction = input('Do you want to convert hours to seconds. Y/N.')
direction2 = input('Do you want to convert minutes to second... | true |
7c7c402f239d4aa58c9f0359fc9e0150d6dd49cd | melbinmathew425/Core_Python | /advpython/oop/quantifiers/rule5.py | 213 | 4.15625 | 4 | import re
x="a{1,3}"#its print the group or individualy, when its no of 'a' is in between {1,3}
r="aaa abc aaaa cga"
matcher=re.finditer(x,r)
for match in matcher:
print(match.start())
print(match.group()) | true |
94a0d3a42611f0bc9ca677c2e70cdfcadd6e2daf | tabrezi/SBLC | /Exp12.py | 385 | 4.25 | 4 | '''
Program to demonstrate series and dataframe in Pandas
'''
import pandas as pd
#Series
'''
Theory about Series
'''
s = pd.Series([10,20,30,40,50])
print(s)
print(s[0])
#some slicing, indexing, other features of Series
#Dataframe
'''
Theory about Dataframe
'''
#some slicing, indexing, other f... | false |
89f0c05070f4b6f6fe4485376461e8b309289a4c | Turjo7/Python-Revision | /car_game.py | 688 | 4.15625 | 4 | command = ""
started = False
# while command != "quit":
while True:
command = input("> ").lower()
if command == "start":
if started:
print("The Car Already Started: ")
else:
started = True
print("The Car Started")
elif command == "stop":
if not ... | true |
30cd1ebf47edc12c42c6383e4d84c35326dee8fd | sdmgill/python | /Learning/range_into_list.py | 312 | 4.21875 | 4 | #putting a range into a list
print("Here is my range placed into a list:")
numbers = list(range(1,6))
print(numbers)
#putting a range into a list and grab only even numbers
print("\nHere is my even list / range:")
even_numbers=list(range(2,11,2)) #start with 2, go to 11(10), increment by 2
print(even_numbers)
| true |
6afa0ebf1d665a64a0a4a7277b18f1ce442c92cf | sdmgill/python | /Learning/7.1-Input.py | 894 | 4.375 | 4 | message = input("Tell me something and I will repeat it back to you: ")
print(message)
name = input("Please enter your name: ")
print("Hello " + name.title())
# building a prompt over several lines
prompt = "This is going to be a very long way of asking "
prompt += "you what you name is. So..................."
prompt... | true |
def46f78814c9ca4e28e153774d8a9d668f78463 | fander2468/week2_day2_HW | /lesser_then.py | 443 | 4.34375 | 4 | # Given a list as a parameter,write a function that returns a list of numbers that are less than ten
# For example: Say your input parameter to the function is [1,11,14,5,8,9]...Your output should [1,5,8,9]
my_list = [1,2,12,14,5,6,77,8,22,3,10,13]
def lesser_than_ten(numbers):
new_list = []
for number in num... | true |
ed8f4819a364d77fdda527f9f6ad69bc45e7b8dd | tyler7771/learning_python | /recursion.py | 2,625 | 4.21875 | 4 | # Write a recursive method, range, that takes a start and an end
# and returns an list of all numbers between. If end < start,
# you can return the empty list.
def range(start, end):
if end < start:
return []
result = range(start, end - 1)
result.insert(len(result), end)
return result
# print... | true |
1df55414bfbee7b20e79850c101f4a18bbdc91b5 | abhinavnarra/python | /Python program to remove to every third element until list becomes empty.py | 646 | 4.375 | 4 | # Python program to remove to every third element until list becomes empty
def removeThirdNumber(int_list):
# list starts with 0 index
pos = 3 - 1
index = 0
len_list = (len(int_list))
# breaks out once the list becomes empty
while len_list > 0:
index = (pos ... | true |
018618289d9e3c9d984aef740fa362be4af586c7 | abhinavnarra/python | /Demonstrate python program to input ‘n’ employee number and name and to display all employee’s information in ascending order based upon their number - dictionary method.py | 716 | 4.5625 | 5 | #Demonstrate python program to input ‘n’ employee number and name and to display all employee’s information in ascending order based upon their number - dictionary method.
dict1={}
dict2={}
No_of_employees=int(input("Enter No of Employees:"))#enter number of employees to be sorted
for i in range(1,No_of_emplo... | true |
2f9607ab1c2e61d71cc16ec72e5caaf03fb25de3 | szeitlin/interviewprep | /make_anagrams.py | 824 | 4.3125 | 4 | #!/bin/python3
import os
# Complete the makeAnagram function below.
def make_anagram(a:str, b:str) -> int:
"""
Count number of characters to delete to make the strings anagrams
:param a: a string
:param b: another string
:return: integer number of characters to delete
"""
b_list = [y for ... | true |
81c57b9e4c681f24c467d8657548fc002739c647 | nikointhehood/unix-101 | /lesson-1/subject/exercises/exercise-0/biggest.py | 820 | 4.3125 | 4 | #! /usr/bin/python3
import sys # This import allows us to interact with the command line arguments
# First, we declare a function which will do the comparison job
def biggest(int1, int2):
if int1 > int2:
print(int1)
elif int2 > int1:
print(int2)
else:
print("The integers are equal")... | true |
03075897173f9640dc3e56e7545f65d7e7ae04b7 | utkarshpal11/w3resource_python__class_solutions | /09.power.py | 273 | 4.25 | 4 | # Write a Python class to implement pow(x, n).
class Power:
def power(self, x, n):
return print("power {x} to {n} is {output}".format(x=x, n=n, output=x**n))
p = Power()
p.power(7, 3)
p.power(7, -3)
p.power(7, 0)
p.power(7, 10)
p.power(-6, 3) | false |
38a378e9ccfc27479b43a229088ff02031a9bad3 | bsk17/PYTHONTRAINING1 | /databasepack/dbClientdemo.py | 2,901 | 4.4375 | 4 | import sqlite3
# create connection to the db
conn = sqlite3.connect("mydb") # for server side programming we have change the connection
# line and we have to mention the varchar(size)
mycursor = conn.cursor()
# function to create the table
def createTable():
print("*" * 40)
sql = '''create table if not exi... | true |
a361f51e6cda567cf1bf3705c2f831bc099e5c50 | CCedricYoung/bitesofpy | /263/islands.py | 1,293 | 4.28125 | 4 | def count_islands(grid):
"""
Input: 2D matrix, each item is [x, y] -> row, col.
Output: number of islands, or 0 if found none.
Notes: island is denoted by 1, ocean by 0 islands is counted by continuously
connected vertically or horizontally by '1's.
It's also preferred to check/mark t... | true |
d76a5bd18aba73166c47dafdc06d5bdede28118b | sumitbatwani/python-basics | /conditions.py | 791 | 4.28125 | 4 | # - if-elif-else -
# is_hot = True
# is_cold = False
# if is_hot:
# print("It is a hot day")
# elif is_cold:
# print("It is a cold day")
# else:
# print("It is a good day")
# Another example
# price = 1000000
# has_good_credit = False
# if has_good_credit:
# print(f"Down Payment ${price * (10 / 100)}"... | false |
be7a281f69933d5a719d3ea23cfa64e2c07786ed | sumitbatwani/python-basics | /lists.py | 879 | 4.25 | 4 | # - List -
# names = ["John", "Sarah", "Aman"]
# print(names[1:2]) # names[start: exclusion_end]
# - Largest number in a list -
# numbers = [5, 1, 2, 4, 3]
# largest_number = numbers[0]
# for item in numbers:
# if item > largest_number:
# largest_number = item
# print(f"largest number = {largest_number}"... | true |
bea8ea16bf04b705c4558705e2333bfb2ec8f840 | avengerweb/gb-ml | /lesson7/task_1.py | 916 | 4.28125 | 4 | # 1. Отсортируйте по убыванию методом "пузырька" одномерный целочисленный массив, заданный случайными числами на
# промежутке [-100; 100). Выведите на экран исходный и отсортированный массивы. Сортировка должна быть реализована в
# виде функции. По возможности доработайте алгоритм (сделайте его умнее).
import random
... | false |
d5db81ef1b7b4886f39d93a916c9c85d23a148ba | Ali-Fani/Theory | /2/assignment2-n-gon.py | 623 | 4.28125 | 4 | import turtle
from math import pi, sin, cos
t = turtle.Turtle()
t.speed(2)
t.shape("turtle")
t.penup()
def draw(side: int, radius: int):
for num in range(side + 1):
angel = num * 360 / side
print(f"slide angle is {angel}")
if num:
t.pendown()
y = sin(angel * pi / 180)... | false |
bc016336933f66d8ec6af96eb078859b7640ac85 | lindaspellman/CSE111 | /W10 Handling Exceptions/class_notes.py | 821 | 4.125 | 4 | import math
def main(): ## program driver - GOAL: Keep lean
## prompt user for how many circles they have
numberOfCircles = int(input("How many circles are we working with? "))
areasList = loopForCircles(numberOfCircles)
displayAreas(areasList)
## display each area: separate print statements or a list?
def dis... | true |
8fc705fb1acb9075ed389a6d979a4f7435e5595f | lindaspellman/CSE111 | /W12 Using Objects/team_asgmt/number_entry.py | 2,887 | 4.28125 | 4 | """This module contains two classes, IntEntry and FloatEntry,
that allow a user to enter an integer or a floating point number.
"""
import tkinter as tk
class IntEntry(tk.Entry):
"""An Entry widget that accepts only
integers between a lower and upper bound.
"""
def __init__(self, parent, lower_bound, ... | false |
186d3639f0c8109d68ad43f442bc6bc49338550a | Techbanerg/TB-learn-Python | /10_MachineLearning/example_numpy.py | 2,359 | 4.34375 | 4 | # NumPy is the fundamental Python package for scientific computing. It adds the capabilities of N-dimensional arrays, element-by-element operations (broadcasting), core
# mathematical operations like linear algebra, and the ability to wrap C/C++/Fortran code.We will cover most of these aspects in this chapter by firs... | true |
f944c425973b7e81855743e7804ab96189e84a3a | Techbanerg/TB-learn-Python | /00_Printing/printing.py | 1,708 | 4.34375 | 4 | # This exercise we are going to print single line and multi line comments
# The following examples will help you understand the different ways of
# printing
import pprint
from tabulate import tabulate
from prettytable import PrettyTable
print ("Mary had a little lamb")
print ("Its Fleece was white as %s ." % 'sno... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.