blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
77eeda8905113f1cbd1d2fe1e13685c814ebe662 | denisefavila/python-playground | /src/linked_list/swap_nodes_in_pair.py | 720 | 4.125 | 4 | from typing import Optional
from src.linked_list.node import Node
def swap_pairs(head: Optional[Node]) -> Optional[Node]:
"""
Given a linked list, swap every two adjacent nodes and return its head.
You must solve the problem without modifying the values in the list's nodes
(i.e., only nodes themselv... | true |
45c1771c5a496bf65e92c07f5fcb8a6d5891f5f4 | chuanski/py104 | /LPTHW/2017-04-26-10-31-18.py | 1,422 | 4.53125 | 5 | # -*- coding: utf-8 -*-
# [Learn Python the Hard Way](https://learnpythonthehardway.org/book)
# [douban link](https://book.douban.com/subject/11941213/)
# ex6.py Strings and Text
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s." % (binary, do_not)
yy ... | true |
4504fdabb7ca47f4c3e20e13050b12971cadb240 | BhagyeshDudhediya/PythonPrograms | /5-list.py | 2,285 | 4.5625 | 5 | #!/usr/bin/python3
import sys;
# Lists are the most versatile of Python's compound data types.
# A list contains items separated by commas and enclosed within square brackets ([]).
# To some extent, lists are similar to arrays in C.
# One of the differences between them is that all the items belonging to a list can b... | true |
ed871e8bf632e9db119245d7b68af57af885343a | BhagyeshDudhediya/PythonPrograms | /2-quoted-strings.py | 994 | 4.3125 | 4 | #!/usr/bin/python
# A program to demonstrate use of multiline statements, quoted string in python
import sys;
item_1 = 10;
item_2 = 20;
item_3 = 30;
total_1 = item_1 + item_2 + item_3;
# Following is valid as well:
total_2 = item_1 + \
item_2 + \
item_3 + \
10;
print("total_1 is:", tot... | true |
4df0cac6d76dda3a1af63e399d508cec7159e781 | BhagyeshDudhediya/PythonPrograms | /18-loop-cntl-statements.py | 2,145 | 4.53125 | 5 | #!/usr/bin/python3
# The Loop control statements change the execution from its normal sequence. When the execution leaves a scope,
# all automatic objects that were created in that scope are destroyed.
# There are 3 loop control statements:
# 1. break, 2. continue, 3. pass
# BREAK STATEMENT
# The break statement is ... | true |
49da84798e3df53e56671287c625dc5d725e42f3 | Niloy28/Python-programming-exercises | /Solutions/Q14.py | 578 | 4.1875 | 4 | # Write a program that accepts a sentence and calculate the number of upper case letters and lower case letters.
# Suppose the following input is supplied to the program:
# Hello world!
# Then, the output should be:
# UPPER CASE 1
# LOWER CASE 9
in_str = input()
words = in_str.split()
upper_letters = lower_... | true |
345ce55214f53b15b5c95309c21ad414da483d78 | Niloy28/Python-programming-exercises | /Solutions/Q24.py | 528 | 4.125 | 4 | # Python has many built-in functions, and if you do not know how to use it, you can read document online or find some books. But Python has a built-in document function for every built-in functions.
# Please write a program to print some Python built-in functions documents, such as abs(), int(), raw_input()
# And add... | true |
da81d7c444c0465736cf3fc0e085db8fa8c607e1 | Niloy28/Python-programming-exercises | /Solutions/Q22.py | 692 | 4.40625 | 4 | # Write a program to compute the frequency of the words from the input. The output should output after sorting the key alphanumerically.
# Suppose the following input is supplied to the program:
# New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python 3.
# Then, the output should be:
# 2:2... | true |
b2ba0782b339b8a9d555378872260f0bae6852e6 | Niloy28/Python-programming-exercises | /Solutions/Q53.py | 603 | 4.3125 | 4 | # Define a class named Shape and its subclass Square. The Square class has an init function which takes a length as argument.
# Both classes have a area function which can print the area of the shape where Shape's area is 0 by default.
class Shape(object):
def __init__(self, length=0):
pass
d... | true |
0870d3f73baba9157e9efc8e59cdf6bf630af41a | Niloy28/Python-programming-exercises | /Solutions/Q57.py | 365 | 4.40625 | 4 | # Assuming that we have some email addresses in the "username@companyname.com" format, please write program to print the user name of a given email address.
# Both user names and company names are composed of letters only.
import re
email_id = input()
pattern = r"([\w._]+)@([\w._]+)[.](com)"
match = re.searc... | true |
0b69e07cf5ee6963767afa0539a63c54292fda1d | olayinka91/PythonAssignments | /RunLenghtEncoding.py | 848 | 4.34375 | 4 | """Given a string containing uppercase characters (A-Z), compress the string using Run Length encoding. Repetition of character has to be replaced by storing the length of that run.
Write a python function which performs the run length encoding for a given String and returns the run length encoded String.
Provide dif... | true |
4f701b58fcf157bd5f96991e082a8b00a6bb220c | scottshepard/advent-of-code | /2015/day17/day17.py | 1,869 | 4.125 | 4 | # --- Day 17: No Such Thing as Too Much ---
#
# The elves bought too much eggnog again - 150 liters this time. To fit it all
# into your refrigerator, you'll need to move it into smaller containers.
# You take an inventory of the capacities of the available containers.
#
# For example, suppose you have containers of ... | true |
053699bdc95f9bf5833916aca6da13fbe99c4a10 | MatheusL3/python-news | /teste_003.py | 799 | 4.125 | 4 | nome = str(input('Digite seu nome completo: '))
print('Seu nome com todas as letras maiúsculas é {}'.format(nome.upper()))
print('Seu nome com todas as letras minúsculas é {}'.format(nome.lower()))
print('Seu nome contem {} letras ao todo, e {} sem contar espaços'.format(len(nome), len(nome.replace(" ", ""))))
print('A... | false |
e67363c2be2fc782679324cffb7afa0900c3b493 | NovaStrikeexe/FtermLabs | /Massive.py | 697 | 4.1875 | 4 | import random
n = 0
n = int(input("Enter the number of columns from 2 and more:"))
if n < 2:
print("The array must consist of at least two columns !")
n = int(input("Enter the number of columns from 2 and more:"))
else:
m = [][]
for i in range(0, n):
for j in range(0, n):
m... | true |
fe0004a380012ba1138fc4cb6fce9e167821c673 | NovaStrikeexe/FtermLabs | /SUM LAST AND FIRST.py | 676 | 4.15625 | 4 | print("Start program.....")# 1.42
#Найти сумму первой и последней цифр любого целого положительного числа.
print("====================")
x = int(input("input x:"))
print("====================")
if x < 0:
print("Your x is negative it wouldnt work")
elif x < 10:
print("Only one simbol in list:", x)
else:... | false |
d3d3e1bd76011772b1617b8c1a2ca18b4e6ec080 | NovaStrikeexe/FtermLabs | /list of lists.py | 1,230 | 4.46875 | 4 | #3.49
#Дано натуральное число n>=2, список списков, состоящий из n элементов по n чисел в элементе.
# Список заполняется случайным образом числами из промежутка от 0 до 199.
# Найти количество всех двухзначных чисел, у которых сумма цифр кратна 2.
import random
i = 0
z = 0
j = 0
n = 0
n = int(input("Enter the ... | false |
0ee66518a54adf969661ad33b91752d508391bad | scarter13/House-Hunting | /hourly_pay.py | 319 | 4.34375 | 4 | hours_worked = float (input("Enter Hours Worked: "))
hourly_rate = float (input("Enter Hourly Rate: "))
#if you worked more than 40
if hours_worked > 40:
overtime = hours_worked - 40
wages = (40* hourly_rate + overtime * hourly_rate * 1.5)
else:
wages = hours_worked * hourly_rate
print ("Total: $", wages) | false |
d641e7077401b04ab5d5ac4502ba363d71f6def3 | keremh/codewars | /Python/8KYU/reverse_array.py | 222 | 4.21875 | 4 | """
Get the number n to return the reversed sequence from n to 1.
Example : n=5 >> [5,4,3,2,1]
"""
def reverse_seq(n):
n_array = []
i = 0
for i in range(n, 0, -1):
n_array.append(i)
return n_array
| false |
c10f523deaca3b606d195f0c80b8dc16188b913e | userddssilva/Exemplos-introducao-a-programacao | /listas.py | 2,775 | 4.6875 | 5 | """
## Listas em python 3
As listas em python são objetos heterogênios iteráveis, isso significa que podem
armazenar em tempo de execução dados de valores e tipos diferentes.
- Exemplo:
```python
>>> lista = ["NOME 1", 12, "QUIN. B", 1.90]
>>> lista
['NOME 1', 12, 'QUIN. B', 1.9]
... | false |
b51ea3673b3366bc2bc8646a49888b13c2dca444 | sanneabhilash/python_learning | /Concepts_with_examples/inbuild_methods_on_lists.py | 350 | 4.25 | 4 | my_list = [2, 1, 3, 6, 5, 4]
print(my_list)
my_list.append(7)
my_list.append(8)
my_list.append("HelloWorld")
print(my_list)
my_list.remove("HelloWorld") # sorting of mixed list throws error, so removing string
my_list.sort() # The original object is modified
print(my_list) # sort by default ascending
my_list.sort... | true |
db7b4af913e90310e154910ef8e11eb52269890b | sanneabhilash/python_learning | /Concepts_with_examples/listOperations.py | 2,139 | 4.40625 | 4 | # List is an ordered sequence of items. List is mutable
# List once created can be modified.
my_list = ["apples", "bananas", "oranges", "kiwis"]
print("--------------")
print(my_list)
print("--------------")
# accessing list using index
print(my_list[0])
print(my_list[3])
# slicing list
print(my_list[1:4])
print(my_... | true |
01677a7c933fa163221e27a8bea963a35b8888be | oddsorevans/eveCalc | /main.py | 2,991 | 4.34375 | 4 | # get current day and find distance from give holiday (christmas) in this case
from datetime import date
import json
#made a global to be used in functions
holidayList = []
#finds the distance between 2 dates. Prints distance for testing
def dateDistance(date, holiday):
distance = abs(date - holiday).days
pr... | true |
70fec296d60c640fc3f7886ee624a2ca90a16799 | pdeitel/PythonFundamentalsLiveLessons | /examples/ch02/snippets_py/02_06.py | 1,577 | 4.15625 | 4 | # Section 2.6 snippets
name = input("What's your name? ")
name
print(name)
name = input("What's your name? ")
name
print(name)
# Function input Always Returns a String
value1 = input('Enter first number: ')
value2 = input('Enter second number: ')
value1 + value2
# Getting an Integer from the User
value = input... | true |
4a9dddf948d68d000c1da8065c0d4762eba63a8c | lokesh-pathak/Python-Programs | /ex21.py | 516 | 4.21875 | 4 | # Write a function char_freq() that takes a string and builds a frequency listing of the characters contained in it.
# Represent the frequency listing as a Python dictionary.
# Try it with something like char_freq("abbabcbdbabdbdbabababcbcbab").
def char_freq(str):
frequency = {}
for n in str:
key = frequency.ke... | true |
0bdc8ceb19ab6e4f6f305bc33ca8682917661dff | lokesh-pathak/Python-Programs | /ex41.py | 1,135 | 4.21875 | 4 | # In a game of Lingo, there is a hidden word, five characters long.
# The object of the game is to find this word by guessing,
# and in return receive two kinds of clues:
# 1) the characters that are fully correct, with respect to identity as well as to position, and
# 2) the characters that are indeed present in the w... | true |
8eafb237ab16ac14decc606b7ee80e4e82119196 | lokesh-pathak/Python-Programs | /ex33.py | 918 | 4.84375 | 5 | # According to Wikipedia, a semordnilap is a word or phrase that spells a different word or phrase backwards.
# ("Semordnilap" is itself "palindromes" spelled backwards.)
# Write a semordnilap recogniser that accepts a file name
# (pointing to a list of words) from the user and finds and prints
# all pairs of words tha... | true |
97d90fb94f6427ae1c13eba623ea4e9ce7665670 | lokesh-pathak/Python-Programs | /ex1.py | 269 | 4.28125 | 4 | # Define a function max() that takes two numbers as arguments and returns the largest of them.
# Use the if-then-else construct available in Python.
def max(num1, num2):
if num1 > num2:
return num1
else:
return num2
#test
print max(3, 5)
print max(10, 6)
| true |
a0ea041eeb131dd28038413c9389d99f0290dc32 | GanLay20/The-Python-Workbook-1 | /pyworkbookex024.py | 353 | 4.125 | 4 | print("The Seconds Calculator\n")
days = int(input("Enter the amount of Days:\n>>> "))
hours = int(input("Enter the amount of Hours:\n>>> "))
minutes = int(input("Enter the amount of Minutes:\n>>> "))
day_s = days * 86400
hour_s = hours * 3600
minute_s = minutes * 60
seconds = day_s + hour_s + minute_s
print("The ... | false |
f4a61563068fa1a16ef68ff5817ff56d76fd7fa0 | GanLay20/The-Python-Workbook-1 | /pyworkbookex046.py | 926 | 4.375 | 4 | print("The Seasons\n")
month = input("Enter the month:\n>>> ")
day = int(input("Enter the day:\n>>> "))
if month == "january" or month == "febuary":
season = "Winter"
elif month == "march":
if day <= 20:
season = "Winter"
else:
season = "Spring"
elif month == "april" or month == "may":
... | false |
0d043a4d307c675be436b57aacf85851d5d55463 | GanLay20/The-Python-Workbook-1 | /pyworkbookex082.py | 560 | 4.125 | 4 | def main():
print(" Taxi Taxi\n~~~Trip Calculator~~~")
km = float(input("Enter distance travelled in KM:\n>>> "))
taxi_fare(km)
def taxi_fare(km):
'''Calculate a taxi fare'''
distance = 7.1428571428571 # 1km ÷ 140 m (7.14...... km)
set_fee = 4.00
fee = .25 # per 140 m
fa... | false |
d242694b3d8ac4b4a5ed9c01c00269ee4c6dca2d | GanLay20/The-Python-Workbook-1 | /pyworkbookex003.py | 226 | 4.125 | 4 | print("The area calculator")
lenth = float(input("Enter The Lenth In Feet >>> "))
width = float(input("Enter The Width In Feet >>> "))
print(lenth)
print(width)
area = lenth * width
print("The Area Is: ", area, " Square Feet") | true |
87e9c3980f14dde7910ba0314d7dd24427849ba2 | GanLay20/The-Python-Workbook-1 | /pyworkbookex014.py | 381 | 4.3125 | 4 | print("Enter you height in FEET followed by INCHES")
feet_height = int(input("Feet:\n>>> "))
inch_height = int(input("Inches:\n>>> "))
print("Your height is", feet_height, "feet", inch_height, "inches\n")
# 1 inch = 2.54cm // 1 foot = 30.48
feet_cm = feet_height * 30.48
inch_cm = inch_height * 2.54
total_height = f... | true |
f7ce7a2b80cea0e04204a84727743e2b9217a293 | GanLay20/The-Python-Workbook-1 | /pyworkbookex066.py | 1,570 | 4.34375 | 4 | print("~~~~Grade Point Average Calculator~~~~\n")
grade_letter = ()
float_grade = 0
average_count = 0
while grade_letter != "":
grade_letter = input("Enter A Grade Letter:\n>>> ")
average_count += 1
if grade_letter == "a+" or grade_letter == "A+":
float_grade = 4.10 + float_grade
elif grade... | false |
0e2655f5c91f4ffaf5644430f0e6de8e3c98e23b | GanLay20/The-Python-Workbook-1 | /pyworkbookex036.py | 373 | 4.28125 | 4 | print("Vowel or Consonant")
letter = input("Enter a letter:\n>>> ")
if letter == "a" or letter == "e" or letter == "i" or letter == "o" or letter == "u":
print("The letter", letter.title(), "is a Vowel.")
elif letter == "y":
print("The letter", letter.title(), "is sometimes a Vowel or Consonant.")
else:
p... | false |
af2e6ddea575ea304623b4f39d8935f1f0e697a0 | GanLay20/The-Python-Workbook-1 | /pyworkbookex055.py | 522 | 4.5 | 4 | print("The 7 Categories Of Radiation\n")
hz = float(input("Enter The Radiation Frequency In Hz:\n>>> "))
type = ""
if hz <= 3 * 10 **9:
type = "Radio Waves"
elif hz <= 3 * 10 **12:
type = "Microwaves"
elif hz <= 4.3 * 10 **14:
type = "Infrared Light"
elif hz <= 7.5 * 10 **14:
type = "Visible Light"
el... | false |
123a72dee8b7f8c819a18acea4f3db365cdf9792 | taichi2781/machineLearning | /test.py | 215 | 4.15625 | 4 | print("こんにちは")
print("10+8=",10+8)
print("10-8=",10-8)
print("10*8=",10*8)
print("九九")
for x in range(0,9):
for y in range(0,9):
print('{0}'.format('%2d'%((x+1)*(y+1))), end="")
print('')
| false |
276158e1754954c9cb1017c535d83bdaaff28867 | Iboatwright/mod9homework | /sum_of_numbers.py | 1,750 | 4.53125 | 5 | # sum_of_numbers.py
# Exercise selected: Chapter 10 program 3
# Name of program: Sum of Numbers
# Description of program: This program opens a file named numbers.dat
# that contains a list of integers and calculates the sum of all the
# integers. The numbers.dat file is assumed to be a string of positive
# integ... | true |
d6a4ee396926531ca232760b942022ba640e8362 | BAFurtado/Python4ABMIpea2019 | /class_da_turma.py | 964 | 4.40625 | 4 | """ Exemplo de uma class construída coletivamente
"""
class Turma:
def __init__(self, name='Python4ABMIpea'):
self.name = name
self.students = list()
def add_student(self, name):
self.students.append(name)
def remove_student(self, name):
self.students.remove(name)
de... | false |
6fea9cb7658163ab3b70cb174d5d78575a8fbc98 | CarolGonz/daily_coding | /camel_case.py | 1,029 | 4.3125 | 4 | # Complete the method/function so that it converts dash/underscore delimited words into camel casing.
# The first word within the output should be capitalized only
# if the original word was capitalized (known as Upper Camel Case, also often referred to as Pascal case).
import re
def to_camel_case(text):
#cria um... | false |
aafc08f19ab42d5f6ca102407c3ebbc3a8fde67d | saikirankondapalli03/HW-05-01 | /new/TestTriangle.py | 1,353 | 4.125 | 4 | from Triangle import classify_triangle
import unittest
class TestCases(unittest.TestCase):
"""This is a testing class for the classify_triangles method"""
def test_equilateral_triangle(self):
assert classify_triangle(1, 1, 1) == 'Equilateral triangle'
assert classify_triangle(100, 100, 100) == ... | false |
9467d64a8114c389f05ca2e4ededfcd967d6e5a2 | MaxLouis/variables | /Python Basics Math Exercise 2.py | 305 | 4.21875 | 4 | #Max Louis
#Python Basics Math: Exercise 2
#14/09/14
int1 = int(input("What is your first integer?"))
int2 = int(input("What is your second integer?"))
int3 = int(input("What is your third integer?"))
multiply = int1 * int2
total = multiply / int3
print("Your Result is: {0}".format(total))
| false |
c292b92e7d84623749c1c4c704cbfa33f0b01017 | Roman-Rogers/Wanclouds | /Task - 2.py | 522 | 4.34375 | 4 | names = ['ali Siddiqui', 'hamza Siddiqui', 'hammad ali siDDiqui','ghaffar', 'siddiqui ali', 'Muhammad Siddique ahmed', 'Ahmed Siddiqui']
count = 0
for name in names: # Go through the List
lowercase=name.lower() # Lower Case the string so that it can be used easily
splitname=lowercase.split() # Split the nam... | true |
ff2ae3318ec47aefe5035cf1ee4f7ea92bcc3291 | Jay168/ECS-project | /swap.py | 306 | 4.125 | 4 | #swapping variables without using temporary variables
def swapping(x,y):
x=x+y
y=x-y
x=x-y
return x,y
a=input("input the first number A:\n")
b=input("input the second number B:\n")
a,b=swapping(a,b)
print "The value of A after swapping is:",a
print "The value of B after swapping is:",b
| true |
1a233003afdf53e979e155a2c8122012183de4c5 | anurag3753/courses | /david_course/Lesson-03/file_processing_v2.py | 850 | 4.3125 | 4 | """In this new version, we have used the with statement, as with stmt
automatically takes care of closing the file once we are done with the file.
"""
filename = "StudentsPerformance.csv"
def read_file_at_once(filename):
"""This function reads the complete file in a single go and put it into a
text string
... | true |
ca9f27843c8dd606097931adad722688d36d060a | pankajiitg/EE524 | /Assignment1/KManivas_204102304/Q09.py | 676 | 4.40625 | 4 | ## Program to multiply two matrices
import numpy as np
print("Enter the values of m, n & p for the matrices M1(mxn) and M2(nxp) and click enter after entering each element:")
m = int(input())
n = int(input())
p = int(input())
M1 = np.random.randint(1,5,(m,n))
M2 = np.random.randint(1,5,(n,p))
M = np.zeros((m,p),dtyp... | true |
50e26426d5913ff0252d1e05fd3d4a26afd04ed1 | pankajiitg/EE524 | /Assignment1/KManivas_204102304/Q03.py | 294 | 4.46875 | 4 | ##Program to print factorial of a given Number
def factorial(num):
fact = 1
for i in range(1,num+1):
fact = fact * i
return fact
print("Enter a number to calculate factorial:")
num1 = int(input())
print("The factorial of ", num1, "is ", factorial(num1))
| true |
a1e0a66a58a5e0d96ddbd2a07424b9b313912a23 | nova-script/Py-Check-IO | /01_Elementary/08.py | 1,247 | 4.46875 | 4 | """
# Remove All Before
## Not all of the elements are important.
## What you need to do here is to remove from the list all of the elements before the given one.
## For the illustration we have a list [1, 2, 3, 4, 5] and we need to remove all elements
## that go before 3 - which is 1 and 2.
#... | true |
0f882f1f2a162f6fac61d29a40ae0a44b7c6b771 | Tarunmadhav/Python1 | /GuessingGame.py | 419 | 4.25 | 4 | import random
number=random.randint(1,9)
chances=0
print("Guess A Number Between 1-9")
while chances<5:
guess=int(input("Guess A Number 1-9"))
if(guess==number):
print("Congratulations")
break
elif(guess<number):
print("Guess Higher Number")
else:
print("Gue... | true |
3c3182c02d122f69bc1aecb800ceb778ccaa6968 | sr-murthy/inttools | /arithmetic/combinatorics.py | 1,277 | 4.15625 | 4 | from .digits import generalised_product
def factorial(n):
return generalised_product(range(1, n + 1))
def multinomial(n, *ks):
"""
Returns the multinomial coefficient ``(n; k_1, k_2, ... k_m)``, where
``k_1, k_2, ..., k_m`` are non-negative integers such that
::
k_1 + k_2 + ... + k_m = ... | true |
4e39eb65f44e423d9695653291c6c15b95920df2 | rocket7/python | /S8_udemy_Sets.py | 695 | 4.1875 | 4 | ###############
# SETS - UNORDERED AND CONTAINS NO DUPLICATES
###############
# MUST BE IMMUTABLE
# CAN USE UNION AND INTERSECTION OPERATIONS
# CAN BE USED TO CLEAN UP DATA
animals = {"dog", "cat", "lion", "elephant", "tiger", "kangaroo"}
print(animals)
birds = set(["eagle", "falcon", "pigeon", "bluejay", "flaming... | true |
dcd02ef61c6b2003024857d5132f8f4d8cf72e01 | venkat284eee/DS-with-ML-Ineuron-Assignments | /Python_Assignment2.py | 605 | 4.46875 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Question 1:
# Create the below pattern using nested for loop in Python.
# *
# * *
# * * *
# * * * *
# * * * * *
# * * * *
# * * *
# * *
# *
# In[1]:
n=5;
for i in range(n):
for j in range(i):
print ('* ', end="")
print('')
for i in range(n,0,-1):
for j ... | true |
faffa16c4ee560cb5fdb32013893bbf83e947ba1 | mrparkonline/py_basics | /solutions/basics1/circle.py | 300 | 4.46875 | 4 | # Area of a Circle
import math
# input
radius = float(input('Enter the radius of your circle: '))
# processing
area = math.pi * (radius ** 2)
circumference = 2 * math.pi * radius
# output
print('The circle area is:', area, 'units squared.')
print('The circumference is:', circumference, 'units.') | true |
c914ff467f6028b7a7e9d6f7c3b710a1445d15e4 | Safirah/Advent-of-Code-2020 | /day-2/part2.py | 975 | 4.125 | 4 | #!/usr/bin/env python
"""part2.py: Finds the number of passwords in input.txt that don't follow the rules. Format:
position_1-position_2 letter: password
1-3 a: abcde is valid: position 1 contains a and position 3 does not.
1-3 b: cdefg is invalid: neither position 1 nor position 3 contains b.
2-9 c: ccccccccc is inva... | true |
17bca95271d269cf806decd0f1efafa05367146c | ycechungAI/yureka | /yureka/learn/data/bresenham.py | 1,424 | 4.125 | 4 | def get_line(start, end):
"""Modified Bresenham's Line Algorithm
Generates a list of tuples from start and end
>>> points1 = get_line((0, 0), (3, 4))
>>> points2 = get_line((3, 4), (0, 0))
>>> assert(set(points1) == set(points2))
>>> print points1
[(0, 0), (1, 1), (1, 2), (2, 3), (3, 4)]
... | true |
f712fa962c06854c9706919f63b52e6a6a6002ab | vasetousa/Python-basics | /Animal type.py | 263 | 4.21875 | 4 | animal = input()
# check and print what type animal is wit, also if it is a neither one (unknown)
if animal == "crocodile" or animal == "tortoise" or animal == "snake":
print("reptile")
elif animal == "dog":
print("mammal")
else:
print("unknown")
| true |
81e59147bf9304406776dc59378b66c5aaa5eaea | ProgramNoona/cti110 | /M6T2_FeetToInches_Reaganb.py | 324 | 4.21875 | 4 | # Program that converts feet to inches
# November 2, 2017
# CTI-110 M6T2_FeetToInches
# Bethany Reagan
INCHES_PER_FOOT = 12
def main():
feet = int(input("Enter a number of feet: "))
print(feet, "feet equals", feetToInches(feet), "inches.")
def feetToInches(feet):
return feet * INCHES_PER_FOOT... | false |
bc25ffa52620a3fd26e1b687452a60cb18dbf75e | Paulokens/CTI110 | /P2HW2_MealTip_PaulPierre.py | 968 | 4.375 | 4 | # Meal and Tip calculator
# 06/23/2019
# CTI-110 P2HW2 - Meal Tip calculator
# Pierre Paul
#
# Get the charge for the food.
food_charge = float(input('Enter the charge for the food: '))
# Create three variables for the tip amounts.
tip_amount1 = food_charge * 0.15
tip_amount2 = food_charge * 0.18
tip_amou... | true |
08bdce0f2d75b36746c86c2ea252adaa3a19741b | michaelzh17/6001_Python | /6001_Python-michael_zhang/isIn.py | 521 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 31 20:59:46 2017
@author: xinyezhang
"""
def isIn(char, aStr):
'''
char: a single character
aStr: an alphabetized string
returns: True if char is in aStr; False otherwise
'''
l = len(aStr)
if l == 0:
return ... | false |
310f273de1a26854e584fe7da798dc0ef9c21322 | jsavon/final-project | /devel/diceroll.py | 2,408 | 4.125 | 4 | import random
print("")
print("Welcome to Josh's Dice rolling program!")
print("Press enter to roll the die")
input()
number=random.randint(1,6)
if number==1:
print("You rolled a one!")
print("[----------]")
print("[ ]")
print("[ O ]")
print("[ ]")
print("[----------]")
if ... | false |
f27015948ad6042d42f278c8cbd287d46b502e93 | GaryLocke91/52167_programming_and_scripting | /bmi.py | 392 | 4.46875 | 4 | #This program calculates a person's Body Mass Index (BMI)
#Asks the user to input the weight and height values
weight = float(input("Enter weight in kilograms: "))
height = float(input("Enter hegiht in centimetres: "))
#Divides the weight by the height in metres squared
bmi = weight/((height/100)**2)
#Outputs the ca... | true |
f1786bf43dc19040524461b7b96c1b0bfb50e5de | zanzero/pyodbc | /test.py | 832 | 4.28125 | 4 | import datetime
from datetime import timedelta
now = datetime.datetime.now()
print("Current date and time using str method of datetime object:")
print(str(now))
d = str(now + timedelta(minutes=2))
print(d[:-3])
print(type(d))
"""
print("Current date and time using instance attributes:")
print("C... | false |
c216eba9270aac25b2475e80237791e74e26797f | contact2sourabh/Collge-Assignmnt-Python- | /Arithmetic.py | 827 | 4.1875 | 4 | #%%
# Addition
num1=int(input('enter number: '))
num2=int(input('enter 2nd number: '))
sum=num1+num2
print('the sum of ',num1,'and',num2,'is :',sum)
#%%
#Subtraction
num1=int(input('enter number: '))
num2=int(input('enter 2nd number: '))
dif=num1-num2
print('the difference of ',num1,'and',num2,'is :',dif)
... | false |
92bc95604d982256a602ef749f090b63b4f47555 | knightscode94/python-testing | /programs/cotdclass.py | 433 | 4.28125 | 4 |
"""
Define a class named Rectangle, which can be constructed by a length and width.
The Rectangle class needs to have a method that can compute area.
Finally, write a unit test to test this method.
"""
import random
class rectangle():
def __int__(self, width, length):
self.width=width
self.length... | true |
499cccb2e57239465a929e0a2dc0db0e9d4602b7 | ivankatliarchuk/pythondatasc | /python/academy/sqlite.py | 872 | 4.1875 | 4 | import sqlite3
# create if does not exists and connect to a database
conn = sqlite3.connect('demo.db')
# create the cursor
c = conn.cursor()
# run an sql
c.execute('''CREATE TABLE users (username text, email text)''')
c.execute("INSERT INTO users VALUES ('me', 'me@mydomain.com')")
# commit at the connection level and n... | true |
0aeaa34a11aef996450483d8026fe6bdc4da6535 | ivankatliarchuk/pythondatasc | /python/main/datastructures/set/symetricdifference.py | 820 | 4.4375 | 4 | """
TASK
Given 2 sets of integers, M and N, print their difference in ascending order. The term symmetric
difference indicates values that exist in eirhter M or N but do not exist in both.
INPUT
The first line of input contains integer M.
The second line containts M space separeted integers.
The third line contains an ... | true |
b64c41f1627f672833c1998c0230d300d6790763 | OMR5221/MyPython | /Analysis/Anagram Detection Problem/anagramDetect_Sorting-LogLinear.py | 626 | 4.125 | 4 | # We can also sort each of the strings and then compare their values
# to test if the strings are anagrams
def anagramDetect_Sorting(stringA, stringB):
#Convert both immutable strings to lists
listA = list(stringA)
listB = list(stringB)
# Sort using Pythons function
listA.sort()
listB.sort()
... | true |
79a96ea2bf66f92ab3df995e2a330fd51cbae567 | OMR5221/MyPython | /Trees/BinarySearchTree.py | 2,308 | 4.125 | 4 | # BinarySearchTree: Way to map a key to a value
# Provides efficient searching by
# categorizing values as larger or smaller without
# knowing where the value is precisely placed
# Build Time: O(n)
# Search Time: O(log n)
# BST Methods:
'''
Map(): Create a new, empty map
put(key,val): Add a new key, value ... | true |
4143917f483f11fde2e83a52a829d73c62fc2fcd | OMR5221/MyPython | /Data Structures/Deque/palindrome_checker.py | 1,264 | 4.25 | 4 | # Palindrome: Word that is the same forward as it is backwards
# Examples: radar, madam, toot
# We can use a deque to get a string from the rear and from the front
# and compare to see if the strings ae the same
# If they are the same then the word is a palindrome
class Deque:
def __init__(self):
self.ite... | true |
bb8c26d9f183f83582717e8fadc247b21f3c174d | freddieaviator/my_python_excercises | /ex043/my_throw.py | 982 | 4.28125 | 4 | import math
angle = float(input("Input angle in degrees: "))
velocity = float(input("Input velocity in km/h: "))
throw_height = float(input("Input throw height in meter: "))
angle_radian = math.radians(angle)
throw_velocity = velocity/3.6
horizontal_velocity = throw_velocity * math.cos(angle_radian)
vertical_velocity... | true |
aad041babf64d755db4dad331ef0f7446a1f7527 | s-ruby/pod5_repo | /gary_brown_folder/temperture.py | 710 | 4.15625 | 4 | '''----Primitive Data Types Challenge 1: Converting temperatures----'''
# 1) coverting 100deg fahrenheit and celsius
# The resulting temperature us an integer not a float..how i know is because floats have decimal points
celsius_100 = (100-32)*5/9
print(celsius_100)
# 2)coverting 0deg fahrenheit and celsius
celsius... | true |
8407a85c075e4a560de9a9fbc2f637c79f813c1e | scottbing/SB_5410_Hwk111 | /Hwk111/python_types/venv/SB_5410_Hwk4.2.py | 2,605 | 4.15625 | 4 | import random
# finds shortest path between 2 nodes of a graph using BFS
def bfs_shortest_path(graph: dict, start: str, goal: str):
# keep track of explored nodes
explored = []
# keep track of all the paths to be checked
queue = [[start]]
# return path if start is goal
if start == goal:
... | true |
3e7fab66175f06fc91f0df355499eafc95d9d197 | borjamoll/programacion | /Python/Act_07/11.py | 660 | 4.21875 | 4 | #Escribe un programa que te pida una frase, y pase la frase como parámetro a una función.
# Ésta debe devolver si es palíndroma o no , y el programa principal escribirá el resultado por pantalla:
#salta lenin el atlas
#dabale arroz a la zorra el abad
print("Ripios")
palindromo=True
dato=str(input("Dime una palabra o ... | false |
bdfbd50066a4fba7c1cbdc0cf774845907450ea3 | chuzirui/vim | /link.py | 894 | 4.25 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
class LinkedNode(object):
def __init__(self, value):
self.next = None
self.value = value
def insert_linked(Head, Node):
Node.next = Head.next
Head.next = Node
def print_list(Head):
while (Head):
print (Head.value)
Head = H... | false |
db8e97cdc0ae8faa35700bfb83502a1d8b0c4712 | Catarina607/Python-Lessons | /new_salary.py | 464 | 4.21875 | 4 |
print('----------------------------------')
print(' N E W S A L A R Y ')
print('----------------------------------')
salary = float(input('write the actual salary of the stuff: '))
n_salary = (26*salary)/100
new_salary = salary + n_salary
print(new_salary, 'is the actual salary')
print('t... | true |
200971a40d96428969d8266c603620ec6e59c0c6 | michaelvincerra/pdx_codex | /wk1/case.py | 852 | 4.4375 | 4 | """
>>> which_case('this_test_text')
'snake_case.'
>>> which_case('this_is_snake_case')
'snake_case.'
>>> which_case('ThisIsCamelCase')
'CamelCase.'
"""
def which_case(words):
print('Python uses two types of naming for variables and files.')
print('ThisIsCamelCase')
print('this_is_snake_case')
prin... | false |
e1c6c077d75f28f7e5a93cfbafce19b01586a26d | michaelvincerra/pdx_codex | /wk1/dice.py | 419 | 4.6875 | 5 | """
Program should ask the user for the number of dice they want to roll
as well as the number of sides per die.
1. Open Atom
1. Create a new file and save it as `dice.py`
1. Follow along with your instructor
"""
import random
dice = input('How many dice?')
sides = input('How may sides?')
roll = random.randint(1, 6... | true |
9faf1d8c84bdf3be3c8c47c8dd6d34832f4a2b1e | vmueller71/code-challenges | /question_marks/solution.py | 1,395 | 4.53125 | 5 | """
Write the function question_marks(testString) that accepts a string parameter,
which will contain single digit numbers, letters, and question marks,
and check if there are exactly 3 question marks between every pair of two
numbers that add up to 10.
If so, then your program should return the string true, other... | true |
cf9a5b5e82b50692179b47f452a597289a26e3d8 | Juan4678/First-file | /Lección 11 de telusko.py | 757 | 4.375 | 4 | #Tipos de operadores
#OPERADORES ARITMÉTICOS
#Ejemplos
x=2
y=3
print(x,"+",y)
print(x+y)
print(x,"-",y)
print(x-y)
print(x,"*",y)
print(x*y)
print(x,"/",y)
print(x/y)
#OPERADORES DE ASIGNACIÓN
#Ejemplos
X=x+2
print(X)
X+=2
print(X)
X*=3
print(X)
a,b=5,6
print(a)
print(b)
... | false |
844abbd605677d52a785a796f70d3290c9754cd6 | Aishwaryasaid/BasicPython | /dict.py | 901 | 4.53125 | 5 | # Dictionaries are key and value pairs
# key and value can be of any datatype
# Dictionaries are represented in {} brackets
# "key":"value"
# access the dict using dict_name["Key"]
student = {"name":"Jacob", "age":25,"course":["compsci","maths"]}
print(student["course"])
# use get method to inform user if a ke... | true |
cc0bbc28266bb25aa4822ac443fa8d371bb12399 | Akrog/project-euler | /001.py | 1,384 | 4.1875 | 4 | #!/usr/bin/env python
"""Multiples of 3 and 5
Problem 1
Published on 05 October 2001 at 06:00 pm [Server Time]
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
import sys
if (2,... | true |
7d3428fd768e5bf71b26f6e6472cf9efa8c79e8b | khyati-ghatalia/Python | /play_with_strings.py | 387 | 4.15625 | 4 | #This is my second python program
# I am playing around with string operations
#Defing a string variable
string_hello = "This is Khyatis program"
#Printing the string
print("%s" %string_hello)
#Printing the length of the string
print(len(string_hello))
#Finding the first instance of a string in a string
print(strin... | true |
962c2ccc73adc8e1a973249d4e92e8286d307bf1 | nihalgaurav/Python | /Python_Assignments/Quiz assignment/Ques4.py | 385 | 4.125 | 4 | # Ques 4. Write a program that accepts a sentence and calculate the number of upper case letters and lower case letters.
s=raw_input()
d={ "UPPER_CASE" :0, "LOWER_CASE" :0}
for c in s:
if c.isupper():
d[ "UPPER_CASE" ]+=1
elif c.islower():
d[ "LOWER_CASE" ]+=1
else:
pass
print("UPPER CAS... | true |
b44cd8d204f25444d6b5ae9467ad90e539ace8b3 | nihalgaurav/Python | /Python_Assignments/Assignment_7/Ques1.py | 219 | 4.375 | 4 | # Ques 1. Create a function to calculate the area of a circle by taking radius from user.
r = int(input("Enter the radius of circle: "))
def area():
a = r * r * 3.14
print("\nArea of circle is : ",a)
area() | true |
ef4f49af3cb27908f9721e59222418ee63c99022 | antoshkaplus/CompetitiveProgramming | /ProjectEuler/001-050/23.py | 2,599 | 4.21875 | 4 | """
A number n is called deficient if the sum of its proper divisors
is less than n and it is called abundant if this sum exceeds n.
As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16,
the smallest number that can be written as the sum of two abundant
numbers is 24. By mathematical analysis, it can be sh... | true |
cf1c83c8cabc0620b1cdd1bc8ecf971e0902806f | pgavriluk/python_problems | /reverse_string.py | 406 | 4.21875 | 4 | def reverse(string):
str_list=list(string)
length = len(string)
half = int(length/2)
for i, char in enumerate(str_list):
last_char = str_list[length-1]
str_list[length-1] = char
str_list[i] = last_char
length = length-1
if i >= half-1:
break;... | true |
918c366baca272bcaef30e1e0e1106769b1610fa | ramsayleung/leetcode | /200/ugly_number_ii.py | 1,318 | 4.15625 | 4 | """
source: https://leetcode.com/problems/ugly-number-ii/
author: Ramsay Leung
date: 2020-03-30
Write a program to find the n-th ugly number.
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.
Example:
Input: n = 10
Output: 12
Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of ... | false |
c963de87cbf668a579a6de35ed4873c07b64ee90 | ramsayleung/leetcode | /600/palindromic_substring.py | 1,302 | 4.25 | 4 | '''
source: https://leetcode.com/problems/palindromic-substrings/
author: Ramsay Leung
date: 2020-03-08
Given a string, your task is to count how many palindromic substrings in this string.
The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characte... | true |
350ff920efd20882b4b138110612d4a6ad08b378 | RobertEne1989/python-hackerrank-submissions | /nested_lists_hackerrank.py | 1,312 | 4.40625 | 4 | '''
Given the names and grades for each student in a class of N students, store them in a nested list and
print the name(s) of any student(s) having the second lowest grade.
Note: If there are multiple students with the second lowest grade, order their names alphabetically and
print each name on a new line.
Ex... | true |
a89e546c4a3f3cd6027c3a46e362b23549eee2d0 | RobertEne1989/python-hackerrank-submissions | /validating_phone_numbers_hackerrank.py | 1,136 | 4.4375 | 4 | '''
Let's dive into the interesting topic of regular expressions! You are given some input, and you are required
to check whether they are valid mobile numbers.
A valid mobile number is a ten digit number starting with a 7, 8 or 9.
Concept
A valid mobile number is a ten digit number starting with a 7, 8 or 9... | true |
8d3e58e5049ef80e24a22ea00340999334358eb2 | RobertEne1989/python-hackerrank-submissions | /viral_advertising_hackerrank.py | 1,709 | 4.1875 | 4 | '''
HackerLand Enterprise is adopting a new viral advertising strategy. When they launch a new product,
they advertise it to exactly 5 people on social media.
On the first day, half of those 5 people (i.e.,floor(5/2)=2) like the advertisement and each shares it with 3 of
their friends. At the beginning of the sec... | true |
dfaea68c6693f63cce8638bb978077536a7dcecc | medetkhanzhaniya/Python | /w3/set.py | 2,461 | 4.71875 | 5 | """
#CREATE A SET:
thisset={"a","b","c"}
print(thisset)
ONCE A SET CREATED
YOU CANNOT CHANGE ITS ITEMS
BUT YOU CAN ADD NEW ITEMS
#SETS CANNOT HAVE 2 ITEMS WITH SAME VALUE
thisset = {"apple", "banana", "cherry"}
print("banana" in thisset)
#out:true
thisset = {"apple", "banana", "cherry"}
thisse... | true |
b17cb584cf6c78c34f6e1c7b78670fb90a9b58dd | manumuc/python | /rock-paper-scissors-lizard-spock.py | 1,905 | 4.28125 | 4 | <pre>[cc escaped="true" lang="python"]
# source: https://www.unixmen.com/rock-paper-scissors-lizard-spock-python/
#Include 'randrange' function (instead of the whole 'random' module
from random import randrange
# Setup a dictionary data structure (working with pairs efficientlyconverter = ['rock':0,'Spock':1,'pa... | true |
fb8a10f89fc38052190a480da6eeeacf88d6dd22 | govind-mukundan/playground | /python/class.py | 2,379 | 4.28125 | 4 | # Demo class to illustrate the syntax of a python class
# Illustrates inheritance, getters/setters, private and public properties
class MyParent1:
def __init__(self):
print ("Hello from " + str(self.__class__.__name__))
class MyParent2:
pass
# Inheriting from object is necessary for @property etc to wor... | true |
c0e4b60e7bdac2719ee37a944fcc4add4bbb1264 | Jhang512/driving | /driving.py | 378 | 4.21875 | 4 | country = input('What is your nationality: ')
age = input('How old are you: ')
age = int(age)
if country == 'taiwan':
if age >= 18:
print('You can learn driving')
else:
print('You cannot learn driving')
elif country == 'usa':
if age >= 16:
print('You can learn driving')
else:
print('You cannot learn drivin... | false |
d3b3a2f39945050d6dd423146c794965069ead21 | jdipietro235/DailyProgramming | /GameOfThrees-239.py | 1,521 | 4.34375 | 4 |
# 2017-05-17
# Task #1
# Challenge #239, published 2015-11-02
# Game of Threes
"""
https://www.reddit.com/r/dailyprogrammer/comments/3r7wxz/20151102_challenge_239_easy_a_game_of_threes/?utm_content=title&utm_medium=browse&utm_source=reddit&utm_name=dailyprogrammer
Back in middle school, I had a peculiar way of deali... | true |
330ba20a83c20ecb7df2e616379023f74631ee2c | olutoni/pythonclass | /control_exercises/km_to_miles_control.py | 351 | 4.40625 | 4 | distance_km = input("Enter distance in kilometers: ")
if distance_km.isnumeric():
distance_km = int(distance_km)
if distance_km < 1:
print("enter a positive distance")
else:
distance_miles = distance_km/0.6214
print(f"{distance_km}km is {distance_miles} miles")
else:
print("You... | true |
924d7324d970925b0f26804bc135ffd318128745 | olutoni/pythonclass | /recursion_exercise/recursion_prime_check.py | 332 | 4.21875 | 4 | # program to check if a number is a prime number using recursion
number = int(input("enter number: "))
def is_prime(num, i=2):
if num <= 2:
return True if number == 2 else False
if num % i == 0:
return False
if i * i > num:
return True
return is_prime(num, i+1)
print(is_pri... | true |
10c70c24825c0b8ce1e9d6ceb03bd152f3d2d0c1 | slohmes/sp16-wit-python-workshops | /session 3/2d_arrays.py | 1,149 | 4.21875 | 4 | '''
Sarah Lohmeier, 3/7/16
SESSION 3: Graphics and Animation
2D ARRAYS
'''
# helper function
def matrix_print(matrix):
print '['
for i in range(len(matrix)):
line = '['
for j in range(len(matrix[i])):
line = line + str(matrix[i][j]) + ', '
line += '],'
print line
... | true |
8aa48619ba0e0741d001f061041aa944c7ee6d05 | amysimmons/CFG-Python-Spring-2018 | /01/formatting.py | 471 | 4.28125 | 4 | # STRING FORMATTING
age = 22
like = "taylor swift".title()
name = "Amy"
print "My age is {} and I like {}".format(age, like)
print "My age is 22 and I like Taylor Swift"
print "My age is {1} and I like {0}".format(age, like)
print "My age is Taylor Swift and I like 22"
print "My name is {}, my age is {} and I like... | true |
297a5886f75bde1bb4e8d1923401512848dcc53f | abhinashjain/codes | /codechef/Snakproc.py | 2,698 | 4.25 | 4 | #!/usr/bin/python
# coding: utf-8
r=int(raw_input())
for i in xrange(r):
l=int(raw_input())
str=raw_input()
ch=invalid=0
for j in str:
if((j=='T' and ch!=1) or (j=='H' and ch!=0)):
invalid=1
break
if(j=='H' and ch==0):
ch=1
if(j=='T' and ch==1... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.