blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
1f3b7f46287e477c08c75ad540c4610cb1ba8799 | jedzej/tietopythontraining-basic | /students/arkadiusz_kasprzyk/lesson_03_functions/exponentiation.py | 296 | 4.25 | 4 | def power(a, n):
if n < 0:
a = 1 / a
n = -n
return power(a, n)
elif n > 0:
return a * power(a, n - 1)
else:
return 1
print("Calculates a^n (a to the power of n).")
a = float(input("Give a: "))
n = int(input("Give n: "))
print(power(a, n))
| false |
15720a0a5e835375b857d2efd3f58b305c0d162f | jedzej/tietopythontraining-basic | /students/sendecki_andrzej/lesson_01_basics/hello_harry.py | 262 | 4.53125 | 5 | # lesson_01_basics
# Hello, Harry!
#
# Statement
# Write a program that greets the user by printing the word "Hello",
# a comma, the name of the user and an exclamation mark after it.
print("Enter your name:")
my_name = input()
print("Hello, " + my_name + "!")
| true |
782275fee4250e4a33a7ec8dc3cb46c9074976d5 | jedzej/tietopythontraining-basic | /students/semko_krzysztof/lesson_01_basic/car_route.py | 404 | 4.125 | 4 | # Problem «Car route» (Easy)
# Statement
# A car can cover distance of N kilometers per day.
# How many days will it take to cover a route of length M kilometers? The program gets two numbers: N and M.
import math
print('Please input km/day:')
speed = int(input())
print('Please input length:')
length = int(input())
p... | true |
9ad0674a05315b989d111ffec5557c847582c540 | jedzej/tietopythontraining-basic | /students/myszko_pawel/lesson_02_flow_control/14_The number of zeros.py | 405 | 4.125 | 4 | # Given N numbers: the first number in the input is N, after that N integers are given.
# Count the number of zeros among the given integers and print it.
# You need to count the number of numbers that are equal to zero, not the number of zero digits.
# Read an integer:
N = int(input())
# Print a value:
zeroes = 0
for... | true |
878f0faf7a7ab7caa19c504133b058008e02645b | jedzej/tietopythontraining-basic | /students/arkadiusz_kasprzyk/lesson_03_functions/badly_organized_calculator.py | 1,316 | 4.15625 | 4 | # functions
def help():
"""help
"""
print("a - add")
print("s - subtract")
print("m - multiply")
print("d - divide")
print("p - power")
print("h,? - help")
print("q - QUIT")
def inputs(message):
"""data input
message : str
"""
print(message)
var_1 = int(input(... | false |
c8c1963bad864b383a77727973232b4e3b7c392b | danserboi/Marketplace | /tema/consumer.py | 2,594 | 4.34375 | 4 | """
This module represents the Consumer.
Computer Systems Architecture Course
Assignment 1
March 2021
"""
import time
from threading import Thread
class Consumer(Thread):
"""
Class that represents a consumer.
"""
def __init__(self, carts, marketplace, retry_wait_time, **kwargs):
"""
... | true |
35d8e0f70cfd155ab513ed9b405903a140164f19 | rkp872/Python | /6)Functions/TypesOfArgument.py | 2,926 | 4.65625 | 5 | # Information can be passed into functions as arguments.
# Arguments are specified after the function name, inside
# the parentheses.
#In python we have different types of agruments:
# 1 : Position Argument
# 2 : Keyword Argument
# 3 : Default Argument
# 4 : Variable length Argument
# 5 : Keyworded Variable... | true |
e87320897e3f5dfaf10564b9f79b6487649dfcc4 | rkp872/Python | /3)Conditional/SquareCheck.py | 272 | 4.34375 | 4 | #Take values of length and breadth of a rectangle from user and check if it is square or not.
len=int(input("Enter length : "))
bre=int(input("Enter breadth : "))
if(len==bre):
print("Given rectangle is square")
else:
print("Given rectangle is not a square") | true |
ac0091ebda2a4599eac69b2467b398a984942c5f | rkp872/Python | /1)Basics/Basic.py | 444 | 4.125 | 4 | print("Hello World")#printing Hello World
#we dont need to declare variable type as python is dyamically typed language
x=10 #aiigning value to any variable
y=20
print(x)
#basic arithmetic operator
z=x+y
print(z)
z=x-y
print(z)
z=x*y
print(z)
z=x/y # will give float result
print(z)
... | false |
1af02fa80c544f52c1f2e4a2f0c767c96b14a4b6 | rkp872/Python | /2)Data Types/Set.py | 726 | 4.21875 | 4 | # Set: Set are the collection of hetrogeneous elements enclosed within {}
# Sets does not allows duplicates and insertion order is not preserved
#Elements are inserted according to the order of their hash value
set1={10,20,20,30,50,40,60}
print(set1)
print(type(set1))
set1.add(36)
print(set1)
s... | true |
d85c3e867c8d10f6b71231e9c581d0f4274ec9c3 | Randy760/Dice-rolling-sim | /Dicerollingsimulator.py | 694 | 4.1875 | 4 | import random
# making a dice rolling simulator
youranswer = ' '
print('Would you like to roll the dice?') #asks if they want to roll the dice
while True:
youranswer = input()
if youranswer == 'yes':
diceroll = random.randint(1,6) #picks a random number between 1 and 6
print(... | true |
7e52cf50f97a380fd642400ed77ac5c0e6e9706a | LukeBrazil/fs-imm-2021 | /python_week_1/day1/fizzBuzz.py | 324 | 4.15625 | 4 | number = int(input('Please enter a number: '))
def fizzBuzz(number):
if number % 3 == 0 and number % 5 == 0:
print('FizzBuzz')
elif number % 3 == 0:
print('Fizz')
elif number % 5 == 0:
print('Buzz')
else:
print(f'Number does not fit requirements: {number}')
fizzBuzz(num... | false |
d385bb61ec1eaf766666c24f71f472a4138cf98e | mahadev-sharma/Python | /biggest among three.py | 490 | 4.125 | 4 | #find the biggest numbr among three numbers
def biggestGuy (num1,num2,num3):
if ((num1 > num2) and (num1 > num3)) :
print('number 1 is the biggest number among them')
elif ((num2 > num1) and (num2 > num3)) :
print('number 2 is the biggest number among them')
elif ((num3 > num2) and (nu... | false |
38611f668686c832c7d1fe7e3c671d54d2f9ecf1 | FdelMazo/7540rw-Algo1 | /Ejercicios de guia/ej34.py | 1,388 | 4.15625 | 4 | import math
def calcular_norma(x,y):
"""Calcula la norma de un punto"""
return math.sqrt(x**2+y**2)
def restar_puntos(punto1,punto2):
"""Resta dos puntos"""
x1 = punto1[0]
y1 = punto1[1]
x2 = punto2[0]
y2 = punto2[1]
return x2-x1, y2-y1
def distancia(punto1, punto2):
"""Calcula la distancia entre dos ... | false |
f6b4bb1aff6e2c8a495f04ae256d68d252e3babf | Rhalith/gaih-students-repo-example | /Homeworks/Hw2-day1.py | 248 | 4.21875 | 4 | n = int(input("Please enter an single digit integer: "))
while (n > 9 or n < 0):
n = int(input("Your number is not a single digit. Please enter an single digit integer: "))
for num in range(n+1):
if num % 2 == 0:
print(num)
| false |
3591366d9968bf42380c2f40c55f8db2ae34052a | keshav1245/Learn-Python-The-Hard-Way | /exercise11/ex11.py | 729 | 4.40625 | 4 | print "How old are you ?",
age = raw_input()
print "How tall are you ?",
height = raw_input()
print "How much do you weight ? ",
weight = raw_input()
#raw_input([prompt])
#If the prompt argument is present, it is written to standard output without a trailing newline. The
#function then reads a line from input, conver... | true |
1f39795b7719af506164b48da51370bd90c397ca | a-tran95/PasswordGenerator | /app.py | 2,059 | 4.125 | 4 | import random
letterbank_lower = 'abcdefghijklmnopqrstuvwxyz'
letterbank_upper = letterbank_lower.upper()
numberbank = '1234567890'
symbolbank = '!@#$%^&*()-=_+`~{}|[];:<>,./?'
thebank = [letterbank_lower,letterbank_upper,numberbank,symbolbank]
password = []
def charcheck(check):
try:
if check.... | false |
2f1bd009c20a51bab241ad3c31528b0f0664ed93 | rohan-khurana/MyProgs-1 | /SockMerchantHR.py | 1,687 | 4.625 | 5 | """
John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are.
For example, there are socks with colors . There is one pair of color and one of c... | true |
0a47ead1f61b1ab1ffe627e55a08f31ebed03c5e | rohan-khurana/MyProgs-1 | /basic8.py | 225 | 4.15625 | 4 | num = input("enter a number to be checked for prime number")
num = int(num)
i = num
j=1
c=0
while j<=i :
if i%j==0 :
c+=1
j+=1
if c==2 :
print("entered number is prime")
else :
print("not prime")
| false |
9f6ee9426e3bd6c017e82c317f0800236cd2dc13 | rohan-khurana/MyProgs-1 | /TestingHR.py | 2,987 | 4.28125 | 4 | """
This problem is all about unit testing.
Your company needs a function that meets the following requirements:
For a given array of integers, the function returns the index of the element with the minimum value in the array. If there is more than one element with the minimum value, the returned index should be the... | true |
8e07f7fdba8ee6adae646070615b9b8d756462bc | rohan-khurana/MyProgs-1 | /TheXORProblemHR.py | 1,865 | 4.25 | 4 | """
Given an integer, your task is to find another integer such that their bitwise XOR is maximum.
More specifically, given the binary representation of an integer of length , your task is to find another binary number of length with at most set bits such that their bitwise XOR is maximum.
For example, let's say ... | true |
f7e30fb9549c6e8c88792ac40d5c59ef0a86edf6 | tonyvillegas91/python-deployment-example | /Python Statements/list_comprehension2.py | 205 | 4.34375 | 4 | # Use a List Comprehension to create a list of the first letters of every word in the string below:
st = 'Create a list of the first letters of every word in this string'
[word[0] for word in st.split()]
| true |
420dc0c8d97e56b4fb94dd5ea72f6bff4a8cec0b | jdstikman/PythonSessions | /AcuteObtuseAndRight.py | 226 | 4.125 | 4 | a = input("Enter number here")
a = int(a)
if a < 90:
print("number is acute")
elif a == 90:
print("right angle")
elif a > 90 and a < 180:
print("obtuce")
else:
print("i have no idea what you are talking about") | false |
79aa8a94a6c3953ea852f3a087f1f0a89dbd0af7 | hamanovich/py-100days | /01-03-datetimes/program2.py | 1,197 | 4.25 | 4 | from datetime import datetime
THIS_YEAR = 2018
def main():
years_ago('8 Aug, 2015')
convert_eu_to_us_date('11/03/2002')
def years_ago(date):
"""Receives a date string of 'DD MMM, YYYY', for example: 8 Aug, 2015
Convert this date str to a datetime object (use strptime).
Then extract the yea... | true |
d1db24e49d5698c3d9f2b6db4794fa94aebb3e5f | inest-us/python | /algorithms/c1/tuple.py | 642 | 4.15625 | 4 | # Tuples are very similar to lists in that they are heterogeneous sequences of data.
# The difference is that a tuple is immutable, like a string.
# A tuple cannot be changed.
# Tuples are written as comma-delimited values enclosed in parentheses.
my_tuple = (2,True,4.96)
print(my_tuple) # (2, True, 4.96)
print(len... | true |
90c309b7049aabd853e1520494df51296dc9a0f6 | inest-us/python | /algorithms/c1/dictionary.py | 1,360 | 4.65625 | 5 | capitals = {'Iowa':'DesMoines','Wisconsin':'Madison'}
print(capitals) # {'Wisconsin': 'Madison', 'Iowa': 'DesMoines'}
# We can manipulate a dictionary by accessing a value via its key or by adding another key-value pair.
# The syntax for access looks much like a sequence access
# except that instead of using the ind... | false |
42d484424e2bb30b0bae4e3ea9a9f3cb668d8f8c | jsburckhardt/pythw | /ex3.py | 693 | 4.15625 | 4 | # details
print("I will now count my chickens:")
# counts hens
print("Hens", float(25 + 30 / 6))
# counts roosters
print("Roosters", float(100 - 25 *3 % 4))
# inform
print("Now I will count the eggs:")
# eggs
print(float(3 + 2 + 1 + - 5 + 4 % 2 - 1 / 4 + 6))
# question 5 < -2
print("Is it true that 3 + 2 < 5 - 7?")
# ... | true |
0081ea28bee4c8b24910c6a3a8b3d559431efde5 | lima-BEAN/python-workbook | /programming-exercises/ch7/larger_than_n.py | 1,565 | 4.40625 | 4 | # Larger Than n
# In a program, write a function that accepts two arguments:
# a list and a number, n. Assume that the list contains numbers.
# The function should display all of the numbers in the list that
# are greater than the number n.
import random
def main():
numbers = Numbers()
user_num = UserNum()
... | true |
43dc28165ec22f719d9e594091c82366cc574384 | lima-BEAN/python-workbook | /programming-exercises/ch2/distance-traveled.py | 618 | 4.34375 | 4 | ## Assuming there are no accidents or delays, the distance that a car
## travels down the interstate can be calculated with the following formula:
## Distance = Speed * Time
## A car is traveling at 70mph. Write a program that displays the following:
## The distance a car will travel in 6 hours
## The distance a car wi... | true |
a913e26be57a7dcad82df5ddf127b85933c4c0c0 | lima-BEAN/python-workbook | /programming-exercises/ch5/kinetic_energy.py | 983 | 4.53125 | 5 | # Kinetic Energy
# In physics, an object that is in motion is said to have kinetic energy.
# The following formula can be used to determine a moving object's kinetic
# energy: KE = 1/2 mv**2
# KE = Kinetic Energy
# m = object's mass (kg)
# v = velocity (m/s)
# Write a program that asks the user to enter values for ma... | true |
44ecf7731cf113a646f9fbfb9358a09f5dead62a | lima-BEAN/python-workbook | /programming-exercises/ch8/date_printer.py | 933 | 4.375 | 4 | # Date Printer
# Write a program that reads a string from the user containing a date in
# the form mm/dd/yyyy. It should print the date in the form
# March 12, 2014
def main():
user_date = UserDate()
date_form = DateForm(user_date)
Results(date_form)
def UserDate():
date = input('Enter a date in the f... | true |
e8404b90ca40907cfca6018ce0c4bebf8752caec | lima-BEAN/python-workbook | /programming-exercises/ch2/ingredient-adjuster.py | 832 | 4.40625 | 4 | ## A cookie recipe calls for the following ingredients:
## - 1.5 cups of sugar
## - 1 cup of butter
## - 2.75 cups of flour
## The recipe produces 48 cookies with this amount of the ingredients.
## Write a program that asks the user how many cookies he or she wants to
## make, and then displays the number of cups o... | true |
cbae1470e46184c8a3b830ff5ad9076fe0f1864f | lima-BEAN/python-workbook | /programming-exercises/ch4/population.py | 720 | 4.46875 | 4 | # Write a program that predicts the approximate size of a population of organisms
# The application should use text boxes to allow the user to enter the starting
# number of organisms, the average daily population increase (as percentage),
# and the number of days the organisms will be left to multiply.
number_organis... | true |
27eda59c433dd226459b8966720505f2c78d0cd1 | lima-BEAN/python-workbook | /programming-exercises/ch10/Information/my_info.py | 794 | 4.46875 | 4 | # Also, write a program that creates three instances of the class. One
# instance should hold your information, and the other two should hold
# your friends' or family members' information.
import information
def main():
my_info = information.Information('LimaBean', '123 Beanstalk St.',
... | true |
8d62cbef5cbe028c9a8d83ddd18c5e52106d9c6b | lima-BEAN/python-workbook | /programming-exercises/ch3/roman-numerals.py | 982 | 4.34375 | 4 | # Write a program that prompts the user to enter a number within the range of 1
# through 10. The program should display the Roman numeral version of that
# number. If the number is outside the range of 1 through 10,
# the program should display an error message.
number = int(input("What number do you want to convert ... | true |
3c683a28f22e656365df3d5a555d2f3128fa1bb8 | lima-BEAN/python-workbook | /programming-exercises/ch8/initials.py | 1,126 | 4.25 | 4 | # Write a program that gets a string containing a person's first, middle
# and last names, and then display their first, middle and last initials.
# For example, John William Smith => J. W. S.
def main():
name = Name()
initials = Initials(name)
Results(initials)
def Name():
name = input('What is y... | false |
f9500fd6cfdd6d846ed4b6fa2b034bd681d3d637 | lima-BEAN/python-workbook | /algorithm-workbench/ch2/favorite-color.py | 220 | 4.21875 | 4 | ## Write Python code that prompts the user to enter his/her favorite
## color and assigns the user's input to a variale named color
color = input("What is your favorite color? ")
print("Your favorite color is", color)
| true |
54b6e4930811ab19c5c64d37afc05fb0a8d69270 | lima-BEAN/python-workbook | /programming-exercises/ch10/Retail/item_in_register.py | 1,023 | 4.25 | 4 | # Demonstrate the CashRegister class in a program that allows the user to
# select several items for purchase. When the user is ready to check
# out, the program should display a list of all the items he/she has
# selected for a purchase, as well as total price.
import retail_item
import cash_register
def main():
... | true |
14abd73ae4d52d04bfa9c06e700d9191d194f6b3 | lima-BEAN/python-workbook | /programming-exercises/ch5/sales_tax_program_refactor.py | 1,702 | 4.1875 | 4 | # Program exercise #6 in Chapter 2 was a Sales Tax Program.
# Redesign solution so subtasks are in functions.
## purchase_amount = int(input("What is the purchasing amount? "))
## state_tax = 0.05
## county_tax = 0.025
## total_tax = state_tax + county_tax
## total_sale = format(purchase_amount + (purchase_amount * t... | true |
3d9deda751cdfa233cdf0c711f3432be950980d3 | tejastank/allmightyspiff.github.io | /CS/Day6/linkedList01.py | 1,399 | 4.21875 | 4 | """
@author Christopher Gallo
Linked List Example
"""
from pprint import pprint as pp
class Node():
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
def __str__(self):
return str(self.data)
class linked_list():
def __init__(self):
self.he... | true |
611d3db5bf36c987bb459ff19b7ab0a215cfec83 | laurenwheat/ICS3U-Assignment-5B-Python | /lcm.py | 753 | 4.25 | 4 | #!/usr/bin/env python3
# Created by: Lauren Wheatley
# Created on: May 2021
# This program displays the LCM of 2 numbers
def main():
a = input("Please enter the first value: ")
b = input("Please enter the second value: ")
try:
a_int = int(a)
b_int = int(b)
if (a_int > b_int):
... | true |
722c9fef00cc8c68bda1a32eb5964413311f1a2d | smtorres/python-washu-2014 | /Assignment01/school.py | 1,042 | 4.21875 | 4 | from collections import OrderedDict
class School():
def __init__(self, school_name):
self.school_name = school_name
self.db = {}
# Function that adds values and keys to a dictionary. Keys are school grades and each can take as value the name of a kid belonging to that grade.
# It returns a dictionary with th... | true |
8a199663c4dc2228104bbab583fd9ecaddcac34d | amitopu/ProblemSet-1 | /NonConstructibleChange/nonConstructibleChange.py | 1,728 | 4.40625 | 4 | def nonConstructibleChangePrimary(coins):
"""
Takes an arrary of coin values and find the minimum change that can't be made by the coins
available in the array.
solution complexity : O(nlogn) time complexity and O(1) space complexity
args:
-----------
coins (array): an array contains available coin values.... | true |
e874e83c5936a8dcd28f2f04dde6de4d604c5980 | amitopu/ProblemSet-1 | /ValidateSubsequence/validate_subsequence.py | 795 | 4.3125 | 4 | def isValidSubsequence(array, sequence):
"""
Takes one array and a sequence(another array) and checks if the sequence is the subsequence of the array.
solution complexity : O(n) time complexity and O(1) space complexity
args:
-----------
array : an array of numbers
sequence : an array of numbers
output... | true |
610395c1c0a55d4f8b7099bea152e4feb27dec23 | Patryk9201/CodeWars | /Python/6kyu/one_plus_array.py | 693 | 4.1875 | 4 | """
Given an array of integers of any length, return an array that has 1 added to the value represented by the array.
the array can't be empty
only non-negative, single digit integers are allowed
Return nil (or your language's equivalent) for invalid inputs.
Examples
For example the array [2, 3, 9] equals 239, addin... | true |
a03d3d86b25f8f132efb169ad8bd8174a9152ddb | Patryk9201/CodeWars | /Python/8kyu/temperature_in_bali.py | 1,092 | 4.1875 | 4 | """
So it turns out the weather in Indonesia is beautiful... but also far too hot most of the time.
Given two variables: heat (0 - 50 degrees centigrade) and humidity (scored from 0.0 - 1.0),
your job is to test whether the weather is bareable (according to my personal preferences :D)
Rules for my personal preference... | true |
6151cf5dbcf387ec524efa0e39cf400c69ca1ee7 | yurjeuna/teachmaskills_hw | /anketa.py | 1,580 | 4.25 | 4 | name = input("Hi! What's your name, friend? ")
year_birth = int(input("Ok, do you remember when you were born? \
Let's start with the year of birth - "))
month_birth = int(input("The month of your birth - "))
day_birth = int(input("And the day of your birth, please,- "))
experience = int(input("Have you studied pr... | true |
9d569685b0d8d137b9ee7a23180289cfdd10488e | ErickaBermudez/exercises | /python/gas_station.py | 1,752 | 4.3125 | 4 | def canCompleteCircuit(gas, cost):
numberOfStations = len(gas)
# checking where it is possible to start
for currentStartStation in range(numberOfStations):
currentGas = gas[currentStartStation]
canStart = True # with the current starting point, we can reach all the points
# go thr... | true |
b2ee470fd49b2af6f975b9571c5f7579082da359 | mhkoehl0829/sept-19-flow-control | /Grade Program.py | 515 | 4.125 | 4 | print('Welcome to my grading program.')
print('This program will determine which letter grade you get depending on your score.')
print('What grade did you make?')
myGrade = input('')
if myGrade >= '90':
print('You made an A.')
else:
if myGrade >= '80' and myGrade < '90':
print('You get a B.')
if my... | true |
cbbcb84d2be44faf95bb4e30d5292deb2224f796 | adri-leiva/python_dev | /Ejercicios_bloque1/ejercicio1.py | 394 | 4.125 | 4 | """
EJERCICIO 1
- Crear variables una "pais" y otra "continente"
- Mostrar su valor por pantalla (imporimi)
- Poner un comentario poniendo el tipo de dato
"""
pais = "Argentina" #tipo de detos: cadena
continente = "Americano" #tipo de detos: cadena
""" print(pais)
print (continente)
"""
#print ("{} \n {}" . for... | false |
ec7c0d69a9e98853f063fd32ef431f4f28448d76 | Alleinx/Notes | /Python/Book_Learning_python/fluent_python/cp8/var.py | 875 | 4.5625 | 5 | # This program demonstrate the difference between shallow copy and deep copy
import copy
class Bus:
def __init__(self, passengers=None):
if passengers is None:
self.passengers = []
else:
self.passengers = list(passengers)
# Defensive programming style, won't mod... | true |
75b1d9b79bf3253b2d1a5c0ff2d9bc3124c9b621 | Alleinx/Notes | /Python/Book_Learning_python/python_crash_course/part2_data_visualization/random_walk.py | 928 | 4.15625 | 4 | from random import choice
class RandomWalk():
""" A class that randomly generate data"""
def __init__(self, num_points=5000):
self.num_points = num_points
self.x = [0]
self.y = [0]
def fill_walk(self):
"""Genereate walking path"""
while len(self.x) < self.num... | false |
6fd363f6a639b159cc6594901c716fd3415a5402 | 023Sparrow/Projects | /Classic_Algorithms/Collatz_Conjecture.py | 420 | 4.28125 | 4 | #**Collatz Conjecture** - Start with a number *n > 1*. Find the number of steps it takes to reach one using the following process: If *n* is even, divide it by 2. If *n* is odd, multiply it by 3 and add 1.
def collatz(n):
k = 0
while n != 1:
if n%2 == 0:
n = n/2
else:
n ... | true |
8e5103a6f4fbae5ce65bcd0fed09a9ea0ad16fbe | JohnFoolish/DocumentationDemo | /src/basic_code.py | 1,426 | 4.4375 | 4 | # -*- coding: utf-8 -*-
"""
This first one is a basic function that includes the code you would need to
add two numbers together!
Why is this function useful?
----------------------------
* It can replace the '+' key!
* It can cause you to bill more hours for less work since the import takes
extra time to type!
* It... | true |
82d0625e5bb5253652418abbe3fe947de76d4114 | AlanStar233/Neusoft_Activity_coding | /basic.py | 402 | 4.1875 | 4 | # # Ctrl+'/'
#
# print('Hello Alan!')
#
# #int
# age = 19
#
# #string
# name = "张三"
#
# #print with var & var_type
# print(age)
# print(type(age))
#
# print(name)
# print(type(name))
# if
name = input("Please type your name:")
age = input("Please type your age:")
if int(age) >= 18:
print('{} Your age {} >= 18 !'.... | false |
bf8a718b87bd57002dfd3037c1ea6ceda4ab0261 | TommyThai-02/Python-HW | /hw04.py | 512 | 4.1875 | 4 | #Author: Tommy Thai
#Filename: hw04.py
#Assignment: hw04
#Prompt User for number of rows
rows = int(input("Enter the number of rows:"))
#input validation
while rows < 1:
#Error message
print("Number of rows must be positive.")
#Prompt again
rows = int(input("Enter the number of rows:"))
... | true |
ef3b8d624346cfbc6516b8d44e8cc22001e88ce9 | damodharn/Python_Week1 | /Week1_Algo/Temp_Conversion.py | 755 | 4.25 | 4 | # *********************************************************************************************
# Purpose: Program for checking if two strings are Anagram or not.
# Author: Damodhar D. Nirgude.
# ************************************************************************************************
from Week1_Algo.Utility2 ... | true |
c93849ff244e494864be212fa94d97a591233291 | damodharn/Python_Week1 | /Week1_Functional/StopWatch.py | 868 | 4.28125 | 4 | # *********************************************************************************************
# Purpose: Program for measuring the time that elapses between
# the start and end clicks.
# Author: Damodhar D. Nirgude.
# ****************************************************************************************... | true |
a1808e94fd51c61a549a7131cf032eb3aa90c8f5 | jsimonton020/Python_Class | /lab9_lab10/lab9-10_q1.py | 642 | 4.125 | 4 | list1 = input("Enter integers between 1 and 100: ").split() # Get user input, and put is in a list
list2 = [] # Make an empty list
for i in list1: # Iterate over list1
if i not in list2: # If the element is not in list2
list2.append(i) # Add the element to list2 (so we don't have to count it again)
... | true |
0dbdddafe5f0a2fad6b8778c78ec913561218eea | AndriyPolukhin/Python | /learn/ex02/pinetree.py | 1,500 | 4.21875 | 4 | '''
how tall is the tree : 5
#
###
#####
#######
#########
#
'''
# TIPS to breakdown the problem:
# I. Use 1 while loop and 3 for loops
# II. Analyse the tree rules:
# 4 spaces _ : # 1 hash
# 3 spaces _ : # 3 hashes
# 2 spaces _ : # 5 hashes
# 1 space _ : # 7 hashes
# 0 spaces _ :... | true |
a2b98b45cc022cabeb8dd82c582fd1c2f37356fb | AndriyPolukhin/Python | /learn/ex01/checkage.py | 805 | 4.5 | 4 | # We'll provide diferent output based on age
# 1- 18 -> Important
# 21,50, >65 -> Important
# All others -> Not Important
# List
# 1. Receive age and store in age
age = eval(input("Enter age: "))
# and: If Both are true it return true
# or : If either condition is true then it return true
# not : Convert a true cond... | true |
06a522784b6f26abb7be62f6bfd8486ffd425db0 | AndriyPolukhin/Python | /learn/ex01/gradeans.py | 437 | 4.15625 | 4 | # Ask fro the age
age = eval(input("Enter age: "))
# Handle if age < 5
if age < 5:
print("Too young for school")
# Special output just for age 5
elif age == 5:
print("Go to Kindergarden")
# Since a number is the result for age 6 - 17 we can check them all with 1 condition
elif (age > 5) and (age <= 17):
... | true |
25d6aada9d0ae475343ca02fa79a5969565a4b7b | RehamDeghady/python | /task 2.py | 753 | 4.3125 | 4 | print("1.check palindrome")
print("2.check if prime")
print("3.Exit")
operation = int (input ("choose an operation:"))
if operation == 1 :
word = str(input("enter the word"))
revword = word[::-1]
print("reversed word is" ,revword)
if word == revword :
print("yes it is palindro... | true |
971f5ec8bb222bbfc91123e24bcccdaf3caece28 | sidsharma1990/Python-OOP | /Inheritance.py | 1,519 | 4.65625 | 5 | ######### Inheritance ######
#####Single inheritance######
###### to inherit from only 1 class####
class fruits:
def __init__(self):
print ('I am a Fruit!!')
class citrus(fruits):
def __init__(self):
super().__init__()
print ('I am citrus and a part of fruit class!')
... | true |
3c41155cbab16bb91e4387aa35d49e1832ce5b72 | codedsun/LearnPythonTheHardWay | /ex32.py | 525 | 4.25 | 4 | #Exercise 32: Loops and List
the_count = [1,2,3,4,5]
fruits = ['apples','oranges','pears','apricots']
change = [1,'pennies',2,'dimes',3,'quaters']
#for loop in the list
for number in the_count:
print("This is %d count"%number)
for fruit in fruits:
print("A fruit of type %s"%fruit)
for i in change:
print... | true |
8c3788b2fc95ce08c9dc6165b6f5de91e7d7d448 | semihyilmazz/Rock-Paper-Scissors | /Rock Paper Scissors.py | 2,933 | 4.40625 | 4 | import random
print "********************************************************"
print "Welcome to Rock Paper Scissors..."
print "The rules are simple:"
print "The computer and user choose from Rock, Paper, or Scissors."
print "Rock crushes scissors."
print "Paper covers rock."
print "and"
print "Scissors cut p... | true |
9a6fe2ffbb280d239d50001e637783520b8d4aef | songseonghun/kagglestruggle | /python3/201-250/206-keep-vowels.py | 272 | 4.1875 | 4 | # take a strign. remove all character
# that are not vowels. keep spaces
# for clarity
import re
s = 'Hello, World! This is a string.'
# sub = substitute
s2 = re.sub(
'[^aeiouAEIOU ]+', #vowels and
# a space
'', #replace with nothing
s
)
print(s2)
| true |
b5363f3d6c5b6e55b3d7607d055a266b215c28ab | dianamenesesg/HackerRank | /Interview_Preparation_Kit/String_manipulation.py | 2,979 | 4.28125 | 4 | """
Strings: Making Anagrams
Alice is taking a cryptography class and finding anagrams to be very useful. We consider two strings to be anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in the same exact fre... | true |
c5d1e2535e6e8d9ac0218f06a44e437b3358049b | michaelschung/bc-ds-and-a | /Unit1-Python/hw1-lists-loops/picky-words-SOLUTION.py | 543 | 4.3125 | 4 | '''
Create a list of words of varying lengths. Then, count the number of words that are 3 letters long *and* begin with the letter 'c'. The count should be printed at the end of your code.
• Example: given the list ['bat', 'car', 'cat', 'door', 'house', 'map', 'cyst', 'pear', 'can', 'spike'], there are exactly 3 qualif... | true |
c9a7bdeb85a94afc6b17c2b6ddf3be0d78de6206 | yangju2011/udacity-coursework | /Programming-Foundations-with-Python/turtle/squares_drawing.py | 755 | 4.21875 | 4 | import turtle
def draw_square(some_turtle):
i = 0
while i<4: # repeat for squares
some_turtle.forward(100)
some_turtle.right(90)
i=i+1
def draw_shape():#n stands for the number of edge
windows = turtle.Screen()#create the background screen for the drawing
w... | true |
ea34741f8866856bdee9702bc20184f57cf65271 | onursevindik/GlobalAIHubPythonCourse | /Homework/HW2/HW2-Day3.py | 843 | 4.15625 | 4 | d = {"admin":"admin"}
print("Welcome!")
username = input("Enter your username: ")
password = input("Enter your password: ")
for k,v in d.items():
if (k != username and v == password):
print(" ")
print("xxXxx Wrong username! xxXxx")
elif(k == username and v != password):
print(" ")
... | false |
1bb3d699d6d1e7ef8ea39a5cdc7d55f79ac4ed3d | theelk801/pydev-psets | /pset_lists/list_manipulation/p5.py | 608 | 4.25 | 4 | """
Merge Lists with Duplicates
"""
# Use the two lists below to solve this problem. Print out the result from each section as you go along.
list1, list2 = [2, 8, 6], [10, 4, 12]
# Double the items in list1 and assign them to list3.
list3 = None
# Combine the two given lists and assign them to list4.
list4 = No... | true |
d7aa917a00b2f582c7b15c8b40de0462ca274a66 | theelk801/pydev-psets | /pset_classes/fromagerie/p6.py | 1,200 | 4.125 | 4 | """
Fromagerie VI - Record Sales
"""
# Add an instance method called "record_sale" to the Cheese class. Hint: You will need to add instance attributes for profits_to_date and sales (i.e. number of items sold) to the __init__() method in your Cheese class definition BEFORE writing the instance method.
# The record_sa... | true |
1859b100bd9711dfa564f8d3a697202bc42d96c2 | theelk801/pydev-psets | /pset_conditionals/random_nums/p2.py | 314 | 4.28125 | 4 | """
Generate Phone Number w/Area Code
"""
# import python randomint package
import random
# generate a random phone number of the form:
# 1-718-786-2825
# This should be a string
# Valid Area Codes are: 646, 718, 212
# if phone number doesn't have [646, 718, 212]
# as area code, pick one of the above at random
| true |
278cfd9000b17eaf249eebad07b11d078e934c35 | theelk801/pydev-psets | /pset_classes/bank_accounts/solutions/p2.py | 1,377 | 4.21875 | 4 | """
Bank Accounts II - Deposit Money
"""
# Write and call a method "deposit()" that allows you to deposit money into the instance of Account. It should update the current account balance, record the transaction in an attribute called "transactions", and prints out a deposit confirmation message.
# Note 1: You can for... | true |
9d9d044b0bff764cc3a8f4e31634f1138f05e2b4 | Arin-py07/Python-Programms | /Problem-11.py | 888 | 4.1875 | 4 | Python Program to Check if a Number is Positive, Negative or 0
Source Code: Using if...elif...else
num = float(input("Enter a number: "))
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
Here, we have used the if...elif...else statement. We can do the same t... | true |
5b428c1de936255d8a787f6939528031fa3ddc9b | Arin-py07/Python-Programms | /Problem-03.py | 1,464 | 4.5 | 4 | Python Program to Find the Square Root
Example: For positive numbers
# Python Program to calculate the square root
# Note: change this value for a different result
num = 8
# To take the input from the user
#num = float(input('Enter a number: '))
num_sqrt = num ** 0.5
print('The square root of %0.3f is %0.3f'%(nu... | true |
e6dead53cca8e5bef774435616a2dd02452e6389 | ejoconnell97/Coding-Exercises | /test2.py | 1,671 | 4.15625 | 4 | def test_2(A):
# write your code in Python 3.6
'''
Loop through S once, saving each value to a new_password
When a numerical character is hit, or end of S, check the new_password
to make sure it has at least one uppercase letter
- Yes, return it
- No, reset string to null and con... | true |
0860ed14b0d55e8a3c09aeb9e56075354d1e1298 | npandey15/CatenationPython_Assignments | /Task1-Python/Task1_Python/Q3.py | 547 | 4.15625 | 4 | Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> x=6
>>> y=10
>>>
>>> Resultname=x
>>> x=y
>>> y=Resultname
>>> print("The value of x after swapping: {}".format(x))
The value of x after swapping:... | true |
8a99191f6780e06be6e14501b671cc981f42bf0d | npandey15/CatenationPython_Assignments | /Passwd.py | 1,188 | 4.34375 | 4 |
# Passwd creation in python
def checker_password(Passwd):
"Check if Passwd is valid"
Specialchar=["$","#","@","*","%"]
return_val=True
if len(passwd) < 8:
print("Passwd is too short, length of the password should be at least 8")
return_val=False
if len(passwd) > 30:
print... | true |
2255001526278b22c7cb99594f4f5274b399371a | aparna-narasimhan/python_examples | /Matrix/sort_2d_matrix.py | 1,281 | 4.28125 | 4 | #Approach 1: Sort 2D matrix in place
def sort_2d_matrix(A, m, n):
t=0
for x in range(m):
for y in range(n):
for i in range(m):
for j in range(n):
if(A[i][j]>A[x][y]):
print("Swapping %d with %d"%(A[i][j], A[x][y]))
t=A[x][y]
A[x][y]=A[i][j]
... | false |
6da25701a40c8e6fce75d9ab89aaf63a45e2ecfe | aparna-narasimhan/python_examples | /Strings/shortest_unique_substr.py | 1,322 | 4.15625 | 4 | '''
Smallest Substring of All Characters
Given an array of unique characters arr and a string str, Implement a function getShortestUniqueSubstring that finds the smallest substring of str containing all the characters in arr. Return "" (empty string) if such a substring doesn’t exist.
Come up with an asymptotically op... | true |
0111fd00103f42a032074e0c3b4d40006f1029f9 | aparna-narasimhan/python_examples | /Arrays/missing_number.py | 866 | 4.28125 | 4 | '''
If elements are in range of 1 to N, then we can find the missing number is a few ways:
Option 1 #: Convert arr to set, for num from 0 to n+1, find and return the number that does not exist in set.
Converting into set is better for lookup than using original list itself. However, space complexity is also O(N).
Opti... | true |
8d401a11b4ea284f9bb08c2e2615b9414fd3d3ac | aparna-narasimhan/python_examples | /Misc/regex.py | 2,008 | 4.625 | 5 | #https://www.tutorialspoint.com/python/python_reg_expressions.htm
import re
line = "Cats are smarter than dogs";
searchObj = re.search( r'(.*) are (.*?) .*', line, re.M|re.I)
if searchObj:
print "searchObj.group() : ", searchObj.group()
print "searchObj.group(1) : ", searchObj.group(1)
print "searchObj.grou... | true |
ac26b98728ecf7d49aa79f70aa5dd5e3238ef10d | aparna-narasimhan/python_examples | /pramp_solutions/get_different_number.py | 1,319 | 4.125 | 4 | '''
Getting a Different Number
Given an array arr of unique nonnegative integers, implement a function getDifferentNumber that finds the smallest nonnegative integer that is NOT in the array.
Even if your programming language of choice doesn’t have that restriction (like Python), assume that the maximum value an integ... | true |
93354f664979d327f700a7f5ed4a28d92b978b16 | premraval-pr/ds-algo-python | /data-structures/queue.py | 1,040 | 4.34375 | 4 | # FIFO Structure: First In First Out
class Queue:
def __init__(self):
self.queue = []
# Insert the data at the end / O(1)
def enqueue(self, data):
self.queue.append(data)
# remove and return the first item in queue / O(n) Linear time complexity
def dequeue(self):
if self.... | true |
d73c7a9bec4f30251d31d42a17dfa7fde9a48f8e | danieltapp/fcc-python-solutions | /Basic Algorithm Scripting Challenges/caesars-cipher.py | 848 | 4.21875 | 4 | #One of the simplest and most widely known ciphers is a Caesar cipher, also known as a shift cipher. In a shift cipher the meanings of the letters are shifted by some set amount.
#A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.
#W... | true |
2248f6b4e815240d85ee37a6af3dc6c58d44d2d7 | danieltapp/fcc-python-solutions | /Basic Algorithm Scripting Challenges/reverse-a-string.py | 313 | 4.4375 | 4 | #Reverse the provided string.
#You may need to turn the string into an array before you can reverse it.
#Your result must be a string.
def reverse_string(str):
return ''.join(list(reversed(str)))
print(reverse_string('hello'))
print(reverse_string('Howdy'))
print(reverse_string('Greetings from Earth'))
| true |
759f39154fc321a20f84850be8482262b21b427e | oluwaseunolusanya/al-n-ds-py | /chapter_4_basic_data_structures/stackDS.py | 967 | 4.375 | 4 | class Stack:
#Stack implementation as a list.
def __init__(self):
self._items = [] #new stack
def is_empty(self):
return not bool(self._items)
def push(self, item):
self._items.append(item)
def pop(self):
return self._items.pop()
def peek(self):
... | true |
6eeaf28db7712b70d7ada9c3632b832c0fdeec74 | melany202/programaci-n-2020 | /talleres/tallerCondicional.py | 1,918 | 4.125 | 4 | #Ejercicio 1 condicionales
print('ejercicio 1')
preguntaNumero1='Ingrese un numero entero : '
preguntaNumero2='Ingrese otro numero entero : '
numero1=int(input(preguntaNumero1))
numero2=int(input(preguntaNumero2))
if(numero1>numero2):
print(f'el {numero1} es mayor que el {numero2}')
elif(numero1==numero2):
p... | false |
12c60f5ae394f343056619738299f0d2a68e9bbb | userzz15/- | /力扣/Mysort.py | 2,774 | 4.125 | 4 | import random
def bubble_sort(arr, size):
"""冒泡排序"""
for i in range(size - 1):
for j in range(size - 1 - i):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
def select_sort(arr, size):
"""选择排序"""
for i in range(size - 1):
temp = i
f... | false |
33c05d544f56bec9699add58b0a26673d41e974a | shubee17/Algorithms | /Array_Searching/search_insert_delete_in_unsort_arr.py | 1,239 | 4.21875 | 4 | # Search,Insert and delete in an unsorted array
import sys
def srh_ins_del(Array,Ele):
# Search
flag = 0
for element in range(len(Array)):
if Array[element] == int(Ele):
flag = 1
print "Element Successfully Found at position =>",element + 1
break
else:
flag = 0
if flag == 0:
print "Element Not F... | true |
5aca9da4c1d5edc7ab40f828cdbf9cc81a79894d | Foxcat-boot/Python_ym | /python_01/py_11_字符串查找和替换.py | 797 | 4.125 | 4 | # 判断是否以某字符串开头
str1 = "str123 321"
print(str1.startswith("str"))
print(str1.startswith("Str"))
"""
⬆此方法区分大小写
"""
# 判断是否以某字符串结尾
str2 = "hu1 mao"
print(str2.endswith("mao"))
print(str2.endswith("Mao"))
"""
同样区分大小写
"""
# 查找字符串
str3 = "123humao321159 xhm"
print(str3.find("159"))
print(str3.find("1"))
p... | false |
9ab2e315097803b322a0c57f4e3f33ee165807c9 | Olishevko/HomeWork1 | /operators.py | 466 | 4.53125 | 5 | # Арифметические операторы
# + - * / % ** //
#print(2+5)
#print(3-5)
#print(5 / 2)
#print(5 // 2)
#print(6 % 3)
#print(6 % 5)
#print(5 ** 2)
#number = 3 + 4 * 5 ** 2 +7
#print(number)
# Операторы сравнения
# == != > < >= <=
#print(1 == 1)
#print(1 == 2)
#print('One' == 'ONE')
#print('One' != 'ONE')
# Операторы п... | false |
0bacac4830fb2e7fa4edef9892ac255a4eed721e | SoliDeoGloria31/study | /AID12 day01-16/day04/day03_exercise/delete_blank.py | 283 | 4.1875 | 4 | # 2. 输入一个字符串,把输入的字符串中的空格全部去掉,打印出处理
# 后的字符串的长度和字符串的内容
s = input("请输入字符串: ")
s2 = s.replace(' ', '')
print('替换后的长度是:', len(s2))
print('替换后的内容是:', s2)
| false |
567c6e083ddbe7de37c7fc2be8e2126062197326 | SoliDeoGloria31/study | /AID12 day01-16/day08/exercise/print_even.py | 351 | 4.125 | 4 | # 练习2
# 写一个函数print_even,传入一个参数n代表终止的整数,打印
# 0 ~ n 之间所有的偶数
# 如:
# def print_even(n):
# ..... 此处自己完成
# print_even(10)
# 打印:
# 0
# 2
# 4
# 6
# 8
def print_even(n):
for x in range(0, n+1, 2):
print(x)
print_even(10)
| false |
cecaa8ff2d1ce042a9da127173ef3e292676a426 | SoliDeoGloria31/study | /AID12 day01-16/day09/day08_exercise/student_info.py | 1,393 | 4.125 | 4 |
# 3. 改写之前的学生信息管理程序:
# 用两个函数来封装功能的代码块
# 函数1: input_student() # 返回学生信息字典的列表
# 函数2: output_student(L) # 打印学生信息的表格
def input_student():
L = [] # 创建一个列表,准备存放学生数据的字典
while True:
n = input("请输入姓名: ")
if not n: # 如果用户输入空字符串就结束输入
break
a = int(input("请... | false |
a67330c5dc0ad81a9fac382ec8fdcb5c310d5750 | SoliDeoGloria31/study | /AID12 day01-16/day01/exercise/circle.py | 376 | 4.25 | 4 | # 练习:
# 指定一个圆的半径为 r = 3 厘米
# 1) 计算此圆的周长是多少?
# 2) 计算此圆的面积是多少?
# 圆周率: 3.1415926
# 周长 = 圆周率 * 半径 * 2
# 面积 = 圆周率 * 半径 * 半径
r = 3
pi = 3.1415926
length = pi * r * 2
print("周长是:", length)
area = pi * r * r # r ** 2
print("面积是:", area)
| false |
b1ec062d544dfb65fbd8f09e67bb03dce65aeef6 | betta-cyber/leetcode | /python/208-implement-trie-prefix-tree.py | 784 | 4.125 | 4 | #!/usr/bin/env python
# encoding: utf-8
class Trie(object):
def __init__(self):
self.root = {}
def insert(self, word):
p = self.root
for c in word:
if c not in p:
p[c] = {}
p = p[c]
p['#'] = True
def search(self, word):
nod... | true |
919a37ba58267ffe921c2485b317baca4d2f33d9 | garymale/python_learn | /Learn/Learn04.py | 1,096 | 4.3125 | 4 | #创建数值列表
#使用函数 range()可以生成一系列数字,打印1-4
for value in range(1,5):
print(value)
#range()创建数字列表,使用函数list()将range()的结果直接转换为列表
numbers = list(range(1,6))
print(numbers)
#使用函数range()时,还可指定步长,下列步长为2
enen_numbers = list(range(2,11,2))
print(enen_numbers)
#例:创建一个列表,其中包含前 10个整数(即1~10)的平方,在Python中,两个星号(**)表示乘方运算
squares = []... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.