blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
9999fdb784af5ae8d5a46e1565f836bcedeff36f | atymoshchuk/python_tutorials | /python_decorators/02_function_decorators/02_02_stacked_function_decorator.py | 979 | 4.1875 | 4 | # first simple decorator
def first_dec(func):
def wrapped(*args, **kwargs):
print("Something happened in First decorator!")
return func(*args, **kwargs)
return wrapped
# second simple decorator
def second_dec(func):
def wrapped(*args, **kwargs):
print("Something happened in Second... | true |
2c5516c20469978ff2a55ad5c80ae30545bfc227 | andyslater/Python-Fundamentals | /Introduction to Python Fundamentals/modularity2.py | 1,656 | 4.3125 | 4 | """ Retrieve and print words from a list
Tools to read a UTF-8 text document from a URL which will be split in to its component words for printing.
This is from pluralsight, Python Fundamentals, Strings and collections chapter
https://app.pluralsight.com/player?course=python-fundamentals&author=austin-bingham&name=... | true |
115ccb803cbabadd0a91997826bac178dea5e97e | Vadali-19/Hacktoberfest_2K21 | /Python/basic_calculator.py | 628 | 4.28125 | 4 | print("Welcome to python calculator\n")
#Taking input from the user.
num1 = float(input("Enter first number : "))
num2 = float(input("Enter second number : "))
while True:
#Knowing the choice from user about the operation to be performed.
option = int(input("1. Addition\n2. Substraction\n3. Divition\n4. Multiplic... | true |
5837be02bf4ec3da8e84480cf1f0abdce6dbc5b3 | NeelShah18/googletensorflow | /operation.py | 1,559 | 4.28125 | 4 | import tensorflow as tf
#Defining constant using tensorflow object
a = tf.constant(2)
b = tf.constant(3)
'''
Open tensorflow session and perform the task, Here we use "with" open the tensorflow because with will close the session automatically so we dont need to remember to close
each sessiona fter starting it. We c... | true |
eac586ac0a1860fb576c0c534fd98ee58713084d | thedejijoseph/collection | /dirtyscripts/matrix.py | 582 | 4.21875 | 4 | # 02072018; 1433
# reading and re-learning algebra => artificial intelligence
# matrix multiplication
def matmul(A, B):
"""Perform a matrix multiplication of two matrices."""
# matrix A should have the same columns as B as rows.
if len(A) != len(B):
raise ParseError("Incompatible matrices of differing sizes.")
... | true |
f975ddb5437609a81f3932a02c0b1aeac1dfd939 | aiurforever/python_class | /navigating_dirs_and_files/find_files.py | 1,773 | 4.375 | 4 | #this file has examples of using the python os module for navigating directories and files
import os
print '\nPart 1:\n'
#the easiest way to go through all directories and files is os.walk
for root, dr, filename in os.walk('dirs_and_files'):
#it walks down from the top directory
print 'root = ', root
print... | true |
ee5eb65ce57b4497ed1a7fa9c4da9af9ee46dc87 | RGero215/Interview_Questions | /recursion.py | 1,166 | 4.1875 | 4 | import tokenize
import inspect
nums = [1,2,3]
# define a function name recursion that takes a list of numbers name nums and index default 0
def recursion(nums, index=0):
'''
This function traverse a list recursibly
'''
# create a current variable starting at the first index of nums
current = nums[0... | true |
476c9430ac50b2947b6a48aa51df07bb8f782ded | avishgos/Basic-Python-Programs | /03 Prime Number.py | 682 | 4.125 | 4 | #Using user input
num = int(input('Enter a number to check whether it is prime or not:'))
if num>1:
for i in range(2,num):
if (num % i == 0 ):
print(num,'is not a prime number')
break
else:
print(num,'is a prime number')
else:
print(num,'is not a prime ... | true |
f3ee92a53da7dc83febd45545f5c989fa6ea49be | kumardev0614/Durgasoft | /13 OOPs/07 Static Method.py | 1,675 | 4.21875 | 4 | # Here we will see how static method works.
class devMath:
@staticmethod
def d_add(a, b):
return a + b
@staticmethod
def d_mul(a, b):
return a * b
@staticmethod
def d_div(a, b):
return a/b
print(devMath.d_add(10,50))
print(devMath.d_mul(10,50))
print(devMath.d_div(10... | true |
e508ad7f8a76f5145e88634f1d06f3cab2c7a84b | kumardev0614/Durgasoft | /13 OOPs/00 Class and Objects.py | 1,693 | 4.65625 | 5 | # Here we will learn what is:
# Class
# Object
# Reference variable
# Suppose We have to built Many TV sets of new model
# Then there will be a design of that TVs with there internal architecture, properties, Things that TV can do etc
# 1) Class = This DESIGN will work as ClASS
# Now based on the design We will creat... | true |
0dea084259c702d9b0bc84347da6b98362633331 | kumardev0614/Durgasoft | /11 Modules/37 Ramdom Module.py | 2,174 | 4.5625 | 5 | # Here in this file we will see many important and mostly used methods of random Module
from random import *
from math import *
# 1) random()
print('---------random()---------------')
# it will generate float values between 0 and 1, not including 0 and 1, 0<x<1
for x in range(5):
print(random())
# -------------... | true |
48f0d6b36f093178af3c2e29f880f8bf057e3d6a | uvkrishnasai/algorithms-datastructures-python | /datastructures/linkedlist/OddEvenLinkedList.py | 1,521 | 4.21875 | 4 | """
Given a singly linked list, group all odd nodes together followed by the even nodes.
Please note here we are talking about the node number and not the value in the nodes.
You should try to do it in place.
The program should run in O(1) space complexity and O(nodes) time complexity.
Example 1:
Input: 1->2->3->4->... | true |
198249dfbadc89c11fb564cc849c2a576438f299 | uvkrishnasai/algorithms-datastructures-python | /algorithms/other/IntegerToEnglishWords.py | 2,784 | 4.21875 | 4 | """
Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.
Example 1:
Input: 123
Output: "One Hundred Twenty Three"
Example 2:
Input: 12345
Output: "Twelve Thousand Three Hundred Forty Five"
Example 3:
Input: 1234567
Output: "One Million Two Hundred Th... | true |
cef8117729a52c2650c5468edad49306fac1618f | lokeshraogujja/practice | /accept_names_display_in_ sorted _an_without_duplicates.py | 276 | 4.125 | 4 | # accept names until user gives end and display them in sorted order without duplicates
names = set()
while True :
n = input("Enter a Name (press end to stop) : ")
if n == "end":
break
names.add(n)
print(f"The given names are : {sorted(names)}")
| true |
870e50ba61afba078c47355782ff8bd4d8ae3241 | itsbhagya95/Python-OOPS | /str_method.py | 857 | 4.21875 | 4 | '''class Student:
def __init__(self,name,rollno,marks):
self.name=name
self.rollno=rollno
self.marks=marks
s1=Student('Bhagya',101,95)
s2=Student('MAdhu',102,50)
print(s1)
print(s2)
In the above case,whenever we directly try to print the object,internally __str__ will get called whose defaul... | true |
947c11b86063dad550e1391f4bb769df1aff79e0 | pfkevinma/stanCode_Projects | /stanCode_Projects/huffman_encoding/huffman_encoding.py | 2,316 | 4.25 | 4 | """
File: huffman_encoding.py
Name: Pei-Feng(Kevin) Ma
-----------------------------------
This program demonstrates the idea of zipping/unzipping
through the algorithm of Huffman Encoding.
We will be using all of the important concepts
we learned today to complete this hugh project.
"""
from ds import Tree, PriorityQ... | true |
582496abf71acdb1d9c17503ef01f123f0a83524 | pfkevinma/stanCode_Projects | /stanCode_Projects/hangman_game/hangman.py | 2,821 | 4.1875 | 4 | """
Name: Pei-Feng (Kevin) Ma
File: hangman.py
-----------------------------
This program plays hangman game.
Users sees a dashed word, trying to
correctly figure the un-dashed word out
by inputting one character each round.
If the user input is correct, show the
updated word on console. Players have N_TURNS
to try in ... | true |
ed5c546563573b8a646773661fb8bf29e503099b | mariodportillo/First-Python-Class-11-11-2017 | /Python Class/tertP2.py | 374 | 4.1875 | 4 | #x = 0
#def fac(num):
#if x == 0
# return 1
#else
# return x*fac(x-1)#
num = int(input("Choose a number."))
factorial = 1
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factori... | true |
79b411500113f21039421f48906929feaf959a78 | tusharpanda88/python-utils | /conditional_while.py | 1,882 | 4.21875 | 4 | #Qns:
# Use a while statement to loop through a list of words and to find the first word with a specific number of characters.
# Use a while statement to loop through a list; pop each item off the right end of the list and print the item, until the list is empty.
# Write a function that uses a while statement and str.f... | true |
00665ac0a3e7af22fa17a4e7d7f858912579122c | JRHyc/Python | /Practice/bike.py | 796 | 4.15625 | 4 | class Bike(object):
def __init__(self, price, max_speed, miles = 0):
self.price = price
self.max_speed = max_speed
self.miles = miles
def diplay_info(self):
print self.price
print self.max_speed
print self.miles
return self
def ride(self):
pr... | true |
a9d458b2cfcfab2edc8620d794f2af467bf71de7 | JRHyc/Python | /Practice/fun_with_functions_2.py | 414 | 4.375 | 4 | # Multiply:
# Create a function called 'multiply' that iterates through each value in a list (e.g. a = [2, 4, 10, 16])
# and returns a list where each value has been multiplied by 5.
# The function should multiply each value in the list by the second argument. For example, let's say:
def multiply(arr,num):
for x ... | true |
e4123aa50a4e790b84dd74548196407f2d8869ce | laiananardi/100daysofcode | /courses/python_scrimba/09ListBasics/exercise.py | 936 | 4.25 | 4 | # SELLING LEMONADE
# The lists show number of lemonades sold per week
# Profit for each lemonade sold is 1.5$
# 1- Add another day to week 2 list by capturing a number as input
# 2- Combine the two lists into the list called 'sales
# 3- Calculate/print how much you have earned on: best day, worst day, separately and in... | true |
f825b404260542dc232ca48c6632d4e5a5526e3d | Passbee/passbee_rep | /lesson7/task2.py | 505 | 4.5 | 4 | """
Task 2
Creating a dictionary.
Create a function called make_country, which takes in a country’s name and capital as parameters.
Then create a dictionary from those parameters, with ‘name’ and ‘capital’ as keys.
Make the function print out the values of the dictionary to make sure that it works as intended.
"""
... | true |
d553c9efb3301b31aeb1f9ed1ddb773dbacb6e48 | ek17042/ORS-PA-18-Homework04 | /task3.py | 812 | 4.53125 | 5 | """
=================== TASK 3 ====================
* Name: Area Of Circle
*
* Write a function `area_of_circle` that will
* return area enclosed by a circle of radius `r`.
* Consider that only float value for radius will
* be passed. Negative values should be considered
* as typo and function should ignore sign of... | true |
91f57cc5b94f127089fb631c8e10b5f47ab9ffb9 | hkowrada/new | /1.4.py | 236 | 4.3125 | 4 | print('finding the volume of a sphere with diameter 12 cm.')
print('Volume formula : V=4/3 * π * (r*r*r)')
print('We already know that radius is half of diameter.Hence r=D/2')
r = 12/2
V = ((4/3)*(22/7)*(r*r*r))
print('Volume is:', V)
| true |
c5e7ddf0d51f617eaeaae5b7c2f44cb078ab554d | olteffe/GrokkingAlgorithms | /2-SelectionSort/selection_sort.py | 508 | 4.15625 | 4 | def find_smallest(arr: list) -> int:
smallest: int = arr[0]
smallest_index: int = 0
for i in range(1, len(arr)):
if arr[i] < smallest:
smallest = arr[i]
smallest_index = i
return smallest_index
def selection_sort(arr: list) -> list:
new_arr: list = []
for i in r... | true |
98914ce479b1cefcf82892c11b2854c210eba5a5 | SetoKibah/Simple-Machine-Learning | /main.py | 1,069 | 4.28125 | 4 | #Description: Build a simple machine learning python program
#Import dependencies
from sklearn.linear_model import LinearRegression
import random
#Create two empty lists
feature_set = []
target_set = []
#Get the number of rows for the data set
number_of_rows = 200
#Limit the possible values in the data set
random_nu... | true |
cc173193edff8c2778e4ec07a0bdee352b0d5657 | georgesims21/Python_HR-Challenges | /2-Basic_Data_Types/lists.py | 1,804 | 4.34375 | 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 ... | true |
b564073b719c1dc315941e6242cbca6b8a269ad2 | georgesims21/Python_HR-Challenges | /4-Strings/find_a_string.py | 1,110 | 4.125 | 4 | #------------------------------------------------------------------------------#
# In this challenge, the user enters a string and a substring. You have to print
# the number of times that the substring occurs in the given string. String
# traversal will take place from left to right, not from right to left.
# NOTE: St... | true |
e402e88b17d96c2656d30033397a639042c8f26d | iamraufodilov/Text-Summarization | /Text Summarization with NLTK/nltk_model.py | 2,427 | 4.1875 | 4 | # load libraries
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize, sent_tokenize
#get input text
text = """When most people hear the term artificial intelligence, the first thing they usually think of is robots.
That's because big-budget films and novels weave stories about human... | true |
1bc944a1dd4f9209d2b9fc3504aa513356534e88 | silverfield/pythonsessions | /s03_input_and_while/input_and_while.py | 1,340 | 4.375 | 4 | # print positive integers up to 47 (excluding)
x = 1
while x < 47:
print(x)
x = x + 1
print("------------------------------------------")
# print all odd numbers up to 50
x = 1
while x < 50:
if x % 2 == 1:
print(x)
x += 1 # concise way of incrementing x
print("-------------------------------... | true |
d258d11cb908a1627db612d52b9df23a3f1850e7 | paolotof/python | /MITcourse/lec03.py | 2,391 | 4.3125 | 4 | ###Find the cube root of a perfect cube
##x = int(raw_input('Enter an integer: '))
##ans = 0
##while ans*ans*ans < abs(x):
## ans = ans + 1
## #print 'current guess =', ans
##if ans*ans*ans != abs(x):
## print x, 'is not a perfect cube'
##else:
## if x < 0:
## ans = -ans
## print 'Cube root of ' +... | true |
822031bc45512c6c6afb93c99490ae04752081a3 | rexliu3/Coding-Python | /Base Converter.py | 703 | 4.15625 | 4 | def converterTO(number, base):
finished = ""
mainNum = number
while mainNum > 0:
res = mainNum % base
finished = str(res) + finished
mainNum = int(mainNum / base)
print(finished)
def converterFROM(number, base):
finished = 0
mainNum = number
k = 0
lengths = l... | true |
1132309e4a2c0032d9f5b07a6d137c1d0df345e3 | Achatch/Python-Foolishness | /Critical Thinking 4 - Option 2 - Achatch.py | 772 | 4.21875 | 4 | """The current tuition is $20,000 per year
tuition is expected to increase by 3 percent each year.
Display the tuition each year for the next 10 years."""
collegeTuition = 20000 # Set current tuition variable
increase = .03 # set tuition increase variable
year = int(2020) # set year at 2020, year doubles as ite... | true |
f4bae2ddd3b6f56694a5d42599237b706adbeedc | aakashsoni1710/MLForsk2019 | /Day1/mileage_cal.py | 256 | 4.25 | 4 | km=input("Enter the Km:") #to store the kilometers the car travelled
fuel=input("Enter the quantity of fuel(in litres):") #to store the quntity of fuel(in litres)
mileage=float(km)/float(fuel) #to calculate and store the average of the car
print (mileage) | true |
60dd87cf456a10f2d1cb0167398aeb0b8201f719 | geometryolife/Python_Learning | /PythonCC/Chapter04/pra/t10_mypets.py | 376 | 4.21875 | 4 | # 使用切片,打印前面、中间、后面三个元素
mypets = ['cat', 'dog', 'fish', 'tiger', 'bird', 'dragon']
print("The first three items in the list are:")
print(mypets[:3])
print("\nThree items from the middle of the list are:")
middle = int(len(mypets) / 3)
print(mypets[middle:middle + 3])
print("\nThe last three items in the list are:")
p... | true |
b0aed765d0152a2f5747b681f885b7d4dd47b8b2 | ishanbhavsar3/python_ | /Practice.py | 2,929 | 4.21875 | 4 | print("Welcome to automatic booking software developed by Ishan Bhavsar.")
name = input("What is your name? ")
age = input("What is your age(In numbers only.) ")
gender = input("What is your gender?(Male/Female) ").upper()
marriage_check = input("Are you married?(Yes or No Only)").upper()
if int(age) < 18:
... | true |
f858ebf455738fbe2416001c5defd31611c79241 | kenzaAndaloussi/kenza_andaloussi_test | /QuestionB.py | 996 | 4.15625 | 4 | # This class compares two strings with three methods: greater, lesser and equal
class StringCompare:
# Constructor
def __init__(self, firstString, secondString):
self.num1 = float(firstString)
self.num2 = float(secondString)
# Greater than Function
def greater(self):
condition =... | true |
281d1d2221ba607db390edb0c0b84c750be50b92 | student-work-agu-gis2021/lesson4-functions-and-modules-Nakamura-tag | /Exercise_4_problem_1.py | 2,154 | 4.90625 | 5 | #!/usr/bin/env python
# coding: utf-8
# ## Problem 1 - Simple temperature calculator (*3 points*)
#
# In the first problem your aim is to create a function that converts the input temperature from degrees Fahrenheit to degrees Celsius. The conversion formula from Fahrenheit to Celsius can be found below.
#
# T_{Ce... | true |
c38199037c65ff62c41525a61b498ed0c0483a60 | M-Minkov/Project-Euler | /Problem 2/Naive Solution.py | 856 | 4.40625 | 4 | """
Runs a iterative fibonacci function, calculating every fibonacci value
It keeps calculating until it gets to the final value above 4000000, or for the general solution, "n"
The particular solution we calculate is where n = 4000000
As the growth of the fibonacci function acts similarly to an exponential function
... | true |
c99ec2cf5dcc921bf67b97b704caf4bd28cb014b | NikoriakViktot/task3 | /Task3.py | 1,365 | 4.21875 | 4 | # Task 1
# String manipulation
# Write a Python program to get a string made of the first 2 and the last 2 chars from a given string. If the string length is less than 2, return instead of the empty string.
# Sample String: 'helloworld'
# Expected Result: 'held'
# Sample String: 'my'
# Expected Result: 'mymy'
# ... | true |
76e3ba9e743065630ad3e1acb4afbe615cd1a349 | AvijitMaity/Assignment-1-Computational-Physics-2 | /QR1.py | 936 | 4.125 | 4 | '''
This program shows the QR decomposition of
using numpy.linalg.qr
'''
import numpy as np
from numpy import linalg
A = np.array([[5,-2],[-2,8]])
Q,R = linalg.qr(A)
print('The orthogonal matrix is',Q)
print('The upper triangular matrix is',R)
# Now we will Use the decomposition to calculate the eigenvalu... | true |
c8930421ec0a1162d9554493769bc7e8fdcf7999 | zecollokaris/toy-problems | /code-wars/Grasshopper-Summation.py | 1,898 | 4.1875 | 4 | #############################################################################################################
######Question######
# Summation
# Write a program that finds the summation of every number between 1 and num. The number will always be a positive integer greater than 0.
# For example:
# summation(2) -> 3... | true |
c85017e9759e38464921b64bedb6bf9950e40c0c | Mrkumar98/Python-Projects-for-Beginners | /Small_Python_Problems/Own_genraterfunc.py | 615 | 4.375 | 4 | # Write your own generator function that works like the built-in function enumerate.
# should output:
# Lesson 1: Why Python Programming
# Lesson 2: Data Types and Operators
# Lesson 3: Control Flow
# Lesson 4: Functions
# Lesson 5: Scripting
lessons = ["Why Python Programming", "Data Types and Operators", "Control... | true |
b67a014c9f126a1dd4c40e77342264e939ed19f8 | Mrkumar98/Python-Projects-for-Beginners | /Small_Python_Problems/Narcissistic.py | 826 | 4.21875 | 4 | def isNarcissistic(x):
"""Returns whether or not a given number is Narcissistic.
A positive integer is called a narcissistic number if it
is equal to the sum of its own digits each raised to the
power of the number of digits.
Example: 153 is narcissistic because 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 15... | true |
e94a55932c43763012b2968296dcb845b23cf5e4 | calmcl1/sltdgfx | /sltd_couple.py | 2,157 | 4.1875 | 4 | class Couple(object):
"""An object that represents a couple, with their name, score and other data."""
def __init__(self):
self.couple_name = ""
self.scores = [0, 0, 0, 0]
self.total = sum(self.scores)
def __update_total(self):
"""Internal function used to update the total... | true |
61afde84fe07f76fd6e426102f9d5b134f796282 | ujjwalrehani/Various-Python-Projects | /Homeworks/hw3/hw3_part3.py | 714 | 4.4375 | 4 | # File: hw3_part3.py
# Author: Ujjwal Rehani
# Date: 2/23/17
# Section: 21
# E-mail: urehani1@umbc.edu
# Description:
# Prints out height of hailstorm
def main():
height = int(input("Please enter the starting height of the hailstone: "))
#Input validation
while (height < 0):
height = int(input(... | true |
bd3712f64e539f466b6480608baa76a20b0f0b0a | codeshef/datastructure-and-algorithm | /python/insertionSort.py | 341 | 4.28125 | 4 | #Insertion sort in decreasing order
def insertionSort(a):
for i in range(1,len(a)):
key = a[i]
j = i-1
while(j>=0 and a[j] < key):
a[j+1] = a[j]
j=j-1
a[j+1] = key
arr = [5,2,4,6,1,3]
insertionSort(arr)
print "Sorted array is : "
for i in range(len(arr)):
... | true |
5986eface5de6fb296ff90fa11f76acac1e2ae90 | camilocalvo/exponents-spring-2018 | /exponents/exp.py | 845 | 4.125 | 4 | ## Get our base and exponent. ##
def get_input():
temp_base = input("What number are you raising? (q to quit) ")
if temp_base == "q":
quit()
try:
base = int(temp_base)
except:
print("Invalid base")
return False
powr = input("2nd, 3rd, or 4th power? ")
i... | true |
cce94a6a673bffc4032f08e1aa84f22c107b6593 | franziskagoltz/python_practice_bits | /remove_duplicates.py | 862 | 4.125 | 4 | """ Remove duplicates in a list
For example::
>>> remove_duplicates([6, 9, 7, 9, 2, 6, 0])
[6, 9, 7, 2, 0]
>>> remove_duplicates([])
[]
>>> remove_duplicates([6, 9, 7])
[6, 9, 7]
"""
def remove_duplicates(items):
"""Remove duplicates in the list items and return that list."""
# k... | true |
a99bf8ebce03eb5b078f00a76c14ac772016244d | Klalena/BIOS823-Statistical_Programming-for-Big-Data | /Homework/Euler_112_BouncyNumbers.py | 1,375 | 4.1875 | 4 |
def main():
"""
The function prints the least number for which the proportion of bouncy numbers is 0.99,
where bouncy numbers are neither increasing nor decreasing numbers such as 155349.
"""
number = 99
bouncy_n = 0
while True:
number += 1
if IsBouncy(number):
... | true |
1f0229e361f38393aa6c600533b28fe24c7b5ee2 | Michaelndula/Python-Projects | /pset6/mario/less/mario.py | 547 | 4.1875 | 4 | from cs50 import get_int
def main():
while True:
# get input from the user
height = get_int("Height: ")
width = height
# if the user inputs an integer which is greater than eight and less than 1 the code should break and prompt the user for new input
if height >= 1 and height <= 8:
... | true |
0e0e53525954de3e5cf4a3272a24d60443d7fd3b | marvance/MIT-OCW-problemsets | /mit60001/ps0&1/ps1b.py | 792 | 4.21875 | 4 | def timeToSave():
annual_salary = float(input("What's your annual salary?"))
portion_saved = float(input("What portion of your salary can you save, as a decimal?"))
total_cost = float(input("How much does your dream home cost?"))
semi_annual_raise = float(input("What's your semi-annual raise percentage,... | true |
e926a2a54e3f9ecf19c9d19cb0543773da2dbe03 | Umair-Manzoor-47/Semester-2 | /week 1/First5multiples.py | 252 | 4.1875 | 4 | number = 37
number = input("Enter number to find Multiples : ") #Taking Input
"""Printing the first 5 Multiples of number"""
print((int(number) * 1))
print((int(number) * 2))
print((int(number) * 3))
print((int(number) * 4))
print((int(number) * 5))
| true |
2bc896519295b49adada904392d760625bc71437 | gbwsh/python | /canPiramid.py | 446 | 4.125 | 4 | #calculates how many levels of a soda can piramid can you stack with
#given money and price per can, each level requires level**2 number of cans
def canPiramid(money, price):
cans = 0
level = 1
while cans < money // price:
cans += level**2
if cans == money // price or cans + (level+1)... | true |
d003b60944fc33caf28490e84c70d8e5e6d86f3a | ballib/SC-T-111-PROG | /verkefni_fyrir_prof/lists/max_min_sum_in_list.py | 327 | 4.28125 | 4 | my_list = []
size = int(input("Enter the size of the list: "))
for x in range(size):
num = int(input("Enter a number to put in the list: "))
my_list.append(num)
print("the highest value in the list is", max(my_list))
print("the lowest value in the list is", min(my_list))
print("the sum of the list is", sum(my_... | true |
d78a75603db4ada33487a6f8b63e4400bb17afc7 | ballib/SC-T-111-PROG | /prof/Lokaprof/Midterm_2/longest_word.py | 585 | 4.375 | 4 | def open_file(filename):
with open(filename, 'r') as file:
word_list = []
for word in file.readlines():
word_list.append(word.strip())
return word_list
def find_word(word_list):
longest_word = ""
for word in word_list:
if len(word) > len(longest_word):
l... | true |
cc2b209409c67f30f707488ff4643b430e27b88d | ballib/SC-T-111-PROG | /ehv/namskeid/namskeid_3/sum_of_elements_in_inst.py | 321 | 4.125 | 4 | size_str = input("please enter a positive integger ")
size_int = int(size_str)
number_list = []
sum_of_list = 0
while size_int > 0:
number_str = input("insert a number ")
number_int = int(number_str)
sum_of_list += number_int
number_list.append(number_int)
size_int -= 1
print(sum_of_list)
... | true |
f2e0b705e5f89758546c077fdf3f608a8eaae198 | ballib/SC-T-111-PROG | /Python book/Chapter 9/my_dict.py | 1,116 | 4.375 | 4 | my_dict = {'a': 2, 3: ['x', 'y'], 'Joe': 'Smith'}
print(my_dict)
print(my_dict['a']) # Use square brackets to index
print('a' in my_dict)
print(2 in my_dict)
print(len(my_dict)) # Number of key : value pairs
for key in my_dict: # Membership of keys
print(key)
for key in my_dict: # Print key and value
prin... | true |
53c828188ad7444ae391498d6f6952e3d6a2dff1 | ballib/SC-T-111-PROG | /prof/Lokaprof/Midterm_2/analyze_list.py | 1,238 | 4.125 | 4 | def get_numbers():
numbers = input("Enter integers separated with commas: ")
input_list = numbers.split(',')
number_list = []
for x in input_list:
num = int(x)
number_list.append(num)
return number_list
def sort_list(number_list):
new_list = number_list[:]
new_list.sort()
... | true |
1bb7b7237994021a7f2d9c0158429634fd8579be | apla02/holbertonschool-higher_level_programming | /0x0B-python-input_output/2-read_lines.py | 658 | 4.1875 | 4 | #!/usr/bin/python3
'''
function to handle open and read files
'''
def read_lines(filename="", nb_lines=0):
'''
function to read exactly n lines in a file
'''
total_lines = number_of_lines(filename)
with open(filename, encoding='utf-8') as f:
if nb_lines <= 0 or nb_lines >= total_line... | true |
b746f2f37308d0f17d0530c4459e0ecdd3d2e3cc | sumaiya-antara/Getting-familiar-with-Python | /set 1.py | 1,321 | 4.65625 | 5 | # Sets are unordered collections of unique objects
# Sets have values only, they don't have any key like dictionaries.
# In sets, there is no duplicate, everything/every value has to be unique.
# We can add data to set by .add() function
# Set objects do not support indexing, we cn look for/search set data by using 'in... | true |
9847e45e7dcaa5ae9b2d873f2ce01566930b1b80 | sumaiya-antara/Getting-familiar-with-Python | /return.py | 562 | 4.34375 | 4 | # The function always has to return something.
# If we don't give 'return' in function, it will give None in output.
# A function either modifies soemthing in our program or returns something.
# As soon as we put return atthe function, it exists the function.
'''
def sum(num1, num2):
return num1 + num2
total = sum(... | true |
7fbc2b639f859b96e7b52f160460f1a7d042d6b0 | sumaiya-antara/Getting-familiar-with-Python | /enumeration.py | 336 | 4.25 | 4 | # Enumerate prints the index number
# Enumerate is usefull as an index counter if we are looping an item.
'''
for i, char in enumerate([1,2,3,4]):
print(i, char)
for i, char in enumerate("Hellooo"):
print(i, char)
'''
for i, char in enumerate(list(range(100))):
print(i, char)
if char == 50:
print(f'Index... | true |
493a5eee8a3b8a7edc4a78360372ad76e7e00fa3 | Manishachermadurai/LetsUpgrade_Assignment | /day2/day2_2.py | 399 | 4.1875 | 4 | import string
#pangram is a string that contains all the alphabet in that
def ispangram(str):
alphabet = "abcdefghijklmnopqrstuvwxyz"
for char in alphabet:
if char not in str.lower():
return False
return True
# main
string =str(input("Enter the string to be checked whether pangram or no... | true |
cb534b44fc7e6cc9c54be6d06105fea1678786e7 | WGC575/python_learning | /tutorial/22_zipper.py | 596 | 4.375 | 4 | #This function returns a list of tuples. The i th tuple contains the i th element from each argument sequences or iterables.
#If the argument sequences are of unequal lengths, then the returned list is truncated to the length of the
#shortest argument sequence
#---https://www.hackerrank.com/challenges/zipped/proble... | true |
8033526414b6973c58535380c4b05221675de192 | livrbecca/PythonScrimba | /for_loops/forloops.py | 1,398 | 4.34375 | 4 | for letter in "my hero academia": # could use any word, not just letter
print(letter)
print("for loop done")
for num in range(8):
print(num)
print("for loop2 done")
# range, up to 8 but not
# doing range(2,8) would print from 2 up till 8 but not including 8
# doing range(1, 15, 3) would do the same in steps... | true |
e8852fe8c6a89f84e8b04b3ef6edecabbbdfbe09 | livrbecca/PythonScrimba | /katas/max.py | 474 | 4.25 | 4 | # Find max item in list
# function:
# =========
# name: maxInList
# parameter: numbers: list of numbers
# return type: number
# pseudo code:
# ============
# set biggest to first number in list
# for each number n in list
# if n is greater than biggest
# set biggest to n
# return biggest
def maxInList(arr):
... | true |
50b08d0213bf857cb9f1c2f5b0d5f56f12b813a9 | livrbecca/PythonScrimba | /while_loops/whileloops.py | 907 | 4.125 | 4 | # code that runs repeatedly until a condition tells it to stop
# Three Loop Questions:
# 1. What do I want to repeat?
# -> message
# 2. What do I want to change each time?
# -> starts
# 3. How long should we repeat?
# -> 5 times
i = 0
while i < 5:
i += 1
print(f"{i}." + "*"*i + "loops are awesome" + "*"*i... | true |
7a76777fc318487b42c7a6fcac1b04aa655ede19 | ecxzqute/python3-basics | /lists.py | 863 | 4.3125 | 4 | # A List is a collection which is ordered and changeable. Allows duplicate members.
# Create a list
numbers = [1, 2, 3, 4, 5]
fruits = ["apples", "oranges", "grapes", "pears"]
# Creating a list via constructor
numbers2 = list((1, 2, 3, 4, 5))
# print(numbers)
# print(numbers2)
# Printing lists specific value
print... | true |
1e51741ebade9d493a45e1d46669bd02fb532dfd | geog3050/namacdon | /Example_Code/cels_to_far.py | 291 | 4.46875 | 4 | # program to convert Celsius into Fahrenheit
# this is the set value of celsius
celsius = 37.5
celsius = input('degrees celsius:')
celsius = float(celsius)
# function
fahrenheit = celsius * 1.8 + 32
print('%0.1f degrees Celsius is equal to %0.1f degrees Fahrenheit' %(celsius,fahrenheit))
| true |
11791761e8c75ef84683de5dba326105b7df4af0 | runalb/Python-Problem-Statement | /PS-1/ps49.py | 375 | 4.4375 | 4 | # PS-49 WAP to accept a string and display whether it is a palindrome
def check_palindrome_str(str):
s1 = ''
for ch in str:
s1 = ch + s1
if s1 == str:
return True
else:
return False
str = input("Enter string: ")
if check_palindrome_str(str):
print(str,"is Palindrome strin... | true |
2a53dd8e92e7e933c39860fa0c40d02d39efb222 | runalb/Python-Problem-Statement | /PS-1/ps32.py | 416 | 4.5625 | 5 | # PS-32 Ask the user for a string and print out whether this is palindrome or not.(A palindrome is a string that reads the same forwards and backwards)
print("Check the string is palindrome or not")
str = input("Enter your string: ")
rev_str = ""
for x in str:
rev_str = x + rev_str
if rev_str == str:
... | true |
c5ad54f43bc2b44c39cfee54be41afecc9a23fd9 | runalb/Python-Problem-Statement | /PS-1/ps18.py | 282 | 4.21875 | 4 | # PS-18 WAP to accept two numbers from user and display all numbers between those numbers
# ex- if user enters 3 and 9 program should display 3,4,5,7,8 and 9
start = int(input("Enter no: "))
end = int(input("Enter no: "))
for x in range(start,end+1):
print(x,end=" ")
| true |
81e54251b6de1b4cea3435898023bcdffb420a47 | runalb/Python-Problem-Statement | /PS-1/ps43.py | 375 | 4.21875 | 4 | # PS-43 WAP to accept two numbers from user and display all numbers between those numbers
'''
Ex- If user enters 3 and 9 program should display numbers 3,4,5,6,7,8,9
'''
no1 = int(input("Enter 1st no: "))
no2 = 0
while no2 < no1:
print("2nd no. should be greater than 1st no.")
no2 = int(input("Enter 2nd no: "... | true |
251d5e69d1563217757879861fb0c2ecbeb52727 | stephenyoon84/Udacity_IPND | /stage_2/My_Submission(Stephen_ver.2)/fill_in_the_blanks_Ver2.py | 2,453 | 4.1875 | 4 | # Input your name.
# Load problem set
# Print out the problem set
# Problem subject - Python related.
# Solution set
#Python - pp_sol
# User input for solution
# Chances = 2
# Result print out
user_name = []
pp_set = ['__1__','__2__','__3__','__4__']
pp_sol = ['object','language', 'class', 'particular']
test_set = ... | true |
6cbca2485f7a94902f363f0e84d660a7aa90c737 | msurrago/ISU-CS | /cs201/sort.py | 1,131 | 4.3125 | 4 | #!/usr/bin/env python3
import sys
args = sys.argv[1:]
#Check for args passed
if len(args):
#Use arguments as list to sort
str_list = args
nums_list = []
for i in str_list:
nums_list.append(float(i))
else:
#Get arguments from stdin
nums_list = []
while True:
num = input("E... | true |
480551f090a0c37335274bb65562338002a54f64 | eddowh/Project-Euler | /021_to_030/021_Amicable_Numbers.py | 2,363 | 4.125 | 4 | # -*- coding: utf-8 -*-
# Conventions are according to NumPy Docstring.
"""
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
For example, th... | true |
306e02188a7326ca31924b883ba33887aa8faa0c | eddowh/Project-Euler | /001_to_010/009_Special_Pythagorean_Triplet.py | 1,858 | 4.375 | 4 | """
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
import time
import math
# See how to get from
# a + b + c = 1000
# to... | true |
f133d80f5c4c60bdfa8ae3d611a4566fcabaaf09 | yemgunter/inscrutable | /ch10_2_class_coin_flip.py | 660 | 4.1875 | 4 | # Ch 10.2 Classes Coin Flip
import coin
def main():
# create an object from the Coin class
call_the_toss()
def call_the_toss():
# Get prediction from two players
player1_guess = input("heads or tails? ")
player2_guess = input("heads or tails? ")
# toss the coin
a_coin = Coin()
a_coi... | true |
67ec807fcb8173f704655a7118727c7216cf1aa7 | yemgunter/inscrutable | /chapter2.py | 550 | 4.28125 | 4 | ##name = input("Enter your name: ")
##age = '50'
##print('Hi ', name, ', you are ', age, ' years old.', sep='')
##
##Print("Thursday January 28 2021")
##
##name = "Henry"
##name2 = "Archibald"
##
##print("""I said "I'm hungry" """)
##
##hot_dogs_sold_today = 56
##
##x = 5
##
##
##print(3)
##
##print()
##
##
### Finds o... | true |
d6f116e43b443989fc950530fd83cba3ed19a378 | yemgunter/inscrutable | /loops4.py | 611 | 4.3125 | 4 | # The "for" Loop 4.4
##MAX = 5 # The maximum number
##
##total = 0.0 # Initialize the accumulator variable
##
##print("This program calculates the sum of")
##print(MAX, "numbers you will enter.")
##
##for counter in range(MAX):
## number = int(input("Enter a numnber: "))
## total += number
##
## print("The ... | true |
e93689edd0aab65e0e9f40eb76c9ea940265d9e8 | yemgunter/inscrutable | /ch10_2_class_oop.py | 1,122 | 4.21875 | 4 | # Ch 10.2 Classes
class Rectangle:
def __init__(self):
# data attributes __ makes it private
self.__length = 0
self.__width = 0
self.__perimeter = 0
self.__area = 0
# accessors - method to give access to data attributes
# these retrieve
def get_length(self):
... | true |
d1192d204eac3192c2d73d78ed5f339798405c55 | spacedlevo/Cheaty-Randomize-Team | /Ranomize Team.py | 2,865 | 4.25 | 4 | import random
import time
# Function will check to see if my name is in the player_list and find how FC Bayern has been entered and print that is my team.
def print_random_team(players, teams):
""" Randomly assign players to the teams and pretty print results """
# local copy of the lists. Now real lists are ... | true |
c6d059db31c0376f38428fb28c956a41e1e1aa99 | jiiFerr/exercism-python | /collatz-conjecture/collatz_conjecture.py | 812 | 4.4375 | 4 | def steps(number):
"""
The Collatz Conjecture or 3x+1 problem can be summarized as follows:
Take any positive integer n. If n is even, divide n by 2 to get n / 2. If n is odd, multiply n by 3 and add 1 to get 3n + 1. Repeat the process indefinitely. The conjecture states that no matter which number you star... | true |
1027a8a4cac97f71c54d9bb97e3c97abc311f84c | m-01101101/code_wars | /counting_duplicates.py | 723 | 4.28125 | 4 | # Write a function that will return the count of
# distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string.
# The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.
# my answer
def duplicate_count(text):
... | true |
00425a7ecdf2a11bb5258d689b37da86dd9d1c3e | ynsgkturk/solid-principles-and-design-patterns-in-python | /patterns/creational/borg_pattern.py | 2,132 | 4.21875 | 4 | """
The borg pattern is an alternative take on the `Singleton` pattern. In the
borg pattern, instances of a class share the same state. Whereas the Singleton
pattern tries to manage that only a single instance is ever created, instances
using the borg pattern can be created freely. The `Borg` pattern can also be
kno... | true |
b2703c1fce0837298e5725b00815ec66d5fb5f50 | easternpillar/AlgorithmTraining | /SW Expert Academy/D2/가랏! RC카!.py | 901 | 4.125 | 4 | # Problem:
# Given the commands of acceleration, print the total distance traveled.
# Condition(s):
# 1. The initial speed is 0.
# 2. Command 0 means maintaining the current speed.
# 3. Command 1 means acceleration by the next number.
# 4. Command 2 means deceleration by the next number.
# My Solution:
T = int(input()... | true |
4ab1ec83b832a6565b2dc9386b04ec921a2a5ed1 | Muniah-96/PA-WiT-Python-S21 | /week_3/HW3_template.py | 2,743 | 4.375 | 4 | #Welcome to Python Kitchen!
#Here is a list of dishes Python Kitchen provides. It is a list of tuples.
#Each tuple has information of one dish in order: (Number, Name, Price, Origin, Whether is vegetarian)
dishes=[(1,'Salmon Sushi', 30, 'Japan', 'N'),(2,'Pork Dumplings', 25, 'China', 'N'),(3,'Choziro Tacos', 20, '... | true |
f374334ac991df5630ae488dd2cb7767133f437b | evantkchong/PyPractice | /palindrome_shortest_lexicographic.py | 1,727 | 4.28125 | 4 | '''
Question:
Given a string, find the palindrome that can be made by inserting the
fewest number of characters as possible anywhere in the word.
If there is more than one palindrome of minimum length that can be made,
return the lexicographically earliest one (the first one alphabetically).
For example, given the ... | true |
9e022faa3c84a2e790f98856c1626fb71364e5de | ZumeITInc/Shiva | /function001.py | 540 | 4.4375 | 4 | #Functions are methods that are created by us for our use cases.
#By using functions we can add different types of methods.
#Lets do an example to show how we use a function>
def name_function():
print('hello')
#Up here we just created a function.
#'def' is the keyword used to create a function.
#when we cal... | true |
80d9fa2670dde228bd9014dd842e8c52b3ee5dde | frontendprof/Derek-s-Python-Channel | /vid_3/ExceptionHandling.py | 370 | 4.15625 | 4 | # B_R_R
# M_S_A_W
# The User is asked to enter a number
# Whereby entry of non digit values prevented by exception handling
while True:
try:
number=int(input("Enter a number: "))
break
except NameError:
print("You did not enter a number.")
except:
print("Unknown error oc... | true |
8957b1651be6880767000cc8399cf344c230040d | cherart/leetcode-problems | /easy/101_SymmetricTree.py | 1,195 | 4.34375 | 4 | """
101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree [1,2,2,3,4,4,3] is symmetric:
1
/ \
2 2
/ \ / \
3 4 4 3
But the following [1,2,2,null,3,null,3] is not:
1
/ \
2 2
\ \
3 3
Note:
Bon... | true |
1e6c06ee065b085e7cfee2656a9e9df4e1847897 | yashviradia/project_lpthw | /lpthw/ex15.py | 569 | 4.28125 | 4 | # imports argument variable: sys is package and argv is feature
from sys import argv
# ask for argument to print
script, filename = argv
# Makes file object
txt = open(filename)
# usually prints the filename, f-string
print(f"Here's your file {filename}:")
# command to python '.' as read the file
print(txt.read())
p... | true |
e07a61bf683283e3a22979d492d6a8362bf75661 | branks42/codingbat-python | /string-2.py | 1,648 | 4.15625 | 4 | # 1. Given a string, return a string where for every char in the original, there are two chars.
def double_char(str):
new_str = ""
for char in str:
new_str += char*2
return new_str
# 2. Return the number of times that the string "hi" appears anywhere in the given string.
def count_hi(str):
return st... | true |
47612128e3fcc13096e3fe04b62f995099797e1f | suzukisteven/tic-tac-toe-AI | /errors.py | 1,880 | 4.34375 | 4 | # Run the code. Read the error message.
# Fix it
# Error 1:
# Use * syntax to take variable arguments
def mean(*numbers):
print(type(numbers))
total = sum(numbers)
return total / len(numbers)
mean(5, 3, 6, 10)
# Error 2:
# Define a method called student_details that takes in two arguments
def user_det... | true |
983e03422638321a1f9dcef3bd9488e5cf5e743a | christopher-burke/python-scripts | /cb_scripts/rock_paper_scissors.py | 1,168 | 4.25 | 4 | #!/usr/bin/env python3
"""Rock, Paper, scissors."""
from random import choice
def computer():
"""Return the computer player"s choice."""
return choice(["ROCK", "PAPER", "SCISSORS"])
def player():
"""Get the player"s choice."""
input_ = ""
if input_ not in ["ROCK", "PAPER", "SCISSORS"]:
... | true |
be62741985b5a45b9d1a3e4026310138a73b5000 | norinee/Python-for-Everybody | /Introduction/04-Numeric Variables/Numeric_data_types.py | 952 | 4.28125 | 4 | # Numbers can be stored in varibles
pi = 3.14159
print(pi)
# You can do math with numbers
first_num = 6
second_num = 2
print(first_num + second_num)
print(first_num ** second_num)
# If you combine with numbers, Python gets confused
# When displaying a string that contains numbers you must convert the numbers into str... | true |
486129c0ab01b328a6378813cbeb27110d7670fc | ThiagoBaader/MITx-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python | /Problem_Set_1/Problem_3.py | 746 | 4.3125 | 4 | # Problem 3
# 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 the case of ties, p... | true |
c0d91322ed9fe0262f82ced67a2d06a14d65c387 | yprodev/p2016-00004-python-data-structures | /lesson3-list-and-tuple/l3_part10.py | 907 | 4.3125 | 4 | # Addition and Multiplication
# ==================================================
print(['apple'] * 3) # ['apple', 'apple', 'apple']
print((123, 456) * 3) # (123, 456, 123, 456, 123, 456)
print([['apple']] * 3) # [[apple], [apple], [apple]]
print([['apple'], ['orange']] * 3) # [['apple'], ['orange'], ['apple'], ['or... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.