blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
0845a8058a1f22565907dadcfa4460b724e0f40a | GuuMee/ExercisesTasksPython | /1 Basics/30_units_of_pressure.py | 936 | 4.59375 | 5 | """
In this exercise you will create a program that reads a pressure from the user in kilopascals.
Once the pressure has been read your program should report the equivalent
pressure in pounds per square inch, millimeters of mercury and atmospheres. Use
your research skills to determine the conversion factors between th... | true |
77e332d53b52a2e36485d1a36b3ffd2716122197 | GuuMee/ExercisesTasksPython | /5 Lists/_121_count_the_elements.py | 2,349 | 4.40625 | 4 | """
Python’s standard library includes a method named count that determines how
many times a specific value occurs in a list. In this exercise, you will create a new
function named countRange which determines and returns the number of elements
within a list that are greater than or equal to some minimum value and less ... | true |
9ce4b5a2c382c97c04d06d3b3fb2960644a1c546 | GuuMee/ExercisesTasksPython | /3 Loops/66_compute_a_grade_point_average.py | 1,778 | 4.5 | 4 | """
Exercise 51 included a table that shows the conversion from letter grades to grade
points at a particular academic institution. In this exercise you will compute the
grade point average of an arbitrary number of letter grades entered by the user. The
user will enter a blank line to indicate that all of the grades h... | true |
429e370886bb8a02b6f5bbf15d611128342b985e | GuuMee/ExercisesTasksPython | /6 Dictionaries/_132_postal_codes.py | 2,287 | 4.28125 | 4 | """
In a Canadian postal code, the first, third and fifth characters are letters while the
second, fourth and sixth characters are numbers. The province can be determined
from the first character of a postal code, as shown in the following table. No valid
postal codes currently begin with D, F, I, O, Q, U, W, or Z.
The... | true |
3537afca8701c17f277c832255b7b12efcd5118a | GuuMee/ExercisesTasksPython | /4_Functions/85_convert_an_integer_to_its_original_number.py | 1,389 | 4.75 | 5 | """
Words like first, second and third are referred to as ordinal numbers. In this exercise,
you will write a function that takes an numeger as its only parameter and returns a
string containing the appropriate English ordinal number as its only result. Your
function must handle the numegers between 1 and 12 (inclusive... | true |
9ef0f06750869ea25e47f00598e56a66a92a4453 | GuuMee/ExercisesTasksPython | /5 Lists/_125_does_a_list_contain_a_sublist.py | 2,044 | 4.375 | 4 | """
A sublist is a list that makes up part of a larger list. A sublist may be a list
containing a single element, multiple elements, or even no elements at all. For example,
[1], [2], [3] and [4] are all sublists of [1, 2, 3, 4]. The list [2, 3] is also a
sublist of [1, 2, 3, 4], but [2, 4] is not a sublist [1, 2, 3, 4... | true |
b2a8a028bc2abebeeb01f1f5bc3466b3b70caa61 | GuuMee/ExercisesTasksPython | /6 Dictionaries/_134_unique_characters.py | 711 | 4.53125 | 5 | """
Create a program that determines and displays the number of unique characters in a
string entered by the user. For example, Hello, World! has 10 unique characters
whilezzzhas only one unique character. Use a dictionary or set to solve this problem.
"""
# Compute the number of unique characters in a string using a ... | true |
564cb2f78a42a8646b5356760aef5a2fc4c7504f | GuuMee/ExercisesTasksPython | /5 Lists/_107_avoiding_duplicates.py | 884 | 4.34375 | 4 | """
In this exercise, you will create a program that reads words from the user until the
user enters a blank line. After the user enters a blank line your program should dis�play each word entered by the user exactly once. The words should be displayed in
the same order that they were entered. For example, if the user ... | true |
e9abf62577c80a6c9bea72fcd4addb2785097246 | GuuMee/ExercisesTasksPython | /2 If Statements/39_sound_levels.py | 1,676 | 4.75 | 5 | """
Write a program that reads a sound level in decibels from the user. If the user
enters a decibel level that matches one of the noises in the table then your program
should display a message containing only that noise. If the user enters a number
of decibels between the noises listed then your program should display... | true |
389b5704929af7f6665197f1cc7aebf7fba817e0 | Tsarcastic/2018_code_wars | /6kyu_kebabize.py | 461 | 4.125 | 4 | """https://www.codewars.com/kata/57f8ff867a28db569e000c4a/train/python ."""
def kebabize(string):
"""Turn from camel case into kebab case."""
kebab = ""
for i in string:
if i.isdigit():
pass
elif kebab == "":
kebab += i.lower()
elif i.isupper(... | false |
7b5755046b371d33bac343efb1cd0cb3e62ede8e | Tsarcastic/2018_code_wars | /6kyu_exclamation_marks.py | 623 | 4.21875 | 4 | """
Find the balance.
https://www.codewars.com/kata/57fb44a12b53146fe1000136/train/python
"""
def balance(left, right):
"""Find the balance of left and right."""
def weigh(side):
"""Find the weight of each side."""
weight = 0
for i in side:
if i == "!":
w... | true |
389ef03dd353855ebd9f08f9e94b5a17ec249cbf | SuhaybDev/Python-Algorithms | /5_implement_bubble_sort.py | 487 | 4.375 | 4 | def bubbleSort(arr):
n = len(arr)
# Iterate through all array elements
for x in range(n):
for y in range(0, n-x-1):
# Interchange places if the element found is greater than the one next to it
if arr[y] > arr[y+1] :
arr[y], arr[y+1] = arr[y+1], arr[y]
ar... | true |
82fe374357589692c9c06b073c60ef25252e475a | Srijha09/Leetcode-Solutions- | /Easy/countPrimes.py | 504 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jul 1 20:23:58 2021
@author: Srijhak
"""
def countprimes(n):
if n == 0:
return 0
if n == 1:
return 0
primes = [1]*n #create a list consisting of all true
primes[0]=0
primes[1]=0
i = 2
while i<n:
tmp = i
if pri... | false |
04ef2144425b8bffa456085932a3cbd90a295c06 | GLOOMYY/FISIC-CALC | /modulo_fisica.py | 1,622 | 4.15625 | 4 |
def distancia():
print("Distancia")
v = float(input("Ingrese la velocidad "))
t = float(input("Ingrese el tiempo "))
d = v * t
print("El resultado es: ", d )
def velocidad():
print("Velocidad")
d = float(input("Ingrese la distancia "))
t = float(input("Ingrese el tiempo "))
v = d /... | false |
624045aebcbcfae035f0d6c7dcdbfc8fc4bb1410 | Abdurrahmans/Data-Structure-And-Algorithm | /SeriesCalculation.py | 386 | 4.15625 | 4 | import math
number=int(input("Enter any positive number:"))
sum = 0
sum = number*(number + 1)/2
print("The sum of series upto {0} = {1}".format(number,sum))
total = 0
total =(number*(number+1)*(2*number+1))/6
print("The sum of series upto {0} = {1}".format(number,total))
total =math.pow(number*(number+1)/2,... | true |
b9bdc8a9d9bc5a4bb7a0e416c0034dd6cabf82bf | Abdurrahmans/Data-Structure-And-Algorithm | /SortingAlgorithm/BubbleSortDescendingOrder.py | 551 | 4.1875 | 4 | inputArray = []
ElementCount = int(input("Enter number of element in array:"))
print("Enter {} number".format(ElementCount))
for x in range(ElementCount):
value = int(input("Please inter the {} element of list:".format(x)))
inputArray.append(value)
for i in range(ElementCount-1):
for j in range(El... | true |
4af43c0a242bc188ae56cad5d6035d6cc3cc40af | candytale55/lambda-challenges-Py_3 | /rate_movie.py | 351 | 4.21875 | 4 | # rate_movie takes a number named rating. If rating is greater than 8.5, return "I liked this movie". Otherwise return "This movie was not very good"
rate_movie = lambda rating : "I liked this movie" if rating > 8.5 else "This movie was not very good"
print rate_movie(9.2)
# I liked this movie
print rate_movie(7.2)
... | true |
cf9b83419c713fe08a22f87d40d6bef18538bfa6 | liuhu0514/py1901_0114WORK | /days0121/list列表.py | 698 | 4.59375 | 5 | '''
列表的语法结构:通过一堆方括号包含起来的数据序列,可以存放重复数据
列表:list
可以嵌套
'''
list1=[1,"o",3,["a:","b"]] # 可以嵌套
# 列表数据的查看,可以通过索引/下标进行查看
print(list1[0])
print(list1[3][1])
# 列表中追加数据:append()
list1.append(["l","hu"])
print(list1)
# 列表中指定位置追加数据:insert()
list1.insert(1,["a","m"])
print(list1)
# 删除列表末尾的元素:pop()
list1.pop()
print(list1)
... | false |
d977a962c7e16af4c634881646cbb0f3e0b4aad7 | abdulahad0001/Prime_number_cheker | /primalitiy.py | 429 | 4.125 | 4 | num1 = int(input("Enter your number:"))
if num1 > 1:
for integer in range(2,num1):
if(num1%integer)==0:
print(num1, "is not a prime number")
break
else:
print("Congrats!", num1,"is a prime number")
print("\n When you're checking for 0 and 1, Note that 0 and 1 are not pri... | true |
b1751095b11d6bfb0adcc764e58a0d13ace5a52e | gyuri23/tkinter_examples | /tkinter_grid.py | 1,142 | 4.1875 | 4 | import tkinter
root = tkinter.Tk()
for r in range(3):
for c in range(5):
tkinter.Label(root, text='R%s/C%s' % (r, c),
borderwidth=1).grid(row=r, column=c)
# column : The column to put widget in; default 0 (leftmost column).
#
# columnspan: How many columns wid... | true |
926bdeb78d59c57aeee972a8e72a816c227833bf | satish3922/ML_python | /sum_magic.py | 1,086 | 4.21875 | 4 | #!/usr/bin/env python3
# Program of magic Addition
#Taking input of 1st Number
num1 = int(input("Enter 1st Number :"))
#Calculating Magic Sum (result = add 2 before num-2)
result1 = '2' + str(num1 - 2)
print("User : ",num1)
print("User : *****")
print("Comp : *****")
print("User : *****")
print("Comp : *****")
pri... | true |
17d6cd0b17d82a791c56fd945ec30167335593e6 | juliano60/scripts_exo | /ch2/exo3.py | 259 | 4.15625 | 4 | #!/usr/bin/env python3
## enter a list of strings
## output them in sorted order
print("Enter a list of words on separate lines: ")
words = []
while True:
try:
words.append(input())
except:
break
print()
print(list(sorted(words)))
| true |
4cd35312a195fa64910ac773618152a52f340377 | uccgit/geekthology | /menu_a.py | 1,850 | 4.125 | 4 | import os
# This is the menu system for the game
# The plan is to create custom menus where needed
def display_title_bar():
#clears the terminal screen, and displays a title bar
os.system('cls' if os.name == 'nt' else 'clear')
print "\t*******************************************"
print "\t*** Welcome... | true |
85a1aa8da913d587c0161b010dcecb222f10cb99 | stillaman/python-problems | /Python Program to Check Prime Number.py | 211 | 4.15625 | 4 | num = int(input("Enter number:: "))
for i in range (2,num):
if num%i == 0:
print("The Given number is not Prime Number!!")
break
else:
print("The Given Number is a Prime Number!!")
| true |
fbc8cdab7eaa40a0637b7b0535f62d5cded48274 | lucas-jsvd/python_crash_course_2nd | /python_work/modulo_restaurante.py | 998 | 4.40625 | 4 | class Restaurante():
"""Uma classe para descrever restauranes."""
def __init__(self, nome, cozinha):
self.nome = nome
self.cozinha = cozinha
self.num_atendimento = 0
def descricao(self):
print(f'\nNome do restaurante: {self.nome}')
print(f'Tipo de cozinha: {self.coz... | false |
193caba1bc562722fefadd6e795713a66e041ba1 | jmanning1/python_course | /IfProgramFlow/adv_ifprogramflow.py | 797 | 4.21875 | 4 | age = int(input("How old are you? "))
#if (age >=16) and (age <= 65): #looks for the Range between 16 and 65
# if 15 < age < 66:
# print("Have a good day at work")
#Brackets (Parentatesis) make things easier to read and also make you intentions in the code clearer.
if (age < 16) or (age > 65): #Or look... | true |
5612948f2d4f70a88b2aaa498337f31e950f92e2 | hoomanali/Python | /ProgrammingAssignments/pa2.py | 785 | 4.375 | 4 | # Ali Hooman
# alhooman@ucsc.edu
#
# Programming Assigment 2
# BMI Calculator
#
# BMI = (massKg) / (heightM**2)
print("**** BMI Calculator ****")
# Get weight in pounds
weightPounds = float(input("Your weight (pounds): "))
# Convert to kg ( 1 pound = 0.45 Kg )
massKg = weightPounds * 0.45
# Get heig... | false |
d7644b4c86ed96dc404b3dd96728d325b6c1bb24 | hoomanali/Python | /ClassProblems/RectArea.py | 766 | 4.40625 | 4 | #
# Ali Hooman
# alhooman@ucsc.edu
# Class Problem 2 - Area of Rectangle
#
# Ask user for inputs for height and width.
# Calculate area of rectangle and print the result
# Calculate circumference
#
# Get height
heightStr = input("Enter height: ")
heightInt = int(heightStr)
# Get width
widthStr = input... | true |
36634355781134ba0a2ff1ce4e7c18500e82e8f8 | seanjohnthom/Automatetheboringstuff | /guessing_game.py | 710 | 4.125 | 4 | #this is a guess the number game
import random
print("Hello, what is your name?")
name = input()
print("Hi " + name + "!", "I'm thinking of a number between 1 and 20.")
secret_number = random.randint(1,20)
#This will allow X number of guesses
for guesses_taken in range (1,7):
print("Take a guess")
guess = int(... | true |
148d3eb2808fc8484bf4163fbebef45e5fde9bd7 | akshar-bezgoan/python-home-learn | /Lessons/Apr17/conversation.py | 248 | 4.125 | 4 | print('NOTICE ENTER ONLY IN LOWER-CASE!')
name = raw_input('Hi, what is your name:')
print str('Hello ') + name
mood = raw_input('How are you?:')
print str('I am also ') + mood
q = raw_input('So anything happening today?:')
print ('Me as well')
| true |
e8f510d5b623a730f36e3845d10b97dc00b494f1 | mahesh671/Letsupgrade | /Prime number.py | 307 | 4.15625 | 4 | #this is mahesh kumar
#prime number assignment using functions
def PrimeorNot(n):
for i in range(2,n):
if n%i==0:
return False
else:
pass
return True
number = int(input("Enter the number: "))
if PrimeorNot(number):
print(number,":Number is prime")
else:
print(number,": is not Prime")
| true |
8632095039153860069de824710456d19e8c88ed | Hacksdream/Leetcode_Training | /2.LinkList/linkedlist_tail_insert.py | 886 | 4.15625 | 4 | # -*- coding:utf-8 -*-
class Node():
def __init__(self,data=None):
self.data = data
self.next = None
class LinkedList():
def __init__(self):
self.head = None
def print_list(self):
node = self.head
while node:
print(node.data)
node = node.... | false |
1d470ce86c70853849831afeead8efdb9c54f4ff | Nidhi331/Data-Structures-Lab | /BipartiteGraph.py | 1,867 | 4.21875 | 4 |
#Bipartite graph
# A graph can be divided to two sets such that there is not any two vertices
# in a single set which contain an edge
# S(x) != S(y)
# Can a tree be Bipartite tree?
"""
1
2 3
4 5 6 7
"""
# in the above eg. set1=[1,4,5,6,7] and set2=[2,3] is the solution ... | true |
6f32f9d3a99a0ca2a9d125ec422223c6a080c955 | omarsalem14/python-with-Elzero | /variables_part1.py | 1,020 | 4.78125 | 5 | # ------------------------------------------------------
# --variables --
# ----------------
# syntax => [Variable Name] [Assigment Operator] [Value]
#
# Name Convention and Rules
# [1]Cant start with (a-z A-Z) or Underscore
# [2]I Can't begin with number or Special Charecters {2myVariable},{-myVariable}
# [3]Can incl... | true |
32ce44f3319596094760a0e74e1b2d75ea60a572 | gorehx/LaboratorioVCSRemoto | /main.py | 466 | 4.15625 | 4 | a=float(input("Ingrese el número a:"))
b=float(input("Ingrese el número b:"))
c=float(input("Ingrese el número c:"))
d=(((b*2)-(4*a*c))*(1/2))
neg=(((-1*b)-(d**(1/2))/2*a))
pos=(((-1*b)+(d**(1/2))/2*a))
if d>0:
print( "La parte negativa es: ", neg , "y la parte postiva es: ", pos)
else:
if d==0:
print("El valor neg... | false |
0321483364f00778472d1783e21c68fc2a5adf69 | DingXiye/PythonDemo | /PythonDemo/src/com/11.类和对象/类.py | 1,501 | 4.21875 | 4 | '''
类
self相当于this
2018年6月9日
@author: dingye
'''
class Photo:
def __init__(self,name):
self.name=name
def kick(self):
print("我叫%s"%self.name)
p=Photo("土豆")
p.kick()
#在属性前加上"__"就变成私有属性 __name为私有属性
class Person:
def __init__(self,name):
self.__name=name
def getname(self):
r... | false |
85de4cd34fbbe0459b3a1c5248347d8c2ea462d5 | amaurirg/testes | /Hackerrank/running_time_and_complexity.py | 1,559 | 4.15625 | 4 | """
Objetivo
Hoje estamos aprendendo sobre o tempo de execução!
Tarefa
Um primo é um número natural maior que 1 que não possui divisores positivos além de 1 e ele próprio.
Dado um número, n, determine e imprima se é Prime ou Not prime.
Nota: Se possível, tente criar um algoritmo de primalidade 0 (^ N) ou veja que tipo... | false |
ed2d9440951ec26852941721bf5819a670cd7a83 | ishaniMadhuwanthi/Python-Codes | /set3/Code5.py | 312 | 4.28125 | 4 | # Given a two list of equal size create a set such that it shows the element from both lists in the pair
listOne=[2,3,4,5,6,7,8]
listTwo=[4,9,16,25,36,79,68]
print('First List:',listOne)
print('Second List:',listTwo)
result=zip(listOne,listTwo)
resultList=set(result)
print('Result pairs:',resultList)
| true |
a2f6f11239ce6db80e09511c918faaf7968023fd | ishaniMadhuwanthi/Python-Codes | /set3/Code9.py | 407 | 4.375 | 4 | #Given a dictionary get all values from the dictionary and add it in a list but don’t add duplicates
myList={'jan':47, 'feb':52, 'march':47, 'April':44, 'May':52, 'June':53,
'july':54, 'Aug':44, 'Sept':54}
print('values of the dictionary:',myList.values())
newList=list()
for item in myList.values()... | true |
35ca5475df3b6351d2440e161362534e1150f2b6 | ishaniMadhuwanthi/Python-Codes | /set1/Code9.py | 490 | 4.21875 | 4 | #Given a two list of ints create a third list such that should contain only odd numbers from the first list and even numbers from the second list
def mergeList(listOne, listTwo):
thirdList = []
for i in listOne:
if(i % 2 != 0):
thirdList.append(i)
for i in listTwo:
if(i % 2 == 0):
th... | true |
63aa4993095bde9c5168b6d70b24c724c346e701 | johanesn/CTCI-Practice | /CTCI 5_1.py | 1,360 | 4.3125 | 4 | '''
Insertion : You are given two 32-bit numbers, N and M and two bit positions, i and j. Write a method to insert M into N such that M starts at bit j and ends at bit i. You can assume that bits j through i have enough space to fit all of M. That is if M = 10011, you can assume that there are at least 5 bits between ... | true |
15bec55949ce491cb086f8b0809da553e49de0b4 | johanesn/CTCI-Practice | /CTCI 10_5.py | 1,038 | 4.34375 | 4 | # Sparse Search: Given a sorted array of strings that is interspersed with empty strings, write a method to find the location of a given string.
def sparseSearch (arr, key, low, high):
while low <= high:
mid = int(low + (high-low)/2)
if arr[mid] == '':
left = mid-1
right = mid+1
while True:
print (... | true |
5afda28d2dd3996f26739ea8d527d1414daa725a | johanesn/CTCI-Practice | /TreeTraversal.py | 1,912 | 4.21875 | 4 | # Tree Traversal (Inorder, Preorder and Postorder)
'''
1
/ \
2 3
/ \
4 5
(a) Inorder (Left, Root, Right) : 4 2 5 1 3
> In case of BST, inorder traversal gives nodes in non-decreasing order
(b) Preorder (Root, Left, Right) : 1 2 4 5 3
> Used to... | true |
b4bd32a3e5a5fa2c5f93f4dc1aa6ed162889ece3 | Pratham-vaish/Harshit-Vashisth-Python-Begginer-Course-Notes | /chapter_1/center_method.py | 335 | 4.21875 | 4 | #center method is used to put any symbol in starting ad ending of a string
print("This program can center your name with any character")
print("Things you have to input :- YOUR NAME,CHARACTER,FREQUENCY")
name, x, y = input('enter your name, the character and how many times : ').split(",")
print(name.center(len(nam... | true |
31413461c1047082a86d1a9b645b83d1ff5453da | Pratham-vaish/Harshit-Vashisth-Python-Begginer-Course-Notes | /chapter_1/string_methods.py | 414 | 4.1875 | 4 | name = "pRaTHaM VaiSH"
#len() func conts number of characters including spaces
Length = len(name)
print(Length)
#.lower() method changes all characters to lower case
small_letters = name.lower()
print(small_letters)
#.upper() method changes all characters to upper case
big_letters = name.upper()
print(bi... | true |
c4b3abc532c6ac9f0d0daeb63c00b5739267879d | Pratham-vaish/Harshit-Vashisth-Python-Begginer-Course-Notes | /chapter_1/input_int.py | 428 | 4.125 | 4 | #we use input function for user in put
#for example
name = input('Enter your name ')
print('Hello ' + name)
#A input_func alwasy take input as string
# for example
age = input("whta is your age ")
print("your age is " + age)
#To take input as a integer we use int_func
number_1=int(input("enter your first numbe... | true |
d2d93880bfa842b2804e9d53cd844d780299b353 | Pratham-vaish/Harshit-Vashisth-Python-Begginer-Course-Notes | /chapter_2/if_elif_else.py | 408 | 4.21875 | 4 | name = input("PLEASE ENTER YOUR NAME.. ")
age = int(input("PLEASE ENTER YOUR AGE... "))
if age <= 3:
print(f"Ticket fee for you baby {name} if FREE!!!")
elif age <= 14:
print(f"Ticket fee for you kid {name} is 250rs. ")
elif age <= 60:
print(f"Ticket fee for you sir {name} is 300rs ")
else:
pri... | false |
ceb0f904d7c456a0a5328b55f3e2b7e7e0ba5277 | berkcan98/Python_ogrenme | /hata_ayiklama.py | 610 | 4.125 | 4 | for i in range(3):
ilk_sayı=input("ilk sayı:(Programdan çıkmak için q tuşuna basınız.")
if ilk_sayı=="q":
print("çıkılıyor...")
break
elif i ==2:
print("bu alanı 3 kez yanlış doldurdunuz."
"lütfen daha sonra yeniden deneyiniz.")
ikinci_sayı= input("ikinci sayı:")
... | false |
f6192a855d61998b6f23cd419da2596421644cb7 | unnatural-X/Study_Introduction | /LiaoPage/example4_if.py | 452 | 4.21875 | 4 | # -*- coding: utf-8 -*-
# input your height and weight
s1 = input('please input your height(m):')
height = float(s1)
s2 = input('please input your weight(kg):')
weight = float(s2)
# calculate BMI
BMI = weight/(height*height)
# output the results
print('Your BMI is: %.1f' % BMI)
if BMI < 18.5:
print('过轻')
elif BMI ... | true |
e264ce0306efed9aa8e98b92bbd9f22812617092 | unnatural-X/Study_Introduction | /LiaoPage/example8_functiondef.py | 1,019 | 4.21875 | 4 | # -*- coding: utf-8 -*-
# the solution of quadratic equation
import math # import the math package
def quadratic(a, b, c): # define the function
if a==0:
print('The coefficient of the quadratic term cannot be zero')
elif b*b-4*a*c < 0:
print('The equation doesn\'t have solutions')
elif ... | true |
80740202b28e6126c20c12ceb65cde14c60b3278 | pushpa-ramachandran/DataStructures | /ListAccessingRemovePop.py | 2,773 | 4.53125 | 5 | ############ Accessing the list
print('\n # # # Accessing the list')
list = ['LIST4','LIST5','LIST6']
print(list)
print(list[2])
####### Accessing the multi dimensional list
print('\n # # # Accessing the multi dimensional list')
list = [['LIST4','LIST5','LIST6'],['LIST7','LIST8']]
print(list)
print... | true |
cebabf4a4d549717fe1c652d6325f0ef84627078 | renuka123new/Training | /Python-Code/occuranceOfDigit.py | 420 | 4.125 | 4 | #Find total occurrences of each digits (0-9) using function.
def countOcc(n):
l = []
while (n >= 1):
reminder = int(n % 10)
n = n / 10
l.append(reminder)
for i in range(0, 10):
count = 0
for j in l:
if (i == j):
count = count + 1... | true |
3dce5cf1a5665280f3fdf49a71e81f560c4e68fa | Crowbar97/python_hw | /tutor/5_5.py | 681 | 4.15625 | 4 | # Условие
# Дана строка. Если в этой строке буква f встречается только один раз, выведите её индекс. Если она встречается два и более раз, выведите индекс её первого и последнего появления. Если буква f в данной строке не встречается, ничего не выводите.
# При решении этой задачи не стоит использовать циклы.
s = input... | false |
84c91b2e7671f1f416f689faf267ab1f32626f9f | Crowbar97/python_hw | /tutor/8_5.py | 558 | 4.21875 | 4 | # Условие
# Дана последовательность целых чисел, заканчивающаяся числом 0. Выведите эту последовательность в обратном порядке.
# При решении этой задачи нельзя пользоваться массивами и прочими динамическими структурами данных. Рекурсия вам поможет.
def reverse():
n = int(input("n = "))
if n != 0:
rever... | false |
eaa0624f9710ed758e48c8320f225d9174bacc7b | Crowbar97/python_hw | /tutor/11_1.py | 725 | 4.15625 | 4 | # Условие
# В единственной строке записан текст. Для каждого слова из данного текста подсчитайте, сколько раз оно встречалось в этом тексте ранее.
# Словом считается последовательность непробельных символов идущих подряд, слова разделены одним или большим числом пробелов или символами конца строки.
text = input("text ... | false |
a737549e9f7efb08b08bde75b0d84edf62395291 | sidsharma1990/Basic-program | /To reverse a text.py | 501 | 4.25 | 4 | text_to_reverese = 'We are working'
def reverse_func(string):
print (string[::-1])
reverse_func (text_to_reverese)
############################
text_to_reverese = 'We are working'
def reverse_func(text_to_reverese):
print (text_to_reverese[::-1])
reverse_func (text_to_reverese)
##########... | false |
903f9d4a703e3f625da5f13f6fe084e8894d723b | SymmetricChaos/NumberTheory | /Polynomials/PolynomialIntegerTypeUtils.py | 1,843 | 4.28125 | 4 | def poly_print_simple(poly,pretty=False):
"""Show the polynomial in descending form as it would be written"""
# Get the degree of the polynomial in case it is in non-normal form
d = poly.degree()
if d == -1:
return f"0"
out = ""
# Step through the ascending list of co... | true |
083dcb1dfcad83b453ed7bc8b7fc9eb4f3d61b4d | SymmetricChaos/NumberTheory | /Sequences/Representations.py | 1,839 | 4.125 | 4 | # For alternate representations, generally as strings
from Sequences.Simple import naturals
from Sequences.MathUtils import int_to_roman, int_to_name
def roman_numerals_str():
"""
The positive integers as standard Roman Numerals, returns strings
"""
for n in naturals(1):
yield int_to_roma... | true |
3007394485bc0fb025ce002bb5a20fff99ebbfa5 | SymmetricChaos/NumberTheory | /Examples/FermatFactorizationExample.py | 935 | 4.375 | 4 |
from Computation.RootFinding import int_root, is_square
print("Fermat's method for factorization relies on the difference squares.")
print("\na^2 - b^2 = (a+b)(a-b)")
print("\nThis means that any number which can be written as the difference of two squares must have a+b and a-b as factors.")
a = 17
b = 6
p = (a+b)*(a... | true |
872833bd837287b5c36a446ae1029f0244a383d0 | miloszfoksinski/EXERCISES_PRACTISEPYTHON | /EXERCISE_11.py | 320 | 4.21875 | 4 | """Ask the user for a number and determine whether the number is prime or not."""
x = int(input('Write Your number to check whether it is prime or not: '))
count = 0
for a in range (1,x+1):
if x%a == 0:
count +=1
if count > 2 :
print('Your number ',x,' is not prime')
else:
print('Your number ',x,' is prime')
| true |
fc3b8a2eee36062324c6f0bf7176a9425c69bf4e | sforrester23/SlitherIntoPython | /chapter7/Question3.py | 930 | 4.15625 | 4 | # Write a program that takes a string as input from the user.
# The string will consist of digits and your program should print out the first repdigit.
# A repdigit is a number where all digits in the number are the same.
# Examples of repdigits are 22, 77, 2222, 99999, 444444
# Building upon the previous exercise,
# ... | true |
ef004154a0a6592c88a2d9cfe3db2657b9510f7a | momchil-lukanov/hack-bulgaria | /programming-0/week-3/problems_construction/triangles.py | 1,013 | 4.15625 | 4 | import math
def is_triangle(a, b, c):
if a + b > c or a + c > b or b + c > a:
return True
else:
return False
print(is_triangle(3, 4, 5))
def area(a, b, c):
p = (a + b + c)/2
s = math.sqrt(p*(p-a)*(p-b)*(p-c))
return s
print(area(3, 4, 5))
def is_pythagorean(a, b, c):
... | false |
7b3c25989bd57a5f918b5d8fed972f6ff28bc1ec | DevXerxes/Python-Projects | /InheritanceAssignment.py | 931 | 4.40625 | 4 | # Here im defining a parent class with its properties and using a printname method.
class Bikes:
#function to give structure to objects in the class Bikes
def __init__(self, type_of, color):
self.type_of = type_of
self.color = color
#function for defining structure of the printname m... | true |
cc0145453f692d5e6e291fc12fef82c2c2c3fbaa | phodiep-other/PythonCertSpring | /week-03/code/super/super_test.py | 616 | 4.34375 | 4 | #!/usr/bin/env python
"""
some example code, demostrating some super() behaviour
"""
class A(object):
def __init__(self):
print "in A __init__"
s = super(A, self).__init__()
class B(object):
def __init__(self):
print "in B.__init__"
s = super(B, self).__init__()
class C(objec... | false |
1124a57ea03b0131c2704274666f39061e05eff7 | Deepakvm18/luminardeepak | /language fundamentals/highestof3.py | 466 | 4.25 | 4 | num1=int(input("enter the first number"))
num2=int(input("enter the second number"))
num3=int(input("enter the third number"))
if(num1>num2):
print("first number is greater than second")
if(num1>num2):
print("num1 is greatest of three numbers")
else:
print("num3 is greatest of three numbers"... | true |
e997e5aba7d5a5f546b4a6d94fa9e3336edc0a65 | CodevilJumper/CodeWars | /YourOrder Code Wars.py | 1,241 | 4.15625 | 4 | # Your order, please
#
# INSTRUCTIONS
#
# Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result.
#
# Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0).
#
# If the input string is empty, return... | true |
e100972f2bd606bf312c57850ac8a7013062b67c | VANSHDEEP15577/TEST-C-121 | /ques5.py | 351 | 4.1875 | 4 | array=[]
w=int(input("ENTER THE NO. OF ELEMENTS YOU WANT:"))
for i in range(0,w):
p=input("ENTER THE ELEMENT:")
array.append(p)
print(array)
array1=[]
we=int(input("ENTER THE NO. OF ELEMENTS YOU WANT:"))
for j in range(0,we):
pe=input("ENTER THE ELEMENT:")
array1.append(pe)
print(array1)
arr... | false |
4987c269bbe20c3b6b273adba26055ecfdbd1ce5 | peazybabz/Python-Tutorials-for-beginners | /prg10.py | 254 | 4.125 | 4 | #10. Python Program to Check if a Number is Positive, Negative or 0
num = float(input("Input a number: "))
if num > 0:
print("The number ",num,"is a positve number")
elif num == 0:
print(num,"is Zero")
else:
print("It is a negative number")
| true |
552e867ddb90a4311b7336b879bd83581bae359a | peazybabz/Python-Tutorials-for-beginners | /prg8.py | 329 | 4.5 | 4 | #8. Python Program to Convert Kilometres to Miles
#input provided by program
# kilometers = 5.3
#input from user
kilometers = float(input("Enter value in kilometers:"))
#conversion factor
conv_fac = 0.621371
#calculate miles
miles = kilometers * conv_fac
print("%0.2f kilometers is equal to %0.2f miles"%(kilometers... | true |
e8c56deedf0d6f71ac46b26e9952ed8f49228cbb | titus-ong/chordparser | /src/chordparser/music/roman.py | 2,533 | 4.25 | 4 | class Roman:
"""A class representing Roman numeral notation.
The `Roman` is composed of its `root`, `quality` and `inversion`. When printed, the standard Roman numeral notation is displayed.
Parameters
----------
root : str
The scale degree of the `Roman`. Uppercase if major/augmented and ... | true |
c69ad85e21e632dbecfaaeb0aad6e6a04b43c47c | noodlexpoodle/PY | /Maps.py | 684 | 4.15625 | 4 | from random import shuffle
def jumble(word):
#anagram is a list of the characters
anagram = list(word)
shuffle(anagram) #shuffle the list
return ''.join(anagram)
#words = ['apple','pear','melon']
words = []
i = 1
while i == 1:
word = input('Enter word. Type "Done" to stop ')
if word.lower() != ... | true |
87b0708072b055a340b48c4588199b94512f333b | mbrown2330/tip_calculator2 | /tip_calculator2.py | 1,302 | 4.46875 | 4 | # Make a python script tip_calculator.py that takes a user's input at the command line for:
# Cost of the food
# Number of people splitting the bill
# Percentage of the tip
# Hint: you might want to use the input() function for taking user input
# Then, the script should output:
# The total bill (including tip)
# ... | true |
93c810befaea331717e552e66a366ccdb4dfdf22 | steveSuave/practicing-problem-solving | /code-wars/expanded-form.py | 566 | 4.34375 | 4 | ##Write Number in Expanded Form
##
##You will be given a number and you will need to return
##it as a string in Expanded Form. For example:
##
##expanded_form(12) # Should return '10 + 2'
##expanded_form(42) # Should return '40 + 2'
##expanded_form(70304) # Should return '70000 + 300 + 4'
##
##NOTE: All numbers will be... | true |
f37d2e3ea1340ca5ae07a2aab0b33f0a713408fa | DanilooSilva/Cursos_de_Python | /Curso_de_Python_3_do_Basico_Ao_Avancado_Udemy/aula116/metaclasses.py | 809 | 4.28125 | 4 | """
EM PYTHON TUDO É UM OBJETO: Incluindo classes
Metaclasses são as "classes" que criam classes.
type é uma metaclasse (!!!???)
"""
class Meta(type):
def __new__(mcs, name, bases, namespace):
if name == 'A':
return type.__new__(mcs, name, bases, namespace)
if 'b_fala' not in namespa... | false |
07320850bf2c94779f0ce375fbc78a0f1022d09f | Aegis-Liang/Python3_Mac | /Data Structures & Algorithms/Part01/L03_PythonFunctions.py | 247 | 4.125 | 4 | # Example function 1: return the sum of two numbers.
def sum(a, b):
return a+b
# Example function 2: return the size of list, and modify the list to now be sorted.
def list_sort(my_list):
my_list.sort()
return len(my_list), my_list
| true |
95f1cb5d3eac411483411e06feb7c59e40ff7951 | Aegis-Liang/Python3_Mac | /GUI_Tkinter/T5_Caculator.py | 2,909 | 4.125 | 4 | from tkinter import *
root = Tk()
root.title("Simple Calculator")
e = Entry(root, width=35)
e.grid(row=0, column=0, columnspan=3)
def button_click(number):
e.insert(END, str(number))
def button_add():
global first_number
global math
first_number = int(e.get())
e.delete(0, END)
math = "add... | false |
5ce751ddd79daaa9a22728fab5c2ac64411158a8 | colioportfolio/final491edited | /main.py | 1,630 | 4.125 | 4 | from bike import Bike
from fordPinto import Car
from parts import Vehicle
checker = 0
checker2 = 0
checker3 = 0
def wrong_bike():
print("Sorry! That currently is not a bike option")
while checker == 0:
user = input("Hi there! is this Wayne or Garth? ")
if user in ["Garth", "garth", "GARTH"]:
bik... | true |
16dbab5d36bfd3d910566b8b8fd2a5bc6ae7e7be | mygnu/MIT6.00 | /Nth_prime_number.py | 768 | 4.28125 | 4 | prime_l = []
nth_prime = int(input('Enter a number to find n\'th prime: '))
def next_prime(current):
next_prime = current + 1 # start checking for primes 1 number after the current one
i = 2
while next_prime > i: # check with numbers up to next_prime - 1
if next_prime % i == 0: # if number is divisi... | false |
c51630f8c80dd17412816ad617555820a3ad498e | bogataurus/Temperature-Select | /temperature_select.py | 1,118 | 4.15625 | 4 | radiators_list = ["kitchen","livingRoom","diningRoom","bathroom","bedroom1","bedroom2", "bedroom3"]
temperatur_list = [15, 18, 22, 26, 30, 35, 40, 45]
heating_radiator = ""
temperature = ""
while True:
radiator_select = input ( "Select radiator at list: kitchen, livingRoom , diningRoom , bathroom , bedroom1 , b... | true |
fcee985fa8c4af5aad96b3ffef49d6489787d75e | hanaum/MIT--6.001x-Python | /ProblemSet1/pset1-vowel search.py | 394 | 4.28125 | 4 | '''Counting Vowels: counts up the number of vowels contained in the string 's'
Valid vowels are 'a','e','i','o','u'
ex:
s = 'azcbobobegghakl' should print "Number of vowels: 5"
MIT-6.001x Python
Hana Um
'''
vowels = 0
for letter in s:
if letter == 'a' or letter == 'e' or letter == 'i' or letter == 'o' or le... | false |
7982ede29a971bf120c1cf2557348d34e30fb8e6 | ShelMX/gb_algorithm_hw | /lesson_7/hw_07.py | 1,858 | 4.40625 | 4 | __author__ = 'Шелест Леонид Викторович'
"""
Module with the functions that are used in each homework.
"""
import random as rnd
def generate_int_array(low: int = -100, up: int = 99, size: int = 100) -> list:
"""
function generate list of random numbers (int type).
:param low: type int, lower bound of rando... | true |
a14cf45fffea00d2e3309b9851c4e84bad081006 | NathanDDarmawan/AP-programming-exercises-session-10 | /4.py | 313 | 4.15625 | 4 | def calc_new_height():
m = int(input("Enter the current width: "))
n = int(input("Enter the current height: "))
z = int(input("Enter the desired width: "))
ratio = n/m
new_height = z*ratio
print("The corresponding height is:", new_height)
return new_height
calc_new_height()
| true |
cc14e6627e6e867e30021c0dfe9bb1c2b6e01ca0 | Darrenrodricks/PythonProgrammingExercises | /GitProjects/sepIteams.py | 427 | 4.40625 | 4 | # Question: Write a program that accepts a comma separated sequence of words as input and prints the words in a
# comma-separated sequence after sorting them alphabetically. Suppose the following input is supplied to the program:
# without,hello,bag,world Then, the output should be: bag,hello,without,world
items = [x f... | true |
1f319726aebea1d6d18ef3a9dfd69293025be6f6 | Darrenrodricks/PythonProgrammingExercises | /GitProjects/factorial.py | 423 | 4.1875 | 4 | # Question: Write a program which can compute the factorial of a given numbers. The results should be printed in a comma-separated
# sequence on a single line. Suppose the following input is supplied to the program: 8 Then, the output should be: 40320
def factorial(x):
if x == 0:
return 1
return x * fac... | true |
f6c7e0042cd3a6a82751ceeda0a7360c095153e2 | wy7318/Python | /basic/whileProgramming.py | 833 | 4.21875 | 4 | available_exit=["east", "west", "north", "south"] #creating list
choosen_exit=""
while choosen_exit not in available_exit:
choosen_exit=input("please choose direction:")
if choosen_exit == "exit":
print("game over")
break
else:
print("glad you got out")
#####################################... | true |
c6ebcc4d45a499061f33c72c4e0d8548ebbdca1d | wy7318/Python | /basic/List.py | 1,744 | 4.125 | 4 | ipAddress = input("please enter an IP address")
print(ipAddress.count(".")) #counting specific character
#===============================================================================#
word_list=["wow", "this", "that", "more"]
#===============================================================================#
word_list... | true |
3250e52a4c73bb240705e1412ffda922c8694ef5 | yqxd/LEETCODE | /44WildcardMatching.py | 2,329 | 4.1875 | 4 | '''
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'.
'?' Matches any single character.
'*' Matches any sequence of characters (including the empty sequence).
The matching should cover the entire input string (not partial).
Note:
s could be empty and conta... | true |
ada055efcc03e73f8d40d6c045925997f0bdb453 | greshan/python_assignments | /28.py | 410 | 4.28125 | 4 | #28. Implement a progam to convert the input string to inverse case(upper->lower, lower->upper) ( without using standard library)
str_data = 'Greshan'
result = ''
for char in str_data:
if ord(char) >= 65 and ord(char) <= 90:
result += chr(ord(char) - 32)
print(result)
elif ord(char)<=97 and or... | true |
f4a5629e49c56439096843cb8e9559d2bfb372b5 | greshan/python_assignments | /11.py | 736 | 4.25 | 4 | #Implement a program with functions, for finding the area of circle, triangle, square.
def main():
print("Area of Circle - 1\n")
print("Area of Triangle - 2\n")
print("Area of Square - 3\n")
num = int(input("Enter num: \n"))
if num == 1:
r = float(input("Enter radius value:\t"))
a ... | false |
e0c509792b018be0c9c6b68ad28b8e9271f3dc08 | greshan/python_assignments | /23.py | 212 | 4.34375 | 4 | #23. Implement a program to write a line from the console to a file.
inp = input("Enter text to print in file : \n")
file = open("23.txt","w")
if(file.write(inp)):
print("written to 23.txt")
file.close()
| true |
2fc21a984fd786cef73fbf20698492d822f87fc8 | kellibudd/code-challenges | /get_century.py | 712 | 4.1875 | 4 | import math
def centuryFromYear(year):
"""
Source: Codesignal
Given a year, return the century it is in. The first century spans
from the year 1 up to and including the year 100, the second - from
the year 101 up to and including the year 200, etc.
Test case:
>>> centuryFromYear(1905)
... | true |
a5f501cc47fc3130f0a1672bd64b6a45e1df35a0 | rhit-catapult/2021-session1 | /individual_tutorials/pygamestartercode-gdhill-master/00-IntroToPython/07_mutation.py | 1,727 | 4.28125 | 4 | """
This module demonstrates MUTATION and RE-ASSIGNMENT.
Authors: David Mutchler, Vibha Alangar, Matt Boutell, Dave Fisher, Mark Hays,
Derek Whitley, their colleagues.
"""
##############################################################################
# TODO: 2. Read the code, then run it.
# Make sure you u... | true |
88b6094a8fff4e796496c08edfe152e557bf31cf | emildekeyser/tutoring | /fh/opl/Solutions-session5/Solutions-new/ex2b_fibindex.py | 715 | 4.21875 | 4 | def index_of_fib(s):
# The number 1 is the value of fib_1 and fib_2 so we choose to return fib_1
if s == 1:
return 1
s1 = 1
s2 = 1
s3 = s1 + s2
n = 3
# Same calculation as in ex2a but now we keep calculating new fib values until we reach our limit s
while s3 < s:
s1 = s2
... | true |
9f28e77623dd07cb1cf88b3e434b630240e45dc2 | emildekeyser/tutoring | /fh/opl/solutions_session8/ex5.py | 688 | 4.21875 | 4 | # each node in BST is represented as [left_child, value, right_child]
def bst_insert(tree, item):
if len(tree) == 0:
tree.append([])
tree.append(item)
tree.append([])
elif len(tree) == 3:
if item <= tree[1]:
bst_insert(tree[0], item)
else:
bst_inse... | false |
d0dd68ae68aa8d92162e2ce76116a08131eb8a6f | emildekeyser/tutoring | /fh/opl/oefenzitting_3_opl(1)/E2 Celsius to Fahrenheit.py | 399 | 4.40625 | 4 | input_string = input('Enter the temperature in Celsius: ')
while input_string != 'q':
celsius = float(input_string)
fahrenheit = celsius * 9/5 + 32
print('The temperature in Fahrenheit is:', fahrenheit)
input_string = input('Enter the temperature in Celsius: ')
# for this exercise you cannot use a for... | true |
74dbd77b513f89ef069d3fda4f67557bb72ed693 | alekssro/CompThinkBioinf | /Week02/src/sort.py | 1,268 | 4.34375 | 4 | def insertion_sort(lst):
"""Sort a list of numbers.
Input: lst -- a list of numbers
Output: a list of the elements from lst in sorted order.
"""
s = []
for x in lst:
# s contains contains all the element we have
# seen so far, in sorted order
smaller = [y for y in s if y <= x]
larger = [y for y in s if y ... | true |
87e673cc2faf46fd5d33335586782acbd31fd6bb | candyer/Daily-Coding-Problem | /dcp_12.py | 1,384 | 4.375 | 4 | # Daily Coding Problem: Problem #12
# There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N,
# write a function that returns the number of unique ways you can climb the staircase.
# The order of the steps matters.
# For example, if N is 4, then there are 5 unique ways:
#... | true |
a04620b19b1a89931217119f14b0d18b2de4c676 | habraino/meus-scripts | /_prog/_python/_aulas/_dados/string_v1.py | 1,663 | 4.28125 | 4 | # file_name: string.py
'''
Nota: com esse exemplo tu irá minima noção de como trabalhat com "strings"
E o uso de input("") é mesmo que str(input("")), só quando para stings
'''
var = input("Digite qualquer coisa: ")# lê qualquer coisa pelo teclado
# retorna o tamanho da 'palavra' informada
print("O taman... | false |
88080fdc0a346368f15042dff08bf4fedc446219 | ganesh1729ganesh/Algos_task_3 | /problem_1_task3.py | 1,058 | 4.125 | 4 |
n = input("Enter the number: ")
#Taking input in the form of string
sumTemp = 0
count = 0
while (len(n) > 1): #only we need to find sum of digits only when it is a non-single digit number
sumTemp = 0
for i in range(len(n)):
sumTemp += int(n[i])# simply to con... | true |
b7bf1e1da7246b4d32a3ee82ee44d9e173e18bad | nandha-batzzy/Python-Projects-and-Learning | /Code forces Simple probs/ep11_Healpful maths.py | 1,327 | 4.1875 | 4 | '''Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.
The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough f... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.