blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
76e97fc42db60802575bb4b9be80a7499298d26e | Ankitpahuja/LearnPython3.6 | /Tutorials - Examples/GUI - Tkinter/boilerplate.py | 1,170 | 4.4375 | 4 | import tkinter as tk
window = tk.Tk()
window.title("Tkinter's Tutorial")
window.geometry("550x400")
# Label
title = tk.Label(text="Hello World. Welcome to tkinter's tutorial!", font=("Times New Roman",20))
title.grid(column=0,row=0)
#Button1
button1 = tk.Button(text="Click Me!", bg="red")
button1.gri... | true |
dfe339423b83149a43710cbf6eef8ad51cb9c1e9 | pavanvittanala/Coding_programs | /uniformity.py | 1,475 | 4.15625 | 4 | ''' ----->>>>> PROBLEM STATEMENT <<<<<----- '''
''' You are given a string that is formed from only three characters ‘a’, ‘b’, ‘c’. You are allowed to change atmost ‘k’ characters in the given string while attempting to optimize the uniformity index.
Note : The uniform... | true |
eccaf13f1f46e435b9547ecffe26c55e63108852 | atseng202/ic_problems | /queues_and_stacks/queue_with_two_stacks/queue_two_stacks.py | 1,371 | 4.125 | 4 | class Stack(object):
def __init__(self):
# """Initialize an empty stack"""
self.items = []
def push(self, item):
# """Push a new item onto the stack"""
self.items.append(item)
def pop(self):
# """Remove and return the last item"""
# If the stack is empty, return None
# (it would also be reasonable to thr... | true |
63a9ad33825620de6667c0d694471fbe8e939149 | Garima-sharma814/The-faulty-calculator | /faultycalculator.py | 1,596 | 4.3125 | 4 | # faulty calculator
# Design a calculator which will correctly solve all the problems except the following ones:
# if the combination of number contain 56 and 9 it will give you 77 as the answer no matter what operation your perform
# same for 45 and 3 , 56 and 6
# Your program should take operator and two numbers as i... | true |
ce9b53ac17bff836d778e08c55000090e9a3b1c3 | MAD-reasoning/Python-Programming | /Elementry/Elementry_04.py | 324 | 4.28125 | 4 | # Write a program that asks the user for a number and prints the sum of the numbers 1 to number.
try:
num_sum = 0
number = int(input("Enter a natural number: "))
for i in range(1, number+1):
num_sum += i
except ValueError:
print("Enter a valid number")
else:
print("Sum = ", num_su... | true |
e376359a4434b559d8b9e7845b1a9aa428429d71 | GuilhermeBiavati/Trabalho-python | /2.py | 389 | 4.1875 | 4 | # Recebe nome e armazena na variavel
nome = input('Informe o nome: ')
# Transforma string para maiusculo, e substitui as vogais pelos caracteres requiridos
retorno = nome.upper().replace('A', '@').replace('E', '&').replace('I',
'!').replace('O', '#').re... | false |
e29ff540a0375f255ae163e88d222460ee72e8d9 | jay-bhamare/Python_for_Everybody_Specialization_University_of_Michigan | /PY4E_Python_Data_Structures/Assignment 8.4.py | 996 | 4.1875 | 4 | #-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: jayvant
#
# Created: 08/04/2020
# Copyright: (c) jayvant 2020
# Licence: <your licence>
#-------------------------------------------------------------------------------
... | true |
6be03d03fa0505d440baa4a07c9726fb6c752644 | TuhinChandra/PythonLearning | /Basics/Shaswata/test2_video8_Variables.py | 889 | 4.53125 | 5 | print('Variables examples are here...')
x = 10
# Anything in python is an Object unlike other languages
print('x=', x, sep='')
print('type of x :', type(x))
print('id of x :', id(x))
y = 15
print('y=', y, sep='')
print('id of y :', id(y))
# Now see the id of y will change to id of x
y = 10
print('# Now see the id of y... | true |
89d6cc60549a3807b8736670d0b28bd12e298f4f | TuhinChandra/PythonLearning | /Basics/Shaswata/test9_video17_relationalOperator.py | 314 | 4.25 | 4 | print('Relational operator examples are here...')
x = 10
y = 5
print('Type of relational operator results :', type(x > y))
print('x > y (True):', x > y)
print('x < y (False):', x < y)
print('x >= y (True):', x >= y)
print('x <= y (False):', x <= y)
print('x == y (False):', x == y)
print('x != y (True):', x != y)
| false |
6e1ebc1b1f077968f102c31e157e7d1af37a0e3a | TuhinChandra/PythonLearning | /Basics/Shaswata/test5_video12_intFunc.py | 599 | 4.375 | 4 | print('int function examples are here...')
x = '1100'
print("x =", x)
print("type of x :", type(x))
# int string -> int
print('int string -> int')
y = int(x) # default base is 10
print("y =", y)
print("type of y :", type(y))
# binary string -> int
print('binary string -> int')
z = int(x, 2)
print("z =", z)
# ValueE... | false |
66858c07ada89061322b79ebf6898778d2bce2b8 | aricaldoni/band-name-generator | /main.py | 390 | 4.28125 | 4 | #Welcome message
print("Welcome to the authomatic Band Name generator.")
#Ask the user for the city that they grew up in
city = input("What city did you grow up in?: \n")
#Ask the user for the name of a pet
pet = input("What is the name of your pet: \n")
#Combine the name of their city and pet and show them their band ... | true |
5c90d207ec78f0c29467ad3e5f7a66bca9d21e44 | JaredJWoods/CIS106-Jared-Woods | /ses8/PS8p5 [JW].py | 1,144 | 4.1875 | 4 | def incomeTax(gross):
if gross >= 500001:
rate = 0.30
print("You are in the highest tax bracket with a 30% federal income tax rate.")
elif gross >= 200000 and gross <= 500000:
rate = 0.20
print("You are in the middle tax bracket with a 20% federal income tax rate.")
else:
rate = 0.15
pr... | true |
28cde805af45660b4d1f69504a1f709f5a9d28a9 | sofiacavallo/python-challenge | /PyBank/Drafts/homework_attempt_4.py | 2,126 | 4.1875 | 4 | # Reading / Processing CSV
# Dependencies
import csv
import os
# Files to load and output
budget_data = "budget_data.csv"
budget_analysis = "budget_analysis.txt"
# Read the csv and convert it into a list of dictionaries
with open(budget_data) as budget_data:
reader = csv.reader(budget_data)
# Read the he... | true |
67a4705ab7e55c17de86ac966540fb552e4b645c | qaespence/Udemy_PythonBootcamp | /6_Methods_and_Functions/Homework.py | 2,178 | 4.4375 | 4 |
# Udemy course - Complete Python Bootcamp
# Section 6 Homework Assignment
# Write a function that computes the volume of a sphere given its radius
def vol(rad):
return (4.0/3)*(3.14159)*(rad**3)
print(vol(2))
# Write a function that checks whether a number is in a given range
# (Inclusive of high and low)
def... | true |
5948ceed31db511b3ec6894e8c76e9a3f80f9865 | lynnvmara/CIS106-Lynn-Marasigan | /Session 5/Extra Credit.py | 935 | 4.21875 | 4 | print("What is your last name?")
name = input()
print("How many hours?")
hours = int(input())
print("What is your rate per hour?")
rate = int(input())
if hours > 40:
print(name + "'s regular pay for the first 40 hours is $" + str(rate) + " per hour for a total of $" + str(40 * rate) + ". The " + str(hours - 40) + " h... | true |
c25c418679ffdeb532dffb1409fbfe486167ca5a | lynnvmara/CIS106-Lynn-Marasigan | /Session 7/Assignment 2.py | 237 | 4.125 | 4 | print("What is the starting value?")
start = int(input())
print("What is the stop value?")
stop = int(input())
print("What is the increment value?")
increment = int(input())
while start <= stop:
print(start)
start = start + increment | true |
34c244ca5ffea4bd647dd29bc2eb7bccfa436db8 | radunm/jobeasy-algorithms-course | /HW_1.py | 1,789 | 4.1875 | 4 | # Sum of 3 modified
# Rewrite a program with any number of digits.
# Instead of 3 digits, you should sum digits up from n digits number,
# Where User enters n manually. n > 0
from random import randint
min_rand = 1
max_rand = "9"
result = 0
digit = int(input("Please, enter digit: "))
digit -= 1
while digit > 0... | true |
dada4202db884cbeb2c19042d26089564d2fb435 | MorKalo/L10_HomeWork20-10-21 | /Targil 9.py | 1,155 | 4.1875 | 4 | #ייצר את הפונקציות הבאות: div, mul, sub, add
#פונקציות אלו צריכות לקבל שני פרמטרים y, x .כל אחת מהן צריכה לחשב את הפעולה המתמטית שהיא מייצגת ולהחזיר את התוצאה
#כעת קלוט שני מספרים מהמשתמש )באמצעות input ,)קרא לארבעת הפונקציות שכתבת והדפסאת מה שהן החזירו
#default ל- y, x אשר הוא אפס
#add=חיבור
def getDiv(x=0,y=... | false |
998649baa7285122e041cdaf4a5dfbe984bc7c86 | vishnuap/Algorithms | /Chapter-03-Arrays/Zip-It/Zip-It.py | 1,449 | 4.875 | 5 | # Chapter-3: Arrays
# Zip-It
# 1. Create a function that accepts two arrays and combines their values sequentially into a new array at alternating indices starting with the first array. Extra values of either array should be included afterwards. Given [1,2] and [10,20,30], return [1,10,2,20,30]
# 2. Combine the two arr... | true |
c847c6634e70a105c0fd65c0f83619e55e07937f | vishnuap/Algorithms | /Chapter-01-Fundamentals/You-Say-Its-Your-Birthday/You-say-its-your-Birthday.py | 385 | 4.21875 | 4 | # Chapter-1: Fundamentals
# You-say-its-your-Birthday:
# If 2 given numbers represent your birth month and day in either order, log "How did you know?", else log "Just another day..."
myBDate = [3, 6]
def bd(num1, num2):
if num1 in myBDate and num2 in myBDate:
print("How did you know?")
else:
... | true |
56c6b7dc97ec4603e5ab899bd72463ba3b15db7f | vishnuap/Algorithms | /Chapter-03-Arrays/Array-Nth-Largest/Array-Nth-Largest.py | 2,588 | 4.40625 | 4 | # Chapter-3: Arrays
# Array-Nth-Largest
# Given 'arr' and 'N', return the Nth largest element, where N-1 elements are larger. Return null if needed
# Assume the arguments are an array with integers and an integer and both are passed to the function
# Since we want Nth largest such that N-1 elements are larger, if ther... | true |
3dc49d530e386fd3b266e007bc640f34d7046ef2 | vishnuap/Algorithms | /Chapter-01-Fundamentals/Always-Hungry/Always-Hungry.py | 489 | 4.1875 | 4 | # Chapter-1: Fundamentals
# Always-Hungry
# Create a function that accepts an array and prints "yummy" each time one of the values is equal to "food". If no array element is "food", then print "I'm hungry" once
# Assume the argument passed is an array
def yummy(arr):
hungry = 1
for i in range(0, len(arr)):
... | true |
93cb895cbc0a72249e25dac5489153f304dcac91 | vishnuap/Algorithms | /The-Basic-13/Print-Ints-and-Sum-0-255/Print-Ints-and-Sum-0-255.py | 260 | 4.28125 | 4 | # The Basic 13
# Print-Ints-and-Sum-0-255
# Print integers from 0 to 255. With each integer print the sum so far
def printIntsSum():
sum = 0
for i in range(0, 256):
sum += i
print("{} - Sum so far = {}").format(i, sum)
printIntsSum()
| true |
23355dd307a13236d38a8bde6571435771f8f1c2 | vishnuap/Algorithms | /Chapter-03-Arrays/Array-Nth-to-Last/Array-Nth-to-Last.py | 453 | 4.46875 | 4 | # Chapter-3: Arrays
# Array-Nth-to-Last
# Return the element that is N from array's end. Given ([5,2,3,6,4,9,7], 3), return 4. If the array is too short return null
# Assume the arguments are an array and an integer and both are passed
def nthToLast(arr, num):
return None if num > len(arr) else arr[-1 * num]
myAr... | true |
2dee4ac13bfc34d72b3a4bb04d199ab8be5de782 | vishnuap/Algorithms | /Chapter-01-Fundamentals/What-Really-Happened/What-Really-Happened.py | 1,334 | 4.15625 | 4 | # Chapter-1: Fundamentals
# What-really-Happened
# (refer to Poor Kenny for background)
# Kyle notes that the chance of one disaster is totally unrelated to the chance of another. Change whatHappensToday() to whatReallyHappensToday(). In this new function test for each disaster independantly instead of assuming exactly... | true |
c86a6295b69a14f635b5433edd3ad9f1b6044ca6 | vishnuap/Algorithms | /Chapter-04-Strings-AssociativeArrays/Drop-the-Mike/drop-the-mike.py | 997 | 4.25 | 4 | # Create a function that accepts an input string, removes leading and trailing white spaces (at beginning and ending only), capitalizes the first letter of every word and returns the string. If original string contains the word Mike anywhere, immediately return "stunned silence" instead. Given " tomorrow never dies ... | true |
0d0ffaa8f3359bedd40bb5a1495339eecb8f03bc | vishnuap/Algorithms | /Chapter-01-Fundamentals/Multiples-of-3-But-Not-All/Multiples-of-3-but-not-all.py | 386 | 4.65625 | 5 | # Chapter-1: Fundamentals
# Multiples of 3 - but not all:
# Using FOR, print multiples of 3 from -300 to 0. Skip -3 and -6
# multiples from -300 down means multiply 3 with -100 and down. -3 and -6 are 3 * -1 AND 3 * -2. So if we skip them, the multipliers are -100 down to -3.
for i in range(-100, 1):
if ((i != -1... | true |
905092abe8da1ea55e92a9d4a6b7f34565f2597b | vishnuap/Algorithms | /Chapter-02-Fundamentals-2/Statistics-Until-Doubles/Statistics-Until-Doubles.py | 838 | 4.1875 | 4 | # Chapter-2: Fundamentals-2
# Statistics-Until-Doubles
# Implement a 20-sided die that randomly returns integers between 1 and 20 (inclusive). Roll the die, tracking statistics until you get a value twice in a row. After that display number of rolls, min, max and average
import random as rd
def stats():
done = Fa... | true |
31b22e49ea518465e4e9b84f9bce3ff9ac222f46 | f-alrajih/Simple-Calculator | /directions.py | 2,879 | 4.5625 | 5 | # Welcome, Faisal, to your first project in Python!
# Today's project is to build a simple calculator that allows the user to choose what type of operation they want to do (add, subtract, multiply, or divide) and then takes the two numbers the user gives it and does the operation.
# You will need to build four differ... | true |
9fb5a1366d12831b7f3b22d2f68b65a8ca773910 | rosarioValero/Programacion | /Ejercicios-Pr6/ejercicio9.py | 746 | 4.28125 | 4 | qq"""ROSARIO VALERO MIRANDA - 1º DAW - PRACTICA6 - EJERCICIO 9
Escribe un programa que permita crear una lista de palabras y que, a continuación,
cree una segunda lista con las palabras de la primera,
pero sin palabras repetidas (el orden de las palabras
en la segunda lista no es importante). """
print("Dime cuá... | false |
466f1535379027fbf6cc322b1baf90095e73e57e | rosarioValero/Programacion | /Ejercicios-Pr7/ejercicio4.py | 575 | 4.375 | 4 | """ROSARIO VALERO MIRANDA - 1º DAW - PRACTICA7 - EJERCICIO 4
Escribe un programa que pida una frase, y le pase como parámetro a una función
dicha frase. La función debe sustituir todos los espacios en blanco
de una frase por un asterisco, y devolver el resultado para
que el programa principal la imprima por pantall... | false |
d2e1f8e6121ab0aa44fe8e899166b768028f39ed | rosarioValero/Programacion | /Ejercicios-Pr5/ejercicio9.py | 748 | 4.21875 | 4 | """ROSARIO VALERO MIRANDA - 1º DAW - PRACTICA5 - EJERCICIO 9
Escriu un programa que et demani noms de persones i els seus números de telèfon.
Per a terminar de escriure nombres i numeros s'ha de pulsar Intro quan et demani el nom.
El programa termina escribint noms i números de telèfon.
Nota: La llista en la que es... | false |
9d6b104a638a7d302a5aa5f89467ce47d7b5e972 | tarunvelagala/python-75-hackathon | /input_output.py | 239 | 4.125 | 4 | # Input Example
name, age = [i for i in input('Enter name and age:').split()]
# Output Example
print('Hello "{}", Your age is {}'.format(name, age))
print('Hello %s, Your age is %s' % (name, age))
print('Hello', name, 'Your age is', age)
| true |
2ccf71624478a3e9867ca75475630053040631b2 | dheerajsharma25/python | /assignment8/assignment9/ass9_1.py | 437 | 4.3125 | 4 | #Q.1- Create a circle class and initialize it with radius. Make two methods getArea and getCircumference inside this class.
import math
class circle:
def __init__(self,radius):
self.radius=radius
def area(self):
getarea=math.pi*self.radius*self.radius
print(getarea)
def circumference(self):
... | true |
47f111e1242d64f5655027c836ebfa25b802f312 | dheerajsharma25/python | /assignment10/ass10_4.py | 646 | 4.15625 | 4 | #Q.4- Create a class Shape.Initialize it with length and breadth Create the method Area.
class shape:
def __init__(self,length,breadth):
self.length=length
self.breadth=breadth
def area(self):
self.result=self.length*self.breadth
class rectangle(shape):
def arearect(self):
print("area of re... | true |
c0c4d692956d733993d63a42fdfdcf609c9b7eba | sv1996/PythonPractice | /sortList.py | 509 | 4.28125 | 4 | number =[3,1,5,12,8,0]
sorted_list =sorted(number)
print("Sorted list is " , sorted_list)
#original lst remain unhanged
print("Original list is " , number)
# print list in reverse order
print("Reverse soretd list is " , sorted(number , reverse =True))
#original list remain unchanged
print("Original list is " , number)... | true |
a528ae279f5773160001dd56b9ffb7df47714a86 | viditvora11/GK-quiz | /Python assements/v2 (Instructions and welcome)/v2a_instructions_and_welcome.py | 707 | 4.4375 | 4 | #Asking if they want to know the quiz rules.
rule = input("\nDo you want to read the rules or continue without the rules? \npress y to learn the rules or x to continue without knowing the rules : ")#Asking for the input
if rule == "y" or rule == "yes": #Use if function
print("\nThe basic rules are as follows \n ... | true |
2ca1a0ce4909965a4b4d0bcf2080d406bb9a5732 | FernandoGarciafg/m02_boot_0 | /recursividad.py | 1,503 | 4.1875 | 4 | # la recursividad es una funcion que para repetirse se invoca a si misma, una funcion es recursiva si para definirse se necesita
# solo a si misma y se llama a si misma, la recursividad tiene que tener una condicion de parada
def retroContador(numero):
print("{}\n".format(numero), end = "")
if numero > 0:
... | false |
6f013967c7998c120b1a1f8ca681add61a969ae3 | preciousakura/Atividades-Python | /listas.py | 278 | 4.1875 | 4 | num = []
num.append(0)
num.append(9)
num.append(8)
num.append(2)
for x, cont in enumerate(num):
print(f"Na posição {x} encontrei o valor {cont}!")
print("Cheguei ao fim da lista")
x = ('apple', 'banana', 'cherry')
y = enumerate(x)
print(list(y))
| false |
c57799bb1ea76d52ec15085c90ede41dc76ea625 | Punkrockechidna/PythonCourse | /advanced_python/functional_programming/map.py | 294 | 4.125 | 4 | # MAP
# previous version
# def multiply_by_2(li):
# new_list = []
# for item in li:
# new_list.append(items * 2)
# return new_list
# using map
def multiply_by_2(item):
return item * 2
print(list(map(multiply_by_2, [1, 2, 3]))) #not calling function, just running it
| true |
947f37fca0d63f02ec4af7a6c063496765ce4f06 | brandon-vargas24/PythonCode | /Python/merge_sort.py | 1,245 | 4.21875 | 4 | #Extra Credit Homework Assignment, Merge Sort
#VARGAS, BRANDON
#April 24, 2017
#Iterative:
def merge_sort_iterative(l, m):
result = []
i = j = 0
total = len(l) + len(m)
while len(result) != total:
if len(l) == i:
result = result + m[j:]
break
elif len(m) == j:
... | false |
6d3ef737751193c05f7a6791ca698a94c6cc77b7 | ChuqiaoW/Sandbo | /prac_05/hex_colours.py | 572 | 4.3125 | 4 | COLORS = {"aliceblue": "#f0f8ff", "antiquewhite": " #faebd7", "brown": "#a52a2a", "burlywood": "#deb887",
"cadetblue": "#5f9ea0", "coral": "#ff7f50", "chocolate": "#d2691e", "cornflowerblue": "#6495ed",
"darkgoldenrod": "#b8860b", "darkorange": "#ff8c00"}
color_chose = input("Pls enter color name... | false |
7c61b9cc81d4ae45d91866e38ec0051b045cdc00 | khatriajay/pythonprograms | /in_out_list_.py | 418 | 4.4375 | 4 | #! /usr/bin/env python3
#Python3 program for checking if you have a pet with name entered.
petname= ['rosie', 'jack', 'roxy', 'blossom'] #Define a list with pet names
print (' Enter your pet name')
name = input()
if name not in petname: #Check if name exists in list
print ('You dont hav... | true |
0487755cae67b8f59554449aae3a6612b0dc3b7e | rosteeslove/bsuir-4th-term-python-stuff | /numerical_analysis_methods/gaussianelimination/gauss_elim_partial_pivoting.py | 2,048 | 4.125 | 4 | """
Схема частичного выбора.
"""
import numpy as np
def solve(A: np.array, b: np.array, interactive) -> np.array:
"""
Solves A*x = b that is returns x-vector.
"""
if interactive:
print('Схема частичного выбора:\n')
input()
# securing args:
A = A.copy()
b = b.copy()
... | false |
0cc442ea2ed19f5130e5cdff5886b6dce22441c4 | tayadehritik/NightShift | /fact.py | 217 | 4.1875 | 4 | args = int(input())
def factorial(num):
fact = num
for i in range(num-1,1,-1):
fact = fact * i
return fact
for i in range(args):
num = int(input())
fact = factorial(num)
print(fact)
| true |
cd067c9c7ee918b908e31959d1e77d36dae5b36d | destrauxx/famped.github.io | /turtles.py | 469 | 4.125 | 4 | def is_palindrome(s):
tmp = s[:]
tmp.reverse()
print(s, 'input list')
print(tmp, 'reversed list')
if tmp == s:
return True
else:
return
def word(n):
result = []
for _ in range(n):
element = input('Enter element: ')
result.append(element... | true |
42160b7b926a67cfea2f482584f39c38e11c4c17 | ssenviel/Python_Projects-Udemy_zero_to_hero | /Generators_play.py | 909 | 4.46875 | 4 | """
problem 1:
create a Generator that generates the squares of numbers up to some number 'N'
problem 2:
create a generator that yields "n" random number between a low and high number
NOTE: use random.randrange or random.randint
problem 3:
use the iter() function to con... | true |
bd160ff2bbf7bc2b6c004d39a51180a45c0e9a84 | MarceloSaied/py | /python/helloworld/python1.py | 485 | 4.15625 | 4 | # print ("hello world")
# counter = 100 # An integer assignment
# miles = 1000.0 # A floating point
# name = "John" # A string
import datetime
currentDate = datetime.date.today()
currentDate=currentDate.strftime('%a %d %b %y')
print(currentDate)
# print (counter)
# print (miles)
# print (n... | true |
c648e44b121c114f7fc4d4d28b83700720388604 | jw3329/algorithm-implementation | /sort/selectionsort.py | 600 | 4.1875 | 4 | def swap(arr, i, j):
temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
# find minimum element, and swap with its element from the start
def selectionsort(arr):
for i in range(len(arr)):
min_index = i
for j in range(i + 1, len(arr)):
if arr[min_index] > arr[j]:
min... | true |
99dddf7531d25ca94c177a77f81c1ace561e7cd5 | alina-j/6 | /8.py | 1,120 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#Решите задачу: создайте словарь, связав его с переменной school , и наполните данными,которые бы отражали количество учащихся в разных классах (1а, 1б, 2б, 6а, 7в и т. п.).Внесите изменения в словарь согласно следующему: а) в одном из классов изменилось количество учащи... | false |
fbee41e0deb8a6a257f6a4a6977151eb79d273f0 | akomawar/Python-codes | /Practise_Assignments/reverse.py | 238 | 4.375 | 4 | while 1:
string=input("Eneter your string: ")
reverse=string[::-1]
print("Reverse order is : ",reverse)
if(string==reverse):
print('yes it is an palindrome')
else:
print('No it is not a palindrome')
| true |
17ab687aea8f2853c8feadd8d729503651fd2497 | saikiran-gutla/Ifassignment | /Daysinmonth.py | 405 | 4.34375 | 4 | month = input('Enter the month : ')
mon = month[0:3].lower()
print(mon)
if mon == 'jan' or mon == 'may' or mon == 'mar' or mon == 'jul' or mon == 'aug' or mon == 'oct' or mon == 'dec':
print(mon, "has 31 days")
elif mon == 'apr' or mon == 'jun' or mon == 'sep' or mon == 'nov':
print(mon, 'has 30 days')
elif mon... | false |
9ec4fc796e36856083bd46e275a5b46aef7b8baa | saikiran-gutla/Ifassignment | /tenp.py | 272 | 4.1875 | 4 | ch = input('Enter a character :')
if ((ch >= 'a' and ch <= 'z') or (ch >= 'A' and ch <= 'Z')) :
print(ch ,'is a character')
elif (ch >= '0' and ch <= '9'):
print(ch ,'is a number')
elif ch ==' ':
print('Its a space')
else:
print('its a special character')
| false |
01956a8f807fea39c05553178b47c9b4a81b73c8 | MarkChuCarroll/pcomb | /python/calc.py | 2,172 | 4.34375 | 4 | # A simple example of using parser combinators to build an arithmetic
# expression parser.
from pcomb import *
## Actions
def digits_to_number(digits, running=0):
"""Convert a list of digits to an integer"""
if len(digits) == 0:
return running
else:
r = (running * 10) + int(digits[0])
return digits... | true |
1789bc3863b74780b5dc95da3544b5ee4eee5c9b | Vijay1234-coder/data_structure_plmsolving | /Heap/NearlyKsortedArray.py | 960 | 4.125 | 4 | '''important'''
'''Given an array of n elements, where each element is at most k away from its target position, devise an algorithm that sorts in O(n log k) time. For example, let us consider k is 2, an element at index 7 in the sorted array, can be at indexes 5, 6, 7, 8, 9 in the given array.
Example:
Input : arr[] =... | false |
e11491e4a4ee97151df1055abd9ef0a5d9d9b878 | Vijay1234-coder/data_structure_plmsolving | /LINKED_LISTALLMETHODS/InsertionSortLL.py | 1,597 | 4.21875 | 4 | class Node:
def __init__(self,data):
self.data = data
self.nref = None
self.pref = None
class DoublyLL:
def __init__(self):
self.head = None
def print_LL(self): # Forward Direction Traversal
if self.head ==None:
print("Empty LL")
else:
... | false |
b6ed10576f670be063516122126826ef88918fb1 | Vijay1234-coder/data_structure_plmsolving | /SEARCHING AND SORTING/Binary Search/Implementation.py | 979 | 4.15625 | 4 | def binary_search(arr,target):
first = 0
last = len(arr)-1
found = False
while (first <= last) and (found == False):
mid = (first+last)//2
if arr[mid] == target:
print("found at index {0}".format(mid))
found = True
else:
if target > arr[mid]:
... | false |
7cfd67cc83713cec92f7ce1807bcaeed84028c0b | sprajwol/python_assignment_II | /assignment_Q11.py | 863 | 4.71875 | 5 | # # 11. Create a variable, filename. Assuming that it has a three-letter
# # extension, and using slice operations, find the extension. For
# # README.txt, the extension should be txt. Write code using slice
# # operations that will give the name without the extension. Does your
# # code work on filenames of arbitrary ... | true |
487db65523fc0db80945c254b577d3a9a3cf7f61 | sprajwol/python_assignment_II | /assignment_Q7.py | 1,054 | 4.25 | 4 | # 7. Create a list of tuples of first name, last name, and age for your
# friends and colleagues. If you don't know the age, put in None.
# Calculate the average age, skipping over any None values. Print out
# each name, followed by old or young if they are above or below the
# average age.
import statistics
list_of_da... | true |
e53d462fc353654d6ebbc5e3b1ad3b654e135a75 | korzair74/Homework | /Homework_4-20/family.py | 235 | 4.34375 | 4 | """
Create a variable called family
Assign it a list of at least 3 names of family members as strings
Loop through the list and print everyone's name
"""
family = ['Shea', 'Owen', 'Chris']
for name in family:
print(name) | true |
6d832510ef2179b0a5fc908e6904c4b12e4d55fa | EOT123/AllEOT123Projects | /All Python Files Directory/Bounties/Bounty11.py | 495 | 4.3125 | 4 | # 10/30/17
# Number flipper opposite output neg=pos/pos=neg
print("")
print("_______________________________________")
print("Welcome To The Opposite Number Flipper")
print("_______________________________________")
print("")
while True:
num = int(input('Enter A Number To Be Flipped: '))
if num > 0:
pri... | false |
b7838d90f734023df37e7de90f8d01373a112fb2 | mogarg/Python-Tutorial-Lynda | /variables-syntax.py | 359 | 4.25 | 4 | #!/usr/bin/python3
def main():
atuple = (1,2,3) #A tuple is immutable
alist = [1,2,3] #A list is mutable
print(atuple,type(atuple))
print(alist,type(alist))
alist.append(5)
print(alist)
alist.insert(2,7)
print(alist)
x = "string" #A string is an immutable sequence
for i in x:
pr... | false |
aebd73b4f15e97b86345ee31cd6e0df8e6e57b6d | matthpn2/Library-Database-Application | /backend_database.py | 1,929 | 4.53125 | 5 | import sqlite3
class Database:
'''
SQLite database which can be viewed, searched, inserted, deleted, updated and closed upon.
'''
def __init__(self, db):
self.connection = sqlite3.connect(db)
self.cursor = self.connection.cursor()
self.cursor.execute("CREATE TABLE IF NOT EX... | true |
97bc749ebc6f382ace489e57bbe092de06e98025 | AndreiSystem/python_aula | /mundo01/ex031.py | 520 | 4.15625 | 4 | """
Desenvolva um programa que pergunte a distância de uma viagem em Km.
Calcule o preço da passagem, cobrando R$0,50 por Km para viagens de até 200Km
e R$0.45 para viagens mais longas.
"""
distancia = float(input('Digite a distância da viagem em Km: '))
print(f'Viagem de {distancia:.1f}Km.')
if distancia <= 200:
... | false |
018840bac1a0cbb7a539d9a708eeb7d3a022c8d6 | AndreiSystem/python_aula | /mundo01/Modulo.py | 512 | 4.21875 | 4 | """"
**import math importa toda a biblioteca de matemática
import math
num = int(input('Digite um número: '))
raiz = math.sqrt(num)
print(f'A raíz de {num} é igual a {raiz:.2f} e se arrendoda-la resulta em {math.ceil(raiz)}')
#from math import importa somente um módulo especifico
from math import sqrt
num = int(inp... | false |
514acc07466de29f954cb0ff734384a1772592e2 | sharingplay/Introduccion-a-la-programacion | /Recursividad de pila/Listas/listaSumParImpar.py | 850 | 4.15625 | 4 | """Suma valores pares e impares de una lista"""
def suma (lista):
#if type (lista) == list, tambien verifica que lista sea de tipo lista
if isinstance (lista,list):
print "Suma pares: " , validarPar (lista)
print "Suma impares: ",validarImpar(lista)
else:
return "Error, el val... | false |
6bf7618ce1538e6394f9aa52375cdda7e1fcc3a7 | sharingplay/Introduccion-a-la-programacion | /Python/Matrices/tarea matriz.py | 1,627 | 4.3125 | 4 |
"""multiplica los primeros numeros de una columna contra los numeros de
una fila"""
def multiplicacionMatriz(lista1,lista2):
if isinstance (lista1,list) and (lista2,list):
return matrices(lista1,lista2,0,0,0,0,[],[])
else:
return "Error"
def matrices (lista1,lista2,contCol_1,contCol_2... | false |
4e5d7c36099415e09ff077fba1e06bc3262950dc | samhita-alla/flytesnacks | /cookbook/core/basic/task.py | 2,089 | 4.15625 | 4 | """
Tasks
------
This example shows how to write a task in flytekit python.
Recap: In Flyte a task is a fundamental building block and an extension point. Flyte has multiple plugins for tasks,
which can be either a backend-plugin or can be a simple extension that is available in flytekit.
A task in flytekit can be 2 ... | true |
251f4cf3e4b649230e0180803aecd6ef3c0e249d | kimchol0/Python | /range.py | 483 | 4.5625 | 5 | #遍历数字序列
for i in range(10):
print(i,end=" ")
print("\n----------")
#遍历指定区间的值
for i in range(0,20):
print(i,end=" ")
print("\n----------")
#以指定数字开始并指定不同的增量(甚至可以为负数,也叫做“步长”)
for i in range(0,10,3):
print(i,end=" ")
print("\n----------")
#负数
for i in range(-10,-100,-30):
print(i,end=" ")
print("\n---------... | false |
5fe0ad7defc54cb146a4d187e0ec03c001da7b82 | manrajpannu/ccc-solutions | /ccc-solutions/2014/Triangle.py | 1,239 | 4.21875 | 4 | # Triangle
# Manraj Pannu
# 593368
# ICS3U0A
# 23 Oct 2018
firstAngle = int(input()) # input: the first angle of the triangle
secondAngle = int(input()) # input: the second angle of the triangle
thirdAngle = int(input()) # input: the third angle of the triangle
totalAngle = (firstAngle + secondAngle + thi... | true |
790b036fd87b8e76e6a41bc2737dce28fc5ef6f3 | sharifnezhad/python-workout1 | /calculator.py | 1,349 | 4.125 | 4 | import math
i='y'
while i=='y':
number_one=int(input('please enter number1:'))
Operator=input('please enter Operator: (+|-|*|/|^|radical|sin|cos|tan|cot|factorial)')
if Operator == '+' or Operator == '-' or Operator == '*' or Operator == '/' or Operator == '^' :
number_two=int(input('please en... | false |
871d961154232ad57478058b1f58f6ca47c9f03f | JustinLaureano/python_projects | /python_practice/is_prime.py | 563 | 4.3125 | 4 | """
Define a function isPrime/is_prime() that takes one integer argument and
returns true/True or false/False depending on if the integer is a prime.
Per Wikipedia, a prime number (or a prime) is a natural number greater than 1
that has no positive divisors other than 1 and itself.
"""
def is_prime(num):
if num ... | true |
e84bee8c7f1151fde0a1d9be3c1bf96400ac5949 | JustinLaureano/python_projects | /python_practice/max_subarray_sum.py | 924 | 4.21875 | 4 | """
The maximum sum subarray problem consists in finding the maximum sum of a
contiguous subsequence in an array or list of integers:
maxSequence([-2, 1, -3, 4, -1, 2, 1, -5, 4])
# should be 6: [4, -1, 2, 1]
Easy case is when the list is made up of only positive numbers and the maximum
sum is the sum of the whole arra... | true |
dea1a14a5d21acab0295d8cf41cfc85deae87015 | itspayaswini/PPA-Assignments | /exception.py | 221 | 4.15625 | 4 | numerator=int(input("enter the numerator "))
denominator=int(input("enter the denominator "))
try:
result= (numerator/denominator)
print(result)
except ZeroDivisionError as error:
print("Division by zero!")
| true |
5db2515b14384ef59c4dc2459305b3d4f0f91853 | perfectgait/eopi | /python2/7.2-replace_and_remove/telex_encoding.py | 1,401 | 4.25 | 4 | """
Telex encode an array of characters by replacing punctuations with their spelled out value.
"""
__author__ = "Matt Rathbun"
__email__ = "mrathbun80@gmail.com"
__version__ = "1.0"
def telex_encode(array):
"""
Telex encode an array of characters using the map of special characters
"""
special_strin... | true |
2d9b2e241a24df7fa44ce2fd51be999d07a1d40e | Vangasse/NumPyTutorial | /NumPySortSearch.py | 725 | 4.28125 | 4 | # %%
import numpy as np
import matplotlib.pyplot as plt
# %% How to get the indices of the sorted array using NumPy in Python?
a = np.array([2, 4, 8, 6, 1, 9, 5, 3, 7])
print(np.argsort(a))
# %% Finding the k smallest values of a NumPy array
a = np.array([2, 4, 8, 6, 1, 9, 5, 3, 7])
k = 3
print(np.sort(a)[:k])
# %% H... | true |
c4d8a7398a895035637e2c36ca6c26f9a2fdf666 | gmendiol-cisco/aer-python-game | /brehall_number-guessing-game.py | 1,073 | 4.1875 | 4 | #random number generator
import random
number=random.randint(1,100)
#define variables.
TOP_NUM=100
MAXGUESS=10
guesscount=0
#game rules
print("Welcome to the Number Guessing Game...")
print("I'm thinking of a number between 1 and", TOP_NUM,". You have", MAXGUESS,"chances to figure it out." )
#collect information
... | true |
ded3e0219922eb6440c7901bc97a3ce4003c8a05 | leeseu95/MetodosNumericos | /Parcial1/SeungLee_P1.py | 2,320 | 4.15625 | 4 | # Seung Hoon Lee Kim - A01021720
# Examen - Parcial 1
# Pregunta 1 Manejo de inventario
# Solución escrita en Python 3
# Librerías utilizadas: random
# Librerías utilizadas: math
# Librerías utilizadas: statistics
import random
import numpy
import math
import statistics
inventory = 0
limite = 5
order = 0
costOrder ... | false |
ac233558523fd4d10a3f327417816cf9aafcfa9c | kchaoui/me | /week2/exercise1.py | 1,958 | 4.65625 | 5 | """
Commenting skills:
TODO: above every line of code comment what you THINK the line below does.
TODO: execute that line and write what actually happened next to it.
See example for first print statement
"""
import platform
# I think this will print "hello! Let's get started" by calling the print function.
print("h... | true |
94101d0179b9826da4e12ed61fbb1f08cf93e7e5 | sghosh1991/InterviewPrepPython | /LeetCodeProblemsEasy/543_Diameter_of_binary_tree.py | 2,650 | 4.40625 | 4 | '''
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
Example:
Given a binary tree
1
/ \
2 3
/ \
4 ... | true |
5ac54dd56d88f98d8a0877706ef05f53f0bcbec1 | sghosh1991/InterviewPrepPython | /LeetCodeProblemsEasy/461_HammingDistance.py | 1,254 | 4.15625 | 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.
Hints: XOR followed by count set bits. Counting set bits can be done in many ways. Lookup table in O(1). Brutoforce O(n) Brian- Kerningha... | true |
41df50dd1f20e926992b910468b7c44859377dfe | Aurales/DataStructuresHomework | /Data Structures/Lab 04/Lab04A_KyleMunoz.py | 367 | 4.1875 | 4 | #Kyle Munoz
#Collatz Conjecture Recursively
def CollatzConjecture(n, c = 0):
if n == 1:
print("Steps Taken: ",c)
elif n % 2==0:
return CollatzConjecture(n/2, c + 1)
else:
return CollatzConjecture(((n * 3) + 1), c + 1)
def main():
x = int(input("What number would you like t... | true |
736b387e21f6927a74aedffd1580eb89d92a4f06 | feyfey27/python | /age_calculator.py | 669 | 4.25 | 4 | from datetime import datetime, date
def check_birthdate(year, month, day):
today = datetime.now()
birthdate = datetime(year, month, day)
if birthdate > today:
return False
else:
return True
def calculate_age(year,month,day):
today = datetime.now()
birthdate = datetime(year, month, day)
age = today - birt... | true |
84f9b09013e04222ed26dfc6af70fcc91dcf2324 | aindrila2412/DSA-1 | /Booking.com/power_set.py | 1,609 | 4.1875 | 4 | """
Given an integer array nums of unique elements, return all possible subsets
(the power set).
The solution set must not contain duplicate subsets. Return the solution in
any order.
Example 1:
Input: nums = [1,2,3]
Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
Example 2:
Input: nums = [0]
Output: [[],[0]]
... | true |
b77cdbe352caec79714a00d9de8536ecb1bf15a6 | aindrila2412/DSA-1 | /Recursion/reverse_a_stack.py | 1,350 | 4.25 | 4 | """
Reverse a Stack in O(1) space using Recursion.
Example 1
Input: st = [1, 5, 3, 2, 4]
Output:[4, 2, 3, 5, 1]
Explanation: After reversing the stack [1, 5, 3, 2, 4]
becomes [4, 2, 3, 5, 1].
Example 2
Input: st = [5, 17, 100, 11]
Output: [11, 100, 17, 5]
Explanation: After reversing the stack [5, 17, 100, 11]
becom... | true |
391ce6e49583edf602e8dca5690384ca5e614bfe | aindrila2412/DSA-1 | /Recursion/ways_to_climb_stairs.py | 1,342 | 4.125 | 4 | """
Given a staircase of n steps and a set of possible steps that we can climb at
a time named possibleSteps, create a function that returns the number of ways
a person can reach to the top of staircase.
Example:
Input:
n = 10
possibleSteps = [2,4,5,8]
Output: 11
Explanation:
[2,2,... | true |
03eaa82c091996233aece88866bdf83c04b43d0a | aindrila2412/DSA-1 | /crackingTheCodingInterview/ArrayAndStrings/largest_number_at_least_twice_of_others.py | 1,445 | 4.3125 | 4 | """
You are given an integer array nums where the largest integer is unique.
Determine whether the largest element in the array is at least twice as much
as every other number in the array. If it is, return the index of the largest
element, or return -1 otherwise.
Example 1:
Input: nums = [3,6,1,0]
Output: 1
Expla... | true |
9bb56f95c93a03afdd983e623f94dad18e526228 | alicetientran/CodeWithTienAndHieu | /1-introduction/Task1-tien.py | 914 | 4.3125 | 4 | """
Task:
Ask the user for a number
Tell the user if the number is odd or even
Hint: use % operator
Extras:
If the number is a multiple of 3, print "Third time's a charm"
Ask the user for two numbers: one number to check (call it num) and one number to divide by (check).
If {check} divides e... | true |
b24e15f6714bd51c24148ecc514362f850623233 | houtan1/Python_Data_Cleaner | /helloworld.py | 888 | 4.25 | 4 | # run with python helloworld.py
# print("hello world")
# tab delimited text dataset downloaded from https://doi.pangaea.de/10.1594/PANGAEA.885775 as Doering-etal_2018.tab
# let's read in that data
file = open("data/Doering-etal_2018.tab", "r")
line = file.readlines()
# print(line[28])
# print(len(line))
for x in rang... | true |
a583763a983846a55d86f58a5ac5146e40d273ce | tzwyf/Learning | /python/学习笔记/输入输出.py | 883 | 4.5 | 4 | # 用户输入
def reverse(text):
return text[::-1]
def is_palindrome(text):
return text == reverse(text)
something = input("Enter text: ")
if(is_palindrome(something)):
print("Yes, it is a palindrome")
else:
print("No,it is not a palindrome")
#pickle 模块
#Python 提供了一个叫做 p... | false |
adde8bcdf70592e681d642befa152e0737ffc754 | marat-biriushev/PY4E | /py.py | 2,071 | 4.21875 | 4 | #!/usr/bin/python3
def f(x, y = 1):
"""
Returns x * y
:param x: int first integer to be added.
:param y: int second integer to be added (Not requared, 1 by default).
:return : int multiplication of x and y.
"""
return x * y
x = 5
#print(f(2))
#a = int(input('type a number'))
#b = int(input(... | true |
0f71e4012a72306a5c67cae91d404a2229d641c4 | marat-biriushev/PY4E | /ex_7_1.py | 2,122 | 4.625 | 5 | #!/usr/bin/python3
''' Exercise 1: Write a program to read through a file
and print the contents of the file (line by line) all
in upper case.'''
fname = input('Enter a filename: ')
fhand = open(fname)
for line in fhand:
line = line.upper()
line = line.rstrip()
print(line)
#################################... | true |
889e82e3ca53f9e78d1ed1aaf2573b2fc32ab599 | Rodrigs22/ExerciciosCursoEmvideo | /PycharmProjects/PythonexExercícios/ex037.py | 547 | 4.1875 | 4 | numero = int(input('digite um numero inteiro para transformar: '))
c1 = int(input('''[ 1 ] converter para BINÁRIO
[ 2 ] converter para OCTAL
[ 3 ] converter para HEXADECIMAL
Escolha: '''))
if c1 == 1:
print('O numero {} convertido em binário é, {}.'.format(numero, bin(numero)[2:]))
elif c1 == 2:
print('o Numero... | false |
63d20821cc349256ae4929da0ef0a2691713a831 | gchristofferson/credit.py | /credit.py | 2,681 | 4.15625 | 4 | from cs50 import get_int
import math
# prompt user for credit card
# validate that we have a positive integer between 13 and 16 digits
while True:
ccNum = get_int('Enter Credit Card Number: ')
if ccNum >= 0:
break
# reset value of ccNum
copyCCNum = ccNum
count = 0
# count the number of digits in the ... | true |
dcb7085f360547f5cf4fe1b3f324dedd937b8e02 | rylee-boop7/booga_booga_123 | /celsius.py | 480 | 4.125 | 4 | temp = input ("Imput the tempurture you like to convert? (e.g., 45f, 102c etc.) : ")
degree = int(temp[: _1])
i_convention = temp[-1]
if i_convention.upper() == "C":
result = int(round((9 * degree) / 5 + 32))
o_convention = "Fahrenheit"
elif i_convention.upper() =="F":
result = int(round((degree - 32) * 5... | false |
72b76b4fdadfd01b0139c323b6412008fd70e90d | omi-akif/My_Codes | /Python/DataAnalysis/MIS401/Class Resource/1st Class/MIS401-Class 1.py | 1,402 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[12]:
# In[17]:
Name ='Kazi' #Assigning String Variable
# In[56]:
Age=28 #assigning variable
# In[15]:
Name #Printing varibale without using Print
# In[16]:
Age #Printing varibale without using Print
# In[18]:
Name
# In[19]:
print(Name)
# In[21... | true |
954959ab38ebc709a8f81657b636fcf5f6d3ede3 | tiago-falves/FPRO-Python | /RE/Outros/min_path.py | 1,790 | 4.15625 | 4 | """
5. Minimum path
Write a function min_path(matrix, a, b, visited=[]) that discovers the minimum path
between a and b inside the matrix maze without going through visited twice. Positions a
and b are tuples (line, column), matrix is a matrix of booleans with False indicating no
obstacle and True indicating an obstacl... | true |
9b2f498eb5a9866cf6feb8f99303d850812b6fb5 | kaizokufox/Python | /ExercRepetição.py | 2,458 | 4.125 | 4 | #1) calcular a soma dos numeros digitados e a media
'''
soma = 0
media = 0
numero = 1
qdt = 0
while numero != 0 :
numero = int(input("Digite um numero: "))
if numero != 0:
soma = soma + numero
qdt = qdt + 1
media = soma / qdt
print("A soma dos números é: %d " % soma)
print("A medi... | false |
8180da315e37a3b95d2b2a5bb98f70040a5951cb | kaizokufox/Python | /Exerc2.py | 1,214 | 4.53125 | 5 | #print("flavia e te amo")
#Operadores aritméticos auxiliares em python
''' ** potenciação Exemplo -> 2**3 = 8
math.sqr Radiciação exemplo -> math.sqrt(4) = 2
% Resto de Divisão Exempl -> 4%3 = 1'''
#Prioridades
'''Pareneses mais internos
pot rad
* / mod
+ -'''
#Exemplo/Exemplo de operação arimética
# A... | false |
c0896304188088cb6bfa4644741f6ac469b07a28 | absupriya/Applied-Algorithms | /1. Bubble sort/bubble_sort.py | 2,273 | 4.375 | 4 | #Reading the entire input file
orig_file=open('input.txt','r').readlines()
#Convert the input data from strings to integer data type
orig_file = list(map(int, orig_file))
#Create an empty list to hold the average elapsed time and the number of inputs
avg_elap_time_list=[]
num_of_inputs_to_sort=[]
#Setting up the arr... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.