blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
b433ed328d118c05a67b42d8085391af87955ba7 | isaolmez/core_python_programming | /com/isa/python/chapter7/SetOperators.py | 899 | 4.21875 | 4 | ## 1. Standard Type Operators
set1 = set([1, 2, 3, 3]) # Removes duplicates
print set1
set2 = set("isa123")
print set2
print 1 in set1
print "i" in set2
print "---- Equality test"
set1Copy = set(set1)
print "set1 == set1Copy", set1 == set1Copy
print "set1 < set1Copy", set1 < set1Copy # Strictly must be smaller. Equa... | true |
fade8fcd236ccbf30038d4ca49cd11dd18dae898 | isaolmez/core_python_programming | /com/isa/python/chapter6/ShallowCopy.py | 1,228 | 4.28125 | 4 | ## SHALLOW COPY
person = ["name", ["savings", 100.00]]
print id(person), id(person[:])
print "---- Slice copy"
husband = person[:]
print id(person), id(person[:])
print id(person), id(husband)
# They both refer to the same string "name" as their first element and so on.
print "id() of names:", id(person[0]), id(husban... | true |
0c2c06e78b487259157082a78e21bdcf951a457b | Supython/SuVi | /+or-or0.py | 287 | 4.5 | 4 | #To Check whether the given number is positive or negative
S=int(input("Enter a number: "))
if S>0:
print("Given number {0} is positive number".format(S))
elif S<0:
print("Given number {0} is negative number".format(S))
else:
print("Given number {0} s Zero".format(S)) | true |
c139098a2859b272f95868d767b9c108f04d7f8f | Utkarsh811/workclass | /ASSIGNMENT_9/9.py | 1,421 | 4.375 | 4 | #for matrix addition matrix should have equal dimensions , means equal number of rows and columns
row=int(input('Enter the number of rows of matrix-1'))
cols=int(input('Enter the number of cols of matrix-1'))
row1=int(input('Enter the number of rows of matrix-2'))
cols1=int(input('Enter the number of columns of matrix-... | false |
528e345293daabc200c244daa47bbd0ed62ce033 | Izavella-Valencia/programacion | /Talleres/Taller2.py | 1,296 | 4.375 | 4 | #------preguntas------
MENSAJE_INTRODUCCION = "procederemos a hacer operaciones con numeros escogidos por ti"
NUMERO_A = "escoja un numero entero del 1 al 20 :"
NUMERO_B = "escoja un numero entero del 1 al 20 :"
#-------codigos--------
print ("#"*15, "insertar numeros", 15*"#")
print (MENSAJE_INTRODUCCION)
numeroA = ... | false |
7c52c9f202315ffc5d90cb6b81118d92051240d1 | Izavella-Valencia/programacion | /Clases/Listas.py | 1,763 | 4.1875 | 4 | nombres = []
print (type(nombres))
print (nombres)
nombres = ['Santiago', 'Samuel', 'Alejandra', 'Elsa']
print (nombres)
print (nombres[2])
nombres.append ('Mauricio')
print (nombres)
print (nombres [2])
edades = [18,19,20,17]
estaturas = [1.62, 1.80, 1.67, 1.98]
#el ultimo numero
print (edades [-2])
print (edades [... | false |
d4c1b4e64302f1f0a851ed7fa7061142b687320d | chisoftltd/PythonFilesOperations | /PythonWriteFile.py | 1,443 | 4.375 | 4 | # Write to an Existing File
import os
f = open("demofile2.txt", "a")
f.write("Now the file has more content! TXT files are useful for storing information in plain text with no special formatting beyond basic fonts and font styles.")
f.close()
myfile = open("Tutorial2.txt", "w")
myfile.write("Python Programming Tutor... | true |
937fd7ed313414abdcf79356bd51f06a2571f0e2 | EvelynMC/intro-python | /intro-python/controlFlujo.py | 1,101 | 4.40625 | 4 | # ----IF Control de Flujo-----
# if 2 < 5:
# print('2 es menor que 5')
# a == b
# a < b
# a > b
# a != b
# a <= b
# a >= b
# if 2 == 2:
# print('2 es igual a 2')
# if 2 ==3:
# print('2 es igual a 3')
# if 2 > 5:
# print('2 es mayor que 5')
# if 5 > 2:
# print('5 es mayor a 2')
# if 2 != 2:
# ... | false |
10aa1cd421da8e9c821f15281f1b3bdca4fe32d4 | xs2pranjal/data_structures | /linear/linkedlist.py | 1,701 | 4.4375 | 4 | class LinkedList(object):
"""
This is an implementation of a LinkedList in python.
"""
def __init__(self):
self.head = None
def print_ll(self, node=None):
if not node:
node = self.head
print(node.value)
# Calling the print_ll recursively
if nod... | false |
8c2035389bee962cd81c58f710e21d5f5e15d5cd | artorious/simple_scripts_tdd | /test_longer_string.py | 998 | 4.15625 | 4 | #!/usr/bin/env python3
""" Tests for longer_string.py """
import unittest
from longer_string import longer_string
class TestLongerString(unittest.TestCase):
""" Test cases for longer_string() """
def test_invalid_input(self):
""" Tests both arguments are strings """
self.assertRaises(
... | true |
e4a9b2f2f3c847ea444f2380217eca63adf7ffd3 | JessBrunker/euler | /euler23/euler23.py | 2,576 | 4.125 | 4 | #!/usr/bin/python3
'''
A perfect number is a number for which the sum of its proper divisors is
exactly equal to the number. For example, the sum of the proper divisors
of 28 would be 1+2+4+7+14=28, which means 28 is a perfect number.
A number n is called deficient if the sum of its proper divisors is
less than n and... | true |
8ffa90066929fb6ada2524fedba217edd785c2e4 | jorge-jauregui/guess-the-number-game | /guess the number.py | 587 | 4.125 | 4 | print("Welcome to Jorge's 'guess the number' game!")
print("I have in mind a number between 1 and 100. Can you guess what it is?")
import random
random.randrange(1, 101)
number_guess = random.randrange(1, 101)
chances = 0
while chances < 100000:
user_guess = int(input("Type your guess: "))
if user_guess == n... | true |
5289398156ac28b120441ed9158c132411d511da | bennettokotcha/python_start | /hello_world.py | 1,503 | 4.53125 | 5 | # print ('Hello World')
# print ('new language means creating new pathwyas in my brain...alot of learning!!')
# x = 'Hello Python'
# print (x)
# y = 42
# print (y)
# print (x, y)
# print('this is a sample string')
# name = '`Bennett` the Don!'
# print('My name is ' + name)
# first_name = "Bennett"
# last_name = "Okotch... | false |
316688cfd723a90690b103add5d1b582ca75bbf9 | akshay-1993/Python-HackerRank | /Staircase.py | 574 | 4.40625 | 4 |
# Problem
# Consider a staircase of size : n = 4
#
# #
# ##
# ###
# ####
# Observe that its base and height are both equal to n, and the image is drawn using # symbols and spaces. The last line is not preceded by any spaces.
#
# Write a program that prints a staircase of size n.
#!/bin/python3
im... | true |
83338738da87bdcc5cd4ef0522b5eb70c913046a | yokohamaH/deeplerninglen | /test.py | 462 | 4.21875 | 4 | def accumulate_list(iterable):
current = 0
lst = []
for element in iterable:
current += element
lst.append(current)
return lst
def accumulate_generator(iterable):
current = 0
for element in iterable:
current += element
yield current
# ジェネレータイテレータ
gen = accumul... | false |
272470f47bd4c525369e615ea3b8346e2d525488 | yoheiMune/Python-LectureNote | /day2/common.py | 984 | 4.3125 | 4 | #
# 共通処理 - Python Lecture Day2
#
import numpy as np
import matplotlib.pyplot as plt
def load_data():
"""線形回帰に利用するデータを読み込みます"""
X = np.loadtxt("./automobile.txt", delimiter=",")
return X.tolist(), X[:,0].tolist(), X[:,1].tolist()
def show(data, x_vals=None, y_vals=None, Theta=None, hypothesis_func=None):
... | false |
36d0406ea682acc2c1847191849ac889a75d75c9 | dagamargit/absg_exercises | /04_changing_the_line_spacing_of_a_text_file.py | 1,063 | 4.125 | 4 | #!/usr/bin/python
# Write a script that reads each line of a target file, then writes the line back to stdout,
#+but with an extra blank line following. This has the effect of double-spacing the file.
#
# Include all necessary code to check whether the script gets the necessary command-line argument (a filename),
#+and... | true |
e267a34267b31cae25ca650817d9f6ec23097ccc | jeremy-techson/PythonBasics | /tuples.py | 621 | 4.375 | 4 | # Tuples are immutable list
numbers = (1, 2, 3, 4, 5)
print(numbers)
# Operations available to tuples are almost the same with list
print(numbers[0:3])
print("Length: ", len(numbers))
numbers = numbers + (6, 7)
print(numbers)
print("7 in tuple?", 7 in numbers)
for num in numbers:
print(num, end=", ")
print(""... | true |
fb5aeea26dd41fbeb9a6857358ee9d55bad7e798 | RafaelSanzio0/FACULDADE-PYTHON.2 | /Material para n2/N2 ESTUDO/Funções/SomaDigito.py | 626 | 4.34375 | 4 | '''9) Dado um número inteiro positivo, escreva um programa modularizado para calcular a soma de seus dígitos.
O seu programa deve contar uma função que lê um número inteiro e positivo, bem como uma função,
chamada somaDigitos, que recebe um inteiro e positivo n
e retorna um inteiro e positivo, representando a soma do... | false |
36020dbf86285bcb3904085cdd86a2abe920d528 | RafaelSanzio0/FACULDADE-PYTHON.2 | /Material para n2/N2 ESTUDO/Listas/ListaAmigos.py | 1,968 | 4.21875 | 4 | def msg():
print("-=-="*20)
print("LISTA DE AMIGOS :)")
msg()
def op():
print("\n")
print("(1) - Cadastrar um amigo no final da lista")
print("(2) - Mostrar o nome de todos na lista")
print("(3) Cadastrar um amigo no início da lista")
print("(4) Remover um nome")
print("(5) Substituir u... | false |
2500df19b972bec81642da911c1ee72101bf0ee8 | tjguk/kelston_mu_code | /20181124/primes.py | 635 | 4.21875 | 4 | """A simple function which will indicate whether a number is a prime or not
"""
def is_prime(n):
#
# Check every number up to half of the number
# we're checking since if we're over half way
# we must have hit all the factors already
#
for factor in range(2, 1 + (n // 2)):
if n % factor ... | true |
316e325d6eb23a574569332c4796dc70118847bc | ardenzhan/dojo-python | /arden_zhan/Python/Python Fundamentals/string_list.py | 862 | 4.125 | 4 | '''
String and List Practice
.find()
.replace()
min()
max()
.sort()
len()
'''
print "Find and Replace"
words = "It's thanksgiving day. It's my birthday, too!"
print "Position of first instance of day:", words.find("day")
print words.replace("day", "month", 1)
print ""
print "Min and Max"
x = [2,54,-2,7,12,98]
print "... | true |
4d79f25d46800b34809bfa18691f99567f91ce20 | ardenzhan/dojo-python | /arden_zhan/Python/Python Fundamentals/scores_and_grades.py | 800 | 4.34375 | 4 | '''Scores and Grades'''
# generates ten scores between 60 and 100. Each time score generated, displays what grade is for particular score.
'''
Grade Table
Score: 60-79; Grade - D
Score: 70-79; Grade - C
Score: 80-89; Grade - B
Score: 90-100; Grade - A
'''
# import random
# #random_num = random.random()
# #random funct... | true |
c63063ed71536d139b127cc48d2aae18a915e8ba | muhammad-masood-ur-rehman/Skillrack | /Python Programs/adam-number.py | 665 | 4.375 | 4 | Adam number
A number is said to be an Adam number if the reverse of the square of the number is equal to the square of the reverse of the number. For example, 12 is an Adam number because the reverse of the square of 12 is the reverse of 144, which is 441, and the square of the reverse of 12 is the square of 21, whic... | true |
7451ad703a6c8c56d0976ef8e6d481ef3e7feae0 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/sum-unit-digit-3-or-6.py | 667 | 4.34375 | 4 | Sum - Unit Digit 3 or 6
The program must accept N integers as the input. The program must print the sum of integers having the unit digit as 3 or 6 as the output. If there is no such integer then the program must print -1 as the output.
Boundary Condition(s):
1 <= N <= 100
1 <= Each integer value <= 10^5
Example Input... | true |
1c96e07d40bd8283d1b28ac27fe4c5d8af4d31e4 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/replace-border-with-string.py | 907 | 4.3125 | 4 | Replace Border with String
The program must accept a character matrix of size RxC and a string S as the input. The program must replace the characters in the border of the matrix with the characters in the string S in the clockwise direction. Then the program must print the modified matrix as the output.
Example Inpu... | true |
ada01c186d7844f188d4231a43681cedd802029c | muhammad-masood-ur-rehman/Skillrack | /Python Programs/product-of-current-and-next-elements.py | 1,369 | 4.125 | 4 | Product of Current and Next Elements
Given an array of integers of size N as input, the program must print the product of current element and next element if the current element is greater than the next element. Else the program must print the current element without any modification.
Boundary Condition(s):
1 <= N <= ... | true |
5c30823a56d59cc5c51b764f4781fed4b1ba1997 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/find-duplicates-in-folder.py | 1,562 | 4.1875 | 4 | Find Duplicates In Folder
The directory structure of a file system is given in N lines. Each line contains the parent folder name and child file/folder name. If a folder has two files/folders with the same name then it is a duplicate. Print all the duplicate file/folders names sorted in ascending order. If there is no... | true |
63f9c82f95090e789395286b4f977b74ac621a4b | muhammad-masood-ur-rehman/Skillrack | /Python Programs/matching-word-replace.py | 1,307 | 4.3125 | 4 | Matching Word - Replace ?
The program must accept two string values P and S as input. The string P represents a pattern. The string S represents a set of words. The character '?' in P matches any single character. The program must print the word in S that matches the given pattern P as the output. If two or more words... | true |
5de0252734c9525ea7956e7cd76d14401e1b3d7d | muhammad-masood-ur-rehman/Skillrack | /Python Programs/python-program-for-interlace-odd-even-from-a-to-b.py | 1,509 | 4.4375 | 4 | Python Program for Interlace odd / even from A to B
Two numbers A and B are passed as input. The program must print the odd numbers from A to B (inclusive of A and B) interlaced with the even numbers from B to A.
Input Format:
The first line denotes the value of A.
The second line denotes the value of B.
Output Format... | true |
c2b2db90bec32dd87464306cbc8a57b91b3d0243 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/odd-even-row-pattern-printing.py | 940 | 4.59375 | 5 | Odd Even Row - Pattern Printing
Given a value of N, where N is the number of rows, the program must print the character '*' from left or right depending on whether the row is an odd row or an even row.
- If it is an odd row, the '*' must start from left.
- If it is an even row, the '*' must start from right.
After the... | true |
25e72d166e88791aaac58cdd83ed552c38b3867f | muhammad-masood-ur-rehman/Skillrack | /Python Programs/check-sorted-order.py | 1,127 | 4.125 | 4 | Check Sorted Order
The program must accept N integers which are sorted in ascending order except one integer. But if that single integer R is reversed, the entire array will be in sorted order. The program must print the first integer that must be reversed so that the entire array will be sorted in ascending order.
Bo... | true |
a8d6708bf1f9958cd05214bf00e43a3cf3dcdfe0 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/count-overlapping-string-pattern.py | 1,039 | 4.1875 | 4 | Count Overlapping String Pattern
Two string values S and P representing a string and pattern are passed as the input to the program. The program must print the number of overlapping occurrences of pattern P in the string S as the output.
Note: The string S and pattern P contains only lowercase alphabets.
Boundary Cond... | true |
6ee5cd6a8e090682bf699c788e467ccb8cfb975c | muhammad-masood-ur-rehman/Skillrack | /Python Programs/first-m-multiples-of-n.py | 558 | 4.46875 | 4 | First M multiples of N
The number N is passed as input. The program must print the first M multiples of the number
Input Format:
The first line denotes the value of N.
The second line denotes the value of M.
Output Format:
The first line contains the M multiples of N separated by a space.
Boundary Conditions:
1 <= N <... | true |
15125f1513e68e317ad5bc79e4f09f7c6dbb4dbd | muhammad-masood-ur-rehman/Skillrack | /Python Programs/direction-minimum-shift.py | 2,093 | 4.3125 | 4 | Direction & Minimum Shift
The program must accept two string values S1 and S2 as the input. The string S2 represents the rotated version of the string S1. The program must find the minimum number of characters M that must be shifted (Left or Right) in S1 to convert S1 to S2. Then the program must print the direction (... | true |
c88a8f7c2ef64b308a95bd5b040b5f98df2f40b1 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/remove-characters-from-left.py | 1,445 | 4.28125 | 4 | Remove Characters from Left
Remove Characters from Left: The program must accept two string values S1 and S2 as the input. The program must print the minimum number of characters M to be removed from the left side of the given string values so that the revised string values become equal (ignoring the case). If it is n... | true |
aa6ea506e424f5b0a50f4537652395b31a901596 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/rotate-matrix-pattern.py | 1,377 | 4.46875 | 4 | Rotate Matrix Pattern
The program must accept an integer matrix of size N*N as the input. The program must rotate the matrix by 45 degrees in the clockwise direction. Then the program must print the rotated matrix and print asterisks instead of empty places as the output.
Boundary Condition(s):
3 <= N <= 100
Input For... | true |
8ec84a6f4492aa2fc49b4fee6a9e6a9ca41083f6 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/sum-of-digits-is-even-or-odd.py | 690 | 4.125 | 4 | Sum of Digits is Even or Odd
Sum of Digits is Even or Odd: Given an integer N as input, the program must print Yes if the sum of digits in a given number is even. Else it must print No.
Boundary Condition(s):
1 <= N <= 99999999
Input Format:
The first line contains the value of N.
Output Format:
The first line contain... | true |
1321a5a0862b67f2f4568189562a86f3444a201e | muhammad-masood-ur-rehman/Skillrack | /Python Programs/batsman-score.py | 844 | 4.125 | 4 | Batsman Score
Batsman Score: Given an integer R as input, the program must print Double Century if the given integer R is greater than or equal to 200. Else if the program must print Century if the given integer R is greater than or equal to 100. Else if the program must print Half Century if the given integer R is gr... | true |
dc3805fb23ea3f2f06c3263183c16edd3967deed | muhammad-masood-ur-rehman/Skillrack | /Python Programs/toggle-case.py | 617 | 4.3125 | 4 | Toggle Case
Simon wishes to convert lower case alphabets to upper case and vice versa. Help Simon by writing a program which will accept a string value S as input and toggle the case of the alphabets. Numbers and special characters remain unchanged.
Input Format: First line will contain the string value S
Output For... | true |
cd8de721b5a119f128606b24071ed7a2c4aafed0 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/top-left-to-bottom-right-diagonals-program-in-python.py | 1,296 | 4.28125 | 4 | Top-left to Bottom-Right Diagonals Program In Python
The program must accept an integer matrix of size RxC as the input. The program must print the integers in the top-left to bottom-right diagonals from the top-right corner of the matrix.
Boundary Condition(s):
2 <= R, C <= 50
1 <= Matrix element value <= 1000
Input ... | true |
6c7286a208f6e7c8152d488ceb97ebb1df8c7bbf | muhammad-masood-ur-rehman/Skillrack | /Python Programs/unique-alphabet-count.py | 596 | 4.3125 | 4 | Unique Alphabet Count
A string S is passed as input to the program which has only alphabets (all alphabets in lower case). The program must print the unique count of alphabets in the string.
Input Format:
- The first line will contain value of string S+
Boundary Conditions:
1 <= Length of S <= 100
Output Format:
The ... | true |
5ae44003eed074094a44f7b9f3edf268e48f022f | muhammad-masood-ur-rehman/Skillrack | /Python Programs/python-program-to-print-fibonacci-sequence.py | 575 | 4.5625 | 5 | Python Program To Print Fibonacci Sequence
An integer value N is passed as the input. The program must print the first N terms in the Fibonacci sequence.
Input Format:
The first line denotes the value of N.
Output Format:
The first N terms in the Fibonacci sequence (with each term separated by a space)
Boundary Condit... | true |
10e61b1d76df5b45f241b64dc305f9420d297a2e | muhammad-masood-ur-rehman/Skillrack | /Python Programs/print-numbers-frequency-based.py | 1,045 | 4.46875 | 4 | Print Numbers - Frequency Based
An array of N positive integers is passed as input. The program must print the numbers in the array based on the frequency of their occurrence. The highest frequency numbers appear first in the output.
Note: If two numbers have the same frequency of occurrence (repetition) print the sma... | true |
1370e5de23f56dad4a80ed2d09096913b7899778 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/sparse-matrix.py | 706 | 4.34375 | 4 | Sparse Matrix
Write an algorithm and the subsequent Python program to check whether the given matrix is sparse or not. A matrix is said to be a “Sparse” if the number of zero entries in the matrix, is greater than or equal to the number of non-zero entries. Otherwise it is “Not sparse”. Check for boundary conditi... | true |
82212ae4feda9fea0df5846fdc235aee5d457ddf | muhammad-masood-ur-rehman/Skillrack | /Python Programs/all-digits-pairs-count.py | 1,119 | 4.21875 | 4 | All Digits - Pairs Count
The program must accept N integers as the input. The program must print the number of pairs X where the concatenation of the two integers in the pair consists of all the digits from 0 to 9 in any order at least once.
Boundary Condition(s):
2 <= N <= 100
1 <= Each integer value <= 10^8
Input Fo... | true |
27381d83b8d936ffeff2ef2e10665d913a7a166b | alexandroid1/PytonStarter_Lesson1_PC | /calculator.py | 370 | 4.1875 | 4 | x = float(input("First number: "))
y = float(input("Second number: "))
operation = input("Operation")
result = None
if operation == '+':
result = x + y
elif operation == '-':
result = x-y
elif operation == '*':
result = x*y
elif operation == '/':
result = x/y
else:
print('Unsupported operation')
i... | true |
70f77d776c25ec8bb620e789c5f579451bb5ba09 | tapans/Algorithms-Puzzles-Challenges | /CTCI_6e/1.9_string_rotation.py | 1,072 | 4.15625 | 4 | #!/usr/bin/python
import unittest
def isSubstring(s1, s2):
'''
Returns True if s2 is a substring of s1
'''
return s1 in s2
def is_string_rotation(s1,s2):
'''
Returns True if s2 is a rotation of s1 using only one call to isSubstring. False o/w
Time Complexity: let a be len of s1, b be len of s2,... | false |
fc8f710a881f74f7bf2cfc65a6c00ecccd939dfe | urstkj/Python | /thread/thread.py | 1,484 | 4.125 | 4 | #!/usr/local/bin/python
#-*- coding: utf-8 -*-
import _thread
import threading
import time
# Define a function for the thread
def print_time(threadName, delay):
count = 0
while count < 5:
time.sleep(delay)
count += 1
print("%s: %s" % (threadName, time.ctime(time.time())))
# Create two... | true |
0236e95fdffd9e769366713f402c0833f2023599 | anabeatrizzz/exercicios-pa-python | /exercicios_5/exercicios_5_01.py | 2,466 | 4.25 | 4 | """Escreva um programa que peça para o usuário digitar uma data contendo dia, mês e ano
e o programa deverá informar se é uma data válida ou não."""
class Data():
def __init__(self):
self.dia = 0
self.mes = 0
self.ano = 0
def VerificaDia(dia, mes, resultado):
if (mes == 1 or 3 or 5 or 7 or 8 or 10 or 12) and ... | false |
6eff63e0b9409caaa59773416df3adb8128c880e | anabeatrizzz/exercicios-pa-python | /exemplos_Aula_4/Aula_4_07.py | 306 | 4.28125 | 4 | matriz = [
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
]
print("Entre com o valor em cada posição da matriz: ")
for a in range(0, 3):
for b in range(0, 3):
matriz[a][b] = int(input(f"mat[{a}][{b}] = "))
print("\nExibindo os dados da matriz: ")
for a in range(0, 3):
for b in range(0, 3):
print(matriz[a][b]) | false |
dc8b6496247dbcd6c0e1af69d9f44880a4567dde | anabeatrizzz/exercicios-pa-python | /exercicios_do_caderno/exercicio01_do_caderno.py | 477 | 4.28125 | 4 | """Elabore um algoritmo que receba dois números e mostre na tela o resultado da soma, subtração, multiplicação
e divisão desses números"""
num1 = float(input("Digite um numero: "))
num2 = float(input("Digite outro numero: "))
print(f'A soma desses dois numeros é: {num1 + num2}')
print(f'A subtração desses dois numeros... | false |
7c5ce778fe8d215102fd05915c7d370faec8044b | anabeatrizzz/exercicios-pa-python | /exercicios_4/exercicios_4_03.py | 1,132 | 4.34375 | 4 | """Escreva um programa que leia uma matriz (3x5 ou 5x3) de 15 números inteiros e exiba ao final
a soma dos valores de cada linha que estão armazenados nesta matriz."""
matriz = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
valores = 0
for l in range(0, 3):
for c in range(0, 5):
matriz[l][c] = int(input(f'Linh... | false |
98af71260debdb1435845afefa1dc166ea4301d3 | anabeatrizzz/exercicios-pa-python | /exercicios_1/exercicios_1_10.py | 484 | 4.125 | 4 | # Escreva um programa que calcule a expressão lógica, sendo que o usuário deverá informar os valores (números inteiros)
# para as variáveis.
# ((X >= Y) AND (Z <=X)) OR ((X == W) AND (Y == Z)) OR (NOT(X != W))
X = int(input("Informe um valor para X: "))
Y = int(input("Informe um valor para Y: "))
Z = int(input("Inform... | false |
38aa843a83904894f86e1c447fcdb138b281a370 | luckeyme74/tuples | /tuples_practice.py | 2,274 | 4.40625 | 4 | # 12.1
# Create a tuple filled with 5 numbers assign it to the variable n
n = ('2', '4', '6', '8', '10')
# the ( ) are optional
# Create a tuple named tup using the tuple function
tup = tuple()
# Create a tuple named first and pass it your first name
first = tuple('Jenny',)
# print the first lette... | true |
abe6186dcccda09293dd055eb09cbb0c24de9a93 | saidaHF/InitiationToPython | /exercises/converter2.py | 1,031 | 4.15625 | 4 | #!/usr/bin/env python
# solution by cpascual@cells.es
"""
Exercise: converter2
---------------------
Same as exercise converter1 but this time you need to parse the header
to obtain the values for the gain and the offset from there.
Also, you cannot assume that the header has just 3 lines or that the order
of the i... | true |
e1be8a6391e8d69d9906b8712357a171952493c4 | mauricejenkins-00/Python-Challenge | /pypoll/main2.py | 2,486 | 4.34375 | 4 | #Import libraries os, and Csv
import os
import csv
#Give canidates a variable to add the canidates and vote count to
candidates = {}
#election_csv is a variable that calls for the election data file in the resources folder
election_csv = os.path.join('.','Resources','election_data.csv')
#With statement opens... | true |
1c4c1304afa4fb8619848032eafba93110c4eb19 | jackmar31/week_2 | /parkingGarage/# Best Case: O(n) - Linear.py | 901 | 4.28125 | 4 | # Best Case: O(n) - Linear
def swap(i,j, array):
array[i],array[j] = array[j],array[i]
def bubbleSort(array):
# initially define isSorted as False so we can
# execute the while loop
isSorted = False
# while the list is not sorted, repeat the following:
while not isSorted:
# assume t... | true |
9c3a48801a65a13415cb5f4ff705facfb5bf2469 | cleitonPiccini/calculo_numerico | /metodo_newton.py | 797 | 4.34375 | 4 | #python 3
#Cleiton Piccini
#Algoritmo do metódo de Newton para encontrar raizes de funções.
import math
# Função
def funcao (x):
#x = (x / (math.e**(10*x))) - (1 / (math.e ** 5))
x = math.cos(50 * x + 10) - math.sin(50 * x - 10)
return x
# Derivada da Função
def derivada (x):
#x = (math.e**(-10*x)) *... | false |
06ea29eec33fe7ef9b2254a7b3fcd28b33bd6a60 | simgroenewald/StringDataType | /Manipulation.py | 869 | 4.34375 | 4 | # Compulsory Task 3
strManip = input("Please enter a sentence:")#Declaring the variable
StrLength = len(strManip)#Storing the length of the sentence as a variable
print(StrLength)# Printing the length of the sentence
LastLetter = strManip[StrLength-1:StrLength] #Storing the last letter of the lentence as a variable... | true |
3695661c954293f8c27fd7f1ea75e22e4003c377 | ulicqeldroma/MLPython | /basic_slicing.py | 696 | 4.15625 | 4 | import numpy as np
x = np.array([5, 6, 7, 8, 9])
print x[1:7:2]
"""Negative k makes stepping go toward smaller indices. Negative i and j are
interpreted as n + i and n + j where n is the number of elements in the
corresponding dimension."""
print x[-2:5]
print x[-1:1:-1]
"""If n is the number of items in the dimens... | true |
5a30f84ddc0999fc6ad5f6c964eb18447ffba7a3 | tenedor/SourceFlowPlotter | /tracers/test.py | 401 | 4.15625 | 4 | def double(x):
x *= 2
return x
def triple(x):
x += double(x)
return x
def recursive_1(x, i):
if i > 0:
x += i
x = recursive_2(x, i - 1)
return x
def recursive_2(x, i):
if i > 0:
x *= i
x = recursive_1(x, i - 1)
return x
def recursive_start(n):
m = recursive_1(1, n)
print m
if __... | false |
da2a27e14b2e98b13c25310fea2ea62af5f9e07c | JIANG09/LearnPythonTheHardWay | /ex33practice.py | 354 | 4.125 | 4 | def while_function(x, j):
i = 0
numbers = []
while i < j:
print(f"At the top i is {i}")
numbers.append(i)
i = i + x
print("Numbers now: ", numbers)
print(f"At the bottom i is {i}")
return numbers
numbers_1 = while_function(7, 10)
print("The numbers: ")
for ... | true |
620a67cbe340ace45f2db953d28b110f9fb0ac3d | timwilson/base30 | /base30/base30.py | 2,528 | 4.4375 | 4 | #!/usr/bin/env python3
"""
This module provides two functions: dec_to_b30 and b30_to_dec
The purpose of those functions is to convert between regular decimal
numbers and a version of a base30 system that excludes vowels and other
letters than may be mistaken for numerals. This is useful for encoding large
numbers in... | true |
400b14f32ee96af63ee8fbf4c750443ec51c1532 | hamk-webdev-intip19x6/petrikuittinen_assignments | /lesson_python_basics/side_effect.py | 629 | 4.375 | 4 | # WARNING! DO NOT PROGRAM LIKE THIS
# THE FOLLOWING FUNCTION HAS AN UNDOCUMENTED SIDE EFFECT
def mymax(a):
"""Return the item of list a, which has the highest value"""
a.sort() # sort in ascending order
return a[-1] # return the last item
a = [1, 10, 5, -3, 7]
print(mymax(a))
print(a) # a is sorted as ... | true |
cfb4d5c4bfeeb729969a5cd3169d09ee8c63e079 | hamk-webdev-intip19x6/petrikuittinen_assignments | /lesson_python_file_and_web/typing_hints.py | 779 | 4.125 | 4 | from typing import List, Dict, Tuple, Union, Any
def square(x: float) -> float:
return x*x
def is_negative(x: float) -> bool:
return x < 0
def print_many(s: Union[str, int, float], n: int = 5) -> None:
for i in range(n):
print(s)
def multiply_list(a: List[float], n: float) -> List[float]:
re... | false |
047fe4c0903be5318f414cff2ce4fbb295768f58 | hamk-webdev-intip19x6/petrikuittinen_assignments | /lesson_python_file_and_web/ask_float_safely.py | 533 | 4.15625 | 4 | def ask_float(question):
"""display the question string and wait for standard input
keep asking the question until user provides a valid floating
point number. Return the number"""
while True:
try:
return float(input(question))
except ValueError:
print("Please giv... | true |
8b3498cef391bc920ca5d9db2966bd3cbe71bcfd | hamk-webdev-intip19x6/petrikuittinen_assignments | /lesson_python_basics/closure.py | 322 | 4.21875 | 4 | # Example of a closure
def make_multiplier(x): # outer / enclosing function
def multiplier(y): # inner / nested function
return x*y
return multiplier
mul10 = make_multiplier(10) # mul is the closure function
print(mul10(5)) # 50
print(mul10(10)) #100
mul2 = make_multiplier(2)
print(mul2(10)) # 2... | true |
f162f9720be4566474fcd6e09731c5f43a727059 | sterlingb1204/EOC2 | /HW4.py | 998 | 4.5 | 4 | #-- Part 2: Python and SQLite (25 Points)
#--
#-- Take your Homework 1, Part 1 module and re-write
#-- it to so that it queries against the sqlite3
#-- babynames database instead.
#--
#-- The beauty of this approach is that, because
#-- your original code was in a module, you can
#-- change how the module fulfills the... | true |
e37de75b4b15d71da1d709b52889d49cbef78bd8 | volodiny71299/Right-Angled-Triangle | /02_number_checker.py | 1,010 | 4.3125 | 4 | # number checker
# check for valid numbers in a certain range of values
# allow float
def num_check(question, error, low, high, num_type):
valid = False
while not valid:
try:
response = num_type(input(question))
if low < response < high:
return response
... | true |
2571fb011cab5aed53fa2d7a10bb66470982bbf9 | volodiny71299/Right-Angled-Triangle | /01_ask_what_calculate.py | 962 | 4.40625 | 4 | # ask user what they are trying to calculate (right angled triangle)
valid_calculations = [
["angle", "an"],
["short side", "ss"],
["hypotenuse", "h"],
["area", "ar"],
["perimeter", "p"]
]
calculation_ok = ""
calculation = ""
for item in range(0,3):
# ask user for what they are trying to cal... | true |
8f24a35c4ff8b1ebbb4e476e7ac6dd74d4a652dc | pjarcher913/python-challenges | /src/fibonacci/module.py | 1,020 | 4.15625 | 4 | # Created by Patrick Archer on 29 July 2019 at 9:00 AM.
# Copyright to the above author. All rights reserved.
"""
@file asks the user how many Fibonacci numbers to generate and then generates them
"""
"""========== IMPORTS =========="""
"""========== GLOBAL VARS =========="""
"""========== MAIN() =========="""
... | true |
cfc949e732347cebc4b073cc891826075cb9520e | julianvalerio/ExemploPython | /Listas/Listas.py | 1,817 | 4.1875 | 4 | import copy
#lista de listas ou matrizes
notas = [['nota1', 'nota2', 'nota3'], [7, 8.2, 6]]
print(notas[0][1],notas[1][1])
#uso do for#
nomes = ['julian', 'rodrigues', 'valerio']
#for i in ['julian', 'rodrigues', 'valerio']
for i in range(len(nomes)):
print('Indice '+str(i)+ ' descrição ' + nomes[i])
#dessa f... | false |
c4cccf258eab393d27882e0e80b006df10784546 | phu-n-tran/LeetCode | /monthlyChallenge/2020-05(mayChallenge)/5_02_jewelsAndStones.py | 1,349 | 4.15625 | 4 | # --------------------------------------------------------------------------
# Name: Jewels and Stones
# Author(s): Phu Tran
# --------------------------------------------------------------------------
"""
You're given strings J representing the types of stones that are jewels,
and S representing the s... | true |
0482288b53ef2ee63980d4d388ae8dc7d9b6ae7f | phu-n-tran/LeetCode | /monthlyChallenge/2020-06(juneChallenge)/6_29_UniquePaths.py | 2,214 | 4.5 | 4 | # --------------------------------------------------------------------------
# Name: Unique Paths
# Author(s): Phu Tran
# --------------------------------------------------------------------------
"""
A robot is located at the top-left corner of a m x n grid
(marked 'Start' in the diagram below).
... | true |
68cb6a414b42c04874e1a204a7bd2ffd16f3dba9 | phu-n-tran/LeetCode | /monthlyChallenge/2020-07(julychallenge)/7_02_BTLevelOrderTraversal2.py | 2,801 | 4.21875 | 4 | # --------------------------------------------------------------------------
# Name: Binary Tree Level Order Traversal II
# Author(s): Phu Tran
# --------------------------------------------------------------------------
"""
Given a binary tree, return the bottom-up level order traversal of its
nodes'... | true |
5b5cda38002926df07c4809361992ba67ed62c2a | phu-n-tran/LeetCode | /monthlyChallenge/2020-06(juneChallenge)/6_18_HIndex_V2.py | 2,119 | 4.25 | 4 | # --------------------------------------------------------------------------
# Name: H-Index II
# Author(s): Phu Tran
# --------------------------------------------------------------------------
"""
Given an array of citations sorted in ascending order (each citation is
a non-negative integer) of a re... | true |
862417cfb9e359619f04610c0a1ee27492e43ddc | phu-n-tran/LeetCode | /monthlyChallenge/2020-06(juneChallenge)/6_13_LargestDivisibleSubset.py | 2,169 | 4.15625 | 4 | # --------------------------------------------------------------------------
# Name: Largest Divisible Subset
# Author(s): Phu Tran
# --------------------------------------------------------------------------
"""
Given a set of distinct positive integers, find the largest subset such
that every pair (S... | true |
cb8cb4431ddc8182c23adff86c9e3f1b21d1f63c | mily-chan/scripts-python | /calculadora.py | 500 | 4.1875 | 4 | def calculadora(n1, n2, operador):
if operador == '+':
print( n1 + n2)
elif operador == '-':
print( n1 - n2)
elif operador == '*':
print(n1 * n2)
else:
print( n1 / n2)
n1 = int(input("Digite um número: "))
while True:
operador= input("Digite o operador válido (+, -, *... | false |
890540caa1d454ce7c0d7dd0944d8fde13ed3193 | aernesto24/Python-el-practices | /Basic/Python-university/Functions/ArithmeticTables/arithmeticTables.py | 2,650 | 4.46875 | 4 | """This software shows the arithmetic tables based on the input the user provides, it can show:
multiplication table, sum tablet, etc. """
#Function to provide the multiplication table from 0 to 10
def multiplicationTables(LIMIT, number):
counter = 0
print("Tabla de multiplicar de " + str(number))
for... | true |
15a69ecb35cec652121faaf582966f25ea7dad8b | gaoyangthu/leetcode-solutions | /004-median-of-two-sorted-arrays/median_of_two_sorted_arrays.py | 1,815 | 4.28125 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
There are two sorted arrays nums1 and nums2 of size m and n respectively.
Find the median of the two sorted arrays.
The overall run time complexity should be O(log (m+n)).
Example 1:
nums1 = [1, 3]
nums2 = [2]
The median is 2.0
Example 2:
nums1 = [1, 2]
nums2 = [3... | true |
3153c6df49836cc64a8b4cf94a57c9bcf1b30927 | dgibbs11a2b/Module-9-Lab-Assignment | /Problem2NumList10.py | 711 | 4.1875 | 4 | #----------------------------------------
#David Gibbs
#March 10, 2020
#
#This program will use a while loop to append the current
#value of the current counter variable to the list and
#then increase the counter by 1. The while loop then stops
#once the counter value is greater than 10.
#------------------------------... | true |
6efd4db15c5bd72c01c320701715f3845ca25b4c | wanglun0318/pythonProject | /register.py | 1,587 | 4.15625 | 4 | # 注册新用户
def new_user():
username = input("请输入用户名:")
while username in accounts:
username = input("此用户名已经被使用请重新输入:")
else:
accounts[username] = input("请输入你的密码:")
print("注册成功,赶紧试试登录吧!")
# 用户登录
def old_user():
username = input("请输入用户名:")
while username not in accounts:
p... | false |
4764110d5c381f3322608d31b9498f87139a3d8d | wanglun0318/pythonProject | /mageic/iteratortest.py | 1,071 | 4.1875 | 4 | """
迭代是重复反馈过程的活动,其目的通常是为了接近并到达所需的目标或结果。每一次对过程的重复
被称为异常“迭代”,而每一次迭代得到的结果会被用来作为下一次的迭代的初始值
迭代器就是实现了__next__()方法的对象,用于遍历容器中的数据
__iter__(self) 定义当迭代容器中的元素的行为
__next__() 让对象可以通过next(实例名)访问下一个元素
"""
import datetime as dt
class LeapYear:
def __init__(self):
self.now = dt.date.today().year # 获取当前年份
def... | false |
84cce619cee66ec68eb13425e3d6c11ef2cb6ec1 | JonasKanuhsa/Python | /Survey/Survey.py | 573 | 4.1875 | 4 | '''
Make a program that can take survey information.
@author: Jonas Kanuhsa
'''
question = "What is your name?"
name = input("What is your name")
print(name)
response = "What is your favorite color?"
color = input("What is your favorite color?")
print(color)
var = = "What city did you grow up in?"
city = inp... | true |
f0345277450b059093e85d4a310eddb279d501ea | MistyLeo12/Learning | /Python/double_linked.py | 1,967 | 4.21875 | 4 |
class Node(object):
def __init__(self, data = None):
self.data = data
self.next = None
self.prev = None
class doublyLinkedList(object):
def __init__(self):
self.root = Node()
self.size = 0
def get_size(self):
current = self.root
counter = 0
... | true |
da11b4c7fdf486d72914db90af4b471bb91709bf | ErickMwazonga/learn_python | /others/mothly_rate.py | 1,097 | 4.1875 | 4 | import locale
# set the locale for use in currency formatting
result = locale.setlocale(locale.LC_ALL, '')
if result == 'C':
locale.setlocale(locale.LC_ALL, 'en_US')
# display a welcome message
print("Welcome to the Future Value Calculator")
# print()
choice = 'Y'
while choice.lower() == 'y':
# get input from the ... | true |
c75f229bf209fb251f09cac3f2c7746a8c834007 | 09-03/Infa | /Exam/UPD/7.py | 591 | 4.125 | 4 | """
Реализовать программу, способную находить наибольший и наименьший элемент в
списке и менять их местами. Список задается с клавиатуры
"""
list = [int(i) for i in input("Введите список чисел через пробел: ").split()]
max_value = max(list)
min_value = min(list)
for n in range(len(list)):
if list[n] == min_value:
... | false |
85c7222686015f91f512afc68fa49a2d3689f67a | edithclaryn/march | /hobbies.py | 251 | 4.28125 | 4 | """Create a for loop that prompts the user for a hobby 3 times, then appends each one to hobbies."""
hobbies = []
# Add your code below!
for i in range(3):
hobby = input("Enter your hobby: ")
print (hobby)
hobbies.append(hobby)
i += 1 | true |
0a2280f39b0f3bcc6ed11af2df1001813cc342b9 | edithclaryn/march | /battleship.py | 945 | 4.21875 | 4 | """Create a 5 x 5 grid initialized to all 'O's and store it in board.
Use range() to loop 5 times.
Inside the loop, .append() a list containing 5 "O"s to board.
Note that these are capital letter "O" and not zeros."""
board = []
for i in range(0,5):
board.append(["O"]*5)
print (board)
#Use the print command to displa... | true |
291b9fcbb8a201634e37bc6ffded8ca809404b6e | nahymeee/comp110-21f-workspace | /exercises/ex05/utils.py | 1,120 | 4.125 | 4 | """List utility functions part 2."""
__author__ = "730330561"
def only_evens(first: list[int]) -> list[int]:
"""Gives back a list of only the even numbers."""
i: int = 0
evens: list[int] = []
while i < len(first):
if first[i] % 2 == 0:
evens.append(first[i])
i += 1
ret... | true |
a5d9456a0bfc97f70d8555b4c9ce4f34c543edb3 | mucheniski/python-exemplos | /exercicios/operacao-matematica.py | 477 | 4.125 | 4 | # Escreva um programa que receba dois números e um sinal, e faça a operação matemática definida pelo sinal.
n1 = int(input("Digite o primeiro número: "))
n2 = int(input("Digite o segundo número: "))
operacao = input("Digite o sinal da operação: ")
calculo = 0
if operacao == "+":
calculo = n1 + n2
elif o... | false |
1f23bfe9500c5f4405f3f1ad69e472dd5a755a05 | NickPerez06/Python-miniProjects | /rpsls.py | 1,802 | 4.34375 | 4 | '''
This mini project will create the game rock, paper, scissors,
lizard, spock for your enjoyment.
Author: Nicholas Perez
'''
import random
def name_to_number(name):
'''converts string name to number for rpsls'''
number = 0
if( name == "rock" ):
number = 0
return number
elif ( name == "Spock" ... | true |
29bcc76645fbf2a3133fe36f2799a53ac5de279b | MicahJank/Intro-Python-I | /src/16_stretch.py | 1,893 | 4.3125 | 4 | # 3. Write a program to determine if a number, given on the command line, is prime.
# 1. How can you optimize this program?
# 2. Implement [The Sieve of
# Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes), one
# of the oldest algorithms known (ca. 200 BC).
import sys
import math
#... | true |
99bfc65a4a0cffca30b37ff18a129edd81b8b359 | kom50/PythonProject | /Simple Code/Factorial.py | 369 | 4.21875 | 4 | # find factorial using loop
def fact(num): # 1st function
f = 1
for i in range(1, num + 1):
f *= i
return f
# find factorial using recursive function
def fact1(num): # 2nd function
if num == 1:
return 1
return num * fact1(num - 1)
# 1st function
print('Factorial : ', fact(4))... | true |
6aa47cd97da9f307b127f9ba7df2b81325f5674b | tlkoo1/Lok.Koo-Chatbot | /ChatBotTemplate.py | 569 | 4.25 | 4 | #open text document stop-words.txt
file = open("stop-words.txt")
stopwords = file.readlines()
#function going through all stopwords
def removeStopwords(firstWord):
for word in stopwords:
next = word.strip()
firstWord = firstWord.replace(" " + next + " ", " " )
return firstWord
#while inpu... | true |
ef6c8b1057839016de9dd2b51ffd879435043270 | martinaobrien/pands-problem-sets | /sumupto.py | 1,128 | 4.28125 | 4 | # Martina O'Brien: 24 - 02 - 2019
# Problem Set Programming and Scripting Code 1
#Calculate the sum of all factorials of positive integer
# Input variable needed for calculation
# Int method returns an integer as per python programming
# input "Enter Number" will be visible on the user interface
# setting up va... | true |
0debb74096cb6fb8c78922e17677242b87b884d9 | rmaur012/GraphicalSequenceAlgorithm | /GraphicalSequenceAlgorithm.py | 2,392 | 4.3125 | 4 | #Setting up the sequence list
try:
sizeOfSeq = raw_input("How many vetices are there? ")
sizeOfSeq = int(sizeOfSeq)
index = 0
sequence = [None]*sizeOfSeq
except ValueError:
print 'A Non-Numerical Value Was Entered. Please Try Again And Enter With A Numerical Value.'
quit(... | true |
adab3d9ccab42569ced54c6fd3551335a7b34969 | hsrwrobotics/Robotics_club_lectures | /Week 2/Functions/func_echo.py | 1,497 | 4.375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Oct 21 16:15:36 2019
HSRW Robotics
@author: mtc-20
"""
# A function definition starts with the keyword def followed the function
# name which can be anything starting with an alphabet, preferably in
# lowercase followed by a colon {:}. The body(the block of code to... | true |
b746788b2a554acf3ce050acede7af3fb3ae19d3 | danilokevin/Lote-1---Python | /Lote 1/Ex24.py | 329 | 4.34375 | 4 | # Objetivo: Receba um valor inteiro. Verifique e mostre se é divisível por 2 e 3.
A=int(input("Digite um número: "))
if(A%6)==0:
print("SIM! É DIVISÍVEL POR 2 E 3")
elif(A%3)==0:
print("DIVISÍVEL SOMENTE POR 3")
elif(A%2)==0:
print("DIVISÍVEL SOMENTE POR 2")
else:
print("NÃO É DIVISÍVEL POR 2 OU 3") | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.