blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
b4e07f1cebe20358900ad5b98e2276b405ff98c8 | ugiriwabo/Password-Locker | /user.py | 1,924 | 4.40625 | 4 | class User:
"""
Class to create user accounts and save their information
"""
users_list = [] #Empty users
def __init__(self,user_name,password):
# instance variables
self.user_name = user_name
self.password = password
def save_user(self):
User.users_list.append(self)
def delete_user(self... | true |
4a232f2117c1618a546d67c0be4b9841944d2d6f | rlpmeredith/cn-python-programming | /labs/06_classes_objects_methods/06_01_car.py | 823 | 4.4375 | 4 | '''
Write a class to model a car. The class should:
1. Set the attributes model, year, and max_speed in the __init__() method.
2. Have a method that increases the max_speed of the car by 5 when called.
3. Have a method that prints the details of the car.
Create at least two different objects of this Car class and dem... | true |
5936e432e417828c89003a9293e519367d2f7e12 | ashmin123/data-science | /Reshaping array.py | 631 | 4.5 | 4 | # numpy.reshape(array, shape, order = ‘C’) : Shapes an array without changing data of array.
# Python Program illustrating numpy.reshape() method
import numpy as geek
array = geek.arange(8)
print("Original array : \n", array)
# shape array with 2 rows and 4 columns
array = geek.arange(8).reshape(2, 4)
print("\narray... | true |
3ec34394f0f0143d42ba868e6755755cdfc30401 | ashmin123/data-science | /Array Creation using functions.py | 1,126 | 4.75 | 5 | # Python code to demonstrate the working of array()
# importing "array" for array operations
import array
# initializing array with array values
# initializes array with signed integers
arr = array.array('i', [1, 2, 3]) #array(data type, value list)
print(arr)
# printing original array
print("The new created array ... | true |
82feb24ae8a9cbb9f8a663cf6eb901415770529a | nadavperetz/python_newtork | /chapter_1/machine_info.py | 446 | 4.1875 | 4 | import socket
def print_machine_inf():
"""
Pretty self explained, it will print the host name and ip address
:return:
"""
host_name = socket.gethostname()
ip_address = socket.gethostbyname(host_name) # Returns the host IP
print "Host name: " + str(host_name)
print "IP address: " + str... | true |
290ef7dc080563fb975d50229e7741588711a356 | OpenLake/Introduction_Python | /BFS.py | 753 | 4.1875 | 4 | # python3 implementation of breadth first search algo for a
# given adj matrix of a connected graph
def bfs(graph, i):
visited = []
queue = [i]
while queue:
node = queue.pop(0)
if node not in visited:
visited.append(node)
neighbo... | true |
d2a4058cff3826230088a75ab5bca53385aa36df | beingajharris/MPG-Python-Script | /3-5-3.py | 614 | 4.40625 | 4 | # Calculate the Miles Per Gallon
print("This program loves to calculate MPG!")
# Get miles driven from the user
miles_driven = input("Please Enter the miles driven:")
# The next line Converts the text entered into a floating point number
miles_driven = float(miles_driven)
#Next is where we receive the gallons used... | true |
36f2ccfa2c1b84229e6602553078186ce714f903 | neternefer/codewars | /python/adjacent_element_product.py | 389 | 4.28125 | 4 | def adjacent_element_product(array):
'''Find largest product of adjacent elements.'''
#Product of first two elements
first = array[0] * array[1]
product = first
for i in range(len(array)- 1):
first = array[i] * array[i + 1]
if (first > product):
product = first
return product
def adjacent_element_p... | true |
65d52e82d90fb475fd02c6f1c21007cf0287420f | vholley/Random-Python-Practice | /time.py | 767 | 4.40625 | 4 | '''
time.py
This program takes an input for the current time and an input for a number of
hours to wait and outputs the time after the wait.
'''
# Take inputs for the current time and the number of hours to wait
current_time_str = input('What is the current time (in 24 hour format)? ')
wait_time_str = inp... | true |
a4d0ffdfb5fab128aeb7c8c5f921f37d9c92ec92 | roman-4erkasov/coursera-data-structures-algorithms | /prj01_algorithmic_toolbox/week05wrk01_change_dp.py | 1,174 | 4.1875 | 4 | # Uses python3
"""
As we already know, a natural greedy strategy for the change problem
does not work correctly for any set of denominations. For example, if
the available denominations are 1, 3, and 4, the greedy algorithm will
change 6 cents using three coins (4 + 1 + 1) while it can be changed
using just two coins (... | true |
06c96be1b6641b5395a51bcf0c742980ec45c192 | Meta502/lab-ddp-1 | /lab2/trace_meong.py | 2,840 | 4.1875 | 4 | '''
DDP-1 - WEEK 2 - LAB 2: MEONG BROSSS
BY: ADRIAN ARDIZZA - 2006524896 - DDP1 CLASS C
This project was made as a demonstration of branching and looping in Python. For this lab project, I decided to use a single class
to centralize all of the variables (since coordinate of player can be stored in a cl... | true |
b4864c7d4277b01b67e6e807285ba42eb2e0c904 | arbwasisi/CSC120 | /square.py | 881 | 4.15625 | 4 | """
Author: Arsene Bwasisi
Description: This program returns a square 2d list from the function
square, which takes in as arguments, the size of the list,
that starting value, and how much to increment.
"""
def square(size, start, inc):
''' Function wil return 2d list of len... | true |
a0ec1fc89bf7ae53b7a60fa252fdc4a29a674652 | arbwasisi/CSC120 | /puzzle_match.py | 1,148 | 4.125 | 4 | """
Author: Arsene Bwasisi
Description: This program will compare two values in lists left
and right, top and bottom to check for any matches.
it specifically looks for the reversed value in the
other list.
"""
def puzzle_match_LR(left,right):
"""
Fucntion... | true |
60b81f2e02dda3d6426982bb83892e619e725182 | CruzanCaramele/Python-Programs | /biggest_of_three_numbers.py | 1,030 | 4.5625 | 5 | # this procedure, biggest, takes three
# numbers as inputs and returns the largest of
# those three numbers.
def biggest(num1, num2, num3):
if num2 < num1:
if num3 < num1:
return num1
if num1 < num2:
if num3 < num2:
return num2
if num1 < num3:
if num2 < n... | true |
fea42a4b4fbd017a085e48cb8c9b132a92c53d43 | anaelleltd/various | /PYTHON/flower.py | 713 | 4.15625 | 4 | import turtle
def draw_triangle (some_turtle):
for i in range(1,5):
some_turtle.forward(80)
some_turtle.right(120)
def draw_art():
window = turtle.Screen()
window.bgcolor("white")
#Create the flower-turtle
flower = turtle.Turtle()
flower.shape("circle")
flower.... | true |
801fd049aec6b79ee3dc915808c319cb5119b670 | jonathanpglick/practice | /get_highest_product_from_three_ints.py | 1,646 | 4.46875 | 4 | # -*- coding: utf-8 -*-
"""
Given a list of integers, find the highest product you can get from three of the integers.
The input list_of_ints will always have at least three integers.
@see https://www.interviewcake.com/question/python/highest-product-of-3
"""
from __future__ import unicode_literals
from functools imp... | true |
17b797398202b61e8c8fcc08c120650cd547eec1 | NLGRF/Course_Python | /10-5.py | 294 | 4.125 | 4 | try:
Val1 = int(input('Type the first number: '))
Val2 = int(input('Type the second number: '))
ans = Val1/Val2
except ValueError:
print('You must type a whole number!')
except ZeroDivisionError :
print('Can not divide by zero')
else :
print(Val1, '/', Val2, ' = ',ans)
| true |
c4c7e3665bb9e69bf5e970b73513fc4db37e7555 | lancelote/algorithms_part1 | /week1/quick_union.py | 1,884 | 4.15625 | 4 | """Quick Union algorithm (weighted)"""
class QuickUnion:
"""Object sequence represented as a list of items
Item value corresponds to a root of object
"""
def __init__(self, n):
"""
Args:
n (int): Number of objects
"""
self.data = list(range(n... | true |
833dda99119ffc1f39c309f3d4c188a5516a65c2 | daniel-tok/oldstuff | /hangman.py | 2,654 | 4.125 | 4 | import random
lines = open("words").read() # reads all the text in the 'words' file
line = lines[0:] # sets all the lines starting from the first to 'line' variable
words = line.split() # splits the string of 'line' into separate words
myWord = random.choice(words) # makes a random choice from split string
def d... | true |
fba058525aeeae5aa3062b2b75d28f8e49962668 | rohanmukhija/programming-challenges | /project-euler/euler04.py | 996 | 4.3125 | 4 | #!/usr/bin env python2.7
# determine the largest palindrome product of two 3-digit numbers
upper = 999
lower = 100
limit = (upper - lower) / 2
def is_palindrome(seq):
'''
determines if a sequence is a palindrome by matching from ends
inward
'''
seq = str(seq)
length = len(seq)
depth = 0
if length % ... | true |
a3177f2b22aaef2589ffed4da3935da8e6a602b7 | GeeksIncorporated/playground | /554.brick-wall.py | 1,496 | 4.28125 | 4 | # https://leetcode.com/problems/brick-wall/description/
# There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. You want to draw a vertical line from the top to the bottom and cross the least bricks.
# The brick wall is repres... | true |
07f2c03cfcde68f89bbfce8b6b4cf246e95d6e50 | GeeksIncorporated/playground | /2d_matrix_pretty_pattern.py | 1,852 | 4.15625 | 4 | # https://www.interviewbit.com/problems/prettyprint/
# Print concentric rectangular pattern in a 2d matrix.
# Let us show you some examples to clarify what we mean.
#
# Example 1:
#
# Input: A = 4.
# Output:
#
# 4 4 4 4 4 4 4
# 4 3 3 3 3 3 4
# 4 3 2 2 2 3 4
# 4 3 2 1 2 3 4
# 4 3 2 2 2 3 4
# 4 3 3 3 3 3 4
# 4 4 4 4 4 4 ... | true |
1927df5434f4ae609363d4e5f3b7f3ac6372c5fe | easulimov/py3_learn | /ex03.py | 469 | 4.28125 | 4 | print('I will count the animals')
print("Chicken", 25+30/6)
print("Roosters", 100-25*3%4)
print('And now I will count the eggs:')
print(3+2+1-5+4%2-1/4+6)
print('Is it true that 3+2<5-7')
print(3+2<5-7)
print("How much will 3+2", 3+2)
print("And how much will 5-7?", 5-7)
print("Oh I think I'm confused. Why False?")... | true |
c04061d832c99c18afe11ebe9277434d2626170d | meheboob27/Demo | /Hello.py | 240 | 4.1875 | 4 | #Calculate Persons age based on year of Birth
name=str(input("Please enter your Good name:"))
year=int(input("Enter your age:"))
print(year)
Currentage=2019-year
print(Currentage)
print ("Hello"+name+".your are %d years old."% (Currentage)) | true |
4eabea62ef072aca451b042f4bcd9d7a888e33ac | dimitar-daskalov/SoftUni-Courses | /python_OOP/labs_and_homeworks/08_iterators_and_generators_exercise/06_fibonacci_generator.py | 213 | 4.25 | 4 | def fibonacci():
previous, current = 0, 1
while True:
yield previous
previous, current = current, previous + current
generator = fibonacci()
for i in range(5):
print(next(generator))
| true |
f1e5e9a302b3e1b34d304174453e6a107bfaa24e | dimitar-daskalov/SoftUni-Courses | /python_advanced/labs_and_homeworks/02_tuples_and_sets_lab/02_average_student_grades.py | 517 | 4.125 | 4 | number_of_students = int(input())
student_grades_dict = {}
for student in range(number_of_students):
student_name, grade = input().split()
grade = float(grade)
if student_name not in student_grades_dict:
student_grades_dict[student_name] = [grade]
else:
student_grades_dict[student_name]... | true |
f7b5ae11c0125dc50500b6042e5cc5f4f7f6243c | yuansiang/Demos | /python demos/oop/bankaccount.py | 1,841 | 4.21875 | 4 | #bankaccount.py
class Account():
""" Bank account super class """
def __init__(self, account_no, balance):
""" constructor method """
#something to store and process
self.__account_no = account_no
self.__balance = balance
#stuff that starts with _underscore is... | true |
c3f53c6ca3ef11b9add05c8a25ccdfe47b9911ec | fyzbt/algos-in-python | /implementations/merge_sort.py | 2,051 | 4.125 | 4 | """
count number of inversions in list
inversion: for a pair of indices in list 1 <= i < j <= n if A[i] > A[j]
in a sorted array number of inversions is 0
input:
list size
list elements as string separated by whitespace
"""
import sys
num_inversions = 0
def recursive_merge_sort(data):
"""
recursively merge s... | true |
873a3ddb6047fa6d5b6723d9705cebbb0f823665 | skwirowski/Python-Exercises | /Basics/textual_data.py | 1,591 | 4.5 | 4 | my_message = 'Hello World'
multiple_lines_message = """Hello World! Hello World! Hello World!
Hello World! Hello World! Hello World!"""
print(my_message)
print(multiple_lines_message)
# Get length of the string
print(len(my_message))
# Get specific index character from string (indexes start from 0)
print(my_message[0... | true |
52836e9caa916dff14b3b248bcb74b3ad1144f7b | aileentran/practice | /stack.py | 485 | 4.21875 | 4 | # Implementing stack w/list
# Last in, first out
# Functions: push, pop, peek
class Stack(object):
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[-1]
pancakes = Stack()
print(pancakes.items)
pan... | true |
6aec7f774ca59acb2471454001be7e56202273b8 | aileentran/practice | /daysinmonth.py | 941 | 4.3125 | 4 | """
input: integer == month, integer == year
output: integer - number of days in that month
Notes:
leap year happens % 4 == 0 years --> feb has 29 instead of 28
EXCEPT year % 100 = NOT leap year
EXCEPT year % 400 = IS leap year
Pseudocode:
empty dictionary = months (nums) key: days (value)
check to see if looking f... | true |
b84872de8d43bf1251f0a6015741db80dfdcbbdb | aileentran/practice | /queue.py | 1,337 | 4.3125 | 4 | # Functions - enqueue, dequeue, peek
# Implement with list
# Assumptions: Start of Queue @ idx 0; End of list at the back
class Queue(object):
def __init__(self):
self.items = []
def enqueue(self, item):
self.items.append(item)
def dequeue(self):
return self.items.pop(0)
def ... | true |
a3a2cd79919713788df58da9f220ac26bc16a9d1 | prakashmngm/Lokesh-Classes | /Factorial-Series.py | 601 | 4.25 | 4 | '''
Consider the series : = 0! + 1! + 2! + 3! = 1 + 1 + 2 + 6 = 10
Input : 3
Output : 10
Input : 5
Output : 154
(0! + 1! + 2! + 3! + 4! + 5! )
Use the def Factorial(num): function that we have written before.
'''
def Factorial(num):
if(num == 0):
return 1
else:
fact = 1
index =... | true |
8ad6dded879cf4e788f57a2f9d6d86de1dde5f6a | prakashmngm/Lokesh-Classes | /Harmonic_Mean.py | 709 | 4.1875 | 4 | '''
Problem : Harmonic Mean of ‘N’ numbers.
Pseudo code:
1. Input the list of numbers
2. Initiate a variable called ‘sum’ to zero to store the sum of the elements of the list
3.iterate through each element of the list using for loop and reciprocate the item and add it to the sum
4.calculate the Harmonic Mean by rec... | true |
484cb297a1ef0c8a4bcabdf33bcd175a09fd3f9e | prakashmngm/Lokesh-Classes | /Exponential-Function.py | 977 | 4.3125 | 4 | '''
Problem : Implement exponential function. Input only +ve integers.
def exponential( base, index )
Input : (2,5)
Output : 32
Possible VALID inputs : (0,3),(5,0),(0,0),(4,4), (12, 12)
If base and index is 0 , then the value of the exponent is undefined.
if base == 0 print 0. Go to step 4.
If index == 0 print ... | true |
a2fc3078df459d96f9842c9fdaafed2caab159ef | lacecheung/class-projects2 | /shoppinglist.py | 1,540 | 4.40625 | 4 | #default shopping list
shopping_list = ["milk", "bread", "eggs", "quinoa"]
#function definitions:
def remove_item(item):
shopping_list.remove(item)
shopping_list.sort
print shopping_list
#options
print "Select a choice:"
print "Type 1 to add a item"
print "Type 2 to remove an item"
print "type 3 to replace an i... | true |
b9cbca91633f7dc2ec9e3e0c81faad2f230269b6 | CompThinking20/python-project-Butterfly302 | /Pythonproject.py | 722 | 4.15625 | 4 | def main():
print "What is your favorite food?"
food_answer = raw_input("Enter your food")
print "Hello" + str(food_answer) + " What is your favorite desert?"
desert_answer + raw_input ("Enter your desert")
if str(desert_answer) != "Brownies.":
print "What you like is not availible"
... | true |
242864a5ab2f75766073615addea7b4a18b3a644 | CC-SY/practice | /Desktop/BigData SU2018/Lesson 1/pythoncourse-master/code_example/02-circleCalc/example2.py | 542 | 4.5 | 4 | # wfp, 5/30/07, wfp: updated 9/5/11; rje 5/14/12
# prompt user for the radius, give back the circumference and area
import math
radius_str = input("Enter the radius of your circle:")
radius_float = float(radius_str)
circumference_float = 2 * math.pi * radius_float
area_float = math.pi * radius_float * radiu... | true |
0b1b2edf5b67b0151c3d624b99141d506dfb33c6 | karsonk09/CMSC-150 | /Lab 06 - Text Adventure/lab_06.py | 2,998 | 4.34375 | 4 | # This is the list that all of the rooms in the game will be appended to
room_list = []
# List of all rooms in the game
room = ["You are in a dark, cryptic room with a door to the north and a door to the east.", 3, 1, None, None]
room_list.append(room)
room = ["You walk out into a long hallway. There are doors to the... | true |
66c2d50408a5846a0a4e8e3dc22c1bced2f28345 | namuthan/codingChallenges | /longestWord.py | 629 | 4.3125 | 4 | """
Using the Python language, have the function LongestWord(sen) take the sen parameter
being passed and return the largest word in the string.
If there are two or more words that are the same length, return the first word from the string with that length.
Ignore punctuation and assume sen will not be empty.
"""
imp... | true |
410b303b9d8a44a616ee54369759ff11676e2849 | Indiana3/python_exercises | /wb_chapter7/exercise155.py | 1,378 | 4.46875 | 4 | ##
# Compute and display the frequencies of words in a .txt file
#
import sys
import re
# Check if the user entered the file name by command line
if len(sys.argv) != 2:
print("File name missing...")
quit()
try:
# Open the file
fl = open(sys.argv[1], "r", encoding="utf-8")
# Dict to store words/fr... | true |
070f8b715723c85a202de9d328558cb2b72ed597 | Indiana3/python_exercises | /wb_chapter4/exercise95.py | 1,730 | 4.15625 | 4 | ##
# Capitalize letters in a string typed uncorrectly
#
## Capitalize all the letters typed uncorrectly
# @param s a string
# @return the string with the letters capitilized correctly
#
def capitilizeString(s):
# Create an empty string where adding
# each character of s, capitilized or not capitilized
cap... | true |
0a748aad2adcad109c20284b89a28db46dd014fd | Indiana3/python_exercises | /wb_chapter5/exercise134.py | 846 | 4.28125 | 4 | ##
# Display all the possible sublists of a list
#
## Compute all the sublists in a list of elements
# @param t a list
# @return all the possible sublists
#
def sublists(t):
# Every list has a default empty list as sublist
sublists = []
sublists.append([])
# Find all the sublists of the list
for i ... | true |
9bfedd8151a9f2906f702f67cdcdde63996464b1 | Indiana3/python_exercises | /wb_chapter5/exercise128.py | 1,498 | 4.28125 | 4 | # Determine the number of elements in a list greater than
# or equal to a minimum value and lower than a maximum value
#
## Determine the number of elements in a list that are
# greater than or equal a min value and less than
# a max value
# @param t a list of value
# @param min a minimum value
# @param max a maximum... | true |
2edb1fe95a4245ad15af957212ad5e915c34fa4a | Indiana3/python_exercises | /wb_chapter2/exercise48.py | 1,453 | 4.5625 | 5 | ##
# Determine the astrological sign that matches the user's birth date
#
# Read the date of birth
month = input("Please, enter your month of birth: ")
day = int(input("And now the day: "))
# Determine the astrological sign that matches the birth date
if month == "December" and day >= 22 or month == "January" and day... | true |
9bfdcb6fd86a453a9a4267d3e03c0be44b45582c | Indiana3/python_exercises | /wb_chapter5/exercise115.py | 707 | 4.375 | 4 | ##
# Read a positive integer and compute all its proper divisors
#
## Find the proper divisors of a positive integer
# @param n a positive integer
# @return a list with all the positive integers
def proper_divisors(n):
divisors = []
for i in range (1, n):
if n % i == 0:
divisors.append(i)
... | true |
56d8bec45b39efe200f98f8223cfd525ae98aa32 | Indiana3/python_exercises | /wb_chapter8/exercise174.py | 792 | 4.3125 | 4 | ##
# Compute the greatest common divisor of 2 positive integers
#
## Compute the greatest common divisor of 2 positive integers
# @param a the first positive integer
# @param b the second positive integer
# @return the greatest common divisor
#
def greatestCommonDivisor(a, b):
# Base case
if b == 0:
re... | true |
6dd3a8df69d2504b38ad061533604419703443ba | Indiana3/python_exercises | /wb_chapter1/exercise14.py | 422 | 4.5 | 4 | ##
# Convert height entered in feet and inches into centimeters
#
IN_PER_FT = 12
CM_PER_INCH = 2.54
# Read a number of feet and a number of inches from users
print("Please, enter yout height: ")
feet = int(input(" Number of feet: "))
inches = int(input(" Number of inches: "))
# Compute the equivalent in centimeters
c... | true |
240b19450b6a93c65f5fbe9fff922fdbb930a733 | Indiana3/python_exercises | /wb_chapter7/exercise157.py | 2,007 | 4.34375 | 4 | ##
# Convert grade points to letter grade and viceversa
#
# Create a dictionary with letter grades as keys
# and grade points as values
letter_points = {
"A+" : 4.1,
"A" : 4.0,
"A-" : 3.7,
"B+" : 3.3,
"B" : 3.0,
"B-" : 2.7,
"C+" : 2.3,
"C" : 2.0,
"C-" : 1.7,
"D+" : 1.3,
"D" ... | true |
87a7b85c749279065e38f94e7d9454216a3208bd | Indiana3/python_exercises | /wb_chapter4/exercise94.py | 812 | 4.46875 | 4 | ##
# Determine if three lengths can form a triangle
#
# Check if three lengths form a triangle
# @param a the length 1
# @param b the length 2
# @param c the length 3
# return True if a, b, c are sides of a valid triangle
# return False if they are not
def isATriangle(a, b, c):
if a <= 0 or b <= 0 or c <= 0:
... | true |
d714ad0bb8fe99a43d296e83f2791351bf9e6d38 | Indiana3/python_exercises | /wb_chapter5/exercise121.py | 698 | 4.1875 | 4 | ##
# Generates 6 numbers from 1 to 49 with no duplicates
# Display them in ascending order
#
from random import randint
# Each ticket has 6 numbers
NUMBERS_FOR_TICKET = 6
# Numbers drawn are between 1 and 49
FIRST_NUMBER = 1
LAST_NUMBER = 49
# Start with an empty list
ticket_numbers = []
# Generate 6 random number... | true |
9ef996f50bfb3c0ec5fc60eb9ca597d8b05c17fb | Indiana3/python_exercises | /wb_chapter3/exercise68.py | 1,630 | 4.21875 | 4 | ##
# Convert a sequence of letter grades into grade points
# and compute its avarage
#
A = 4.0
A_MINUS = 3.7
B_PLUS = 3.3
B = 3.0
B_MINUS = 2.7
C_PLUS = 2.3
C = 2.0
C_MINUS = 1.7
D_PLUS = 1.3
D = 1.0
F = 0.0
# Initialize to 0 the sum of grade points
# Initialize to 0 the number of letter grades entered
total_points = ... | true |
a7990f956d2ae393b4a92180de64a25341560c70 | Indiana3/python_exercises | /wb_chapter2/exercise39.py | 379 | 4.5 | 4 | ##
# Display the number of days in a month
#
# Read the month
month = input("Please, enter the name of a month: ")
# Compute the number of days in a month
days = 31
if month == "april" or month == "june" or month == "september" or month == "november":
days = 30
elif month == "february":
days = "28 or 29"
# ... | true |
8d24e50857024702e28bf41c258d9c0be6f75ee0 | Indiana3/python_exercises | /wb_chapter2/exercise45.py | 627 | 4.40625 | 4 | ##
# Display if the day and month entered match one of
# the fixed-date holiday
#
# Read the month and the day from the user
print("Please, enter: ")
month = input("the name of a month (like January): ")
day = int(input("a day of the month: "))
# Determine if month and day match a fixed-date holiday
if month == "Janu... | true |
b07dbba62277f34936ea44beac14c6f6b5b723e1 | Indiana3/python_exercises | /wb_chapter2/exercise37.py | 459 | 4.53125 | 5 | ##
# Display whether a letter is a vowel, semi-vowel or consonant
#
# Read the letter
letter = input("Please, enter a letter: ")
# Determine whether the letter is a vowel, semi-vowel or consonant
if letter == "a" or letter == "e" or \
letter == "i" or \
letter == "o" or letter == "u":
print("The entered l... | true |
b7f8e9548744f01241a2a6620f0d423049be4cc6 | Indiana3/python_exercises | /wb_chapter5/exercise119.py | 1,470 | 4.25 | 4 | ##
# Read a series of values from the user,
# compute their avarage,
# print all the values before the avarage
# followed by the values equal to the avarage (if any)
# followed by the values above the avarage
#
# Start with an empty list
values = []
# Read values from user until blank line is entered
value = input("P... | true |
9e20a1c8b86d3447270e08a2dffcaa246ff479b6 | ITh4cker/ATR_HAX_CTF | /crypto/light_switch_crypto/challenge/solve_me.py | 2,869 | 4.375 | 4 |
"""
This script reads from "key" and "encrypted_flag" and uses "magic_func" to
convert the encrypted flag into its decoded version.
You are asked to implement the magic_func as described in CTF_1.png
Successful decryption should print a valid flag (ATR[....]) in the console.
This script is expected to run with ... | true |
a904d64fcfe0e3a5b08e87478c64ce09d6159d20 | MaximUltimatum/Booths_Algorithm | /booths_algorith.py | 938 | 4.125 | 4 | #! usr/bin/python
def booths_algorithm():
multiplicand_dec = input('Please enter your multiplicand: ')
multiplier_dec = input('Please enter your multiplier: ')
multiplicand_bin = twos_complement(multiplicand_dec)
multiplier_bin = twos_complement(multiplier_dec)
print(multiplicand_bin)
print(mul... | true |
c62620a95f843279a23f63dd91539072da06f283 | ninja-programming/python-basic-series | /for_loop_examples.py | 1,484 | 4.34375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 30 01:40:11 2021
@author: mjach
"""
'''For look examples'''
my_fruits_list = ['apple', 'orange', 'banana', 'watermelon']
#checking is the fruit in my list
print('Is this fruit in my list?:', 'apple' in my_fruits_list)
'''for loop example'''
# for fruit in my_fruits_li... | true |
34933504a0772f57dc179df6824378109f82b1bd | ninja-programming/python-basic-series | /user_input_example.py | 685 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 5 03:13:49 2021
@author: mjach
"""
'''
How to take input from the user
'''
# fruit = input('What fruit do you like?: ')
# print('I like ', fruit)
# #input always take as a string
# #if you put neumaric number you have to converted it to int format
# first_number = int... | true |
ecb414331eb8969f0d1bc41769c25cec5dff9c9a | nmichel123/PythonPractice | /firstprogram.py | 224 | 4.1875 | 4 | def say_hi(name):
if name == '':
print("You did not enter your name!")
else:
print("Hey there...")
for letter in name:
print(letter)
name = input("Type in your name!")
say_hi(name) | true |
a302427405ab86e1db5137d2f12df354401066be | Rahulkumar-source/Albanero_Task_Pratice | /problem5.py | 536 | 4.125 | 4 | def checkOutlier(arr):
oddCount = 0
evenCount = 0
for item in arr:
if item % 2 == 0:
evenCount += 1
else:
oddCount +=1
# This is going to print the count of item if even or odd
# print(oddCount, evenCount)
if oddCount == 1:
fo... | true |
e0a15db4596363ba96f9372234b8971a91a4a4e9 | nchapin1/codingbat | /logic-1/cigar_party_mine.py | 658 | 4.21875 | 4 | def cigar_party(cigars, is_weekend):
"""When squirrels get together for a party, they like to have cigars.
A squirrel party is successful when the number of cigars is between 40 and 60,
inclusive. Unless it is the weekend, in which case there is no upper bound on
the number of cigars. Return True if the... | true |
dfdea4321eb8f4e514469bbc73d532c9542477ce | giri110890/python_gfg | /Functions/partial_functions.py | 540 | 4.28125 | 4 | # Partial functions allows us to fix a certain number of arguments of a function
# and generate a new function
from functools import *
# A normal function
def f(a, b, c, x):
return 1000 * a + 100 * b + 10 * c + x
# A partial function that calls f with a as 3, b as 1 and c as 4
g = partial(f, 3, 1, 4)
# Calling ... | true |
4b825fb64a8c2a660fc38bc53006992ff3344b91 | giri110890/python_gfg | /Functions/args_and_kwargs.py | 1,386 | 4.71875 | 5 | # Python program to illustrate
# *args for variable number of arguments
def myFun(*argv):
for arg in argv:
print(arg)
myFun('Hello', 'Welcome', 'to', 'GeeksforGeeks')
# Python program to illustrate **kwargs for variable number of keyword
# arguments
def myFun1(**kwargs):
for key, value in kwargs.... | true |
9e1dc0c1ceddd29cde85c60493b5e25b12c387fd | loukey/pythonDemo | /chap2/exp2.6.py | 1,142 | 4.34375 | 4 | # -*- coding: utf-8 -*-
#例2.6完整的售价程序设计
def input_data_module():
print 'What is the item\'s name?'
item_name = raw_input()
print 'What is its price and the percentage discounted?'
original_price = input()
discount_rate = input()
return item_name,original_price,discount_rate
def calculations_module():
ite... | true |
172091debab9edbadaa32fe6d09e1cebe6a4bbde | LiliaMudryk/json_navigation | /navigation.py | 2,018 | 4.625 | 5 | '''
This module allows to carry out navigation through any json file.
'''
import json
def read_json_file(path):
"""
Reads json file and returns it in dictionary format
"""
json_file = open(path,mode="r",encoding="UTF-8")
json_data = json_file.read()
obj = json.loads(json_data)
return obj
d... | true |
608058dd4948f105e45a5e1243090aadc4d99909 | sreekanth-s/python | /vamsy/divisible_by_5.py | 264 | 4.15625 | 4 | ## Iterate the given list of numbers and print only those numbers which are divisible by 5
input_list=[1,2,3,4,5,10,12,15.5,20.0,100]
def divisible_by_5(input_list):
for i in input_list:
if i % 5 == 0:
print(i)
divisible_by_5(input_list) | true |
f8b70ce34396a0e5c3d0aac7f95ede04f9169254 | sreekanth-s/python | /old_files/count_number_of_on_bits.py | 350 | 4.28125 | 4 |
print("Enter a number to find the number of ON bits in a number.")
num=int(input("Enter a positive integer: "))
print_num = num
count=0
if num > 0:
while num > 0:
if num & 1:
count+=1
num = num >> 1
print("The number entered", print_num, "has", count, "ON bits.")
else:
print... | true |
0507f088e2b020bb677f3772efd8affcdf63f8b3 | sreekanth-s/python | /old_files/factorial.py | 730 | 4.46875 | 4 | """
num=int(input("Enter a number to find factorial: "))
if (num <= 0):
print("Enter a valid integer! ")
else:
print("You've entered ", num)
for i in range(1,num):
num=num*i
print("and the factorial is ",num)
"""
num=int(input("Enter a number to find factorial: "))
print("You've entered ", num)
... | true |
9363df1f25908275c4b4446c0911a110d7c7585b | sreekanth-s/python | /data_structures/stack_implementation.py | 2,510 | 4.28125 | 4 | def execution():
opr = input("Enter an operation to perform: ")
if opr == "1" or opr == "push":
value = input("Enter a value to push: ")
ret = stack_push(value)
if ret == None:
print("The stack is full. try popping. \n \n")
execution()
else:
... | true |
33c2bf53a6057e5985882bcb595bbf81c995cb8b | moisesvega/Design-Patterns-in-Python | /src/Creational Patterns/Factory Method/Factory.py | 710 | 4.21875 | 4 | '''
Created on Jul 16, 2011
@author: moises
'''
'''Defines the interface of objects the factory method creates'''
class Product:
pass
'''Implements the Product interface'''
class ConcreteProductA( Product ):
def __init__( self ):
self.product = "Guitar"
'''Implements the Product interface'''
class C... | true |
3625d90df67e51c6683231dbe2fe15ab18776c5b | JudoboyAlex/python_fundamentals2 | /reinforcement_exercise2.py | 1,392 | 4.15625 | 4 | # Let's take a different approach to film recommendations: create the same variables containing your potential film recommendations and then ask the user to rate their appreciation for 1. documentaries 2. dramas 3. comedies on a scale from one to five. If they rate documentaries four or higher, recommend the documentar... | true |
942c7fe91f9833c7804f86a42f4b5dcb6aa49e5b | vineetbaj/Python-Exercises | /30 days of code/Day 3 - Intro to Conditional Statements.py | 946 | 4.5625 | 5 | """ ***Day 3***
Objective
In this challenge, we learn about conditional statements. Check out the Tutorial tab for learning materials and an instructional video.
Task
Given an integer, , perform the following conditional actions:
If is odd, print Weird
If is even and in the inclusive range of to , print Not Weird
... | true |
ed57527d425099403a508453e90d0850c3e8e825 | 0f11/Python | /pr04_adding/adding.py | 2,513 | 4.21875 | 4 | """Adding."""
def get_max_element(int_list):
"""
Return the maximum element in the list.
If the list is empty return None.
:param int_list: List of integers
:return: largest int
"""
if len(int_list) == 0:
return None
return max(int_list)
pass
def get_min_element(int_li... | true |
ca58251889ad80531e12647fc58181b86fe0f808 | sonhal/python-course-b-code | /user_loop.py | 421 | 4.125 | 4 | # CLI program for pointlessly asking the user if they want to continue
loop_counter = 0
while(True):
print("looped: "+ str(loop_counter))
loop_counter += 1
user_input = input("Should we continue? ")
if user_input == "yes":
continue
elif user_input == "no":
print("Thank you for playi... | true |
274acbf8fa74954bcf8885b4e0a203f14e6604c3 | donyu/euler_project | /p14.py | 1,028 | 4.3125 | 4 | def collatz_chain(max):
longest_chain.max = max
longest_chain.max_len = 0
longest_chain(1, 1)
return longest_chain.max_len
def longest_chain(x, length):
"""Will find longest Collatz sequence by working backwards recursively"""
if length > 10:
return
# base case if number over 1,000,000
if x > longe... | true |
309aea1305c2be0d6acfcb41f6877965499388a4 | malakani/PythonGit | /mCoramKilometers.py | 757 | 4.71875 | 5 | # Program name: mCoramKilometers.py
# Author: Melissa Coram
# Date last updated: September 21, 2013
# Purpose: Accepts a distance in kilometers and outputs the distance in kilometers
# and miles.
# main program
def main():
# get the distance in kilometers
distance = int(input('Enter the distance in kilometers:... | true |
cbd34a38ce7d9d31317024c247563515d3bb48ad | malakani/PythonGit | /mCoramPenniesForPay.py | 1,171 | 4.59375 | 5 | # Program name: mCoramPenniesForPay.py
# Author: Melissa Coram
# Date last updated: 10/24/2013
# Purpose: Calculates and displays the daily salary and total pay earned.
def main():
# Get the number of days from the user.
print('You start a job working for one penny a day and your pay doubles every day thereaft... | true |
59a6d3c3e45ad3b18ac8089856e5feda50877c3a | CharlieDaniels/Puzzles | /trailing.py | 410 | 4.25 | 4 | #Given an integer n, return the number of trailing zeroes in n!
from math import factorial
def trailing(n):
#find the factorial of n
f = factorial(n)
#cast it as a string
f_string = str(f)
#initialize counters
num_zeroes = 0
counter = -1
#count the number of zeroes in n, starting from the end
while f_string[... | true |
58dae9443233c7661c2740523f7dfd559d313401 | TanvirAhmed16/Advanced_Python_Functional_Programming | /11. List Comprehensions.py | 1,716 | 4.46875 | 4 | '''
# Comprehensions in Python - Comprehensions in Python provide us with a short and concise way to construct new
sequences (such as lists, set, dictionary etc.) using sequences which have been already defined. Python supports
the following 4 types of comprehensions:
# List Comprehensions
# Dictiona... | true |
ff474eb65652308fee85de0d5d38885903b7372e | aaronyang24/python | /Assignment_Ch02-01_Yang.py | 320 | 4.15625 | 4 | time = int(input("Enter the elapsed time in seconds: "))
hours = time // 3600
remainder = time % 3600
min = remainder // 60
sec = remainder % 60
print("\n" + "The elapsed time in seconds = " + str(time ))
print ("\n" + "The equivalent time in hours:minutes:seconds = " + str(hours) +":" + str(min)+":" + str(sec) ) | true |
e5651299e4b4159e6331e910dac0380344e35ba3 | phillib/Python-On-Treehouse.com | /Python-Collections/string_factory.py | 565 | 4.28125 | 4 | #Created using Python 3.4.1
#This will create a list of name and food pairs using the given string.
#Example: "Hi, I'm Michelangelo and I love to eat PIZZA!"
dicts = [
{'name': 'Michelangelo',
'food': 'PIZZA'},
{'name': 'Garfield',
'food': 'lasanga'},
{'name': 'Walter',
'food': 'pancakes'... | true |
277698d0c991dcf689dac18f73eb70137e75c573 | elliehendersonn/a02 | /02.py | 766 | 4.65625 | 5 | """
Problem:
The function 'powers' takes an integer input, n, between 1 and 100.
If n is a square number, it should print 'Square'
If n is a cube number, it should print 'Cube'
If n is both square and cube, it should print 'Square and Cube'.
For anything else, print 'Not a power'
Cube numbers ... | true |
5a7ca588a04c1717f05edb329cd3dda69519b0d7 | ShemarYap/FE595-Python-Refresher | /Python_Refresher_Huq.py | 1,220 | 4.1875 | 4 | # Importing numpy and matplotlib
import numpy as np
import matplotlib.pyplot as plt
# Setting the X values in the x variable
x = np.arange(0, 2*np.pi, 0.01)
# Setting the values for Sine in the sin_y variable
sin_y = np.sin(x)
# Plotting with x variable for X-axis and sin_y for Y-axis.
# The linewidth arg... | true |
13939777116661ac7fcd97f066470d0cd139d195 | ramkishor-hosamane/Python-programming | /comb.py | 646 | 4.25 | 4 | def list_powerset(lst):
# the power set of the empty set has one element, the empty set
result = [[]]
for x in lst:
# for every additional element in our set
# the power set consists of the subsets that don't
# contain this element (just take the previous power set)
# plus th... | true |
286551edca202747a0b390aa212e35136b4f3e21 | yegornikitin/itstep | /lesson12/triple_result.py | 717 | 4.15625 | 4 | try:
a = int(input("Please, insert first integer: "))
b = int(input("Please, insert first integer: "))
# First function, that will only show a + b
def add(a, b):
return a + b
print("---------------")
print("Result without decorator: ", add(a, b))
# Second function wi... | true |
72d6893e88e7ae669fd7d5df179cbfb186f83e4d | simonisacoder/AI | /lab/lab1 数据集处理/re.sub.py | 346 | 4.15625 | 4 | import re
# first way to check whether a word has number
def hasNum1(string):
return any(char.isdigit() for char in string)
#second way: regular expression
def hasNum2(string)
s = "123 a:1 b:2 c:3 ab cd ef"
s = s.split()
print(s)
for i in s:
if re.search(r'\d',s(i),flag=0):
print(s(i).group())
e... | true |
5ea76df223d67ff9b2bf3f6d1046997dc34ffcf0 | bhanurangani/code-days-ml-code100 | /code/day-2/5.Getting Input From User/AppendingN ame.py | 407 | 4.46875 | 4 | #appending first name and last name
name=str(input("enter the first name"))
surname=str(input("enter the last name"))
#no such function to append the string, but simply it can be done this way
name=name +" "+ surname
print(name)
#using %s we can use to in cur the values to print
z="%s is son of Mr. %s"%(name,surname)
p... | true |
f80b64c0f93213a777b10faa04c7a974bb75ecd8 | vijayxtreme/ctci-challenge | /Arrays/isUnique_r1.py | 822 | 4.28125 | 4 | #Is Unique
'''
I rewrote this one for ASCII / Alphabet
Basically if there are more than 256 characters, this can't be unique because there are only 256 ASCII characters allowed.
If we wanted to just do letters, we could do 26 letters and lowercase all entries
The trick here is that unicode goes up to 128, so we can... | true |
d2d7eaabb74520239b0efdccd27413c4b742894b | zwagner42/dailyprogrammer | /Easy Programs/Problems1-20/Calendar_Date.py | 2,005 | 4.625 | 5 | #Program to find the day of the month based on a given number day, number month, and number year
from sys import argv, exit
from calendar import isleap, monthrange, weekday
from Input_Check import is_Number, is_Number_Range
#Displays an error message for an incorrect argument list
def error_Message_Argument_List():
... | true |
cb8284d5ee30e8184ecf6c0bd3579829540a5923 | cjohlmacher/PythonSyntax | /words.py | 367 | 4.3125 | 4 | def print_upper_words(wordList,must_start_with):
"""Prints the upper-cased version of each word from a word list that starts with a letter in the given set"""
for word in wordList:
if word[0] in must_start_with:
print(word.upper())
print_upper_words(["hello", "hey", "goodbye", "yo", "yes"],... | true |
3012f4a88f70458121ad44ac54f5fcbf2d6bbbb7 | Lievi77/csl-LATAM-graph | /public/data/LATAM_filter.py | 2,206 | 4.21875 | 4 | import pandas as pd
# Script to filter out COVID-19 Data
# by: Lev Cesar Guzman Aparicio lguzm77@gmail.com
# ----------------------------METHODS------------------------------------------------------------------
# ------------------------------MAIN---------------------------------------------------------------------... | true |
c05d8a1ab12e4ba46536fcbc1388c1ce99b990fe | ppppdm/mtcpsoft | /test/sharedMemory_test2.py | 892 | 4.1875 | 4 | # -*- coding:gbk -*-
# author : pdm
# email : ppppdm@gmail.com
#
# test shareMemory use
import mmap
with mmap.mmap(-1, 13) as map:
map.write(b'helloworld')
map.close()
import mmap
# write a simple example file
with open("hello.txt", "wb") as f:
f.write(b"Hello Python!\n")
with open(... | true |
9c7870676af46b7a15cdcb2c193a4a3b6a789903 | iamSubhoKarmakar/Python_Practice | /abstract-classes.py | 788 | 4.125 | 4 | #abstract classes - can not be instantiated, can only be ingerited, base class
#it can not directly creeate an object but the data of this class can only be inherited to a
#child clss for in an object
#lets do cal salary
from abc import ABC, abstractmethod
class Employee(ABC):
@abstractmethod
d... | true |
ec1e387ffee6638ecc4084d227a4e4946d5ca223 | akelkarmit/sample_python | /date_to_day.py | 1,210 | 4.28125 | 4 | print "this program asks for your birthday and tells you the day of the\nweek when you were born"
import calendar
birthdate=raw_input("enter your birthdate in dd-mm-yyyy format:")
#raw_input assumes the input is a string
date_of_birth=birthdate.split('-')
day_of_birth=int(date_of_birth[0])
month_of_birth=int(date_of... | true |
6176fd13f6bdf06ff6f1a66564d1d5c68b6a93b7 | bhavikjadav/Python_Crash_Course_Eric_Matthes_Chapter_8 | /8.8_User Album.py | 914 | 4.46875 | 4 | #!/usr/bin/env python
# coding: utf-8
# # 8-8. User Albums: Start with your program from Exercise 8-7. Write a while loop that allows users to enter an album’s artist and title. Once you have that information, call make_album() with the user’s input and print the dictionary that’s created. Be sure to include a quit va... | true |
2b866761322eea62a1ae60e8df76f28c0eb9132b | Pavan53/Python | /phone_directory.py | 789 | 4.21875 | 4 | # program to create a dictionary with name and mobile numbers
phones = {}
while True:
name = input("Enter name :")
if name == "end":
break
mobile = input("Enter mobile number :")
if name in phones: # name is found
phones[name].add(mobile) # add new number to existing set
else:
... | true |
02ab80bea53b59c274ed247a2ea518e91af9da8a | HeyItsFelipe/python_tutorial | /12_if_statements.py | 640 | 4.3125 | 4 | ######## If Statements ########
is_male = True
if is_male:
print("You are a male.")
else:
print("You are not a male.")
is_tall = True
if is_male or is_tall:
print("You are a male or tall or both.")
else:
print("You are neither male or tall.")
if is_male and is_tall:
print("You are a tall male... | true |
005f339a14302990e4093adebbd0428893e55377 | mauroindigne/Python_fundementals | /02_basic_datatypes/1_numbers/02_01_cylinder.py | 296 | 4.25 | 4 | '''
Write the necessary code calculate the volume and surface area
of a cylinder with a radius of 3.14 and a height of 5. Print out the result.
'''
h = 5
r = 3.14
pie = 3.14159265359
volume = (pie * (r ** 2) * h)
surface = ((2 * pie * r * h) + (2 * pie * (r ** 2)))
print(volume)
print(surface) | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.