blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
b50a873c8d0d45fd4ebac22fdeaa92097cdea731 | rakshithsingh55/Clg_project | /FoodSearch/webapp/test.py | 550 | 4.5 | 4 | # Python3 code to demonstrate working of
# Common words among tuple strings
# Using join() + set() + & operator + split()
# Initializing tuple
test_tup = ('gfg is best', 'gfg is for geeks', 'gfg is for all')
# printing original tuple
print("The original tuple is : " + str(test_tup))
# Common words among tuple... | true |
20ce051e440910c78ca5b3c409ff8ebb566520c0 | am3030/IPT | /data/HW5/hw5_182.py | 1,171 | 4.28125 | 4 | def main():
num1 = int(input("Please enter the width of the box: "))
num2 = int(input("Please enter the height of the box: "))
symbol1 = input("Please enter a symbol for the box outline: ")
symbol2 = input("Please enter a symbol for the box fill: ")
boxTop = ""
insideBox = ""
for i in range... | true |
5de5d8d3bedb628d5dfd81a6d4f1df396678c98c | am3030/IPT | /data/HW5/hw5_453.py | 747 | 4.3125 | 4 |
def main():
width = int(input("Please enter the width of the box: ")) # Prompt user for the width of the box
height = int(input("Please enter the height of the box: ")) # Prompt user for the height of the box
outline = input("Please enter a symbol for the box outline: ") # Prompt user for the symbol that w... | true |
7c2eb614d8ed545815425e6181dc9b77cd285d16 | am3030/IPT | /data/HW4/hw4_340.py | 451 | 4.21875 | 4 |
flavorText = "Hail is currently at height"
def main():
height = 0 # 0 is not a valid input because it is not "positive"
while height < 1:
height = int(input("Please enter the starting height of the hailstone: "))
while height != 1:
print(flavorText, height)
if (height % 2) == 0:... | true |
853882de1ef0c0ac6ddc0c41cbfd480fdcaabfef | agatakaraskiewicz/magic-pencil | /eveningsWithPython/stonePaperScissorsGame.py | 1,229 | 4.1875 | 4 | from random import randint
"""
1 - Paper
2 - Stone
3 - Scissors
1 beats 2
2 beats 3
3 beats 1
"""
points = 0
userPoints = 0
howManyWins = int(input('How many wins?'))
def userWins(currentUserScore):
print(f'You won!')
return currentUserScore + 1
def compWins(currentCompScore):
print(f'You loose!')
return curre... | true |
1fe6cd8e407ae44133b561e4c885bc0ef4904560 | kaceyabbott/intro-python | /while_loop.py | 489 | 4.28125 | 4 | """
Learn conditional repetition
two loops: for loops and while loops
"""
counter = 5
while counter != 0:
print(counter)
# augmented operators
counter -= 1
print("outside while loop")
counter = 5
while counter:
print(counter)
counter -= 1
print("outside while loop")
# run forever
while Tru... | true |
b5efc5698eac40c55d378f100337a8e52f9936fa | Nihadkp/python | /co1/16_swap_charecter.py | 396 | 4.1875 | 4 | # create a single string seperated with space from two strings by swapping the charecter at position 1
str1 = "apple"
str2 = "orange"
str1_list = list(str1)
str2_list = list(str2)
temp = str1_list[1]
str1_list[1] = str2_list[1]
str2_list[1] = temp
print("Before exchanging elements:", str1, str2)
print("string after ex... | true |
65efd951f0153acbaee277e256b3e891376ab64a | Nihadkp/python | /co1/4_occurance_of_words.py | 211 | 4.3125 | 4 | #Count the occurrences of each word in a line of text.
text=input("Enter the line : ")
for i in text.strip().split():
print("Number of occurence of word ","\"",i,"\""," is :",text.strip().split().count(i))
| true |
97b16a9798970f1f2d734ed16a60187ae7f3f7e1 | sudhanthiran/Python_Practice | /Competitive Coding/RegEx matching.py | 1,621 | 4.5625 | 5 | """
Given a pattern string and a test string, Your task is to implement RegEx substring matching.
If the pattern is preceded by a ^, the pattern(excluding the ^) will be matched with
the starting position of the text string. Similarly, if it is preceded by a $, the
pattern(excluding the ^) will be matched with the endi... | true |
dd5e52323d02710e902a1bb7ca8615a18ecfb258 | RockMurdock/Python-Book-1-Tuples | /zoo.py | 1,703 | 4.46875 | 4 | # Create a tuple named zoo that contains 10 of your favorite animals.
zoo = (
"elephant",
"giraffe",
"hippopotamus",
"monkey",
"otter",
"peacock",
"panther",
"rhino",
"alligator",
"lama"
)
# Find one of your animals using the tuple.index(value) syntax on the tuple.
print(zoo.i... | true |
c95d54e49c03fc707c8081fb3fa6f67bb27a8046 | kmollee/2014_fall_cp | /7/other/quiz/McNuggets.py | 1,336 | 4.34375 | 4 | '''
McDonald’s sells Chicken McNuggets in packages of 6, 9 or 20 McNuggets. Thus, it is possible, for example, to buy exactly 15 McNuggets (with one package of 6 and a second package of 9), but it is not possible to buy exactly 16 McNuggets, since no non- negative integer combination of 6's, 9's and 20's add up to 16. ... | true |
deaaf816ff3deab54b62b699d53b417ad3cbb3f1 | MehdiNV/programming-challenges | /challenges/Staircase | 1,216 | 4.34375 | 4 | #!/bin/python3
"""
Problem:
Consider a staircase of size (n=4):
#
##
###
####
Observe that its base and height are both equal to n and the image is drawn using # symbols and spaces.
The last line is not preceded by any spaces.
Write a program that prints a staircase of size n
"""
import math
import os
impor... | true |
c957f654ddb5d6c2fa6353ad749a7dbbb151bc44 | MehdiNV/programming-challenges | /challenges/Diagonal Difference | 1,576 | 4.5 | 4 | #!/bin/python3
"""
Problem:
Given a square matrix, calculate the absolute difference between the sums of its diagonals.
For example, the square matrix (arr) is shown below:
1 2 3
4 5 6
9 8 9
Looking at the above, you can see that...
The left-to-right diagonal = 1 +... | true |
586bd4a6b6ec0a7d844531448285fab1499f10bd | NontandoMathebula/AI-futuristic | /Python functions.py | 1,492 | 4.53125 | 5 | import math
#define a basic function
#def function1():
# print("I am a cute function")
#function that takes arguments
#def function2(arg1, arg2):
#print(arg1, " ", arg2)
#funcion that returns a value
#def cube(x):
#return x*x*x
#function with default value for an argument
def power(num, x = 1)... | true |
cf8e3546673231056cd11c663e0dfde3b158fb9c | albertisfu/devz-community | /stacks-queues/stacks-queues-2.py | 2,013 | 4.21875 | 4 |
#Node Class
class Node:
def __init__(self, data):
self.data = data
self.next_node = None
#LinkedList Class
class Stack:
def __init__(self):
self.head = None
#append new elements to linked list method
def push(self, data):
new_node = Node(data)
if self.head =... | true |
796196c624f370d5237a3f5102e900e534adc4e7 | sandeepmendiratta/python-stuff | /pi_value_to_digit.py | 1,004 | 4.28125 | 4 | #!/usr/bin/env python3
""""Find PI to the Nth Digit -
Enter a number and have the program generate PI up to that many decimal places.
Keep a limit to how far the program will go."""
import math
def getValueOfPi(k):
return '%.*f' % (k, math.pi)
def main():
"""
Console Function to create the interactiv... | true |
092a3fd97569804c742af907c3279274384885fa | 333TRS-CWO/scripting_challenge_questions | /draw_box.py | 545 | 4.25 | 4 | from typing import List
'''
Complete the draw_box function so that given a non-negative integer that represents the height and width of a box,
the function should create an ASCII art box for returning a list of strings.
Then wall of the box should be made up of the "X" character
The interior of the box should be ma... | true |
4698e65f6b47edcf78afa0b583ccc0bb873df5a3 | shouryaraj/Artificial_Intelligence | /uniformed_search_technique/uniform-cost-search.py | 1,787 | 4.21875 | 4 | """
Implementation of the uniform cost search, better version of the BFS.
Instead of expanding the shallowest node, uniform-cost search expands the node n with the lowest path cost
"""
from queue import PriorityQueue
# Graph function implementation
class Graph:
def __init__(self):
self.edges = {}
... | true |
5f40dec210d36c3114c1d66a8c2c63371e93fa88 | Pavithralakshmi/corekata | /m7.py | 356 | 4.1875 | 4 | print("cheack the given input is mulitiple by 7");
y=0
while y==0:
num=int(input("enter ur first input"))
if num>1:
for i in range(1,num):
if num%7==0:
print (num,"this number is multiple by 7")
break
else:
print(num,"this number is not multiple by 7")
y=int(input("ë... | true |
581c8b441de9dcafd76d98cfc6841f3b95bdf2c2 | Pavithralakshmi/corekata | /sec.py | 290 | 4.1875 | 4 | print("calculate amounts of seconds ")
days =int(input("Inputdays: ")) * 3600* 24
hours = int(input("Input hours: ")) * 3600
minutes = int(input("Input minutes: ")) * 60
seconds = int(input("Input seconds: "))
time = days + hours + minutes + seconds
print("The amounts of seconds ", time)
| true |
da849e60a9415fcab68301964185eec25d87a179 | ExerciseAndrew/Algorithms | /python/Stack.py | 1,271 | 4.25 | 4 | ### Implementation of a stack using python list
class Stack:
def __init__(self, items):
#creates empty stack
self._theItems = list()
def isEmpty(self)
#returns True if stack is empty
return len(self) == 0
def __len__(self):
#returns number of items in... | true |
eea7f7d0ba7898a1710816682b1aa4fad7ca2731 | Surfsol/Intro-Python-I | /src/12_scopes.py | 1,019 | 4.375 | 4 | # Experiment with scopes in Python.
# Good reading: https://www.programiz.com/python-programming/global-local-nonlocal-variables
# When you use a variable in a function, it's local in scope to the function.
x = 12
def change_x():
x = 99
change_x()
x = 99
# This prints 12. What do we have to modify in chang... | true |
beaeb644f8fe8229b68743dd33a8c898fa70a701 | Nathiington/COMP322 | /Lab03/greatest.py | 279 | 4.1875 | 4 | num1 = int(input('Enter the first number: '))
num2 = int(input('Enter the second number: '))
if num1 > num2:
print('{0} is greater than {1}'.format(num1,num2))
if num2 > num1:
print('{0} is greater than {1}'.format(num2, num1))
else:
print('Both numbers are equal')
| true |
15c333a2098d819b9a27780609d683801c0e8643 | Btrenary/Module6 | /basic_function_assignment.py | 737 | 4.15625 | 4 | """
Author: Brady Trenary
Program: basic_function_assignment.py
Program takes an employee's name, hours worked, hourly wage and prints them.
"""
def hourly_employee_input():
try:
name = input('Enter employee name: ')
hours_worked = int(input('Enter hours worked: '))
hourly_pay_rate = floa... | true |
b247074ec75f920382e80eeae0f68a123d8e15d0 | mathe-codecian/Collatz-Conjecture-check | /Collatz Conjecture.py | 743 | 4.3125 | 4 | """
The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined as follows: start with any positive integer n.
Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half the previous term.
If the previous term is odd, the next term i... | true |
1f77b65cded382e0c1c0b149edf94e02c67f5bb5 | farremireia/len-slice | /script.py | 375 | 4.15625 | 4 | toppings = ['pepperoni', 'pineapple', 'cheese', 'sausage', 'olives', 'anchovies', 'mushrooms']
prices = [2,6,1,3,2,7,2]
num_pizzas = len(toppings)
print('We sell ' + str(num_pizzas) + ' different kinds of pizzas!')
pizzas = list(zip(prices, toppings))
print(pizzas)
pizzas.sort()
print(pizzas)
cheapest_pizza = pizza... | true |
87d31fe1d670b7c6dc43441b6eefc8f578cadc52 | truevines/GenericExercise | /isomorphic_strings.py | 1,115 | 4.1875 | 4 | '''
Given two strings s and t, determine if they are isomorphic.
Two strings are isomorphic if the characters in s can be replaced to get t.
All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character but ... | true |
2087c9753aaa8e60bd2add3256f03431a538d185 | HarleyRogers51295/PYTHON-LEARNING | /1.1 PYTHON/1.4 pythong-numbers.py | 1,445 | 4.21875 | 4 | import math
import random
print("-------------BASICS & MATH--------------")
#integer is a whole number ex. 4, 500, 67, 2........ no decimals
#float has a decimal point ex. 1.521346584 .....
#python auto changes these for you if you do 1 + 1.5 it will be 2.5.
#you can use +, -, /, *, %, **(to the power of!)
print(abs(-... | true |
ade8f044c63fbfac40e25b851ded70da30ab1533 | the-potato-man/lc | /2018/21-merge-two-sorted-lists.py | 776 | 4.125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def mergeTwoLists(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
# Creating pointers ... | true |
87cee9d43718c10c989e16c6c993abd82d40d4ef | uit-inf-1400-2017/uit-inf-1400-2017.github.io | /lectures/05-summary-and-examples/code/PointRobust.py | 1,947 | 4.34375 | 4 | # Program: RobustPoint.py
# Authors: Michael H. Goldwasser
# David Letscher
#
# This example is discussed in Chapter 6 of the book
# Object-Oriented Programming in Python
#
from math import sqrt # needed for computing distances
class Point:
def __init__(self, initialX=0, init... | true |
afec1e0f73187993bcccc19b708eca0234b959f1 | merileewheelock/python-basics | /objects/Person.py | 1,904 | 4.21875 | 4 | class Person(object): #have to pass the object right away in Python
def __init__(self, name, gender, number_of_arms, cell): #always pass self, name is optional
self.name = name
self.gender = gender #these don't have to be the same but often make the same
self.species = "Human" #all Persons are automatically set... | true |
9a16c86ce7f42e1d826b67de35c866885e79c9b6 | merileewheelock/python-basics | /dc_challenge.py | 2,153 | 4.5 | 4 | # 1) Declare two variables, a strig and an integer
# named "fullName" and "age". Set them equal to your name and age.
full_name = "Merilee Wheelock"
age = 27
#There are no arrays, but there are lists. Not push, append.
my_array = []
my_array.append(full_name)
my_array.append(age)
print my_array
def say_hello():... | true |
737f4b4ac58e7c1cd65b096b1f93db0fccfdfaa6 | Zubair-Ali61997/learnOOPspring2020 | /main1.py | 1,752 | 4.3125 | 4 | #Taking the range of number from the user to find even and odd using for loop
startNum = int(input("Enter starting value: "))
endNum = int(input("Enter end value: "))
for eachNumber in range(startNum,endNum+1):
modeValue = eachNumber % 2
if modeValue == 0:
print(eachNumber, "is an even")
else... | true |
6e892b4f6d70d5c79be4b157697d474eb6ebd5cb | G00387847/Bonny2020 | /second_string.py | 279 | 4.25 | 4 | # Bonny Nwosu
# This program takes asks a user to input a string
# And output every second letter in reverse order.
# Using Loop
num1 = input("Please enter a sentence")
def reverse(num1):
str = ""
for i in num1:
str = i + str
return str
print(end="")
print(num1[::-2])
| true |
fb2bb0a3eaab6f9cdc2cc9d35b0d23b992d21e41 | skolte/python | /python2.7/largest.py | 825 | 4.1875 | 4 | # Write a program that repeatedly prompts a user for integer numbers until
# the user enters 'done'. Once 'done' is entered, print out the largest and
# smallest of the numbers. If the user enters anything other than a valid number
# catch it with a try/except and put out an appropriate message and ignore the number.... | true |
d0e11c937aed44b865d184c98db570bfb5d522d5 | jegarciaor/Python-Object-Oriented-Programming---4th-edition | /ch_14/src/threads_1.py | 587 | 4.1875 | 4 | """
Python 3 Object-Oriented Programming
Chapter 14. Concurrency
"""
from threading import Thread
class InputReader(Thread):
def run(self) -> None:
self.line_of_text = input()
if __name__ == "__main__":
print("Enter some text and press enter: ")
thread = InputReader()
# thread.start() # C... | true |
0c98aecf543889b9c73f73b014508a184b0507e2 | Tower5954/Instagram-higher-lower-game | /main.py | 1,790 | 4.21875 | 4 | # Display art
# Generate a random account from the game data.
# Format account data into printable format.
# Ask user for a guess.
# Check if user is correct.
## Get follower count.
## If Statement
# Feedback.
# Score Keeping.
# Make game repeatable.
# Make B become the next A.
# Add art.
# Clear screen between rounds.... | true |
80ac17949c445619dda20aa217ae6a7158b014ce | wz33/MagicNumber | /magic_number.py | 1,761 | 4.3125 | 4 | from builtins import input # for handling user input gracefully in Python 2 & 3
#!/usr/bin/env Python3
# Python 2 & 3
"""
Program generates a random number between 1 and 100, inclusive. User has five attempts to correctly guess the number.
"""
# Import Python module
import random # for "magic" number generatio... | true |
8d56284d45480737b0b2cd79d8c2358355828f8b | zahidkhawaja/cs-module-project-iterative-sorting | /src/iterative_sorting/iterative_sorting.py | 1,989 | 4.375 | 4 | # Runtime complexity: O(n ^ 2) - Quadratic
# Nested for-loop
def selection_sort(arr):
# loop through n-1 elements
for i in range(0, len(arr) - 1):
cur_index = i
smallest_index = cur_index
# TO-DO: find next smallest element
# (hint, can do in 3 loc)
for x in range(cur_ind... | true |
54dde7561bb2c3ef7fab4db446088c997c168037 | ZhaohanJackWang/me | /week3/exercise3.py | 2,448 | 4.40625 | 4 | """Week 3, Exercise 3.
Steps on the way to making your own guessing game.
"""
import random
def check_number(number):
while True:
try:
number = int(number)
return number
except Exception:
number = input("it is not number plz enter again: ")
def check_upper(upper, low):
upper = check_n... | true |
69d705b017380b3127c4c7cfda8636c3d8c16e3d | SOURADEEP-DONNY/PYTHON-3-PROGRAMMING | /week 4/ALIASING.py | 636 | 4.21875 | 4 | list1=[10,20,30]
list2=[10,20,30]
#CHECKING WHETHER THE TWO LISTS ARE SAME OR NOT.
print(list1 is list2)
#CHECKING THE IDS OF THE TWO LISTS.
print('THE ID OF list1 is',id(list1))
print('THE ID OF list2 is',id(list2))
#CHECKING WHETHER THE LISTS ARE EQUIVALENT OR NOT.
print(list1==list2)
#--------AL... | true |
b259e685aef03dabe48233184d84bd228beac2a9 | SOURADEEP-DONNY/PYTHON-3-PROGRAMMING | /PYTHON FUNCTIONS FILES AND DICTIONARIES/week 4/ADDITION OF AS MANY NUMBERS AS POSSIBLE.py | 263 | 4.5 | 4 | #PROGRAM TO ADD AS MANY NUMBERS AS POSSIBLE. TO STOP THE ADDITION ENTER ZERO.
#THIS KIND OF LOOP IS ALSO KNOWN AS LISTENER'S LOOP.
SUM=0
number=1
while number!=0:
number=int(input('Enter a number to add-'))
SUM=SUM+number
print('The sum =',SUM)
| true |
53d6f8a3a438037857021c5d2264c6817c7406a1 | olgarozhdestvina/pands-problems-2020 | /Labs/Topic09-errors/check_input.py | 417 | 4.28125 | 4 | # Olga Rozhdestvina
# a program that takes in a number as an input and subtracts 10%
# prints the result,
# the program should throw a value error of the input is less than 0
# input number
num = int(input("Please enter a number: "))
# calculate 90%
percent = 0.90 # (1- 0.10)
ans = num * percent
if num < 0:
rai... | true |
524e98dfa7805b3c42ff0c3c021510afdabeaf0a | SirMatix/Python | /MITx 6.00.1x Introduction to Computer Science using Python/week 1/Problem set 1/Problem 3.py | 1,413 | 4.15625 | 4 | """
Problem 3
15.0/15.0 points (graded)
Assume s is a string of lower case characters.
Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your program should print
Longest substring in alphabetical order is: beggh
In th... | true |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.