blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
51aac9ce3556555f4292613680e1658480079c57 | venkateshmorishetty/CSPP1 | /m22/assignment2/clean_input.py | 433 | 4.1875 | 4 | '''
Write a function to clean up a given string by removing the special characters and retain
alphabets in both upper and lower case and numbers.
'''
import re
def clean_string(string):
'''filters the string'''
result = re.sub('[^a-zA-Z0-9]', '', string)
return result
def main():
'''read input and pass ... | true |
12fe78e6920e54715d4ca8c9b12520a1419de7ba | venkateshmorishetty/CSPP1 | /m22/assignment3/tokenize.py | 644 | 4.21875 | 4 | '''
Write a function to tokenize a given string and return a dictionary with the frequency of
each word
'''
import re
dictionary = {}
def tokenize(string):
'''tokenize'''
# string1 = re.sub('[^a-zA-Z0-9]','',string)
list1 = string.split(' ')
for index_ in list1:
index1 = re.sub('[^a-zA-Z0-9]', '... | true |
c5ce313a4133c2fa03e8d33b14f0bbae1cdc726d | donyewuc/Personal-Projects | /TicTacToe.py | 1,606 | 4.15625 | 4 | #! python3
#This program lets you play a simple 2-player game of Tic-Tac-Toe
import sys
board = {'tl':' ','tm':' ','tr':' ','ml':' '
,'mm':' ','mr':' ','bl':' ','bm':' ','br':' ',}
count = 0
turn = 'X'
plays = []
def win(check):
'''This function checks to see if you have won the game'''
chec... | true |
f52d78d9aec18519119d29e9ba2abdef0746ff5e | rhwb/python | /numbers3.py | 286 | 4.125 | 4 | num1 = input("Please enter a number here: \n")
print("The number you have entered is: %s \n" %num1)
num2 = input("Enter another number: \n")
print("The second number you have entered is: %s \n" %num2)
num3 = int(num1) + int(num2)
print("%s + %s + %d" %num1 %num2 %num3)
| true |
0cc1d3b2b39b518d6eae67a7b1f06349d2d6b443 | ArchieMuddy/PythonExercises | /List/Exercise1/Approach4.py | 315 | 4.125 | 4 | # Swap the first and last elements of a list
# Approach 4: Use the * operand
inputList =[12, 35, 9, 56, 24]
first, *remaining, last = inputList #stores first element in first, last element in last and remaining element in *remaining
newList = last, *remaining, first #swap first and last
print(newList) | true |
688ffa9841e756a65d959b7fe1773fd87429bfea | ArchieMuddy/PythonExercises | /List/Exercise1/Approach2.py | 382 | 4.1875 | 4 | # Swap the first and last elements of the list
# Approach 2: Don;t use the len function. Instead use list[-1] to access the last element of the list
#swap function
def swapList(newList):
newList[0], newList[-1] = newList[-1], newList[0] #swapping logic without temp variable
return newList
#calling cod... | true |
f51bbb6a8590dd857d55f366d76238761a0a3f06 | sodomojo/Week3 | /hw3.py | 2,476 | 4.375 | 4 | #!/usr/bin/env python
"""
This script will do the following
- Ask the user to enter a starting and ending number
- Check that the starting number is not less than 1
- Check that the ending number is at least 5 times greater than the starting number
- Create a list of integers in the range of the user's starting and e... | true |
1186f93b2e38957a25e78ee8b9d779e0f9677b5c | Thorarinng/prog_01_kaflaverkefni | /Midterm_2/longest_gamla.py | 1,015 | 4.25 | 4 | import string
# Function definitions start here
def open_file(fname):
"""Tekur inn texta skrá or opnar hana"""
try:
word_file = ''
input_file = open(fname, 'r')
# for line in input_file:
# word_file += line
except FileNotFoundError:
print("File {}.txt no... | true |
547302f7fe8bd3ef6a5c35997b5520053af1d85f | Thorarinng/prog_01_kaflaverkefni | /Skilaverkefni/hw2/2-2_characterCounts.py | 734 | 4.15625 | 4 | # Hlynur Magnus Magnusson
# Hlynurm18@ru.is
import string
my_string = input("Enter a sentence: ")
count_digit = 0
count_lower = 0
count_upper = 0
count_punktur = 0
# for every character in the string it checks for digits, lower, upper and punctuations
# on each encounter we add one to the counter
for char in my_str... | true |
30cdfee01e33cbe30f08337a89371974b08debbf | monergeim/python | /fibonacci/func_l.py | 375 | 4.46875 | 4 | #!/usr/bin/python3.8
#calculates the nth Fibonacci number in O(n) time == without using any "for" or "while" loops
import numpy as np
num = input("Enter fibonacci num:")
def fib_matrix(n):
Matrix = np.matrix([[0,1],[1,1]])
vec = np.array([[0],[1]])
F=np.matmul(Matrix**n,vec)
return F[0,0]
print("Fi... | true |
de3a1f6d4905d4ae4b3049bb6fecbc121513a12b | veselotome4e/Programming0 | /Week 2/Saturday_Tasks/is_prime.py | 263 | 4.125 | 4 | import math
n = int(input("Enter n: "))
prime = True
start = 2
while start <= math.sqrt(n):
if n % start == 0:
prime = False
break
start +=1
if prime:
print("The number is prime!")
else:
print("The number is not prime!")
| true |
ecdfd79a0db5fa78a123fcf9f20ecc6f08cc8982 | veselotome4e/Programming0 | /Week 2/AndOrNotProblems/simple_answers.py | 363 | 4.15625 | 4 | userInput = input("Enter some text: ")
if "hello" in userInput or "Hello" in userInput:
print("Hello there, good stranger!")
elif "how are you?" in userInput:
print("I am fine, thanks. How are you?")
elif "feelings" in userInput:
print("I am a machine. I have no feelings")
elif "age" in userInput:
prin... | true |
06bb7485d5b94dff9b03b6ff15a06bdad535e024 | raotarun/assignment3 | /ass2.py | 1,492 | 4.1875 | 4 | #Create a list with user defined inputs.
a=[]
b=int(input("Enter First Element"))
a.append(b)
print(a)
#Add the following list to above created list: [‘google’,’apple’,’facebook’,’microsoft’,’tesla’]
c=["google","apple","facebook","microsoft","tesla"]
c.append(a)
print(c)
#Count the number of time an object occurs in... | true |
a5f490adc76c885d3f41e1f2990baf2e14305eb6 | ericnnn123/Practice_Python | /Exercise6.py | 367 | 4.28125 | 4 | def CheckPalindrome(word):
reverse = word[::-1]
if word == reverse:
print("'{}' is a palindrome".format(word))
else:
print("'{}' is not a palindrome".format(word))
try:
print("Enter a word to check if it's a palindrome")
word = str(input()).lower()
CheckPalindrome(wo... | true |
23e31ffbe33b07da776bcf58aecbd78b6f5c0e3d | JenishSolomon/Assignments | /assignment_1.py | 233 | 4.21875 | 4 |
#Area of the Circle
A = 3.14
B = float(input("Enter the Radius of the circle: "))
C = "is:"
print ("Input the Radius of the circle : ",B);
print ("The area of the circle with radius",B,C)
print (float(A*B**2))
| true |
238496ecca652af5fdefa421a9d0db146e78f7d3 | pteerawatt/Elevator | /elevator1.3.py | 1,348 | 4.4375 | 4 | # In this exercise we demonstrait a program that simulates riding an elevator.
#simple version
# this is 2nd draft
# refractored
import time
import sys
def print_pause(message): #add print_pause() to refractor
print(message)
sys.stdout.flush()
time.sleep(2)
print_pause("You have just arrived at your new... | true |
c2052a8082181a75fe993a36aff6a19cfe23ac8c | melgreg/sals-shipping | /shipping.py | 1,323 | 4.15625 | 4 | class ShippingMethod:
"""A method of shipping with associated costs."""
def __init__(self, name, flat_fee=0.00, max_per_pound=0.00, cutoffs=[]):
self.name = name
self.flat_fee = flat_fee
self.max_per_pound = max_per_pound
self.cutoffs = cutoffs
def get_cost(self, w):
... | true |
a3ca0d1f54d4a9e301fbe78c23a8bd3ebbff2194 | dmayo0317/python-challenge | /PyBank/main.py | 2,210 | 4.1875 | 4 | #Note most of code was provided by the UTSA instructor(Jeff Anderson) just modify to fit the assignment.
#Impot os module and reading CSV modules
import os
import csv
# Creating Variable to hold the data
profit = []
rowcount = 0
TotalProfit = 0
AverageProfit = 0
AverageChange = 0
LostProfit = 0
GainProfit = 0
#locat... | true |
bd56bc9c8f411d9cb58862397e9fa779055a59c0 | vtainio/PythonInBrowser | /public/examples/print.py | 933 | 4.40625 | 4 | # print.py
# Now we know how to print!
print "Welcome to study with Python"
# 1. Write on line 6 code that prints your name to the console
# 2. If you want to print scandic letters you have to add u in front of the text, like this.
# Take the '#' away and click run
# print u"äö"
# 3. We can also print other things... | true |
76708d7104e7cf43dbfef33cdfe3712de9905a31 | hglennwade/hglennrock.github.io | /gdi-intro-python/examples/chained.py | 253 | 4.34375 | 4 | raw_input = input('Please enter a number: ')
#For Python 2.7 use
#raw_input = raw_input('Please enter a number: ')
x = int(raw_input)
if x > 5:
print('x is greater than 5')
elif x < 5:
print('x is less than 5')
else:
print('x is equal to 5') | true |
a4458a5f224971b83dd334bb0c1dbec49495809e | professionalPeter/adventofcode | /2019/day01.py | 885 | 4.125 | 4 |
def calc_simple_fuel_requirement(mass):
"""Return the fuel required for a given mass"""
return int(mass/3) - 2
def calc_total_fuel_requirement(mass):
"""Return the total fuel requirement for the mass including
the recursive fuel requirements"""
fuel_for_this_mass = calc_simple_fuel_requirement... | true |
6f7ad11ac3dbce19b9e8d17e82df4fb74440b6b1 | Bhoomika-KB/Python-Programming | /even_odd_bitwise.py | 236 | 4.40625 | 4 | # -*- coding: utf-8 -*-
num = int(input("Enter a number: "))
# checking the number using bitwise operator
if num&1:
print(num,"is an odd number.")
else:
print(num,"is an even number.") | true |
3e9ed0848c34588af83cf79f29e854e6d1c9d510 | Puthiaraj1/PythonBasicPrograms | /ListRangesTuples/listsExamples.py | 379 | 4.125 | 4 | ipAddress = '1.2.3.4' #input("Please enter an IP address :")
print(ipAddress.count(".")) # Here I am using sequence inbuilt method count
even = [2,4,6,8]
odd = [1,3,5,7,9]
numbers = even + odd # adding two list
numbers.sort() # This is another method to sort the list value in ascending
# You can use sorted(numbers).... | true |
2b587eb5292af3261309413e7cd9436add8b72ef | dilesh111/Python | /20thApril2018.py | 904 | 4.625 | 5 | ''' Python program to find the
multiplication table (from 1 to 10)'''
num = 12
# To take input from the user
# num = int(input("Display multiplication table of? "))
# use for loop to iterate 10 times
for i in range(1, 11):
print(num,'x',i,'=',num*i)
# Python program to find the largest number among the three ... | true |
dfcf5d72d3ccedb10309dfacb5117364d8e7060c | anajera10/mis3640 | /Assignment 1/nim.py | 975 | 4.15625 | 4 | from random import randrange
def nim():
"""
Plays the game of Nim with the user - the pile size, AI intelligence and starting user are randomly determined
Returns True if the user wins, and False if the computer wins
"""
# randomly pick pile size
pile_size = randrange(10,100)
# random - dec... | true |
264f1813ea8c0463f4b6d87be10a167f33e30d5b | wheezardth/6hours | /Strings.py | 1,222 | 4.25 | 4 | # triple quotes allow to use single & double quotes in strings
# No Need For Escape characters! (Yet...)
course = '''***Monty-Python's Course for "smart" people***'''
print(course)
wisdom = '''
Triple quotes also allow to write
string with line breaks in them.
This is super convenient.
Serial.print(vomit)
'... | true |
1c0125fd19de4485bd49b72f0995f57583dd31c7 | wheezardth/6hours | /classes.py | 890 | 4.1875 | 4 | # classes define custom data types that represent more complex structures
# Default python naming convention: email_client_handler
# Pascal naming convention: EmailClientHandler
# classes in python are named using the Pascal naming convention
# classes are defined using the class keyword
# classes are blueprints of co... | true |
881ae7a58bdc18dac968b135294022aec4f641c9 | wheezardth/6hours | /StringTricks.py | 754 | 4.125 | 4 | course = 'Python for Beginners'
# len() gives string length (and other things!)
print(len(course)) # len() is a FUNCTION
course.upper() # .something() is a METHOD because it belong to a class
print(course) # the original variabe is not affected
capString = course.upper()
print(capString) # the new one is tho
print(cou... | true |
34ba84a353937822b8f9329effc073185459a380 | C-Joseph/formation_python_06_2020 | /mes_scripts/volubile.py | 324 | 4.3125 | 4 | #!/usr/bin/env python3
#Tells user if length of string entered is <10, <10 and >20 or >20
phrase = input("Write something here: ")
if len(phrase) < 10:
print("Phrase of less than 10 characters")
elif len(phrase) <= 20:
print("Phrase of 10 to 20 characters")
else:
print("Phrase of more than 20 character... | true |
426dbdf9f784ee6b3c1333b0fda1a9a2eacc2676 | antonborisov87/python-homework | /задание по строкам/test2.py | 903 | 4.5 | 4 | """Задание по строкам:
1.1. Create file with file name test.py
1.2. Create variable x and assign "London has a diverse range of people and cultures, and more than 300 languages are
spoken in the region." string to it.
1.3. Print this string with all letters uppercase.
1.4. Print this string the index of first "c" lette... | true |
7c99435541a487308dba15237bf4c57867e205f3 | neugene/lifelonglearner | /Weight_Goal_Tracker.py | 1,975 | 4.21875 | 4 | #This program tracks weightloss goals based on a few parameters.
# The entries of initial weight and current weight establish the daily weight loss change/rate
# which is used to extrapolate the target weight loss date
from datetime import datetime, timedelta
initial_weight = float(input("Enter initial weight... | true |
d09b15df7682cf7a027b8e70300274a98a5be5df | matham/vsync_rpi_data | /animate.py | 1,557 | 4.375 | 4 | '''
Widget animation
================
This example demonstrates creating and applying a multi-part animation to
a button widget. You should see a button labelled 'plop' that will move with
an animation when clicked.
'''
from os import environ
#environ['KIVY_CLOCK'] = 'interrupt'
import kivy
kivy.require('1.0.7')
from... | true |
ee0c3ca2ae21b7dc7b0c0894210277392cbe3456 | ebonnecab/CS-1.3-Core-Data-Structures | /Code/search.py | 2,869 | 4.28125 | 4 | #!python
def linear_search(array, item):
"""return the first index of item in array or None if item is not found
Worst case time complexity is O(n) where n is every item in array
"""
# implement linear_search_iterative and linear_search_recursive below, then
# change this to call your implementatio... | true |
2ffe0b58632675457a7f159c5da87cda4c8ca5ea | lew18/practicepython.org-mysolutions | /ex16-password_generator.py | 2,119 | 4.15625 | 4 | """
https://www.practicepython.org
Exercise 16: Reverse Word OrderPassword Generator
4 chilis
Write a password generator in Python. Be creative with how you generate
passwords - strong passwords have a mix of lowercase letters, uppercase
letters, numbers, and symbols. The passwords should be random, generating
a new ... | true |
a782134e78b9059206f0068a4896d51898c2d42f | lew18/practicepython.org-mysolutions | /ex18-cose_and_bulls.py | 2,236 | 4.375 | 4 | """
https://www.practicepython.org
Exercise 18: Cows and Bulls
3 chilis
Create a program that will play the “cows and bulls” game with the user.
The game works like this:
Randomly generate a 4-digit number. Ask the user to guess a 4-digit number.
For every digit that the user guessed correctly in the correct place, ... | true |
64fdc533942c6079155317077310ca6a2cf052fc | lew18/practicepython.org-mysolutions | /ex24-draw_game_board.py | 1,891 | 4.8125 | 5 | """
https://www.practicepython.org
Exercise 24: Draw a Game Board
2 chilis
This exercise is Part 1 of 4 of the Tic Tac Toe exercise series.
The other exercises are: Part 2, Part 3, and Part 4.
Time for some fake graphics! Let’s say we want to draw game boards that look like this:
--- --- ---
| | | |
--- -... | true |
56280fb746e3ecab8bd857bfb66615ed32819dbd | lew18/practicepython.org-mysolutions | /ex02-odd_or_even.py | 975 | 4.40625 | 4 | """
https://www.practicepython.org
Exercise 2: Odd or Even
1 chile
Ask the user for a number. Depending on whether the number is even or odd,
print out an appropriate message to the user.
Hint: how does an even / odd number react differently when divided by 2?
Extras:
1. If the number is a multiple of 4, print out a ... | true |
d51ea53c283dcd6fc2af776a8e0600f72a26efa9 | iaryankashyap/ReadX | /Code/ReadX.py | 1,069 | 4.34375 | 4 | # This program calculates the difficulty of a body of text by assigning it a grade
# gets user input about the text
text = input("Text: ")
letters = 0
words = 0
sentences = 0
counter = 0
for i in text:
counter += 1
for i in range(counter):
# counts the letters using ascii code
if (ord(text[i]) >= 65 and... | true |
6d38db8cf36b30a5d45a44aa94592a57b4212251 | ashwithaDevireddy/PythonPrograms | /conditional.py | 280 | 4.125 | 4 | var=float(input("Enter the number :"))
if var > 50:
print("greater")
elif var == 50:
print("equal") // used if multiple conditions are implemented
else:
print("smaller")
output:
Enter the number :2
smaller
Enter the number :50
equal
Enter the number :51
greater
| true |
b9fdb656f713c1ac6f5a408d006ca9823f46b773 | rishabhgupta/HackerRank-Python | /datatypes.py | 2,430 | 4.1875 | 4 | # 1. LISTS
"""
You have to initialize your list L = [] and follow the N commands given in N lines.
"""
arr = []
n = input()
for i in range(int(n)):
input_str = input()
split_str = input_str.split(' ')
if split_str[0] == 'insert':
arr.insert(int(split_str[1]),int(split_str[2]))
elif split_str[... | true |
8ba19ee0a4811e3f73a66d95e82614ac2b553973 | weifengli001/pythondev | /vendingmachine/test.py | 2,787 | 4.28125 | 4 | """
CPSC-442X Python Programming
Assignment 1: Vending Machine
Author: Weifeng Li
UBID: 984558
"""
#Global varable
paid_amount = 0.0#The total amount of insert coins
total = 0 #The total costs
change = 0 # change
drinks = {"Water" : 1, "Soda" : 1.5, "Juice" : 3} # The drinks dictionary stores drinks and their price
sn... | true |
0055ee064f2ecc83380d31b3de93f6fa181d2aa5 | kriyazhao/Python-DataStructure-Algorithms | /7.1_BinaryTree.py | 2,786 | 4.15625 | 4 |
#--------------------------------------------------------------------------
# Define a binary tree using List
def BinaryTree(root):
return [root, [], []]
def insertLeft(root, branch):
leftChild = root.pop(1)
if len(leftChild) < 1:
root.insert(1, [branch, [], []])
else:
root.insert(1, [... | true |
35d14bfa9ce714b65bf4f014cecab4b9be4d5901 | linnienaryshkin/python_playground | /src/basics_tkinter.py | 1,596 | 4.28125 | 4 | from tkinter import *
# Create an empty Tkinter window
window = Tk()
def from_kg():
# Get user value from input box and multiply by 1000 to get kilograms
gram = float(e2_value.get())*1000
# Get user value from input box and multiply by 2.20462 to get pounds
pound = float(e2_value.get())*2.20462
... | true |
7580ac5ec609dc67bcd19be51e92dfd3b0c053e2 | sajalkuikel/100-Python-Exercises | /Solutions/3.Exercise50-75/68.py | 723 | 4.125 | 4 | # user friendly translator
# both earth and EaRtH should display the translation correctly
#
# d = dict(weather="clima", earth="terra", rain="chuva", sajal= "सजल", kuikel="कुइकेल")
#
#
# def vocabulary(word):
# try:
# return d[word]
# except KeyError:
# return "The word doesn't exist in this dic... | true |
112071c49cbf91b77f12e542f3252a3533b750bb | cadenjohnsen/quickSelectandBinarySearch | /binarySearch.py | 2,074 | 4.375 | 4 | #!/usr/bin/env python3
from random import randint
# function to execute the binary search algorithm
def binarysearch(num, array):
row = 0 # start at the top
col = int(len(array[0])) - 1 # start at the far right
while((row < int(len(array))) and (col >= 0)): # search from top right t... | true |
dccd11a977c0cffa7796fd48c9ac7b91f4f392c6 | theOGcat/lab4Python | /lab9.py | 774 | 4.3125 | 4 | #LorryWei
#104952078
#lab9
#Example program that calculate the factorial n! , n! is the product of all positive
#integers less than or equal to n
#for example, 5! = 5*4*3*2*1 = 120
#The value of 0! is 1
#
#PsuedoCode Begin:
#
#using for loops
#for i = 1; i <=n ++1
#factorial *= i
#print out the lis... | true |
c5192b712f8bc5d41532ff4cbdc11407297740ed | theOGcat/lab4Python | /q1.py | 1,598 | 4.34375 | 4 | #LorryWei
#104952078
#Assignment3 Question1
#Example of using function randrange(). Simulates roll of two dices.
#The random module function are given below. The random module contains some very useful functions
#one of them is randrange()
#randrange(start,stop)
#PsuedoCode Begin:
#
#import randrange f... | true |
8946f235acdf5e0fa706a826264c799e8a8f6c4b | Rikharthu/Python-Masterclass | /Variables.py | 2,123 | 4.1875 | 4 | greeting = "Hello"
Greeting = "Greetings" # case-sensitive
name = "Bruce"
print(name)
name = 5 # not an error
print(name)
_myName = "Bob"
_myName2 = "Jack"
# TODO
# FIXME
age = 21
print(age) # OK
# print(greeting+age) #error, age is expected to be a string, since theres no implicit conversion
print(greeting + age... | true |
c15e0bc88eb33491c412f24183dda888e9558c18 | realhardik18/minor-projects | /calculator.py | 1,663 | 4.34375 | 4 | print("this is a basic calculator, for help enter '!help'")
user_command=input(">")
while user_command!="!quit":
if user_command=="!help":
print("to use the below functions type !start")
print("for addition enter a ")
print("for multiplying enter m")
print("for dividing enter d")
... | true |
2d7854170ec59e5368a1570547a74466e7fec9d3 | divu050704/Algo-Questions | /all_negative_elements.py | 661 | 4.28125 | 4 | def move_negative_elements(x):
print('Original list:\t',x)#We will first print the original list
size = int(len(x))#Length of the list
for i in range(0,size):
if x[i] < 0:#if x[i] is negative
main = x[i]#we will first save the element in variable because we are going to pop the element ... | true |
480682406029aacf02ab366cab99dbd00034b8e0 | sushgandhi/Analyze_Bay_Area_Bike_Share_Data | /dandp0-bikeshareanalysis/summarise_data.py | 2,980 | 4.15625 | 4 | def summarise_data(trip_in, station_data, trip_out):
"""
This function takes trip and station information and outputs a new
data file with a condensed summary of major trip information. The
trip_in and station_data arguments will be lists of data files for
the trip and station information, respectiv... | true |
b3a4a8f603b92c15e59fb7389c2b06ba96c11a7a | sweetpand/Algorithms | /Leetcode/Solutions/math/7. Reverse Integer.py | 576 | 4.1875 | 4 | """
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
click to show spoilers.
Note:
The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows.
"""
class Solution(object):
def reverse(self, x):
"""
... | true |
6eebb728c48a8b14b0875c97c733a1624542fd5d | sweetpand/Algorithms | /Leetcode/Solutions/Longest_Palindrome_Substring.py | 1,231 | 4.1875 | 4 | #Question: Given a string, find the longest palindrome in it
#Difficulty: Iterate through each element and determine if its a palindrome
#Difficulty: Easy
def longestPalindrome(s):
#Keep track of largest palindrome found so far
gmax = ""
#Helper function to find the longest palindrome given a l... | true |
13ada5c6d5e949bac39b65e40dded49cbd61e802 | dillon4287/CodeProjects | /Python/Coding Practice/linked_list/linked_list.py | 1,061 | 4.15625 | 4 | class Node:
def __init__(self, data) -> None:
self.value = data
self.Next = None
class linked_list:
def __init__(self) -> None:
self.head = None
def addLast(self, data):
if(self.head is None):
self.head = Node(data)
else:
root = self.head
... | true |
51dda073f8280d086e89356b67ee4aa0779f30a7 | ator89/Python | /MITx_Python/week2/week2_exe3_guessMyNumber.py | 1,217 | 4.125 | 4 | import random
secret = int(input("Please think of a number between 0 and 100!"))
n = random.randint(0,100)
low = 0
high = 100
while n != secret:
print("Is your secret number " + str(n) + "?")
option = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' ... | true |
1b1fe1a95570be4c2444f919cbf5b4eab9a1bd8b | harshithamagani/python_stack | /python/fundamentals/hello_world.py | 808 | 4.46875 | 4 |
print("Hello World!")
x = "Hello Python"
print(x)
y = 42
print(y)
name = "Zen"
print("My name is", name)
name = "Zen"
print("My name is " + name)
#F-Strings (Literal String Interpolation)
first_name="Zen"
last_name="Coder"
age=27
print(f"My name is {first_name} {last_name} and I am {age} years old.")
#string.for... | true |
1e7f9513f24543c2d3248a8c066300f033c6ba78 | harshithamagani/python_stack | /python/fundamentals/Function_Basic_II/valsGreatThanSecnd.py | 753 | 4.375 | 4 | #Write a function that accepts a list and creates a new list containing only the values from the original list that are greater than its 2nd value. Print how many values this is and then return the new list. If the list has less than 2 elements, have the function return False
#Example: values_greater_than_second([5,2,3... | true |
9444dff462f8659dd24b92f896d5e4726f72cd93 | Anju3245/Sample-example | /ex66.py | 393 | 4.1875 | 4 | print("enter number frist:")
frist = input()
print("enter second number:")
second = input()
print("enter third number:")
third = input()
if frist > second:
if frist > third:
print(f"{frist} is the largest")
else:
print(f"{third} is the largest ")
else:
if second > third:
print(f"{se... | true |
3c083f3459f90d53a318a1f3528a0349aa77b509 | thegr8kabeer/Current-Date-And-Time-Shower-Python | /current _date_and_time.py | 635 | 4.1875 | 4 | # A simple python project made by Thegr8kabeer to display the current date and time
# Easy to understand syntax for the person who knows the basics of Python by using the built-in Pyhton modules time and datetime
# Feel free to edit my code and do some experiments!!!
# Don't forget to follow me on instagram at https... | true |
e30351f4fb9d2a579809bca75303940edd726416 | beenorgone-notebook/python-notebook | /py-book/py-book-dive_into_py3/examples/roman3.py | 2,328 | 4.125 | 4 | '''Convert to and from Roman numerals
This program is part of 'Dive Into Python 3', a free Python book for
experienced programmers. Visit http://diveintopython3.org/ for the
latest version.
'''
roman_numeral_map = (('M', 1000),
('CM', 900),
('D', 500),
... | true |
7e389217ee1a884961db1858d48fcd11f2ae42a6 | beenorgone-notebook/python-notebook | /py-recipes/use_translate_solve_alphametics.py | 2,039 | 4.15625 | 4 | def alphametics(puzzle):
'''
Solve alphametics puzzle:
HAWAII + IDAHO + IOWA + OHIO == STATES
510199 + 98153 + 9301 + 3593 == 621246
The letters spell out actual words, but if you replace each letter
with a digit from 0–9, it also “spells” an arithmetic equation.
The trick is to figure out w... | true |
c6f454afce86b20fd2be8c3fd955f810ef5a0d27 | DscAuca/into-to-python | /src/intro/string.py | 2,597 | 4.125 | 4 | print("hello world")
print('hello world')
print('"i think you\'re aweosme tho"')
print('this is "going to work" as i said')
name='salvi'
print('welcome '+ name +' you\'re awesome')
print(3*('i repeat you\'re awesome '))
print(len('aesome shit')/len(name))
print(name[0])
# Quiz: Fix the Quote
# The line of code in th... | true |
209e2d4a62767c2e446e9e53eaf1af476467d63d | DscAuca/into-to-python | /src/data structure/compound_datatype.py | 1,772 | 4.625 | 5 | elements = {"hydrogen": {"number": 1,
"weight": 1.00794,
"symbol": "H"},
"helium": {"number": 2,
"weight": 4.002602,
"symbol": "He"}}
helium = elements["helium"] # get the helium dictionary
hydrogen_weight... | true |
b9b9661b9bb7997c0121d7bc378ad1045abfcd99 | VMGranite/CTCI | /02 Chapter - Linked Lists in Python/2_4_Partition.py | 798 | 4.4375 | 4 | #!/usr/bin/env python3
# 1/--/2020
# Cracking the Coding Interview Question 2.4 (Linked Lists)
# Partition: Write code to partition a linked list around a value x,
# such that all nodes less than x come before all node greater than
# or equal to x. If x is contained within the list, the values
# of x only need to be af... | true |
4006054a3e31786ea7b93aa99cc2be4a305f5949 | candytale55/Copeland_Password_Username_Generators | /username_password_generators_slice_n_shift.py | 1,429 | 4.21875 | 4 | # username_generator take two inputs, first_name and last_name and returns a username. The username should be
# a slice of the first three letters of their first name and the first four letters of their last name.
# If their first name is less than three letters or their last name is less than four letters it should ... | true |
a9fe4064f0aa9a13bc6afcfec7b666f3977ff9e9 | mjdecker-teaching/mdecke-1300 | /notes/python/while.py | 1,958 | 4.28125 | 4 | ##
# @file while.py
#
# While-statement in Python based on: https://docs.python.org/3/tutorial
#
# @author Michael John Decker, Ph.D.
#
#while condition :
# (tabbed) statements
# condition: C style boolean operators
# tabbed: space is significant.
# * Avoid mixing tabs and spaces, Python relies on correct positi... | true |
b47f30bb8fcea15b3b08ec5cf0cd32412ec2b652 | sdesai8/pharmacy_counting | /src/helper_functions.py | 2,962 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 24 00:17:08 2019
@author: savan
"""
from decimal import Decimal
def isPositiveDecimal(number):
"""
To validate if value is positive decimal number
Parameters:
arg1 (string): like example: prescriber_id/drug_cost
Return... | true |
883db011c2393aec6b1ee725ac2eeba0e356d8cb | xubonnie/ICS4U | /Modular Programming/scope.py | 468 | 4.125 | 4 | __author__ = 'eric'
import math
def distance(x1, y1, x2, y2):
d = math.sqrt((x2-x1)**2 + (y2-y1)**2)
return d
def main():
x_1 =input("Enter an x-value for the first point: ")
y_1 =input("Enter an y-value for the first point: ")
x_2 = input("Enter an x-value for the second point: ")
y_2 = inpu... | true |
796531ea77eaec4ece9afdfdcde2ab94bdac913c | domingomartinezstem/QC | /SymmetricKeyEncryption.py | 720 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 25 21:41:05 2018
@author: domin
"""
#this works!
def encrypt(sentence):
result = []
for letter in sentence:
l= ord(letter)
result.append(l)
print("encrypted message")
for numbers in result:
print(numbers, end='')
... | true |
e104f9ebfb10a9d46c3d633b354732e2bb6cec47 | amobiless/Assessment | /04_number_checker_v2.py | 731 | 4.1875 | 4 | # Integer checker - more advanced
def calculate():
valid = False
while not valid:
try:
num = float(input("Enter participant's time: "))
if isinstance(num, float):
valid = True
return num
except ValueError:
print("That is not a n... | true |
e817977014fc2fec163f0df739ba34ccf728c24b | trohit920/leetcode_solution | /python/521. Longest Uncommon Subsequence I.py | 1,662 | 4.21875 | 4 | # Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other strings.
#
# A subsequence is a sequence that can... | true |
e8a0f8465b56dd066ed0dbb4258653ce948e9d4d | trohit920/leetcode_solution | /python/TopInterviewQuestionEasy/others_easy/Hamming Distance.py | 1,525 | 4.21875 | 4 | '''
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Given two integers x and y, calculate the Hamming distance.
Note:
0 ≤ x, y < 231.
Example:
Input: x = 1, y = 4
Output: 2
Explanation:
1 (0 0 0 1)
4 (0 1 0 0)
↑ ↑
The above arrows p... | true |
bce300aea98561a98bb61d797445903c8c1d0bca | Schachte/Learn_Python_The_Hard_Way | /Excercise_33/Excercise_33.py | 621 | 4.40625 | 4 | ################################
######### Excercise 33##########
# Learning Python The Hard Way#
####### Ryan Schachte ##########
################################
#Gain exit conditional input from the user
print 'Loop Count?' #Count number of times user would like to loop through string format
exit_conditional = raw... | true |
163bc5411b58de28c9fb80339d01f5b23629c056 | Schachte/Learn_Python_The_Hard_Way | /Excercise_29/Excercise_29.py | 735 | 4.71875 | 5 | ################################
######### Excercise 29##########
# Learning Python The Hard Way#
####### Ryan Schachte ##########
################################
#Implement a what if statement for python to execute certain code under certain condition
'''
Initial Assignments to children and adults
'''
adults = 30
c... | true |
d2a7dc9657d3c03124364566d5357cfb366e9728 | Schachte/Learn_Python_The_Hard_Way | /Excercise_39/Excercise_39.py | 1,285 | 4.46875 | 4 | ################################
######### Excercise 39##########
# Learning Python The Hard Way#
####### Ryan Schachte ##########
################################
#Description:
#Working with dictionaries in Python
#Mapping multiple items to elements in a list. Each element is a key.
#Example
dict_info = {
'Sta... | true |
570c634276f332186e724395acf46982be490a0f | Schachte/Learn_Python_The_Hard_Way | /Excercise_32/Excercise_32.py | 2,218 | 4.4375 | 4 | ################################
######### Excercise 32##########
# Learning Python The Hard Way#
####### Ryan Schachte ##########
################################
#Objective:
#Build a loop that adds data into a list and then have python print the data using string formatter
'''
loop_data = [] #Instantiate an empty li... | true |
4af768058ec3159db5565e0bcfd1f6bdd2d6a86a | DavinderSohal/Python | /Activities/Activity_9/Exercise2.py | 679 | 4.59375 | 5 | # Create a dictionary with keys ‘firstname’, ‘lastname’ and ‘age’, with some values assigned to each
# Add an additional key ‘address’ to the dictionary
# Print out the list of keys of your dictionary
# Create a ‘name’ key with the value as a string containing both first and last name keys. Is it possible to do this
# ... | true |
8adf5bc896807610f51ac9496e2ed64fdf8c2235 | DavinderSohal/Python | /Activities/Activity_6/Exercise2.py | 1,068 | 4.34375 | 4 | # Create the following python program:
# This program will display a mark table to the user, depending on its input.
# The columns represents the subjects.
# The rows represents the students.
# Algorithm to input data from the user:
# o Ask the user how many subjects (columns) is necessary.
# o Ask the user... | true |
773b2d7e700e82c2205b4f0a41b1c813b510452d | DavinderSohal/Python | /Activities/Activity_2/split.py | 752 | 4.40625 | 4 | # Exercise: Using the following sentence:
# “The quick brown fox jumps over the lazy dog”,
# convert this string into a list and then find the index of the word dog and sort the list of terms/words in
# ascending order. Print out the first two elements of this sorted list. Additionally, as a bonus, try to reverse
... | true |
efa9da8b6523c80bca5f9dfc9c34af4157a57cce | DavinderSohal/Python | /Activities/Activity_11/Exercise1.py | 414 | 4.3125 | 4 | # Create an empty class called Car.
#
# Create a method called initialize in the class, which takes a name as input and saves it as a data attribute.
#
# Create an instance of the class, and save it in a variable called car.
#
# Call the initialize method with the string “Ford".
class Car:
def initialize(self, nam... | true |
4e8fe4ef896f9bd4a7546a1cfa61ff11e0a2143a | DavinderSohal/Python | /Activities/even/even.py | 229 | 4.1875 | 4 | def even_number(number):
try:
if number % 2 == 0:
print("This entered number is even")
except:
print("The number entered by you is not even")
num = input("Enter the number")
even_number(num)
| true |
54adb4c74bdfcd80e96fdef01e7ac94c3f38602e | DavinderSohal/Python | /Activities/Activity_4/Exercise1.py | 409 | 4.28125 | 4 | # Create a string with your firstname, lastname and age, just like in the first week of the class, but this time using
# the string formatting discussed on the previous slides – and refer to the values by name, the output should be
# similar to the following:
# Name:
# Age:
print("Name: {first_name} {last_name} \nAg... | true |
aeda5f94162716a34fb7808246727645197b8a5c | Chetana-Nikam/python | /Python Udemy Course/Function.py | 876 | 4.25 | 4 | # function - It is block of code and it will work only when we call it
def myfun():
print("I am Function")
myfun() # Function call
def myfun(name, age):
print(f"My name is {name} and my age is {age}")
myfun('Chetana', 21)
myfun('Google', 20)
def myfun(*name): # * indicats ... | true |
60ebc2b61f6e2d949fdb22b41ca77d7e5de3bb99 | cs-fullstack-2019-fall/python-arraycollections-b-cw-marcus110379 | /cw.py | 2,002 | 4.1875 | 4 | # Create a function with the variable below. After you create the variable do the instructions below that.
# # ```
# # arrayForProblem2 = ["Kenn", "Kevin", "Erin", "Meka"]
# a) Print the 3rd element of the numberList.
# b) Print the size of the array
# c) Delete the second element.
# d) Print the 3rd element.
def probl... | true |
6557645116815000d065cf2aca60415229417617 | rkang246/data-regression | /Plot Data/plot_data.py~ | 1,915 | 4.125 | 4 | #!/usr/bin/env python2
#
# ======================================================
# Program: plot_data.py
# Author: Robert Kang
# (rkang246@gmail.com)
# Created: 2018-08-01
# Modified 2018-08-01
# ------------------------------------------------------
# Use: To plot a set of data and connect each data point
# w... | true |
b70c21ffd48778f8b30c0673d7bb474c7023d77d | Golgothus/Python | /Ch2/yourName.py | 565 | 4.25 | 4 | # Beginning of the end.
# I'm embarking on my journey to learn Python
# These comments will always be in the beginning of my programs
# Enjoy, Golgothus
# Ch. 2 While Statements
name = ''
while name.lower() != 'your name':
# Above statment makes the users input and forces it to all lower case
print('Please type \'... | true |
5534c84906fc2bb54970d85a825749ec942088f1 | Golgothus/Python | /Ch4/tupleListExamples.py | 658 | 4.21875 | 4 | #! /usr/bin/python3
# tuples are made using () not []
print('an example of a tuple is as follows:')
print('(\'banana\',\'eggs\',\'potato\').')
print('an example of a list is as follows:')
print('[\'banana\',\'eggs\',\'potato\'].')
exampleTuple = ('eggs','potato')
exampleList = ['eggs','potato']
type(exampleTuple)
t... | true |
99d4bc94b4876f5e8579cecde7a4dd475ffa93b8 | Golgothus/Python | /Ch5/validate_chess_board.py | 2,503 | 4.71875 | 5 | #! /usr/bin/python
'''
In this chapter, we used the dictionary value {'1h': 'bking', '6c': 'wqueen', '2g': 'bbishop', '5h': 'bqueen', '3e': 'wking'} to represent a chess board. Write a function named isValidChessBoard() that takes a dictionary argument and returns True or False depending on if the board is valid.
A v... | true |
4e14b565661cad000f21cb9cfadd6b2d09771ad3 | JN1995/Programming-Languages | /python for Beginner/Most_used_Built_in_Functions_and_List_Comprehension.py | 1,663 | 4.5 | 4 | ## Commonly used Built-in functions in Python
# 1) Range function
# 2) Enumerate
# 3) zip
# 4) in
# 1) Range function
for num in range(10):
print(num)
for num in range(3,10):
print(num)
for num in range(0,11,2):
print(num)
my_list = [1,2,3,4,5,6,7,8,9,10]
range(10)
list(r... | true |
ec8560d4b6c63653d71fbfe6fe094e4cb1aaf198 | JN1995/Programming-Languages | /python for Beginner/datatype/List's.py | 1,224 | 4.375 | 4 | ## List's ##
# 1) concatenation
# 2) Define empty list
# 3) Indexing in list
# 4) Editing the list's
# 5) Add list into list
# 6) Python in-build functions with the list's
my_list = ["Hello", 100, 23.47]
print(my_list)
second_list = ["one", "two", "three"]
print(second_list)
print(my_list, second_lis... | true |
5ded636ffafb656e05509d03e6d272fc3323e43f | phaustin/eoas_nbgrader | /Notebooks/python/NotebookStudent4.py | 934 | 4.40625 | 4 | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.2'
# jupytext_version: 1.2.0
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %% [markdown]
# Que... | true |
b5e14aa7c7d4fe50bb56b8b83de4e00afa91d8e3 | Alex-HK-Code/Mini-Database-Exercise | /main.py | 503 | 4.15625 | 4 | books = [] #this is used to store new inputs
while(True):
user_selection = input("Enter '1' to add a new book | Enter '2' to view all books | Enter '3' to quit the program\n")
if(user_selection == str(0)): #str(0) == '0'
break
if(user_selection == str(1)): #str(1) == '1'
book_name = input("Enter Book N... | true |
a71d6595e324adbed8851eea163ad68550a11c1f | Varun901/Small-Projects | /McMaster GPA Calculator.py | 961 | 4.3125 | 4 | from operator import mul
def sum_func(units, grades):
""" For product below you can also use the following commands:
1. [a*b for a,b in zip(a,b)]
2. import numpy as np
product = np.multiply(units,grades)
"""
product = map(mul,units,grades)
sum_product = sum(product)
return sum_product
def num_fun... | true |
06c6af3f560ea8d3f428aa85bdfa8d188c6a9124 | yzziqiu/python-class | /labs/lab2-payment-modi.py | 1,374 | 4.15625 | 4 | # lab2
# algebraic equation
# payment = (((1+rate)^years)*principal*rate/(1+rate)^years-1)
# use variables and two decimal places
# find out annual and monthly payment
principal_in = ((raw_input('Please enter the amount you borrowed:')))
# enter with dollar sign
principal = float(principal_in.replace('$',''))
... | true |
4c10480ed9277a02275d13d06a07902de5e15d6e | theskinnycoder/python-lab | /week8/b.py | 662 | 4.1875 | 4 | '''
8b. Write a program to convert the passed in positive integer number into its prime factorization form
'''
from math import sqrt
def get_prime_factorization_form(num):
ans_list = []
for factor in range(2, int(sqrt(num)) + 1):
count = 0
while num % factor == 0:
count += 1
... | true |
48514e765b3a19947c7056197e9bac63626c6a62 | theskinnycoder/python-lab | /week2/a.py | 418 | 4.1875 | 4 | '''
2a. Write a program to get the number of vowels in the input string (No control flow allowed)
'''
def get_number_of_vowels(string):
vowel_counts = {}
for vowel in "aeiou":
vowel_counts[vowel] = string.count(vowel)
return sum(vowel_counts.values())
input_string = input('Enter any string : ')
p... | true |
84f8f5df072c9e6bc9d026daada6f3ddf90eea47 | AmilaSamith/snippets | /Python-data-science/if_statement.py | 885 | 4.375 | 4 | # if statement
"""
Single if statement
----------------------------------------------------------------
if(condition):
(code to be executed if condition is True)
if-else statement
----------------------------------------------------------------
if(condition):
(code to be execute... | true |
1d273a7086c4554096a9724085d304a21cfcaa53 | dim4o/python-samples | /dynamic-programming/max_sum_subsequence_non_adjacent.py | 1,004 | 4.28125 | 4 | def find_max_non_adjacent_subsequence_sum(sequence):
"""
Given an array of positive number, find maximum sum subsequence such that elements
in this subsequence are not adjacent to each other.
For better context see: https://youtu.be/UtGtF6nc35g
Example: [4, 1, 1, 4, 2, 1], max_sum = 4 + 4 + 1 = 9
... | true |
fc264f6a5a5b7142c7ce9bc619af9e046d578777 | dim4o/python-samples | /dynamic-programming/total_ways_in_matrix.py | 838 | 4.125 | 4 | def calc_total_ways(rows, cols):
"""
Given a 2 dimensional matrix, how many ways you can reach bottom right
from top left provided you can only move down and right.
For better context see: https://youtu.be/GO5QHC_BmvM
Example with 4x4 matrix:
1 1 1 1
1 2 3 4
1 3 6 10
1 4 10 20 ->... | true |
0a8110b50e90fa492f518f18de598d79143a0d29 | dim4o/python-samples | /dynamic-programming/weighted_job_scheduling.py | 1,736 | 4.25 | 4 | def find_best_schedule(jobs):
"""
Given certain jobs with start and end time and amount you make on finishing the job,
find the maximum value you can make by scheduling jobs in non-overlapping way.
For better context see: https://youtu.be/cr6Ip0J9izc
Example:
(start_time, end_time, value)
(... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.