blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
3d98365e0ba0ebbf714acc17e52c5d9b9a219e44 | iamnidheesh/MyCodes | /Python-Files/inputvalidiation.py | 396 | 4.1875 | 4 | #the Collatz sequence
def collatz(m):
if m%2==0 :
m=m//2
return m
elif m%2==1 :
m=3*m+1
return m
c=0
while c!=1 :
try :
n=int(input("Enter number :"))
c=c+1
while True :
print(n)
n=collatz(n)
if n==1 :
... | false |
2cddfcca5ba5885135c7cf4271166db2a18b12a3 | weishanlee/6.00.1x | /PS01/1_3.py | 2,047 | 4.28125 | 4 | # create random letter lists to test PS1
import random
import string
def test(tests,a,b):
'''
tests: int, the number of tests to perform
a: int, the length of the shortest string allowed
b: int, the length of the maximum string allowed
'''
n = 0
while n < tests:
s = genera... | true |
0b204934269b03e929537727a134c4e5685a964f | weishanlee/6.00.1x | /PS03/3_3.py | 1,389 | 4.21875 | 4 | secretWord = 'apple'
lettersGuessed = ['e', 'i', 'k', 'p', 'r', 's']
def getGuessedWord(secretWord, lettersGuessed):
'''
secretWord: string, the word the user is guessing
lettersGuessed: list, what letters have been guessed so far
returns: string, comprised of letters and underscores that represents
... | true |
a51e50f0fdcad1787d9cb0a7ab7f7cab50a4eda6 | weishanlee/6.00.1x | /Lecture 12/Lecture_12_05.py | 1,052 | 4.3125 | 4 | print "Prime generator"
def genPrimes():
primes = []
last = 1
while True:
last += 1
for p in primes:
if last % p == 0:
break
else:
primes.append(last)
yield last
primeList = genPrimes()
for i in range(1,11):
print primeList.ne... | false |
3b5db557711710d79a80e3c008ab4b04fe29e1aa | josephantony8/GraduateTrainingProgram2018 | /Python/Day5/Listcommand.py | 1,828 | 4.5 | 4 | Consider a list (list = []). You can perform the following commands:
insert i e: Insert integer e at position i.
print: Print the list.
remove e: Delete the first occurrence of integer e.
append e: Insert integer e at the end of the list.
sort: Sort the list.
pop: Pop the last element from the list.
reverse: Reverse t... | true |
954fbd695169cf5ca915f4afa14673647e4a77b4 | olzama/Ling471 | /demos/May13.py | 1,688 | 4.15625 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.linear_model import LinearRegression
# Linear regression demo
X = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]
# Want: y = 2x + 0 (m = 2, b = 0)
Y = [2*x for x in X] # list comprehension
Y_2 = [x*x for x in X]
Y_3 =... | true |
8fa9a8bf7fe98cf7785f5a40d0dc19b0173cfa9d | nbackas/dsp | /python/q8_parsing.py | 678 | 4.125 | 4 | # The football.csv file contains the results from the English Premier League.
# The columns labeled Goals and Goals Allowed contain the total number of
# goals scored for and against each team in that season (so Arsenal scored 79 goals
# against opponents, and had 36 goals scored against them). Write a program to re... | true |
8c1ce3b11bdaee1a2cea312cdd71334fd944ca25 | Manpreet-Bhatti/WordCounter | /word_counter.py | 1,477 | 4.28125 | 4 | import sys # Importing the ability to use the command line to input text files
import string # Imported to use the punctuation feature
def count_the_words(file_new): # Counts the total amount of words
bunch_of_words = file_new.split(" ")
amount_of_words = len(bunch_of_words)
return amount_of_words
def mos... | true |
25cfb5db84e817269183a1686d9f4ff72edaaae4 | gcd0318/pe | /l5/pe102.py | 1,454 | 4.125 | 4 | """
Three distinct points are plotted at random on a Cartesian plane, for which -1000 ≤ x, y ≤ 1000, such that a triangle is formed.
Consider the following two triangles:
A(-340,495), B(-153,-910), C(835,-947)
X(-175,41), Y(-421,-714), Z(574,-645)
It can be verified that triangle ABC contains the origin, w... | true |
9010ea2d997ec82fcd62f887802e1dc6f599f70f | edward408/bicycleproject | /bikeclasses.py | 1,717 | 4.25 | 4 | #Modeling the bicycle industry
#Classes layout
#Object-oriented programming (OOP) is a programming paradigm that uses objects and their interactions to design applications and computer programs.
#Methods are essential in encapsulation concept of the OOP paradigm
class Bicycle(object):
def __init__(self,model,weight... | true |
93fe3bdc09d05d492d4752b3d3300120e9c6b902 | pratik-iiitkalyani/Data_Structure_and_Algo-Python- | /interview_problem/reverse_sentance.py | 576 | 4.375 | 4 | # Write a program to print the words of a string in reverse order.
# Sample Test Cases:
# INPUT: Hi I am example for this program
# OUTPUT: Program this for example am I Hi
def revrseSentanse(str):
# spilt all the word present in the sentance
sentance = str.split(" ")
# the first letter of last word of sen... | true |
6d6c68769059fc9e98f45d934c014ca7d1d5c47d | bretuobay/fileutils | /exercises5.py | 684 | 4.1875 | 4 | '''
Write a function translate() that will translate a text into "rövarspråket" (Swedish for "robber's language"). That is, double every consonant and place an occurrence of "o" in between.
For example, translate("this is fun") should return the string "tothohisos isos fofunon".
'''
def translate(str_input):
vow... | true |
d857a6d39e3b537539c9e5f74e45a11c78d1545f | bretuobay/fileutils | /exercises7.py | 440 | 4.59375 | 5 | '''
Define a function reverse() that computes the reversal of a string. For example, reverse("I am testing") should return the string
"gnitset ma I".
'''
# this works by slicing from the end
#This is extended slice syntax. It works by doing [begin:end:step] - by leaving begin and end off and specifying ... | true |
dae27379e51e88f52d0cc08859b3c9486356acea | AndyTian-Devops/PythonSample | /PhoneBook.py | 950 | 4.28125 | 4 | #简单数据库
#使用人名作为键的字典,每个人用另一个字典表示,其中phone和addr分别表示他们的电话号码和地址
people = {
'Alice':{
'phone' : '2341',
'addr' : 'Foo drive 23'
},
'Beth':{
'phone' : '9102',
'addr' : 'Bar street 42'
},
'Cecil':{
'phone' : '3158',
'addr' : 'Baz avenue 90'
... | false |
35b40ee37d55f57f862dd0d76bdf73ce42bf1c92 | rozeachus/Python.py | /NumberGuess.py | 1,035 | 4.40625 | 4 | """
This program will allow a user to guess a number that the dice will roll.
If they guess higher than the dice, they'll get a message to tell them they've won.
If its lower than the dice roll, they'll lose.
"""
from random import randint
from time import sleep
def get_user_guess():
guess = int(input("Guess a ... | true |
e48d3a6156013fcea2a50ad2eddf5f13815baedf | luis95gr/mdh-python01-solutions | /Cod_d1/prueba5.py | 208 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 22 17:11:29 2019
@author: luis9
"""
import math as mt
my_num = int(input('Enter a number to find its factorial: '))
print("Factorial: " , mt.factorial(my_num))
| false |
0ba170e17e18c0b2a2bc93ed8fc6b18399a4687d | thiagocosta-dev/Atividades-Python-CursoEmVideo | /ex008.py | 306 | 4.1875 | 4 | '''
DESAFIO 008
Crie um programa que converta uma valor em metros recebido pelo teclado, em centímetros e milímetros.
'''
metros = float(input('Digite um valor em metros: '))
cent = metros * 100
mili = metros * 1000
print(f'{metros} convertidos para centímetros da {cent} e em milímetros é {mili}')
| false |
96ae307c72437a0d89d2afec2e8fafa73ea49551 | thiagocosta-dev/Atividades-Python-CursoEmVideo | /ex033.py | 476 | 4.125 | 4 | '''
DESAFIO 033
Faça um programa que leia três números e mostre qual é o maior e qual é menor
'''
n1 = int(input('1° Número: '))
n2 = int(input('2° Número: '))
n3 = int(input('3° Número: '))
if n1 > n2 and n1 > n3:
maior = n1
elif n2 > n1 and n2 > n3:
maior = n2
else:
maior = n3
if n1 < n2 and n1 < ... | false |
78ac002848dfceb1477234110f3eaeecaf2850db | kelynch/python_workshop | /exercises/if_else.py | 363 | 4.40625 | 4 | #!/bin/python
#####
## Sample Python Exercise for WIC Programming Workshop
## November 2017
## Katherine Lynch
## If-Else
print("Pick a number between 1 and 10.")
number = int(raw_input())
if number > 10:
print("Your number is greater than 10.")
elif number <= 10 and number > 0:
print("Your number is between 1 an... | false |
a5a954481f937f566af621b3071afb1e90783ab3 | guti7/hacker-rank | /30DaysOfCode/Day08/phone_book.py | 1,020 | 4.3125 | 4 | # Day 8: Dictionaries and Maps
# Learn about key-value pair mappings using Map or a Dicitionary structure
# Given n names and phone numbers, assemble a phone book that maps
# friend's names to their respective phone numbers
# Query for names and print "name=phoneNumber" for each line, if not found
# print "Not found... | true |
aeea679670645912d34b278ae177905d59c87bed | par1321633/problems | /leetcode_october_challenge/minimum-domino-rotations-for-equal-row.py | 2,457 | 4.375 | 4 | """
In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the ith domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)
We may rotate the ith domino, so that A[i] and B[i] swap values.
Return the minimum number of rotations so that all the values in A are the ... | true |
3c9ade5a1d56b9d4ec0e674c7b84b906c1c800fa | PiotrPosiadala/PythonLearning | /S005_L025-lambda.py | 1,050 | 4.25 | 4 | #Lambda - może przyjąć dowolną ilość argumentów
def double(x):
return x*2
x = 10
x = double(x)
print(x)
x = 10
f = lambda x: x*2 #po dwukropku tylko jedno wyrazenie
print(f(x))
#---#
def power(x,y):
return x**y
x = 5
y = 3
print(power(x,y))
f = lambda x,y: x**y
print(f(x,y))
#---#
list_numbers = ... | false |
1cd2a64be451bc3b5375777c203dca390eb4b1cc | Deepak-Deepu/Thinkpython | /chapter-5/exercise5.4.py | 350 | 4.125 | 4 | a = int(raw_input('What is the length of the first side?\n'))
b = int(raw_input('What is the length of the first side?\n'))
c = int(raw_input('What is the length of the first side?\n'))
def is_triangle(a, b,c):
if a > (b+c):
print('No')
elif b>(a+c):
print('No')
elif c > (a+b):
print('No')
else:
print('Yes... | true |
f718b2a829a17b71c720cacf6560e1240ef8d53f | GiovannaPazello/Projetos-em-Python | /AP1/Geração de n aleatórios.py | 1,554 | 4.125 | 4 | '''Faça um programa que gere números aleatórios entre 5 e 95 até gerar um número divisível por 7.
Quando isso ocorrer informar:
- a quantidade de números divisíveis por 4 e maiores que 30 que foram gerados
- a quantidade de números pares OU menores que 30 que foram gerados.
- o percentual de números pares e o percen... | false |
1ab94728578d070cf386755b9b15eab746d72bbe | Ameiche/Homework_22 | /Homework_22.py | 2,039 | 4.125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class linkedList:
def __init__(self):
self.head = None
def append(self, data):
newNode = Node(data)
if self.head == None:
self.head = newNode
return
els... | false |
88350f210e517a64996c1b7a382a93447fda8792 | emilywitt/HW06 | /HW06_ex09_06.py | 951 | 4.3125 | 4 | #!/usr/bin/env python
# HW06_ex09_05.py
# (1)
# Write a function called is_abecedarian that returns True if the letters in a
# word appear in alphabetical order (double letters are ok).
# - write is_abecedarian
# (2)
# How many abecedarian words are there?
# - write function(s) to assist you
# - number of abeced... | true |
9d9206ef57e6dfb7444b1eb1391f5d705fb3c929 | singhsukhendra/Data-Structures-and-algorithms-in-Python | /Chapter#02/ex_R_2_9.py | 2,612 | 4.34375 | 4 | class Vector:
""" Represent a vector in a multidimensional space."""
def __init__(self, d):
""" Create d-dimensional vector of zeros. """
self._coords = [0] * d
def __len__(self): # This special method allows finding length of class instance using len(inst) style .
""" Return the ... | true |
40c50edae79808a40a98d5538f1fba55bdb58938 | fredzhangziji/myPython100Days | /Day9_Class_Object_Advanced/decorators.py | 2,312 | 4.25 | 4 | '''
python内置的 @property装饰器 (Decorators)
之前我们讨论过Python中属性和方法访问权限的问题,虽然我们不建议将属性设置为私有的,
但是如果直接将属性暴露给外界也是有问题的,比如我们没有办法检查赋给属性的值是否有效。
我们之前的建议是将属性命名以单下划线开头,通过这种方式来暗示属性是受保护的,不建议
外界直接访问,那么如果想访问属性可以通过属性的getter(访问器)和setter(修改器)
方法进行对应的操作。如果要做到这点,就可以考虑使用@property包装器来包装getter和
setter方法,使得对属性的访问既安全又方便,代码如下所示。
'''
class Person(objec... | false |
381fe255c58115bb31ccba6a94d3f69216367d9f | fredzhangziji/myPython100Days | /Day3_BranchStructure/practice1_cmToinch.py | 740 | 4.5 | 4 | '''
Convert between cm and inch
12/17/2019
written by Fred Zhang
'''
while True:
print("\n\n-------Welcome to cm/inch Converter Version 1.0-------")
print("Enter 'cm' for converting inch to cm;")
print("Enter 'inch for converting cm to inch;")
print("Enter 'e' for exiting the program.")
pri... | true |
4db295d5fb56f4a6779bffc189e483f6fe58dfb0 | fredzhangziji/myPython100Days | /Day3_BranchStructure/practice2_pointToGrade.py | 678 | 4.15625 | 4 | '''
Convert 100-point scale to grade scale
12/17/2019
written by Fred Zhang
'''
print('\n\nYo this is a grade converter you sucker!\n')
point = int(input('put in your stupid-ass points here: '))
print()
if point <= 100 and point >= 90:
print('You got a fucking A. Greate fucking job!')
elif point < 90 and ... | true |
28df5a8ca0c2ed5bf2bdbc571844a352d9266fd8 | fredzhangziji/myPython100Days | /Day2_Variable_Operator/practice1_FahrenheitToCelsius.py | 1,227 | 4.53125 | 5 | '''
A simple program to convert between Fahrenheit and Celsius degrees.
12/17/2019
written by Fred Zhang
'''
while True:
print('**************************************************')
print('**************************************************')
print('Welcome to Fahrenheit and Celsius degree converter'... | true |
6ff06eb58bc0deca7987c036855822e85e368745 | shivamsood/Python | /factorial.py | 267 | 4.46875 | 4 | #Code to calculate Factorial of the user entered integer
factorial_input = input("Please enter the number to calculate Factorial\n\n")
output = 1
while factorial_input >= 1:
output *= factorial_input
factorial_input -=1
print "The Factorial is {}".format(output) | true |
be172b3b278c917d476ef101884bf526e6997862 | youth-for-you/Natural-Language-Processing-with-Python | /CH-1/Exercises/10.py | 680 | 4.125 | 4 | #Define a variable my_sent to be a list of words,using the syntax my_sent = ["My", "sent"]
# (but with your own words, or a favorite saying).
#Use ' '.join(my_sent) to convert this into a string.
#Use split() to split the string back into the list form you had to start with.
if __name__ == '__main__':
my_sent = ['... | true |
11ff73edd6eb7d4142a374916bfcf13662ee83ff | poojatathod/Python_Practice | /max_of_list.py | 556 | 4.375 | 4 | #que 13: The function max() from exercise 1) and the function max_of_three() from exercise 2) will only work for two and three numbers, respectively. But suppose we have a much larger number of numbers, or suppose we cannot tell in advance how many they are? Write a function max_in_list() that takes a list of numbers a... | true |
e3d61428e98c35ba2812b991330964bc362a0f6c | poojatathod/Python_Practice | /translate.py | 1,023 | 4.15625 | 4 | #que 5: Write a function translate() that will translate a text into "rövarspråket" (Swedish for "robber's language"). That is, double every consonant and place an occurrence of "o" in between. For example, translate("this is fun") should return the string "tothohisos isos fofunon".
def translate(string):
c=0
... | true |
ecc17cab948c55d4262611b10b8cf6152c5297d3 | poojatathod/Python_Practice | /longest_world.py | 401 | 4.34375 | 4 | #que 15: Write a function find_longest_word() that takes a list of words and returns the length of the longest one.
def longest_word(string):
list1=[]
for x in string:
list1.append=len(x)
outpt=max(list1)
outpt1=list1.index(outpt)
outpt2=string[outpt1]
return outpt2
string=input("en... | true |
8e8d9b4f6cca0fba2c9b14d044ae44aa017529d5 | GucciGerm/holbertonschool-higher_level_programming | /0x0A-python-inheritance/1-my_list.py | 589 | 4.28125 | 4 | #!/usr/bin/python3
class MyList(list):
"""
MyList - Created this class to inherit components from list
Args:
list - This is the list that we will be inheriting from
Return:
None, will print the sorted inherited list
"""
def print_sorted(self):
"""
print_sorted - This w... | true |
04e3213d38a169dee4919acce36d7537edcfd27f | GucciGerm/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/3-say_my_name.py | 590 | 4.46875 | 4 | #!/usr/bin/python3
"""
say my name module
"""
def say_my_name(first_name, last_name=""):
"""
say_my_name -
This function will print "My name is <first><last>"
Args:
first_name - is the users first name
last_name - is the users last name
Return:
None
"""
def say_my_name(first_n... | true |
8b06343d1d12cd050ae44928ebcc321809abb08f | GucciGerm/holbertonschool-higher_level_programming | /0x0B-python-input_output/11-student.py | 772 | 4.21875 | 4 | #!/usr/bin/python3
class Student:
"""
Creating a class named Student
"""
def __init__(self, first_name, last_name, age):
"""
__init__ - Initializing attibutes
Args:
first_name - This is the first name passed
last_name - This is the last name passed
age - ... | true |
7e1862d84df0221503be876775e5f752e6a994a4 | aitorlomu/SistemasGestores | /Python/Python/Ejercicios/09.py | 236 | 4.15625 | 4 | num=int(input('Introduzca el número de números que introducirá '))
max=0
for i in range(0,num):
introducido=int(input('Introduce un número '))
if introducido>max:
max=introducido
print('El máximo valor es ',max)
| false |
3c403aebce458271cc65041f15a420abb8f010b3 | Cipher-007/Python-Program | /Convert_miles_to_Km.py | 237 | 4.375 | 4 | #Converting Miles to Kilometers
miles = float(input("Enter Miles to be converted into Kilometers: "))
#Conversion factor
conversion_factor = 1.609
#Conversion
kilometers = miles * conversion_factor
print(f"{miles}mi is {kilometers}Km") | true |
352231acb77b2f54c15df747ec2d98514bbb3427 | toby20-meet/meet2018y1lab5 | /fruit_sorter.py | 224 | 4.15625 | 4 | new_fruit = input("What fruit would you like to choose?")
if "Apple"== new_fruit:
print('Bin1')
elif "Orange" == new_fruit:
print('Bin2')
elif 'Pear' == new_fruit:
print('bin3')
else:
print("wtf dis froot?")
| false |
13c88ffd58b096511ee71e2752e0dc588c71cfed | lchoe20/lchoe20.github.io | /challenge1.py | 806 | 4.21875 | 4 | #challenge 1 prompt: create a guess the number uding a while loop
from random import * #import * is a wild card that says import all information
aRandomNumber = randint(1,20) #inclsuive
#generates a randominteger
guess = input("Guess a number between 1 and 20 inclusive: ")
#assume user's guess is equal to 5
if not... | true |
278597b789075960afb774815cf487ca6fc22cff | appledora/SecurityLab_2_3 | /Task_2/CeaserCipher.py | 1,575 | 4.1875 | 4 | import string
import time
alpha = string.ascii_letters
def ceaser_decrypt_without_key(target):
print("DECRYPTING....")
key = 0
while key <= 26:
temp = ""
for char in target:
if char.isalpha():
temp += alpha[(alpha.index(char)-int(key)) % 26]
... | true |
9802d5ff29b357a696ef27482b55450c1ea6f20e | DomaninaDaria/my_python_hw | /11-14.py | 1,707 | 4.21875 | 4 | import math
print("Exercise number 11")
def degrees_in_radians(degrees):
return (degrees * math.pi) / 180
degrees1 = 45
degrees2 = 40
degrees3 = 60
print("Cos of degrees(%d)= %.4f" % (degrees1, math.cos(degrees_in_radians(degrees1))))
print("Cos of degrees(%d)= %.4f" % (degrees2, math.cos(degrees_in_radians(d... | false |
9603b36b1bba94a0929fb0c2d436e6257184fef8 | elizabethdaly/collatz | /collatz.py | 519 | 4.3125 | 4 | # 16 sept 2019 collatz.py
# n is the number we will perform Collatz on.
# n = 20
# Request user input.
n = int(input("Please enter an integer n: "))
# Keep looping until n = 1.
# Note: Assumes Collatz conjecture is true.
while n != 1:
# Print the current value of n.
print(n)
# Check if n is even.
if n % ... | true |
2d0da772303ac46285ea43b6283a17c4823e52f3 | Noah-Huppert/ksp-sandbox | /src/lib/velocity.py | 1,716 | 4.53125 | 5 | """ calc_energy calculates the kinetic energy for a given body traveling in 1D
Arguments:
- m (float): Mass of body
- v (float): Velocity of body
Returns:
- float: Kinetic energy of body
"""
def calc_energy(m, v):
# Ensure kinetic energy is negative if velocity is negative
# (Separate logic necess... | true |
2801333709f62497a68f7925030ddbe55a0397b6 | MrZebarth/PythonCheatSheet2019 | /Conditionals.py | 977 | 4.40625 | 4 | # Conditionals
# We want to be able to make decisions based on our variables
# We use the "if" statment with a condition to check for a result
num1 = int(input("Enter a first number: "))
num2 = int(input("Enter a second number: "))
if num1 > num2:
print(num1, "is greater than", num2)
elif num1 < num2:
print(num... | true |
e957cb1c881194614a3d58e36d953c14a59da8b7 | sidamarnath/CSE-231-Labs | /lab12.py | 2,876 | 4.25 | 4 | #########################################
# lab12.py
# ALgorithm
# Create a vector class
# Have program do calculations
#########################################
class Vector():
def __init__(self, x = 0, y = 0):
self.__x = x
self.__y = y
#self.__valid = self.__validate()
... | true |
adbe15cb36083194aa46ab708ce15c24a07628d6 | sidamarnath/CSE-231-Labs | /lab08b.py | 1,648 | 4.15625 | 4 | ###############################
# lab08b.py
# Algorithm
# Prints out student scores alphabetically
# If name appears more than once in file, add scores together
###############################
# read file function to open and read file
# takes in dictionary and filename as argument
def read_file(dictionary, f... | true |
3bb6d95502446c35cdbfed74b9067dc54d6d165f | 0rps/lab_from_Alex | /school_42/d02/ex04_ft_print_comb.py | 579 | 4.1875 | 4 | # Create a function on display all different combination of three different digits in ascending order,
# listed by ascending order - yes, repetition is voluntary.
def print_comb():
number = ''
flag = False
for i in range(10):
for k in range(i+1, 10):
for l in range(k+1, 10):
... | true |
20cc7f1c4ff34b334763271c8ea7ccd73071786f | vlvanchin/learn | /learn_python/others/ver3/isOddOrEven.py | 259 | 4.46875 | 4 | #!/usr/bin/env python3
def even_or_odd(number):
'''determines if number is odd or even'''
if number % 2 == 0:
return 'Even';
else:
return 'Odd';
userinput = input("enter a number to check odd or even:");
print (even_or_odd(int(userinput)));
| true |
d46d6e0a8e63ca3ae1f83ecb50707a4f3fa48538 | grrtvnlw/grrtvnlw-python-103-medium | /tip_calculator2.py | 991 | 4.25 | 4 | # write a tip calculator based off user input and quality of service and divide bill in equal parts
# get user input for total bill amount, quality of service, how many ways to split, and tip amount
total_bill = float(input("Total bill amount? "))
service_level = input("Level of service - good, fair, or bad? ")
split =... | true |
c4aaaaa193fb7ee3b670371978dcea295c908fbe | mtj6/class_project | /users.py | 1,199 | 4.125 | 4 | """A class related to users."""
class User():
"""Describe some users."""
def __init__(self, first_name, last_name, age, sex, race, username):
"""initialize user attributes"""
self.first_name = first_name
self.last_name = last_name
self.age = age
self.sex = sex
se... | true |
f1ab20d4eebdbddda94de673206edee24ee84712 | pugmomsf/oh-no-broken-code | /birthday.py | 1,228 | 4.3125 | 4 | from datetime import datetime
number_endings = {
1: 'st',
2: 'nd',
3: 'rd',
}
today = datetime.now()
todays_day = today.day
# get the right ending, e.g. 1 => 1st, 2 => 2nd
# but beware! 11 => 11th, 21 => 21st, 31 => 31st
# test your code by forcing todays_day to be something different
todays_day = 9
e... | false |
3c5d3674ea3d693969e7506308cd58946233a490 | gamer0/python_challenge | /challenge3.py | 487 | 4.1875 | 4 | #! /usr/python3
import sys
import string
import re
def find_pattern(file):
with open(file,'r') as f:
f_gen = (line for line in f.readlines())
my_pattern = re.compile(r'[a-z][A-Z][A-Z][A-Z]([a-z])[A-Z][A-Z][A-Z][a-z]')
match_list = [ my_pattern.search(line) for line in f_gen]
match_list = [ match.group(1) ... | false |
dd7e6f9f16d72acd47a15a4fc73f1405641be2e7 | reginashay/cs102 | /homework01/caesar.py | 1,369 | 4.40625 | 4 | def encrypt_caesar(plaintext):
"""
Encrypts plaintext using a Caesar cipher.
>>> encrypt_caesar("PYTHON")
'SBWKRQ'
>>> encrypt_caesar("python")
'sbwkrq'
>>> encrypt_caesar("0123456")
'0123456'
>>> encrypt_caesar("@#^&*${}><~?")
'@#^&*${}><~?'
>>> encrypt_caesar("")
''
... | false |
2a1b822407b558eda90301a1bfec1f5c159c21cc | alexandermedv/Prof_python7 | /main.py | 1,502 | 4.25 | 4 |
class Stack():
"""Класс, реализующий стек"""
def __init__(self):
"""Инициализация класса"""
self.stek = ''
def isEmpty(self):
"""Проверка, пустой ли стек"""
if self.stek == '':
return True
else:
return False
def push(self, element):
... | false |
32197a9d260623de1d6b2b98e3c1930f8a35115e | amarmulyak/Python-Core-for-TA | /hw06/uhavir/hw06_task1.py | 902 | 4.5625 | 5 | # Provide full program code of fibo(n) function which returns array with elements of Fibonacci sequence
# n - length of Fibonacci sequence.
# NOTE: The Fibonacci sequence it's a sequence where some element it's a sum of two previous elements
# --> 1, 1, 2, 3, 5, 8, 13, 21, 34,...
# EXAMPLE OF Inputs/Ouputs when using t... | true |
f7fa1e213ddd43ea879957bc309c5026addb905e | amarmulyak/Python-Core-for-TA | /hw06/amarm/task1.py | 634 | 4.375 | 4 | """
Provide full program code of fibo(n) function which returns array with
elements of Fibonacci sequence
n - length of Fibonacci sequence.
NOTE: The Fibonacci sequence it's a sequence where some element it's a
sum of two previous elements --> 1, 1, 2, 3, 5, 8, 13, 21, 34,...
EXAMPLE OF Inputs/Ouputs when using this... | true |
17e555d24c9b10c7748c183a1ac62960f9328ba5 | amarmulyak/Python-Core-for-TA | /hw03/pnago/task_2.py | 777 | 4.1875 | 4 | year = int(input("Enter a year: "))
month = int(input("Enter a month: "))
day = int(input("Enter a day: "))
short_months = [4, 6, 9, 11]
# Check if it is a leap year
is_leap = False
if year % 4 != 0:
is_leap
elif year % 100 != 0:
is_leap = True
elif year % 400 != 0:
is_leap
else:
is_leap = True
# Dat... | true |
b08dfa9c61ea32b40594f424dfb140002764f5a5 | amarmulyak/Python-Core-for-TA | /hw06/arus/fibo_func.py | 583 | 4.4375 | 4 | """Provide full program code of fibo(n) function which returns array with elements of Fibonacci sequence
n - length of Fibonacci sequence.
NOTE: The Fibonacci sequence it's a sequence where some element it's a sum of two previous elements --> 1, 1, 2, 3, 5, 8, 13, 21, 34,...
"""
def fibo_func(n):
i = 1
i1 =... | true |
5f0a74b243d2a0d0ed6d504936a19ede39175284 | amarmulyak/Python-Core-for-TA | /hw05/yvasya/hw05_5.py | 995 | 4.125 | 4 | # Дана матриця. Знайти в ній рядок з максимальною сумою елементів, а також стовпець.
from random import random
matrix = []
for i in range(5):
row = []
for j in range(5):
row.append(int(random()*10))
matrix.append(row)
for row in matrix:
print(row)
# sum of the row
biggest_row = []
for row i... | false |
11479ff5ed3027796c3c54b35c4edbc9609ffeac | amarmulyak/Python-Core-for-TA | /hw03/amarm/task1.py | 310 | 4.28125 | 4 | from calendar import monthrange
var_year = int(input("Type the year to found out if it's leap year: "))
february = monthrange(var_year, 2) # Here 2 means second month in the year
february_days = february[1]
if february_days == 29:
print("It's a leap year!")
else:
print("This is not a leap year!")
| true |
8c9320a9c918a667a1e308dc73b7cda9d1b7aa0b | amarmulyak/Python-Core-for-TA | /hw06/yvasya/hw06_01.py | 673 | 4.28125 | 4 | """
Provide full program code of fibo(n) function which returns array with elements of Fibonacci sequence
n - length of Fibonacci sequence.
NOTE: The Fibonacci sequence it's a sequence where some element it's a sum of two
previous elements --> 1, 1, 2, 3, 5, 8, 13, 21, 34,...
EXAMPLE OF Inputs/Ouputs when using this fu... | true |
c4cc1df080077fd565d9afbbb3a6c1129a00501c | aiqbal-hhs/python-programming-91896-JoshuaPaterson15 | /print_statement.py | 384 | 4.21875 | 4 | print("Hello and Welcome to this Digital 200 print statement.")
print("Here is string one." + "Here is string two.")
print("Here is string one times 5." * 5)
name = input("What is your name? ")
print("Welcome to Digital 200 {}.".format(name))
print("Line one \nLine two \nLine three")
print("""This is line one
... | true |
336dc2fe84d34d3865e0209e77ea4d00e6cc9d31 | K4bl0-Skat3R/exercicios-02-2014 | /exercicio 05.py | 302 | 4.125 | 4 |
# algoritimo verificar se o numero e par ou impar
# aluno Genilson
# professor Habib
# exercicio 05
n1= input("digite um numero: ")
if n1 == 0:
print "Neutro" #usei essa opcao para testar o elif(zero e par porem nulo )
elif n1 %2 == 0:
print "este numero e par"
else:
print "este numero e impar"
| false |
1658511ddf06d9124b17445af3164864cdd45c39 | nilearn/nilearn | /examples/05_glm_second_level/plot_second_level_design_matrix.py | 1,994 | 4.34375 | 4 | """
Example of second level design matrix
=====================================
This example shows how a second-level design matrix is specified: assuming that
the data refer to a group of individuals, with one image per subject, the
design matrix typically holds the characteristics of each individual.
This is used i... | true |
a19ab2d3920ca3f956ca83719af3124ff6b9b073 | lberge17/learning_python | /strings.py | 368 | 4.5 | 4 | my_string = "Hello world! I'm learning Python."
print("Hello")
print(my_string)
# using square brackets to access a range of characters
print(my_string[26:30]) # prints "Pyth"
# using commas to print two items
print("My message is:", my_string[13:33]) # prints "My message is: I'm learning Python."
# using string in... | true |
ec39e9b0fffa050ae20a40a3a73bb23cbc5f606b | manisha-jaiswal/Division-of-apples | /problem19.py | 1,258 | 4.25 | 4 | """
-------------------------------------Problem Statement:--------------------------
Harry potter has got n number of apples. Harry has some students among whom, he wants to distribute the apples. These n number of apples are provided to harry by his friends and he can request for few more or few less apples.
You... | true |
296fb4507878591bdde602c63284b9785971509d | hungd25/projects | /CS6390/HW2_P3.py | 2,213 | 4.59375 | 5 | """
"""
def get_input():
"""
# Get height and weight from the user and validate. If inputs are (negative numbers or strings),
the program should throw an error message.
: return: height, weight
"""
try:
# get user input and convert to type float
height_input = float(input("E... | true |
d4a8e2b76d5cce35ebceb4df5064a07886a2d14f | halysl/python_module_study_code | /src/study_checkio/Fizz buzz.py | 768 | 4.5 | 4 | '''
https://py.checkio.org/mission/fizz-buzz/
"Fizz buzz" is a word game we will use to teach the robots about division. Let's learn computers.
You should write a function that will receive a positive integer and return:
"Fizz Buzz" if the number is divisible by 3 and by 5;
"Fizz" if the number is divisible by... | true |
12ab232125ed90cbb8c19aa08924a027f36a3146 | halysl/python_module_study_code | /src/study_checkio/Second Index.py | 1,015 | 4.28125 | 4 | '''
https://py.checkio.org/mission/second-index/
You are given two strings and you have to find an index of the second occurrence of the second string in the first one.
Let's go through the first example where you need to find the second occurrence of "s" in a word "sims". It’s easy to find its first occurrence ... | true |
47d0464a02a778306eb170b12bd379fdfee93af4 | gramanicu/labASC | /lab02/task2.py | 1,164 | 4.25 | 4 | """
Basic thread handling exercise:
Use the Thread class to create and run more than 10 threads which print their name and a random
number they receive as argument. The number of threads must be received from the command line.
e.g. Hello, I'm Thread-96 and I received the number 42
"""
from random imp... | true |
9a3238fa2a37850c15df278017457807432cde9c | flyingaura/PythonLearning | /PY.exercise/exer0905001.py | 1,873 | 4.1875 | 4 | """
定义一个有理数的类,并实现有理数据的加减乘除运算 Rational(N1,N2)
"""
from LearnModule import MY_math
class Rational(object):
def __init__(self,N1,N2 = 1):
if(not isinstance(N1,int) or not isinstance(N2,int)):
raise ValueError('有理数的分子和分母都必须为整数!')
if(N2 == 0):
raise ZeroDivisionError('分母不能为零!')
... | false |
c12079a7505f4a68a30fa8369852f79b52a6d51a | ssahai/python | /if.py | 331 | 4.15625 | 4 | #!/usr/bin/python
# To check whether the guessed number is correct (as per our fixed number)
num = 15
guess = int (raw_input ("Enter you guess : "))
if guess == num:
print 'You guessed it right!'
elif guess > num:
print 'Your guesses a larger number'
else:
print 'You guessed a smaller number'
print 'Prog... | true |
3ad3977085f0aa26d5674c2cb73bbdf592a9ec8e | Aniketa1986/pythonExercises | /fortuneSim.py | 962 | 4.4375 | 4 | # chapter 3, exercise 1
# Fortune Cookie
# Write a program that simulates a fortune cookie. The program should display one of five unique fortunes, at random, each time it’s run.
import random
#generate random number between 1 and 5
randomNum = random.randint(1,5)
#Unique fortune messages
fortune1 = "Some ... | true |
0be016a9ac85a98615dc90cc9e7c3a51015f989b | omarsaad0/Python-Learning | /Python_Elzero/039_PracticalEmailSlice.py | 423 | 4.40625 | 4 | # Practical Email Slice
# email = "omarsaad2411@gmail.com"
the_name = input("What\' Your Name ? ").strip().capitalize()
the_email = input("What\' Your Email ? ").strip().capitalize()
the_username = the_email[:the_email.index("@")].strip().capitalize()
the_domain = the_email[the_email.index("@")+1:].strip()
print(f"H... | false |
d99af8d7a19d0e1545818127008ba451c76e0669 | zainab404/zsfirstrepo | /packing_with_dictionaries.py | 390 | 4.375 | 4 | #packing is when you can pass multiple arguments.
#here, we used **kwargs to signify the use of multiple arguments.
#the for loop will iterate over the arguments given and print each one
def print_student(**kwargs):
for key,value in kwargs.items():
print("{} {}".format(key,value))
print_student(name = "Z... | true |
6aa6d30c03cb59c7a67036aeb778971356e70959 | wherby/hackerrank | /Temp/Scala/add.py | 406 | 4.1875 | 4 | def addInt(input):
if "a" in input and "b" in input:
a = input["a"]
b = input["b"]
try:
int(a)
try:
int(b)
return a+b
except:
print b + " is not int"
except:
print a + " is not int"
el... | true |
2d47bef22ea73a37b69df451cd60b9df4834603a | Andrewzh112/Data-Structures-and-Algorithms-Practice | /Two Pointers II.py | 1,257 | 4.15625 | 4 | # Valid Palindrome
class Solution:
"""
@param s: A string
@return: Whether the string is a valid palindrome
"""
def isPalindrome(self, s):
start, end = 0, len(s) - 1
while start < end:
while start < end and not s[start].isalnum():
start += 1
wh... | true |
958cb78be722ee0cf1de35a0587da701bc078646 | WayneGoodwin95/Algorithms | /selection_sort.py | 710 | 4.125 | 4 | """
SELECTION SORT
loop through list keeping track of smallest unchecked index (min_index)
if another index is smaller swap the value to min_index
once looped through, change the minimum index to the next array element
repeat
"""
def selectionSort(my_arr):
min_index = 0
for min_index in range(len(my_arr)):
... | true |
7fa50383b8b022efbad2ea5bfef8fa843a199411 | lvsheng/practice | /program-arcade-games/lab1/part-a.py | 307 | 4.15625 | 4 | #!/usr/bin/env python
# enter a temperature in Fahrenheit, prints the temperature in Celsius
def fah_to_cels(temp):
return (temp - 32)/1.8
if __name__ == "__main__":
fah_temp = float(input("Enter temperature in Fahrenheit:"))
print("The temperature in Celsius: ", str(fah_to_cels(fah_temp)))
| false |
97bc3c6267200c16610d7e6725c022b0f47730a2 | andre-lobo/Complete-Python-Bootcamp | /011-if_elif_else.py | 446 | 4.1875 | 4 | #if, elif and else examples
if True:
print("It was True")
print()
x = False
if x:
print("x was True")
else:
print("x was False")
print()
loc = "Bank"
if loc == "Auto Shop":
print("Welcome to the Auto Shop")
elif loc == "Bank":
print("Welcome to the Bank")
elif loc == "Mall":
print("Welcome to the Mall")
el... | true |
4069e07be02c7875a78c5353569166a681f9f091 | andre-lobo/Complete-Python-Bootcamp | /005-lists.py | 961 | 4.34375 | 4 | #lists examples
my_list = [1, 2, 3]
my_another_list = ["text", 23, 1.3, "A"]
print(len(my_list))
print(len(my_another_list))
my_another_list = ["One", "Two", "Three", 4, 5]
print(my_another_list[0])
print(my_another_list[1:])
print(my_another_list[:3])
print("\n Add new item in list")
#add new item in list
my_lis... | false |
7a8de130d4c4ee9fccf98ce22e0fb60dd647b0da | Sabrina-Sumona/Python-learning | /oop_1.py | 1,344 | 4.125 | 4 | class StoryBook:
# CLASS VARIABLE
no_of_books = 0
discount = 0.5
def __init__(self, name, price, author_name, author_born, no_of_pages):
# setting the instance variables here
self.name = name
self.price = price
self.author_name = author_name
self.author_born = ... | true |
ce0093d47a713ba94d838410e642adcfe1c6073f | StenNick/LearnPython | /if_else.py | 1,788 | 4.25 | 4 | #---------- if, else
cars = ["bmw", "audi", "subaru", "solswagen", "lada", "mercedes", "skoda"]
for item in cars:
if item == "audi":
print(item.upper(), ' make upper')
else:
print(item.title())
#---- проверка вхождения значений в список с помощью оператора - in
colors = ['red', 'blue', 'whi... | false |
273b56a48a8bcb4eccfd6020852347a27407649c | Napster56/Sandbox | /function_scpoe_demo.py | 666 | 4.21875 | 4 | def main():
"""Demo function for scope of an immutable object."""
x = 3 # int is immutable
print("in main, id is {}".format(id(x)))
function(x)
print("in func, id is {}".format(id(x)))
def function(y: int):
print("in func, id is {}".format(id(y)))
y += 1 # assignment creates a... | true |
87f0528ad87ca333109df2a21864358aff4f4a8e | Napster56/Sandbox | /reverse_text_recursively.py | 284 | 4.28125 | 4 | """
Function to reverse a string recursively.
"""
def reverse(text):
if len(text) < 2: # base case
return text
else:
# recursive step = reverse(rest of text) + first char of text
return reverse(text[1:]) + text[0]
print(reverse("photon")) | true |
1abc35b03c60414bb9261d3ffa35ebfb9c9faefa | Napster56/Sandbox | /Classes demo/person.py | 1,260 | 4.15625 | 4 | """
Program to create a person class
"""
from datetime import datetime
class Person():
def __init__(self, first_name="", last_name="", dob="01/01/1900", gender="female"):
self.first_name = first_name
self.last_name = last_name
self.dob = dob
self.gender = gender
def calculate... | false |
165bd77cb033c6535f0ebf67d16986a24f83dd7f | Napster56/Sandbox | /CreditCard_class.py | 2,471 | 4.15625 | 4 | """
Create a class for a consumer credit card
"""
class CreditCard:
def __init__(self, customer, bank, account, limit):
"""Make a new credit card instance
The initial balance is zero.
"""
self.customer = customer
self.bank = bank
self.account = account
sel... | true |
689b0af2411c98e7bd92590ceb0b24d8ac68b254 | Napster56/Sandbox | /user_name.py | 547 | 4.3125 | 4 | """
Ask user for their name
Tell them how many vowels are in their name
Tell them how many capitals are in their name
"""
count_vowels = 0
name = "Bobby McAardvark"
# name = input("Name: ")
for letter in name:
if letter.lower() in 'aeiou':
count_vowels += 1
print("Out of {} letters, {} has {} vowels".form... | true |
5f522189d56fe7cd74fcdd8153ada80032a89cee | Napster56/Sandbox | /Classes demo/circle_class.py | 498 | 4.46875 | 4 | """
Program to create a Circle class which inherits from the Shape class.
The subclass Circle extends the superclass Shape; Circle 'is-a' Shape.
"""
from shape import Shape
class Circle(Shape):
def __init__(self, x=0, y=0, radius=1):
super().__init__(x, y) # used to access the instance of the Shape cl... | true |
f4ca8f55ec31d63d82b33b20a76085bcb6a258ea | Napster56/Sandbox | /file_methods.py | 813 | 4.15625 | 4 | """
# readline method
temp = open("temp.txt", "r") # open file for reading
first_line = temp.readline() # reads exactly one line
print(first_line)
for line in temp: # read remaining lines
print(line)
temp.readline() # read file, return empty string
print(temp)
temp.close()
# read m... | true |
5e1390f2bdc9044de2dd6049ef3a5e0632cbf2c6 | Djheffeson/Python3-Curso-em-Video | /Exercícios/ex060.py | 330 | 4.1875 | 4 | from math import factorial
num = int(input('Digite um número para calcular seu fatorial: '))
fact = factorial(num)
print('Calculando {}! = '.format(num), end='')
while num != 0:
if num == 1:
print('{}'.format(num), end=' = ')
else:
print('{}'.format(num), end=' x ')
num -= 1
print('{}'.forma... | false |
d9d5bca64263b592ac66cc580cf3d8aff5315a62 | teeradon43/Data_Structure | /Lab/LinkedList/lab43.py | 2,422 | 4.125 | 4 | """
Chapter : 6 - item : 3 - MergeOrderList
จงเขียนฟังก์ชั่นสำหรับการ Merge LinkList 2 ตัวเข้าด้วยกันโดยห้ามสร้าง Class LinkList จะมีแต่ Class Node
ซึ่งเก็บค่า value ของตัวเองและ Node ถัดไป โดยมีฟังก์ชั่นดังนี้
createList() สำหรับการสร้าง LinkList ที่รับ List เข้ามาโดยจะ return Head ของ Linklist
printList() สำหรับกา... | false |
4a50ac2346aee77dfd6080be2541d3c810b04cea | alexisdavalos/DailyBytes | /BinaryTreeVisibleValues/binaryTreeVisibleValues.py | 921 | 4.21875 | 4 | # Given a binary tree return all the values you’d be able to see if you were standing on the left side of it with values ordered from top to bottom.
# This is the class of the input binary tree. Do not Edit!
class Tree:
def __init__(self, value):
self.val = value
self.left = None
self.right... | true |
6681a57d55dbe2ea18d6f6d5c65776935455dde9 | alexisdavalos/DailyBytes | /MakePalindrome/makePalindrome.py | 524 | 4.1875 | 4 | # Write a function that takes in a string with any set of characters
# Determine if that string can become a palindrome
# Returns a Boolean after processing the input string
def makePalindrome(string):
# Your Code Here
return
# Test Cases Setup
print(makePalindrome("aabb")) # => true (abba)
print(makePalind... | true |
dc4b771cc52cb1a5d19e2a5e07858472fcb9254d | razorblack/python_programming | /PythonPractice/PrimeOrComposite.py | 307 | 4.28125 | 4 | userInput = int(input("Enter a number to check for prime \n"))
count = 0 # To count no. of factors of user input number
for i in range(2, userInput):
if userInput % i == 0:
count += 1
if count > 0:
print(f"{userInput} is composite number")
else:
print(f"{userInput} is a prime number")
| true |
e5e647601be99ae9e20aa7c3f0f37f4867a18802 | razorblack/python_programming | /PythonLab/Program6.1.py | 673 | 4.125 | 4 | # Method to perform Linear Search
def linear_search(list_of_number, no_to_search):
size = len(list_of_number)
for i in range(0, size):
if list_of_number[i] == no_to_search:
print(f"Search Successful: Element found at index {i}")
return
print("Search Unsuccessful: Element Not... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.