blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
5c7b1098dcfd64a60e4f92a793317e8558cbf84e | Tabed23/Rock_Paper_Secissor | /rps.py | 1,145 | 4.15625 | 4 | from random import randint
def draw(player, computer):
return player == computer
def is_win(player, computer):
if player == 'r' and computer == 'p':
return 'computer'
elif player == 'p' and computer == 's':
return 'computer'
elif player == 's' and computer == 'r':
... | false |
19760386a0ab964d8bd37d8edb421a72f52c6fbe | kyeeh/holbertonschool-interview | /0x09-utf8_validation/0-validate_utf8.py | 1,247 | 4.34375 | 4 | #!/usr/bin/python3
"""
Write a method that determines if a given data set represents a valid
UTF-8 encoding.
Prototype: def validUTF8(data)
Return: True if data is a valid UTF-8 encoding, else return False
A character in UTF-8 can be 1 to 4 bytes long
The data set can contain multiple characters
Th... | true |
9d967f528151f408f84ff63ca8866ff204e7cfcf | wakoliVotes/Sorting-Elements-Python | /SortListElementsPython.py | 2,284 | 5 | 5 | # In python, we can adopt proper statements and tools that can help sort values
# One can sort values in ascending or sort them in descending order
# In this short example, we are demonstrating sorting items in ascending order
print("|----------------------------------------------------------------------------------... | true |
6adfdb3b77ea3fa1eca8ff303de96769616696e2 | Mguer07/script | /Dice game.py | 325 | 4.125 | 4 | import random
min = 1
max = 12
roll_again = "yes"
while roll_again == "yes" or roll_again == "y":
print ("Rolling the dices")
print ("The values are....")
print ("person 1:",random.randint(min, max))
print ("person 2:",random.randint(min, max))
roll_again = input("Roll the dices again... | true |
5eeea32a4c607db336cecd278854c5f5f7ac53ed | FCHSCompSci/dictionaryinaction-Marsh14-Eric | /Dict Project.py | 2,117 | 4.25 | 4 | #setting up dictionary
off = {
'QB' : '',
'RB' : '',
'WR_1': '',
'WR_2': '',
'WR_3': '',
'TE_1': '',
'LT': '',
'LG': '',
'C': '',
'RG': '',
'RT':'',
}
#setting up functions to make more user freindly
def printdict(a_dict):
for key, value in a_dict.items():
print("%s... | false |
2a9729d52e06fc08d9fd0a08053ec2aa2f14bdf1 | yckfowa/codewars_python | /6KYU/Count characters in your string.py | 442 | 4.21875 | 4 | """
count the number of times a character shows up in the string and output it as a dictionary
"""
def count(string):
new_dict = {}
for ch in string:
if ch not in new_dict:
new_dict[ch] = 1
else:
new_dict[ch] += 1
return new_dict
-------------------------------
#... | true |
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 |
5809d2933fd0b2d894ec1451b9a5da48431e78a9 | neternefer/codewars | /python/is_palindrome.py | 1,419 | 4.34375 | 4 | def is_palindrome1(s):
"""(str) -> bool
Return True if and only if s is a palindrome.
>>> is_palindrome1('noon')
True
>>> is_palindrome1('racecar')
True
>>> is_palindrome1('dented')
False
"""
return reverse(s) == s
def is_palindrome2(s):
"""(str) -> bool
Return True if a... | false |
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 |
59a02bd70ce78ee8b8963954c6b62d5446aa185e | elmotecnologia/Curso_Python | /mostrarmaiorde3.py | 323 | 4.125 | 4 | nota1 = input("Digite a primeira nota: ")
nota2 = input("Digite a segunda nota:" )
nota3 = input("Digite a terceira nota: ")
if nota1 > nota2 and nota1 > nota3:
print ("A maior nota é : ",nota1)
elif nota2 > nota3 and nota2 > nota1:
print ("A maior nota é: ", nota2)
else:
print ("A maior nota é: ", nota3) | false |
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 |
44c14d997476b896ccba854408a05af6b9130af6 | favuur/Aptech_Python | /class.py | 1,752 | 4.1875 | 4 | """class Aptech:
name="oloruntoba favour"
obi=Aptech()
print(obi.name)
class Aptech:
name="oloruntoba favour"
obi=Aptech()
obi1=Aptech()
print(obi.name)
print(obi1.name)
#INITIALIZE A CLASS
class Aptech:
def __init__(self,name,age):
self.nameee=name
self.ageeee=age
ob2=Aptech("favour",29)... | false |
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 |
0e985e0b7d2396bba1a5ce0d0f02625a999dec5e | fffk3045167/desktop_WSL | /python/insertionSort.py | 430 | 4.125 | 4 | # 插入排序
def insertionSort(arr):
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
while arr[j] > key and j >= 0:
arr[j+1] = arr[j]
arr[j] = key
j = j - 1
return arr
def showArr(arr):
for i in range(len(arr)):
print(arr[i], end = ' '... | false |
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 |
87b452a9c96fae96245b0a41ed50faa8c97a4d29 | cygarxtin/python | /for_loops.py | 691 | 4.53125 | 5 | #for loop statement with range
for i in range(1,11):
#print out [1,2,3,4,5,6,7,8,9,10]
print i
#for loop statement without range
for j in [1, 2, 3]:
#print out [1,2,3]
print j
#for loop statement with three arguments
for a in range(0, 20, 2):
#print out [0,2,4,6,8,10,12,14,16,18]
print a
#for loop statement pri... | false |
89c22ac70d948852aa4703f18cf56e0a31ce66d6 | XVXVXXX/leetcode | /0125.py | 1,121 | 4.125 | 4 | # 125. 验证回文串
# 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。
# 说明:本题中,我们将空字符串定义为有效的回文串。
# 示例 1:
# 输入: "A man, a plan, a canal: Panama"
# 输出: true
# 示例 2:
# 输入: "race a car"
# 输出: false
# 来源:力扣(LeetCode)
# 链接:https://leetcode-cn.com/problems/valid-palindrome
# 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
class Solution:
def... | false |
18797636607257baf1cb465a801524c36abe3990 | AliceSkilsara/python | /tasks/task7.py | 1,040 | 4.375 | 4 | # Проверьте, является ли введённое пользователем с клавиатуры натуральное число — простым.
# Постарайтесь не выполнять лишних действий (например, после того, как вы нашли хотя бы один
# нетривиальный делитель уже ясно, что число составное и проверку продолжать не нужно).
# Также учтите, что наименьший делитель натураль... | false |
d8ef648b1f3a7df5a4612f79f6af7b32a9e9690f | AliceSkilsara/python | /tasks/task18.py | 414 | 4.21875 | 4 | #Создать программу, которая будет проверять попало ли случайно выбранное из отрезка [5;155] целое число в интервал
# (25;100) и сообщать результат на экран.
import random
a=random.randint(5,155)
print("Random number is ",a)
if a<25 or a>100:
print("Out of range")
else:
print("In range")
| false |
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 |
a991abf55ca012b8253cea08d6bccf80cc35f8d5 | dimitar-daskalov/SoftUni-Courses | /python_basics/labs_and_homeworks/03_conditional_statements_advanced_exercise/08_on_time_for_the_exam.py | 1,686 | 4.15625 | 4 | exam_hour = int(input())
exam_minute = int(input())
hour_of_arrival = int(input())
minute_of_arrival = int(input())
exam_time_minutes = (exam_hour * 60) + exam_minute
minutes_of_arrival = (hour_of_arrival * 60) + minute_of_arrival
minutes_late = minutes_of_arrival - exam_time_minutes
minutes_left = exam_time_minutes -... | false |
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 |
b1df355d842c1f5db5d2302f8a7810228c6ffe7f | chu83/python-basics | /03/operator-logical.py | 474 | 4.125 | 4 | #논리연산자(NOT, OR, AND)
a = 30
b1 = a <= 30
b2 = not b1
#논리합 or
b3 = a <= 30 or a >= 100
#논리곱 and
b4 = a <= 30 and a>=100
print(b1, b2)
print(not a <= 10)
print(b3)
print(b4)
print(True or 'logical')
print(False or 'logical')
print([] or 'logical')
print([19, 20] or 'logical')
print('operator' or 'logicla')
print(No... | false |
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 |
996bc5aa6ce1db7254ad71d326de11bb795cf206 | pzeiger/aspp_day2_exercises | /exc1_creating_python_package/animals/dangerous/fish.py | 309 | 4.125 | 4 | class Fish:
'''
'''
def __init__(self):
'''
'''
self.members = ['Shark', 'Cod', 'Hering']
def printMembers(self):
'''
'''
print('The members of the class "Fish" are:')
for member in self.members:
print('\t %s' %member)
| false |
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 |
6472112759639ba52f6b1a995d07b7735546bf6e | Focavn/Python-100-Days | /Day01-15/code/Day12/str1.py | 976 | 4.125 | 4 | """
字符串常用操作
Version: 0.1
Author: 骆昊
Date: 2018-03-19
"""
import pyperclip
# 转义字符
print('My brother\'s name is \'007\'')
# 原始字符串
print(r'My brother\'s name is \'007\'')
str = 'hello123world'
print('he' in str)
print('her' in str)
# 字符串是否只包含字母
print(str.isalpha())
# 字符串是否只包含字母和数字
print(str.isalnu... | false |
573e89d5ffa71f7b477ebe165a2d1755cdcb4f8e | chjaju/ssss | /ex110.py | 395 | 4.25 | 4 | #if문이 참이므로 아래있는 else : print("4")는 필요없고 if False: print("1") print("2") else: print("3")으로 간후 참이므로 false문으로 가지않고
#else로 가서 3이 출력된다.
if True :
if False:
print("1")
print("2")
else:
print("3")
else :
print("4")
#if문이 끝났으므로 5가 또 출력된다.
print("5")
#정답=3,5 | false |
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 |
7c5ca6ea977f11f8f1e144255c34b765a7b2c6ae | BillZong/CorePythonProgrammingDemos | /11/11.7.py | 924 | 4.5 | 4 | #!/usr/bin/env python
"""Answer for 11.7 in chapter 11."""
def two_list_to_tuple_list(list1, list2, mapper=map):
"""Using mapper function to 'zip' two lists into one."""
if len(list1) != len(list2):
return None
else:
if mapper == map:
return mapper(None, list1, list2)
... | false |
c1031fce78974833bd1212b04233affa2e938091 | hevalenc/Python-Complete-Course-For-Beginners | /global_local_nonlocal.py | 638 | 4.15625 | 4 | print('Alterando a variável Global com uma função')
x = 'global'
def function1():
global x
y = 'Local'
x = x * 2
print('x: ', x)
print('y: ', y)
print('Global x: ', x)
function1()
print('Global x: ', x) #a função alterou a variável x
print('\nGlobal e Local sem alterações')
a = 5
def function2()... | false |
8dab6a432c805ee78c8d27de9be80511ffb40712 | hevalenc/Python-Complete-Course-For-Beginners | /inheritance.py | 1,332 | 4.3125 | 4 | print('Herança em Python')
'''Criando um classe e um objeto em Python'''
class myBird:
def __init__(self):
print('... myBird class constructor is executing ...')
def whatType(self):
print('I am a Bird ...')
def canSwim(self):
print('I can swim ...')
'''A classe myPenguin herdando... | false |
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 |
d98256ff20e7c8f16eefdbfbe6194f9ea30978d5 | Indiana3/python_exercises | /wb_chapter1/exercise31.py | 534 | 4.21875 | 4 | ##
# Convert kilopascals to pounds per square inch,
# millimeters of mercury and atmospheres
#
PA_IN_KPA = 1000
PA_IN_PSI = 6895
PA_IN_MMHG = 133.322
PA_IN_ATM = 101325
# Read the pressure in KPa
kpa = float(input("Please, enter a pressure" \
" in KPa: "))
# Convert to PSI
psi = kpa / PA_IN_KPA * PA_IN_PSI
# Con... | false |
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 |
e7860a52633ea24a1f729bc4ca837c943f6d9489 | calumpetergunn/functions_lab | /src/python_functions_practice.py | 1,559 | 4.21875 | 4 | def return_10():
return 10
def add(number_1, number_2):
return number_1 + number_2
def subtract(number_1, number_2):
return number_1 - number_2
def multiply(number_1, number_2):
return number_1 * number_2
def divide(number_1, number_2):
return number_1 / number_2
def length_of_string(string):
... | false |
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 |
4d765644d6e5a7bbe84541972a16ccd2865e5489 | azalio/learn_alg | /selection_sort.py | 994 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from random import randint
def selection_sort(rand_list):
for position in range(0, len(rand_list)):
min_position = find_min(rand_list, position)
swap(rand_list, position, min_position)
position += 1
return rand_list
def find_min(rand_list, position):
min_value ... | false |
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 |
cc06e7ff87923e871d168d43d5981f5b1f0b1d44 | ivandos/python-quiz | /prime_num.py | 678 | 4.1875 | 4 | # Задача 2: "Наибольший простой делитель"
# Простые делители числа 13195 - это 5, 7, 13 и 29.
# Каков самый большой делитель числа 600851475143, являющийся простым числом?
import math
def biggest_divider(num: int):
'''
Function to find the biggest divider of a simple value
'''
max_num = 0
for i... | false |
b8218ce3cdfab46aaa1ebe310e5f2496904f136c | JpradoH/Ciclo2Java | /Ciclo 1 Phyton/Unidad 2/Ejercicios/Funcion Format.py | 733 | 4.1875 | 4 | # saca "El valor es 12
print ("El valor es {}".format(12))
# saca "El valor es 12.3456
print ("El valor es {}".format(12.3456))
# Tres conjuntos {}, el primero para el primer parámetro de format(), el segundo para el segundo
# y así sucesivamente.
# saca "Los valores son 1, 2 y 3"
print ("Los valores son {}, {} y {}"... | false |
ed99ff3dcc7cdc2dd4dbebe6840e3812fb547a41 | AlyoshaS/ProgFuncional-Python | /Exercicios-Prog-Funcional/4.py | 490 | 4.125 | 4 | #!/usr/bin/python
# coding: latin-1
# início - recursão mútua
# 04. Defina dois predicados lógicos '[even]' e '[odd]' que
# indiquem se um número 'n' passado como argumento é par ou ímpar respectivamente.
# Não é permitido o uso do operador '%' (resto da divisão).
def even(n):
if n == 0:
return True
e... | false |
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 |
833dcac2c6987ea820f492b73f7ed48d41b47806 | giri110890/python_gfg | /Control_Flow/__iter__and__next__.py | 1,941 | 4.5 | 4 | # Python code demonstrating basic use of iter()
listA = ['a', 'e', 'i', 'o', 'u']
iter_listA = iter(listA)
try:
print( next(iter_listA))
print( next(iter_listA))
print( next(iter_listA))
print( next(iter_listA))
print( next(iter_listA))
print( next(iter_listA))
print( next(iter_li... | false |
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 |
e207f0bb2269b3c535ba3d33e06b729f0d4fedb4 | ShikhaShrivastava/Python-core | /OOP Concept/Operator Overloading.py | 1,768 | 4.21875 | 4 | '''Operator Overloading'''
#type-1
'''print(10+20+30) #addition
print('sh'+'ik'+'ha') #concatination'''
#**********MAGIC METHOD*******************
#type-2
'''class Book:
def __init__(self,page):
self.page=page
b1=Book(200)
b2=Book(400)
#print(b1+b2) --->TypeError :Unsupported operand type
print(b1.page... | false |
ced43f858acb12ba007d9585fe5e47a8b3432115 | ShikhaShrivastava/Python-core | /List/Accessing Index & Value.py | 405 | 4.28125 | 4 | '''Accessing Index and Value of element from list'''
print("I-Accessing Index & Value of element from list")
print(" ")
print("1.Enumerate")
lst = [1, 2, 3, 4, 5, 6, 7]
print(lst)
for i, j in enumerate(lst):
print("Index is:", i, "& Value is:", j)
print(" ")
print("2.Range Function")
lst = [1, 2, 3, 4, 5, 6, 7]
p... | false |
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 |
4167630d5010c99a8545ba6e0d1b64ea478ac033 | sreekanth-s/python | /old_files/temp.py | 863 | 4.125 | 4 | def sum_of_numbers_in_alphanumeric_string(string=""):
"""count the sum of inidividual charecters that are numbers in a given string"""
total = 0
for val in string:
if val.isnumeric():
total=total+int(val)
return total
#x=sum_of_numbers_in_alphanumeric_string("34g3v6456b456456b56b4... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.