blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
3da236e3ada6bafbcef1cfe174dc337ee879fbd4 | ncaleanu/allthingspython | /advanced_func/collections-exercises.py | 2,617 | 4.5 | 4 | from collections import defaultdict, OrderedDict, namedtuple, deque
# PRACTISING WITH SOME DATA STRUCTURES FROM COLLECTIONS
def task1() -> defaultdict:
"""
- create a `defaultdict` object, and its default value would be set to the string `Unknown`.
- Add an entry with key name `Alan` and its value ... | true |
768599312e43354921ef68be9e2ac25d98f03b69 | MaxOvcharov/stepic_courses | /parser_csv_rss/login_validator.py | 1,045 | 4.21875 | 4 | """ Login validator """
import re
def check_login(login):
""" This function checks an login on the following conditions:
1) Check login using a regular expression;
2) Check len of login < 1 and login < 21;
3) Check the prohibited symbol in login;
4) Check login ends on latin letter... | true |
a21d872ddaa4c65c18600112e2dfefe5f611a375 | 7558/GeekBrains | /time.py | 460 | 4.3125 | 4 | # 2. Пользователь вводит время в секундах.
# Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс.
# Используйте форматирование строк.
seconds = int(input("Введите кол-во секунд: "))
minutes = seconds // 60
hours = minutes // 60
print("Время: %02d:%02d:%02d" % (hours, minutes % 60, seconds % 60)) | false |
ed4f48871da3f8540991cd346414a40950ea76a3 | MohammedAbuMeizer/DI_Bootcamp | /Week_6/Day_4/Exercises XP/Exercise 12 Cinemax/Exercise 12 Cinemax.py | 898 | 4.15625 | 4 | age = input("enter your age please or exit: ")
age = int(age)
total = 0
while age != -1 :
if age < 3 :
total = total + 0
age = input("enter your age please or exit: ")
age = int(age)
elif age >= 3 and age <= 12 :
total = total + 10
age = input("enter your age please ... | false |
5cb487213c686fb99dafa28ba059dfa438b79183 | MohammedAbuMeizer/DI_Bootcamp | /Week_7/Day_2/Exercises XP #1/Exercise 2 What’s Your Favorite Book/Exercise 2 What’s Your Favorite Book .py | 284 | 4.125 | 4 | title = input("Enter a title of your favorite Book : ")
def favorite_book(title="Alice in Wonderland"):
print(f"One of my favorite books is {title}")
while title == "" or title ==" ":
print("You didnt type any title we will put our default")
title = "Alice in Wonderland"
favorite_book(title)
| true |
1c4d365c66a38cb35a2fee5fe6656d829888bc03 | mwilso17/python_work | /files and exceptions/reading_file.py | 508 | 4.34375 | 4 | # Mike Wilson 22 June 2021
# This program reads the file learning_python.txt contained in this folder.
filename = 'txt_files\learning_python.txt'
print("--- Reading in the entire file:")
with open(filename) as f:
contents = f.read()
print(contents)
print("\n--- Looping over the lines in the file.")
with open(fil... | true |
77c0c93b87eacd40750c50ff1b4044ed9db38b6d | mwilso17/python_work | /OOP and classes/dice.py | 1,093 | 4.46875 | 4 | # Mike Wilson 22 June 2021
# This program simulates dice rolls and usues classes and methods from the
# Python standard library
from random import randint
class Die:
"""Represents a die that can be rolled."""
def __init__(self, sides=6):
"""Initialize the die. 6 by default."""
self.sides = sides
def ... | true |
3bd1bc2752c36de661bea0628e1e544fa030d403 | mwilso17/python_work | /functions/cars.py | 412 | 4.25 | 4 | # Mike Wilson 20 June 2021
# This program stores info about a car in a dictionary.
def make_car(make, model, **other):
"""makes a dictionary for a car"""
car_dictionary = {
'make': make.title(),
'model': model.title(),
}
for other, value in other.items():
car_dictionary[other] = value
return ... | true |
0e0f98ebf7b50fa048c7d6f384cf7a297ac897a9 | mwilso17/python_work | /lists/lists_loops/slices/our_pizzas.py | 871 | 4.46875 | 4 | # Mike Wilson 8 June 2021
# This program slices from one list and adds it to another, while keeping
# two seperate lists that operate independantly of one another.
my_favorite_pizzas = ['pepperoni', 'deep dish', 'mushroom']
your_favorite_pizzas = my_favorite_pizzas[:]
print("My favorite pizzas are: ")
print(my_favori... | true |
2d452ea8ecfeedd2a5c64bf6c75ffc230358f58b | mwilso17/python_work | /user input and while loops/movie_tickets.py | 590 | 4.15625 | 4 | # Mike Wilson 15 June 2021
# This program takes user input for age then returns the price of their movie
# ticket to them.
prompt = "\nWhat is your age? "
prompt += "\nEnter 'quit' when you are finished."
while True:
age = input(prompt)
if age == 'quit':
break
age = int(age)
if age < 3:
print("Your ... | true |
142c6b7728d282d6d2e1e60eddb6d50cb4193f12 | mwilso17/python_work | /functions/messages.py | 648 | 4.28125 | 4 | # Mike Wilson 20 June 2021
# This program has a list of short messages and displays them.
def show_messages(messages):
"""print messages in list"""
for message in messages:
print(message)
def send_messages(messages, sent_messages):
"""print each message and move it to sent messages"""
print("\nSending al... | true |
a558286ad23fad033b1a2d61fd7d3e959723c13f | mwilso17/python_work | /user input and while loops/deli.py | 841 | 4.5 | 4 | # Mike Wilson 17 June 2021
# This program simulates a sandwich shop that takes sandwich orders
# and moves them to a list of finished sandwiches.
# list for sandwich orders
sandwich_orders = ['club', 'ham and swiss', 'pastrami', 'turkey', 'veggie']
# empty list for finished sandwiches
finished_sandwiches = []
# the ... | true |
5fdff9be03e18e4ff1c7cc64cd210e32a82e3acf | mwilso17/python_work | /user input and while loops/dream_vacation.py | 674 | 4.34375 | 4 | # Mike Wilson 17 June 2021
# The following program polls users about their dream vacations.
# 3 prompts to be used
name_prompt = "\nWhat is your name? "
vacation_prompt = "If you could vacation anywhere in the world, where would you go? "
next_prompt = "\nWould someone else like to take the poll? (yes/no): "
# empty ... | true |
17537c25a434845c6e187f034b266b03648dacc4 | Trice254/alx-higher_level_programming | /0x06-python-classes/5-square.py | 1,413 | 4.53125 | 5 | #!/usr/bin/python3
"""
Module 5-square
Defines class Square with private size and public area
Can access and update size
Can print to stdout the square using #'s
"""
class Square:
"""
class Square definition
Args:
size (int): size of a side in square
Functions:
__init__(self, size)
... | true |
429d7655eb45e48f079bdbda71dc8226a0dba108 | Trice254/alx-higher_level_programming | /0x07-python-test_driven_development/5-text_indentation.py | 555 | 4.21875 | 4 | #!/usr/bin/python3
"""
Text Indention module
"""
def text_indentation(text):
"""
print text
2 new lines after each of these characters: ., ? and :
Args:
text (str): text
Raise
TypeError: when text is not str
"""
if type(text) is not str:
raise TypeError("tex... | true |
495df61d0c1e33a0a9f167d501c471fdad9e8a83 | Trice254/alx-higher_level_programming | /0x06-python-classes/4-square.py | 1,192 | 4.625 | 5 | #!/usr/bin/python3
"""
Module 4-square
Defines class Square with private size and public area
Can access and update size
"""
class Square:
"""
class Square definition
Args:
size (int): size of a side in square
Functions:
__init__(self, size)
size(self)
size(self, value)... | true |
12852a2bc16c9fc29f21c49f2fee14258cd2dcc2 | Trice254/alx-higher_level_programming | /0x07-python-test_driven_development/4-print_square.py | 654 | 4.5 | 4 | #!/usr/bin/python3
"""
Square Printer Module
"""
def print_square(size):
"""
Print square using #
Args:
size (int) : Size of Square
Raise
TypeError: if size is not int
ValueError: if size is less than 0
TypeError: if size is float and less than 0
Return:... | true |
9ec77aa854fa81a09b3007e3c8662f8c22c72cbe | ajjaysingh/Projects | /mybin/pre_versions/addword_v1.0.py | 2,663 | 4.46875 | 4 | #!/Library/Frameworks/Python.framework/Versions/3.4/bin/python3
# File Name : addword.py
# Description : It adds the provided word to my custom dictionary. The new words that I learn.
# Author : Ajay
# Date : 2016-05-03
# Python Version : 3
#==================================================
import os
import s... | true |
caec37b13d91ee25e2a4c8322d1d1f9035277521 | Morgenrode/MIT_OCW | /ex3.py | 213 | 4.125 | 4 | '''Given a string containing comma-separated decimal numbers,
print the sum of the numbers contained in the string.'''
s = input('Enter numbers, separated by commas: ')
print(sum(float(x) for x in s.split(',')))
| true |
fbbb1c4ec214fb01e299d4bbd3f44de9100966d6 | oswalgarima/leetcode-daily | /arrays/max_prod_two_elements.py | 1,334 | 4.21875 | 4 | """
1464. Maximum Product of Two Elements in an Array
https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array/
Given the array of integers nums,
you will choose two different indices i and j of that array.
Return the maximum value of (nums[i]-1)*(nums[j]-1).
Example:
Input: nums = [3,4,5,2]
Output: ... | true |
f0d0be61871f9357033bc8148e11e83edcfc28d0 | oswalgarima/leetcode-daily | /arrays/max_prod_three_nums.py | 681 | 4.125 | 4 | """
628. Maximum Product of Three Numbers
https://leetcode.com/problems/maximum-product-of-three-numbers/
Given an integer array nums, find three numbers whose product is maximum and return the maximum product.
Example:
Input: nums = [1,2,3]
Output: 6
Input: nums = [1,2,3,4]
Output: 24
"""
# Runtime: 252ms (73.64%)... | true |
914f699c06f95507eba2da62deaa44aaf25519ef | limbryan/sudoku_solver | /solver.py | 2,292 | 4.1875 | 4 | import numpy as np
import matplotlib.pyplot as plt
# Takes in a position in the board and outputs if it is possible or not to put the number n inside
def possible(board,x,y,n):
# checks the row
for i in range(len(board[0])):
# exits the function straightaway if the number n already exists in the row... | true |
e2c613f1f0b1a69a554fb52d7f63b7a36a395439 | DavidErroll/Euler-Problems | /Problem_14.py | 1,570 | 4.1875 | 4 | # The following iterative sequence is defined for the set of positive integers:
# n → n/2 (n is even)
# n → 3n + 1 (n is odd)
# Using the rule above and starting with 13, we generate the following sequence:
# 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
# It can be seen that this sequence (starting at 13 and finishing... | true |
de6fa700d107e662dc8fcf8b99e11cd94df60e80 | CODEVELOPER1/PYTHON-FOLDER | /SECRECT_WORD_GAME.py | 566 | 4.28125 | 4 | #Secert Word Game with loops
secert_word = "giraffe" #secert word
guess = "" #stores user response
guess_count = 0
guess_limit = 3
out_of_guesses = False
while guess != secert_word and not(out_of_guesses):
if guess_count < guess_limit:
guess = input("Enter Secert Word Guess. You Only have 3 tries, Choose ... | true |
4ed6dd63fd3eccf0ffebcc101885dce17354a61c | mmrubayet/python_scripts | /codecademy_problems/Wilderness_Escape.py | 2,805 | 4.3125 | 4 | print("Once upon a time . . .")
######
# TREENODE CLASS
######
class TreeNode:
def __init__(self, story_piece):
self.story_piece = story_piece
self.choices = []
def add_child(self, node):
self.choices.append(node)
def traverse(self):
story_node = self # assign story_node to self
print(sto... | true |
9417c401c7b1c7d47b79b381d0aaf82162266b18 | mmrubayet/python_scripts | /codecademy_problems/Sorting Algorithms with python/bubble_sort.py | 310 | 4.15625 | 4 | from swap import *
def bubble_sort(arr):
for el in arr:
for index in range(len(arr)-1):
if arr[index] > arr[index + 1]:
swap(arr, index, index + 1)
##### test statements
nums = [5, 2, 9, 1, 5, 6]
print("Pre-Sort: {0}".format(nums))
bubble_sort(nums)
print("Post-Sort: {0}".format(nums))
| true |
3d39fe527f861f009c8d8817d5355c12014555df | uniinu1/python_study | /python_ch2.py | 586 | 4.125 | 4 | # 출력하기
print("- 출력하기")
print(10)
print(20, 10)
# c언어와는 다른 숫자 출력(숫자 형식 생각하지 않아도 됨)
print("- 다른 자료형의 숫자 출력하기")
a = 10
b = 10.5
print(a, b)
# 다양한 자료형 출력
print("- 다양한 자료형 출력")
a = "Hello"
b = "Goorm!"
c = "10" # 문자열
d = 10 # 숫자
e = b
result = a + b
d = 5
# result = a + d 불가능
print(a, b, c, d, e... | false |
45905e00ddeb09731899b3fb4482103e66e695d4 | blakeskrable/First-Project | /First.Project.py | 248 | 4.21875 | 4 | number=int(input("Guess a number between 1-10: "))
while number != 10:
print("Wrong! Guess Again!")
number=int(input("Enter a new number: "))
if number == 10:
print("Congratulations! Good Guess! You Have Completed The Program!")
| true |
82b96585eba498023c2b5c9bda0017f475f3fee6 | kaloyandenev/Python-learning | /Shopping List.py | 828 | 4.15625 | 4 | initial_list = input().split("!")
command = input()
while not command == "Go Shopping!":
command = command.split()
action = command[0]
product_one = command[1]
if action == "Urgent":
if product_one not in initial_list:
initial_list.insert(0, product_one)
elif action == "Unnecess... | false |
491bbdf5f6977a3b4878d965382d242ec432059f | kaloyandenev/Python-learning | /Smallest of Three Numbers.py | 257 | 4.125 | 4 | def find_smallest_number(n1, n2, n3):
list_of_numbers = [n1, n2, n3]
min_num = min(list_of_numbers)
return min_num
num_one = int(input())
num_two = int(input())
num_three = int(input())
print(find_smallest_number(num_one, num_two, num_three))
| false |
0102e2f8ebaab1d92f6a5fa7c2ffc2d134fd96f1 | ashilp/Pleth_Test | /pleth_2.py | 1,082 | 4.125 | 4 | import os
def read_path(path):
'''
Function to list out directories, subdirectories, files with proper indentation
'''
#indent according to the level of the directory
level = path.count("\\")
print("\n************Output************\n")
if not os.path.exists(path):
print("... | true |
75cb6dc8589bfb41f161f89bbd4d3849d2ecdc3d | jcohenp/DI_Exercises | /W4/D2/normal/ex_6.py | 1,739 | 4.5625 | 5 |
# A movie theater charges different ticket prices depending on a person’s age.
# if a person is under the age of 3, the ticket is free
# if they are between 3 and 12, the ticket is $10
# and if they are over age 12, the ticket is $15 .
# Apply it to a family, ask every member of the famil... | true |
69a0eadad9f12debc8722949571a4ec9adca922f | jcohenp/DI_Exercises | /W4/D2/normal/ex_3 2.py | 695 | 4.40625 | 4 |
# Recap – What is a float? What is the difference between an integer and a float?
# Earlier, we tried to create a sequence of floats. Did it work?
# Can you think of another way of generating a sequence of floats?
# Create a list containing the sequence 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5 without hard-coding the sequence.
... | true |
4d7f787e45e409ae15a01e88740f8acba4d43c45 | jcohenp/DI_Exercises | /W4/D1/ninja/ex_1/ex_2.py | 205 | 4.25 | 4 | # Given two variables a and b that you need to define, make a program that print Hello World only if a is greater than b.
a = 4
b = 6
if a > b:
print("Hello World")
else:
print("a is too small") | true |
a44bfcc01ea351adf209f4642c6dd8510410f435 | ramyasinduri5110/Python | /strings.py | 942 | 4.34375 | 4 | #Strings in python
#how we can write strings in python
str1_singlequote='Hello World!'
str2_doublequotes="The string declaration in double quotes"
str_block=''' this is the biggest block of code with
multiple lines of text
'''
#type gives you the information about the data type
print(type(" Hey! there I am using ... | true |
562b8a5b2b3d0b2dfedc2ba890c3adbd22a57bf1 | neelpopat242/audio_and_image_compression | /app/utils/images/linalg/utils.py | 2,937 | 4.375 | 4 | import math
def print_matrix(matrix):
"""
Function to print a matrix
"""
for row in matrix:
for col in row:
print("%.3f" % col, end=" ")
print()
def rows(matrix):
"""
Returns the no. of rows of a matrix
"""
if type(matrix) != list:
return 1
r... | true |
b6667c81ac17100692ae20ee76abe20ac9bc9d29 | NaveenLDeevi/Coursera-Python-Data-Structures | /Week#3_ProgrammingAssg_part#1.py | 463 | 4.71875 | 5 | # Coursera- Data structures course - Week#3.
#7.1 Write a program that prompts for a file name, then opens that file and reads
#through the file, and print the contents of the file in upper case. Use the file
#words.txt to produce the output below.You can download the sample data at
#http://www.pythonlearn.com/code/... | true |
d4eb39c121483d83e135c3469c31c57ce457a239 | tanmay2298/The-Python-Mega-Course-Udemy | /Tkinter GUI/script1.py | 746 | 4.4375 | 4 | from tkinter import * # Imports everything fromt the tkinter library
# Tkinter program is mainly made of two things -- Window and Widgets
window = Tk() # Creates an empty window
def km_to_miles():
print(e1_value.get())
miles = float(e1_value.get())*1.6
t1.insert(END, miles)
b1 = Button(window, text = "Ex... | true |
4b62175aefa73723e3b4a17ec1783c938df829fd | mishuvalova/Paradigm-homework | /string_task.py | 1,450 | 4.375 | 4 | # Given a string, if its length is at least 3,
# add 'ing' to its end.
# Unless it already ends in 'ing', in which case
# add 'ly' instead.
# If the string length is less than 3, leave it unchanged.
# Return the resulting string.
#
# Example input: 'read'
# Example output: 'reading'
def verbing(s):
length = len(s)
... | true |
a689db24d6b8dd07f061f89f3d729792dfce3096 | HumpbackWhaIe/python_programming | /mycode/3_string/yesterday_count.py | 592 | 4.125 | 4 | # yesterday.txt 파일을 열기
"""
open mode
r : read, w : write
rb : read binary, wb : write binary
"""
def file_read(file_name):
with open(file_name, "r") as file:
lyric = file.read()
return lyric
read = file_read("yesterday.txt")
print(read)
num_of_yesterday = read.upper().count("YESTERDAY")
print(f'... | false |
df9a29f6a9e12dffe386f1bd306fd0a23aad1e56 | elentz/1st-Semester-AP | /dictproblems1.py | 1,074 | 4.5625 | 5 | 1. Write a Python script to add key to a dictionary.
Sample Dictionary : {0: 10, 1: 20} Expected Result : {0: 10, 1: 20, 2: 30}
2. Write a Python script to concatenate following dictionaries to create a new one.
Sample Dictionary : dic1={1:10, 2:20} dic2={3:30, 4:40} dic3={5:50,6:60} Expected Result : {1: 10... | true |
305e920c490417d773339b1f73aae7f640d31d07 | SiegfredLorelle/pld-assignment2 | /Assignment2_Program1.py | 402 | 4.46875 | 4 | """Create a program that will ask for name, age and address.
Display those details in the following format.
Hi, my name is _____. I am ____ years old and I live in _____ .
"""
name = input("Please enter your name: ")
age = int(input("Please enter your age: "))
address = input("Please enter you address: ")
... | true |
6e04f1bead3cb9a26e25b4b5739db6a66631fa90 | spoorthi198/Python_QA | /practicing.py | 1,139 | 4.15625 | 4 | '''print("*" * 10)
birth_year = int(input("enter the birth year"))
age = 2020 - birth_year
print(age) '''
#logical operator
'''has_high_income = True
has_high_credit = False
if (has_high_income and has_high_credit):
print("Eligible for loan")
else:
print("not eligible for true")'''
''' temerature = 45
if t... | false |
cd773903e3d604d872f5b50d0bbbbe0c6e273a43 | MuddCreates/FlexTracker | /flexBackend.py | 488 | 4.125 | 4 | import math
def getPriceD(fileName):
"""
The function reads a text file of the price and name of each possible thing to buy.
It stores each thing as in a dictionary win form
{price:name of thing}
It then returns the dictionary
"""
priceD = {}
file = open(fileName,"r")
... | true |
8111d916e77179b6a49bc9b9cc137b86fb56446d | ravihansa/sorting-algorithms-python | /Sorting Codes/bubble sort.py | 566 | 4.125 | 4 | # Sorts a sequence in ascending order using the bubble sort algorithm.
def bubbleSort( theSeq ):
n = len( theSeq )
# Perform n-1 bubble operations on the sequence
for i in range( 1,n ) :
#print(i)
# Bubble the largest item to the end.
for j in range(0, n-i) :
... | false |
e7f3cb0d77610d3e477e83080408db869b6769e6 | jannekai/project-euler | /037.py | 1,750 | 4.125 | 4 | import time
import math
start = time.time()
def primes():
primes = []
n = 2
yield n
n = 3
while True:
# Return the found prime and append it to the primes list
primes.append(n)
yield n
# Find the next natural number which is not divisible b... | true |
f66e58e76e650ee975c0aad92815373cc6a33274 | DenisRomashov/Stepic | /Python/Programming in Python(Introduction) /PyCharm/3.6/TASKS/Counter.py | 1,231 | 4.15625 | 4 | #Подсчет количества строк, слов и букв в текстовом файле
'''
Для того, чтобы определить количество слов используется следующий алгоритм:
1)Устанавливаем флаг в позицию "вне слова".
2)Как только очередной символ не пробел и флаг имеет значение "вне слова", значит мы вошли в новое слово.
Увеличиваем счетчик слов.
3)Если... | false |
9218ed1c4e3314d3838e36f5516e5880d3e81b5b | vernikagupta/Opencv-code | /Rotation.py | 1,023 | 4.28125 | 4 | '''Rotation of an image means rotating through an angle and we normally rotate the
image by keeping the center. so, first we will calculate center of an image
and then we will rotate through given angle. We can rotate by taking any point on
image, more preferably center'''
from __future__ import print_function
... | true |
ec98c1efd4562a910b4b98129e5cf9aad5b8d7d6 | ksharma377/machine-learning | /univariate-linear-regression/src/main.py | 1,714 | 4.15625 | 4 | """
This is the main file which builds the univariate linear
regression model.
Data filename: "data.csv"
Data path: "../data/"
The model trains on the above data and outputs the parameters and the accuracy.
The number of training cycles is controlled by the variable "epochs".
Input: x
Parameters: w0, w1
Output: y
He... | true |
99181758a8f51a4ae6fc12805cd465feb1a611f6 | gaoruiqing123/proj12 | /zhoukao01/five.py | 1,322 | 4.1875 | 4 | # 5.实现以下功能:(30分)
# s='The column above illustrates apparently' \
# ' the polularity of people ' \
# 'doing exercise in a certain year ' \
# 'from 2013 to 2018.Based upon the data,' \
# 'we can see that python is wonderful. ' \
# 'python is wonderful. Python ' \
# 对这段文字中的单词进行数字统计,并且进行个数升序
# (能够生成字典8分,字典中统计数正确... | false |
e293adefe3f2b90d6e447422070832b53d34685d | nishapagare97/pythone-ideal-programs | /temperature program.py | 653 | 4.28125 | 4 | # question no 2
# author - nisha pagare
#date - 10-0-2021
# program should convert the temperature to the other unit. The conversions are
# f= (9/5c+32)
# c= (5/9f-32)
temp = input("Input the temperature you like to convert? (e.g., 45F, 102C etc.) : ")
degree = int(temp[:-1])
i_convention = temp[-1]
if ... | true |
19da3645aa84ba2c7cd66dda81d5dad120253115 | stanmark2088/allmypythonfiles | /fahrenheit_to_c.py | 954 | 4.59375 | 5 | # Write a Python program to convert a temperature given in degrees Fahrenheit
# to its equivalent in degrees Celsius. You can assume that T_c = (5/9) x (T_f - 32),
# where T_c is the temperature in °C and T_f is the temperature in °F. Your program
# should ask the user for an input value, and print the output. The inp... | true |
932d7741c60da5351cdb12f7ac0ce554232d9490 | CptnReef/Frequency-Counting-with-a-Hash-Table | /HashTable.py | 2,690 | 4.375 | 4 | from LinkedList import LinkedList
class HashTable:
def __init__(self, size):
self.size = size
self.arr = self.create_arr(size)
# 1️⃣ TODO: Complete the create_arr method.
# Each element of the hash table (arr) is a linked list.
# This method creates an array (list) of a given size and populates eac... | true |
97c0335ee71a8d46a3dbbb5ddbd2e3b36bbada6b | colingillette/number-string-puzzles | /interface.py | 2,960 | 4.15625 | 4 | # List Reader
# Input: List
# Output: none, but will print list to console one line at a time
def list_reader(x):
for i in range(len(x)):
print(x[i])
# Fibonacci Sequence
# Input: Number in return series
# Output: List in series
def fib(x):
if x < 1:
return False
elif x == 1:
return... | true |
e29ef9d89303a36e43c0853591d8e596a1321984 | rcadia/notesPython | /More Fuctions.py | 457 | 4.21875 | 4 | #
# Tutorial - 15
# More Functions
#
# Ross Alejandro A. Bendal
# Tuesday June 18 2013 - 5:18PM
#
#
say = ['hey','now','brown']
print say.index('brown') # Search for index that will match in the text parameter
say.insert(2,'show') # Inserts a new value. (Index.'string')
print say
say.pop(2) # Removes a value in inde... | true |
ab4b30dcc2f00fdd64e320336bf731680fc8a646 | Kenn3Th/DATA3750 | /Kinematics/test.py | 1,251 | 4.25 | 4 | """
Handles user input from the terminal and test if
it can connect with the Kinematics_class.py
Also tests for forward and inverse kinematics
"""
import numpy as np
import Kinematics_class as Kc
inner_length = float(input("Length of the inner arm?\n"))
outer_length = float(input("Length of the outer arm?\n"))
answ... | true |
2a1d0766db2123cb8120b5eb9ce958c168340edc | frizzby/coyote-leg | /week2/ex4_done.py | 1,470 | 4.25 | 4 | # 4. Implement a class User with attributes name, age. The instances of this class should be sortable by age by default. So sorted([User(name='Eric', age=34), User(name='Alice', age=22)]) will return a list of sorted users by their age (ASC). How would you sort those objects by name? Don't forget to Implement __str__ m... | true |
55bd778ebeb9465d1be9d73d3fe65b6250125ad9 | mm1618bu/Assignment1 | /HW1_2.6.py | 216 | 4.1875 | 4 | # Ask user for a number
enterNumber = input("Enter a number: ")
# set inital variable to zero
totalnum = 0
# for each integer, add 1
for integer in str(enterNumber):
totalnum += int(integer)
print(totalnum)
| true |
e1063970a9018300bc0d195b71ee5ae8e33b0fd5 | MiguelFirmino/Login-System | /Login System.py | 2,245 | 4.125 | 4 | data_text = []
first_names = []
last_names = []
emails = []
passwords = []
def user_choice():
print('Hello user, create an account or login to an existing one.')
choice = input('Insert "1" if you wish to create an account or "2" if you wish to login: ')
print('\r')
if choice == '1':
... | true |
b26949e87237076f51997342f975fb3ba56ee4d6 | mfahn/Python | /primeFinder.py | 721 | 4.28125 | 4 | #get starting value
user_start = input("Enter a starting value ")
#get ending value
user_end = input("Enter an ending value ")
increment = user_start
count = 2
prime = 1
#find if each value in the range is prime or not
#increment is every number between the user_start and user_end
for increment in range(user_end):
... | true |
4b7a16a68dcf73d62cda7e6e8b46b5c0516eef98 | amariwan/csv-to-db | /csv2sql.py | 1,558 | 4.28125 | 4 | # Import required modules
import csv
import sqlite3
# Connecting to the geeks database
connection = sqlite3.connect('user.db')
# Creating a cursor object to execute
# SQL queries on a database table
cursor = connection.cursor()
# Table Definition
create_table = '''CREATE TABLE IF NOT EXISTS user(
id ... | true |
6a01ba97a6b5558756cf078be161936733a0b406 | SahilTara/ITI1120 | /LABS/lab3-students/q3a.py | 324 | 4.21875 | 4 | ################Question 3a####################
def is_divisible(n, m):
'''(int, int) -> bool
Return if n is divisible by m.
'''
return n % m == 0
x = int(input("Enter 1st integer:\n"))
y = int(input("Enter 2nd integer:\n"))
print(x, "is" + " not" *( not(is_divisible(x,y)) ), "divisible by", y)
... | false |
dd0337366b869db97bb9dbedfcd41a2ecb606028 | SahilTara/ITI1120 | /LABS/lab8-students/NyBestSellers.py | 1,403 | 4.34375 | 4 | def create_books_2Dlist(file_name):
"""(str) -> list of list of str
Returns a 2D list containing books and their information from a file.
The list will contain the information in the format:
Publication date(YYYY-MM-DD), Title, Author, Publisher, Genre.
Preconditions: each line in the file specified... | true |
a97f46d90601ccf4cdae1a5b46862bba1be0a730 | SahilTara/ITI1120 | /LABS/lab3-students/q3b.py | 622 | 4.28125 | 4 | ################Question 3b####################
def is_divisible23n8(n):
'''(int) -> str
Return yes if n is divisible by 2 or 3 and not 8 otherwise no.
'''
if (is_divisible(n, 2) or is_divisible(n, 3)) and (not(is_divisible(n,8))):
return "yes"
else:
return "no"
def is_divisible(n, m... | false |
2fc4a1c279b066bcf01b10b5db8cf014c6e6c394 | SahilTara/ITI1120 | /Datastructures/unbalancedbst.py | 2,328 | 4.125 | 4 | #Binary Search Tree in Python
class Node:
def __init__(self, val):
self.value = val
self.leftChild = None
self.rightChild = None
def insert(self, data):
if self.value == data:
return False
elif self.value > data:
if self.leftChild:
... | false |
33d62035bdab6e284039773e0707cc017ed3b12a | Dmitry-White/CodeWars | /Python/6kyu/even_odd.py | 251 | 4.1875 | 4 | """
Created on Wed Aug 23 2e:28:33 2017
@author: Dmitry White
"""
# TODO: Create a function that takes an integer as an argument and
# returns "Even" for even numbers or "Odd" for odd numbers.
def even_or_odd(n):
return "Even" if n%2 == 0 else "Odd" | true |
bcd5e6cb8f0a48c7f61a2d4ddfddba5bf5579a03 | Dmitry-White/CodeWars | /Python/6kyu/expanded_form.py | 551 | 4.125 | 4 | """
Created on Wed Aug 30 23:34:23 2017
@author: Dmitry White
"""
# TODO: You will be given a number and you will need to return it as a string in Expanded Form.
# For example:
# expanded_form(42), should return '40 + 2'
# expanded_form(70304), should return '70000 + 300 + 4'
def expanded_form(num):
l = len(str... | true |
3ab257aa3e0c99c106f8ae516675cd74f5253c1b | MoAbd/codedoor3.0 | /templating_engine.py | 1,615 | 4.4375 | 4 | '''
It's required to make a templating engine that takes a template and substitute the variables in it. The variables are present in the templates in the form {{some_variable}}. The variables can be nested, so for {{some_{{second_variable}}}} second_variable will be evaluated first and then the other one will be evalua... | true |
ef53c04c4f7085a85906fd95c862136f40f3e1e4 | dzvigelsky/Anti_Mode | /AntiMode.py | 2,203 | 4.25 | 4 | import time
start_time = time.clock() # The clock function
def main():
frequencies = {}
text_file = input("What is the name of the text file you want to read? ")
File_object = open(text_file, 'r') # You can put in the name of the file here
lines = (File_object).readlines() # Read the file and sort... | true |
b80f78ad9e4e5771e748dbe9b4dac54e39f1f044 | fanj1/RobotTeamProject | /sandbox_motors_new/person3_motors.py | 2,677 | 4.625 | 5 | """
Functions for TURNING the robot LEFT and RIGHT.
Authors: David Fisher, David Mutchler and Jun Fan.
""" # DONE: 1. PUT YOUR NAME IN THE ABOVE LINE.
# DONE: 2. Implment turn_left_seconds, then the relevant part of the test function.
# Test and correct as needed.
# Then repeat for turn_left_by_time.
# T... | true |
c7ea01d08f8b054e1570ca82272c5731780fe9f9 | NV230/Stock-Market | /search.py | 1,012 | 4.125 | 4 | # Stock Market
"""
@authors: Keenan, Nibodh, Shahil
@Date: Feb 2021
@Version: 2.2
This program is designed to return the prices of stocks
Allows the user to input the number stocks they want to compare and asks for the ticker for each stock.
"""
# Calculate daily change from close - previous close
# yahoo finance ... | true |
fdd002aae55435a9ebd099484d57e9746d93b927 | heysushil/full-python-course-2020 | /9.for_loop.py | 1,803 | 4.28125 | 4 | # मेरे Youtube चैनल को सबस्क्राइब करना ना भूलो ताकि आपको कोड का पूरा फ़्लो समझमे आए - https://www.youtube.com/channel/UCphs2JfmIClR62wbyf76HDg
# कोई भी सवाल है उसको मेरे यूट्यूब चैनल के कमेन्ट या डिस्कशन सेक्शन मे पूछ सकते हो - https://www.youtube.com/channel/UCphs2JfmIClR62wbyf76HDg/discussion
# और हाँ GitHub पर मुझे... | false |
826d54cefd72c56d387dfec63190cc88b7baeac6 | heysushil/full-python-course-2020 | /2.1.datatypes-in-python.py | 2,845 | 4.125 | 4 | # मेरे Youtube चैनल को सबस्क्राइब करना ना भूलो ताकि आपको कोड का पूरा फ़्लो समझमे आए - https://www.youtube.com/channel/UCphs2JfmIClR62wbyf76HDg
# कोई भी सवाल है उसको मेरे यूट्यूब चैनल के कमेन्ट या डिस्कशन सेक्शन मे पूछ सकते हो - https://www.youtube.com/channel/UCphs2JfmIClR62wbyf76HDg/discussion
# और हाँ GitHub पर मुझे... | false |
1c09b4fdc8672eb7ffae8542592059d1dc5d44d0 | PierceSoul/pythonStudy | /study_基础/面向对象.py | 2,122 | 4.34375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/3/16 下午10:21
# @File : 面向对象.py
import types
# 双下划线开头的实例变量是不是一定不能从外部访问呢?
# 其实也不是。不能直接访问__name是因为Python解释器对外把__name变量改成了_Student__name,
# 所以,仍然可以通过_Student__name来访问__name变量
class Person(object):
def __init__(self, name, age, gender):
self.__... | false |
447f2807b9e1fe0fb10f29ace5f2957080cf6f47 | chao-ji/LeetCode | /python/array/use_input_array_as_auxiliary_memory/lc27.py | 2,362 | 4.15625 | 4 | """27. Remove Element
Given an array nums and a value val, remove all instances of that value in-place and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
The order of elements can be changed. It doesn't matter what ... | true |
3d057680982ace7ea0ab217be3c8667484f1d1f8 | SACHSTech/ics2o1-livehack-2-DanDoesMusic | /problem1.py | 678 | 4.34375 | 4 | ###this takes the 2 speeds the limit and the users speed###
speed = int(input("how fast was the diver: "))
limit = int(input("what is the speed limit: "))
###this chacks if they are above the speed limit it took me a bit but i got it working###
if (speed - limit) >= 1 :
print("your fine is 100$")
elif (speed - lim... | true |
fcbf5247a1961337748b5181a30e1d55a451e201 | zar777/exercises | /chapter_one/unique_characters.py | 934 | 4.125 | 4 | """Implement an algorithm to determine if a string has all unique characters. What if you
can not use additional data structures? Exercises 1.1 """
class UniqueCharacters(object):
"""this class represents an empty dictionary dictionary"""
def __init__(self):
self.dictionary = {}
def unique(self, st... | true |
5fdc21c50426bbeffd1fab5e53df23c7fe218cd3 | zar777/exercises | /Chapter_three/three_stacks.py | 2,384 | 4.21875 | 4 | """Describe how you could use a single array to implement three stacks. Exercises 3.1
I WRONG BECAUSE I USE A LIST AND NOT AN ARRAY"""
class ThreeStacks(object):
"""this class is created to represent an empty array which there are only two divisors used by
delimited the three stacks"""
def __init__(sel... | true |
b494b3cfe84c7cbc8bc786011cbdf475cdf6b809 | ositowang/IMooc_introToAlgorithm | /BasicSorting/selection_sort.py | 776 | 4.375 | 4 | """
N平法复杂度的算法
选择排序
我们从第一个开始,从头到尾找一个个头最小的小盆友,然后把它和第一个小盆友交换。 然后从第二个小盆友开始采取同样的策略,这样一圈下来小盆友就有序了。
"""
def selection_sort(array):
for i in range(0,len(array)):
# 假设当前下标的值是最小的
min_index = i
# 从当前下标的下一个开始遍历
for j in range(i+1,len(array)):
#如果值小于当前的最小值,就更新当前最小值的下标
i... | false |
7f26fdf3884a01b784ac349de84b950039741d55 | thedrkpenguin/CPT1110 | /Week 4/list_modification4.py | 248 | 4.21875 | 4 | FOOD = ["Pizza", "Burgers", "Fries", "Burgers","Ribs"]
print("Here is the current food menu: ")
print(FOOD)
FOOD_ITEM = str(input("Which item would you like to remove? "))
FOOD.remove(FOOD_ITEM)
print("Here is the new food menu: ")
print(FOOD)
| true |
26f43680761d404a6f18137a44934d9583aa3268 | thedrkpenguin/CPT1110 | /Week 11/distance2OriginProgram.py | 1,157 | 4.40625 | 4 | class Point():
def __init__(self,x,y):
self.x = x #self.x = 6
self.y = y #self.y = 8
def distance(self):
return (self.x**2 + self.y**2) ** .5 #pythagorean theorum
#def distance(self,x=0,y=0):
#return (x**2 + y**2) ** .5 #pythagorean theorum
first_poi... | false |
727d74cf441d3d1aa62a98c6b4a2b933b9ccaee0 | thedrkpenguin/CPT1110 | /Week 2/largestnumberCheckFOR.py | 202 | 4.21875 | 4 | num = 0
max_num = 0
for i in range(4):
num = int(input("Enter a value for number: "))
if num > max_num:
max_num = num
print("The largest number entered is ", max_num)
| true |
8eca6001f5fc103ed8ac7a8da3e98d7c3508fd1f | thedrkpenguin/CPT1110 | /Week 1/firstprogram.py | 575 | 4.25 | 4 | print("My Name is ", "Paul", sep = "-", end = " ")
print("Paul", "Burkholder")
year = 2018
month = "August"
number = 3.123456789
millions = 1000000
print(f'The current month is {month} and the year is {year}.')
print("The current month is" , month , "and the year is ", year, ".")
print("The current mont... | false |
83b0b2e4b0eb8ae1db2074ee4d953198ae0eafb0 | learning-dev/46-Python-Exercises- | /ex19b.py | 516 | 4.3125 | 4 | """ The python way of checking for a string is pangram or not """
import string
def is_pangram(in_string, alphabet=string.ascii_lowercase): # function for checking pangram or not
alphaset = set(alphabet) # creating a set of all lower case
return alphaset <= set(in_string.lower()) # checking
while True:
... | true |
6bcf6f675943b9144db51a7fefb97fbc6c0f4381 | lucasolifreitas/ExerciciosPython | /secao8/exerc4.py | 381 | 4.15625 | 4 | """
Faça uma função para verificar se um número é quadrado perfeito.
Um quadrado perfeito é um número inteiro não negativo que pode ser expresso como quadrado
de outro número inteiro.
"""
def quadrado_perfeito(num):
if num > 0 and type(num) == int:
return num ** 2
else:
return 'O número deve s... | false |
dd16f246a0197d5e21e965bc0e8c3e1f4b4bc158 | dmoses12/python-intro | /pattern.py | 929 | 4.25 | 4 | def pattern(number):
"""Function to generate a pattern
syntax: pattern(number)
input: number
output: symmetrical pattern of _ and * according to number provided
return: 0 when complete
"""
print "Pattern for number: %s" % number
# complete this function
max_stars = 2 * number - 1 # ... | true |
efce03538801ff68cee65346772dff3dd078f35f | harshalkondke/cryptography-algorithm | /Multi.py | 533 | 4.125 | 4 | def encrypt(text, key):
result = ""
for i in range(len(text)):
char = text[i]
if char.isupper():
mychar = ord(char) - 65
ans = (mychar * key) % 26
result += chr(ans + 65)
else:
mychar = ord(char) - 97
ans = (mychar * key) % 26
... | true |
7a74c15d52ff4840ea630060d12fde662cf476fc | Abraham-Lincoln-High-School-MESA/2020-2021-Python | /1.- Print statements, Variables, and Operators/2_Operators.py | 2,520 | 4.1875 | 4 | # 11/08/2020 @author: Giovanni B
""" Operators are symbols that tell the compiler to perform certain mathematical or logical manipulations.
For instance, arithmetic, comparison, boolean, etc. There are several operators, and they obviously
have a precedence order, this is, the order of "importance" to decid... | true |
e645d502352b2169a169e6b07b08d143ba88e794 | Abraham-Lincoln-High-School-MESA/2020-2021-Python | /4.- Lists/z_Practice Problems from HW 3/0- Coffee_Machine.py | 1,463 | 4.5 | 4 | # Initializing variables
waterPerCup = 0
milkPerCup = 0
beansPerCup = 0
costPerCup = 0
# Inputting the resources
print("Enter the machine's resources")
water = int(input("ml of water: "))
milk = int(input("ml of milk: "))
beans = int(input("gr of coffee beans: "))
cups = int(input("cups: "))
money = int(input("How mu... | true |
e408ea0cafaad6313366c9fce5c523fbe758479c | max-zia/nand2tetris | /assembly language/multiply.py | 619 | 4.125 | 4 | # multiply integers a and b without multiplication
def multiply(a, b):
# for all n, n*0 = 0
if a == 0 or b == 0:
return 0
# operate on absolute values
product = abs(a)
# add a to itself b times and store in product
for i in range(1, abs(b)):
product += abs(a)
# if a or b < 0, product must be negative
# if ... | true |
8ed06ac79c147dbeca6a1a4a6b4678dc945a95eb | 2266384/ATBSWP | /Ch 7 - Regular Expressions/regexStrip.py | 542 | 4.46875 | 4 | #! python3
# regexStrip.py - Function to strip spaces OR specified characters from a string
import re
def regexStrip(myString, character=' '):
defRegex = re.compile(r'^[\s]+|[\s]+$')
myRegex = re.compile(r'' + re.escape(character))
if character == ' ':
return defRegex.sub('', myString)
else:
... | false |
e358a76b696ef686576b746673732144d79d23d3 | sanashahin2225/ProjectEuler | /projectEuler1.py | 365 | 4.25 | 4 | # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.
def multipleOfThreeandFive(num):
sum = 0
for i in range(1,num):
if i%3 == 0 or i%5 == 0:
sum += i
re... | true |
9a7f00adcc48b8f31f768f495178aac5819f3b32 | mmlakin/morsels | /count_words/count.py | 483 | 4.28125 | 4 | #!/usr/bin/env python3
"""count.py - Take a string and return a dict of each word in the string and the number of times it appears in the string"""
from string import punctuation as punctuationmarks
import re
def count_words(line: str) -> dict:
""" Use re.findall to return a list of words with apostrophes include... | true |
fedb1fb0c6cd6ec4bb814ae119317c47dae223ad | ZergOfSwarm/test | /otslegivaet_knopki_mishi22.py | 1,186 | 4.4375 | 4 | from tkinter import *
#initialize the root window
root = Tk()
#############################
# 7. Click action
#############################
# 1
def printHello():
print("Hello !")
# Once the button is clicked, the function will be executed
button_1 = Button(root, text="Click me !", command = printHello)
button_... | true |
ec3896f603ea5179d441f188ad908852a736693e | andrewcollette/sprint_tutorial | /sprint_tutorial/compute.py | 329 | 4.125 | 4 | """ Module to compute stuff
"""
def my_sum(x, y):
""" Compute the sum of 2 numbers
"""
return x + y
def my_power(a, n):
""" Compute a^n """
pow = a
for i in range(n-1):
pow = pow*a
return pow
def my_root(a, n=2):
""" Compute the nth root of a """
res = a**(1.0/n)
re... | false |
8957d8156bc7f65ea0df95bab71c205aa3978262 | OscarH00182/Python | /Stack.py | 1,067 | 4.34375 | 4 | """
Stack:
This is how we create a stack, we create a simple class for it
and create its functions to handle values being pass to it
"""
class Stack:
def __init__(self):#constructor
self.stack = [] #we create an array named stack to handle the stack
self.size = -1
def Push(self,datavalue):#This... | true |
b6fadc89174f195651271f86522c39c9d0ec444b | OscarH00182/Python | /ChapterTwo.py | 2,094 | 4.5625 | 5 | name = "Oscar Hernandez"
print(name.title())
print("Upper Function: ",name.upper())
print("Lower Function: ",name.lower())
firstName = "Oscar"
lastName = "Hernandez"
fullName = firstName + " " +lastName
print("Combinding Strings: ",fullName)
#rstrip Function
languagee = "Python "
language = "Python "#Notice: "Python "... | true |
9a5dd11136eb707a020db2e3dc97f0b03e91c891 | jpbayonap/programs | /py_prog/decimals1.py | 2,195 | 4.21875 | 4 | #the objective of this programm is to compkute the division of one by a random integer given by the user
#for repeated decimals the programm will print the repeated digits after reaching the first repetition
from time import sleep # used for defining the intervals of time between each operation
d= int(input("Input a ... | true |
b0679af54f904e6f16b72b0dbe786875b55c9778 | martinvedia/app-docs | /codedex/enter_pin.py | 243 | 4.21875 | 4 | # This program accept a correct Bank pink value 1234
print("BANK OF CODÉDEX")
pin = int(input("Enter your PIN: "))
while pin != 1234:
pin = int(input("Incorrect PIN. Enter your PIN again: "))
if pin == 1234:
print("PIN accepted!") | true |
10a3ba409bc987fe4bd08cb7df222316812e28cc | joesmall37/Algorithms | /Recursion/call_stack_fibonacci.py | 263 | 4.125 | 4 | # define the fibonacci() function below...
def fibonacci(n):
# base cases
if n == 1:
return n
if n == 0:
return n
# recursive step
print("Recursive call with {0} as input".format(n))
return fibonacci(n - 1) + fibonacci(n - 2)
fibonacci(5)
| false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.