Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute Python-3 Online

def nbyntable(n):
  for row in range(1,n+1):
    for col in range(1,n+1):
      print((col*row),end="")
    print()
nbyntable(9)

code5

import random
import string

#  Params
# =======================
URL = "https://hitfile.net/4rwrzy1/Outcast.2019.WEBRip-1XBET.avi.html"
IS_SERIAL = 1
SERIES_IN_SERIAL = 10
SEASONS_IN_SERIAL = 1
LINKS_NUMBER = 1
# =======================

input_url = URL.split("/")

if IS_SERIAL:
    for s in range(1, SEASONS_IN_SERIAL + 1):
        for k in range(1, SERIES_IN_SERIAL + 1):
            print()
            for i in range(LINKS_NUMBER):
                result = input_url[:]
                tmp = result[-1].split(".")
                tmp[-3] += ".s01e%s" % ((str(k) if k > 10 else "0%s" % k))
                result[-1] = ".".join(tmp)
                result[3] = ''.join(random.choices(string.ascii_lowercase + string.digits, k=len(result[3])))
                print("/".join(result))
else:
    for i in range(LINKS_NUMBER):
        result = input_url[:]
        result[3] = ''.join(random.choices(string.ascii_lowercase + string.digits, k=len(result[3])))
        print("/".join(result))

Zadatak 03

# zadatak od korisnika prihvaća riječi sve dok se neka riječ ne unese dva puta
# zaredom i dodaje ih u listu rijeci[] nakon toga stvara riječnik rijecnik{} 
# čiji su članovi parovi riječi i njihov broj ponavljanja
# napomena: prije pokretanja programa unijeti riječi u STDIN u zasebne retke

# unos riječi
print ('Unosi riječi: ')
rijeci = []
rijec = ''
while True: 
    rijec = input('')
    # print(rijec)
    rijeci.append(rijec[:-1])
    if len(rijeci) > 1 and (rijeci[len(rijeci) - 1] == rijeci[len(rijeci) - 2]):
        break
print(rijeci)
print('----------')

#stvaranje rječnika
rjecnik = {}
for r in rijeci:
    rjecnik[r] = rjecnik.get(r, 0) + 1
print(rjecnik)
print('----------')

Introduction to Python (Amateur)

# CONDITIONALS -------------
# The if, else and elif statements are used to perform different
# actions based off of conditions
# Comparison Operators : ==, !=, >, <, >=, <=

# The if statement will execute code if a condition is met
# White space is used to group blocks of code in Python
# Use the same number of proceeding spaces for blocks of code

age = 30
if age > 16 :
    print('You are old enough to drive')

# Use an if statement if you want to execute different code regardless
# of whether the condition ws met or not

if age > 16 :
    print('You are old enough to drive')
else :
    print('You are not old enough to drive')

# If you want to check for multiple conditions use elif
# If the first matches it won't check other conditions that follow

if age >= 21 :
    print('You are old enough to drive a tractor trailer')
elif age >= 16:
    print('You are old enough to drive a car')
else :
    print('You are not old enough to drive')

# You can combine conditions with logical operators
# Logical Operators : and, or, not

if ((age >= 1) and (age <= 18)):
    print("You get a birthday party")
elif (age == 21) or (age >= 65):
    print("You get a birthday party")
elif not(age == 30):
    print("You don't get a birthday party")
else:
    print("You get a birthday party yeah")

# FOR LOOPS -------------
# Allows you to perform an action a set number of times
# Range performs the action 10 times 0 - 9
for x in range(0, 10):
    print(x , ' ', end="")

print('\n')

# You can use for loops to cycle through a list
grocery_list = ['Juice', 'Tomatoes', 'Potatoes', 'Bananas']

for y in grocery_list:
    print(y)

# You can also define a list of numbers to cycle through
for x in [2,4,6,8,10]:
    print(x)

# You can double up for loops to cycle through lists
num_list =[[1,2,3],[10,20,30],[100,200,300]];

for x in range(0,3):
    for y in range(0,3):
        print(num_list[x][y])

# WHILE LOOPS -------------
# While loops are used when you don't know ahead of time how many
# times you'll have to loop
random_num = random.randrange(0,100)

while (random_num != 15):
    print(random_num)
    random_num = random.randrange(0,100)

# An iterator for a while loop is defined before the loop
i = 0;
while (i <= 20):
    if(i%2 == 0):
        print(i)
    elif(i == 9):
        # Forces the loop to end all together
        break
    else:
        # Shorthand for i = i + 1
        i += 1
        # Skips to the next iteration of the loop
        continue

    i += 1

# FUNCTIONS -------------
# Functions allow you to reuse and write readable code
# Type def (define), function name and parameters it receives
# return is used to return something to the caller of the function
def addNumbers(fNum, sNum):
    sumNum = fNum + sNum
    return sumNum

print(addNumbers(1, 4))

# Can't get the value of rNum because it was created in a function
# It is said to be out of scope
# print(sumNum)

# If you define a variable outside of the function it works every place
newNum = 0;
def subNumbers(fNum, sNum):
    newNum = fNum - sNum
    return newNum

print(subNumbers(1, 4))

# USER INPUT -------------
print('What is your name?')

# Stores everything typed up until ENTER
name = sys.stdin.readline()

print('Hello', name)

# STRINGS -------------
# A string is a series of characters surrounded by ' or "
long_string = "I'll catch you if you fall - The Floor"

# Retrieve the first 4 characters
print(long_string[0:4])

# Get the last 5 characters
print(long_string[-5:])

# Everything up to the last 5 characters
print(long_string[:-5])

# Concatenate part of a string to another
print(long_string[:4] + " be there")

# String formatting
print("%c is my %s letter and my number %d number is %.5f" % ('X', 'favorite', 1, .14))

# Capitalizes the first letter
print(long_string.capitalize())

# Returns the index of the start of the string
# case sensitive
print(long_string.find("Floor"))

# Returns true if all characters are letters ' isn't a letter
print(long_string.isalpha())

# Returns true if all characters are numbers
print(long_string.isalnum())

# Returns the string length
print(len(long_string))

# Replace the first word with the second (Add a number to replace more)
print(long_string.replace("Floor", "Ground"))

# Remove white space from front and end
print(long_string.strip())

# Split a string into a list based on the delimiter you provide
quote_list = long_string.split(" ")
print(quote_list)

Introduction to Python Programming (Beginner)

# import is used to make specialty functions available
# These are called modules
import random
import sys
import os

# Hello world is just one line of code
# print() outputs data to the screen
print("Hello World")

'''
This is a multi-line comment
'''

# A variable is a place to store values
# Its name is like a label for that value
name = "Derek"
print(name)

# A variable name can contain letters, numbers, or _
# but can't start with a number

# There are 5 data types Numbers, Strings, List, Tuple, Dictionary
# You can store any of them in the same variable

name = 15
print(name)

# The arithmetic operators +, -, *, /, %, **, //
# ** Exponential calculation
# // Floor Division
print("5 + 2 =", 5+2)
print("5 - 2 =", 5-2)
print("5 * 2 =", 5*2)
print("5 / 2 =", 5/2)
print("5 % 2 =", 5%2)
print("5 ** 2 =", 5**2)
print("5 // 2 =", 5//2)

# Order of Operation states * and / is performed before + and -

print("1 + 2 - 3 * 2 =", 1 + 2 - 3 * 2)
print("(1 + 2 - 3) * 2 =", (1 + 2 - 3) * 2)

# A string is a string of characters surrounded by " or '
# If you must use a " or ' between the same quote escape it with \
quote = "\"Always remember your unique,"

# A multi-line quote
multi_line_quote = ''' just
like everyone else" '''

print(quote + multi_line_quote)

# To embed a string in output use %s
print("%s %s %s" % ('I like the quote', quote, multi_line_quote))

# To keep from printing newlines use end=""
print("I don't like ",end="")
print("newlines")

# You can print a string multiple times with *
print('\n' * 5)

# LISTS -------------
# A list allows you to create a list of values and manipulate them
# Each value has an index with the first one starting at 0

grocery_list = ['Juice', 'Tomatoes', 'Potatoes', 'Bananas']
print('The first item is', grocery_list[1])

# You can change the value stored in a list box
grocery_list[0] = "Green Juice"
print(grocery_list)

# You can get a subset of the list with [min:up to but not including max]

print(grocery_list[1:3])

# You can put any data type in a a list including a list
other_events = ['Wash Car', 'Pick up Kids', 'Cash Check']
to_do_list = [other_events, grocery_list]

print(to_do_list)

# Get the second item in the second list (Boxes inside of boxes)
print(to_do_list[1][1])

# You add values using append
grocery_list.append('onions')
print(to_do_list)

# Insert item at given index
grocery_list.insert(1, "Pickle")

# Remove item from list
grocery_list.remove("Pickle")

# Sorts items in list
grocery_list.sort()

# Reverse sort items in list
grocery_list.reverse()

# del deletes an item at specified index
del grocery_list[4]
print(to_do_list)

# We can combine lists with a +
to_do_list = other_events + grocery_list
print(to_do_list)

# Get length of list
print(len(to_do_list))

# Get the max item in list
print(max(to_do_list))

# Get the minimum item in list
print(min(to_do_list))

# TUPLES -------------
# Values in a tuple can't change like lists

pi_tuple = (3, 1, 4, 1, 5, 9)

# Convert tuple into a list
new_tuple = list(pi_tuple)

# Convert a list into a tuple
# new_list = tuple(grocery_list)

# tuples also have len(tuple), min(tuple) and max(tuple)

# DICTIONARY or MAP -------------
# Made up of values with a unique key for each value
# Similar to lists, but you can't join dicts with a +

super_villains = {'Fiddler' : 'Isaac Bowin',
                  'Captain Cold' : 'Leonard Snart',
                  'Weather Wizard' : 'Mark Mardon',
                  'Mirror Master' : 'Sam Scudder',
                  'Pied Piper' : 'Thomas Peterson'}

print(super_villains['Captain Cold'])

# Delete an entry
del super_villains['Fiddler']
print(super_villains)

# Replace a value
super_villains['Pied Piper'] = 'Hartley Rathaway'

# Print the number of items in the dictionary
print(len(super_villains))

# Get the value for the passed key
print(super_villains.get("Pied Piper"))

# Get a list of dictionary keys
print(super_villains.keys())

# Get a list of dictionary values
print(super_villains.values())

Execute Python-3 Online

class FourSum:
    def __init__(self,inp,target):
        self.inp = inp
        self.inp.sort()
        self.target = target
        self.tmp_solutions = set([])

    def recurse(self,tmp_sol,candidates):
        if len(tmp_sol)==4 and sum(tmp_sol)==self.target:
            tmp_sol.sort()
            self.solutions.add(tuple(tmp_sol))
        elif len(tmp_sol)>4:
            return None
        else:
            for i,num in enumerate(self.inp):
                j = i
                while self.inp[j]==self.inp[i]:
                    j+=1
                    if j>=len(self.inp):
                        break
                self.recurse(tmp_sol+[num],candidates[j:])

inp = [1, 0, -1, 0, -2, 2]
target = 0

s = FourSum(inp,target)
s.recurse([],s.inp)

Python Basics

# import is used to make specialty functions available
# These are called modules
import random
import sys
import os

# Hello world is just one line of code
# print() outputs data to the screen
print("Hello World")

'''
This is a multi-line comment
'''

# A variable is a place to store values
# Its name is like a label for that value
name = "Derek"
print(name)

# A variable name can contain letters, numbers, or _
# but can't start with a number

# There are 5 data types Numbers, Strings, List, Tuple, Dictionary
# You can store any of them in the same variable

name = 15
print(name)

# The arithmetic operators +, -, *, /, %, **, //
# ** Exponential calculation
# // Floor Division
print("5 + 2 =", 5+2)
print("5 - 2 =", 5-2)
print("5 * 2 =", 5*2)
print("5 / 2 =", 5/2)
print("5 % 2 =", 5%2)
print("5 ** 2 =", 5**2)
print("5 // 2 =", 5//2)

# Order of Operation states * and / is performed before + and -

print("1 + 2 - 3 * 2 =", 1 + 2 - 3 * 2)
print("(1 + 2 - 3) * 2 =", (1 + 2 - 3) * 2)

# A string is a string of characters surrounded by " or '
# If you must use a " or ' between the same quote escape it with \
quote = "\"Always remember your unique,"

# A multi-line quote
multi_line_quote = ''' just
like everyone else" '''

print(quote + multi_line_quote)

# To embed a string in output use %s
print("%s %s %s" % ('I like the quote', quote, multi_line_quote))

# To keep from printing newlines use end=""
print("I don't like ",end="")
print("newlines")

# You can print a string multiple times with *
print('\n' * 5)

first

# -*- coding: utf-8 -*-
n, q = input().split()
n = int(n)
q = int(q)

while n != 0 and q != 0:
    
    vetor = [None] * n
    for i in range(len(vetor)):
        vetor[i] = (vetor[i])
            
        
    q2 = int(input())
    for i in range(len(vetor)):
        if vetor[i] == q2:
            print("CASE# 1:\n" % q % " found at " % i)
        

scanlan

import socket
class LANScanner():
    def_init_(self):
        self.hostname = socket.gethostname()
        self.networkIP = socket.gethostbyname(self.hostname)
        self.networkPrefix self.networkIP.split(",")
        del(self.networkPrefix[-1])
        self.networkPrefix =",".join(self.networkPrefix)
        
def checkIP(self, currentIP):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREM)
    s.settimeout(0.01)
    if not s.connect_ex((currentIP,135)):
        s.close()
        return 1
        else:
            s.close()
            
def startScan(self):
    print('your IP:%s'%(self.networkIP))
    print('scanning lan network.....')
    for ip in range(1,255):
        currentIP = self.networkPrefix + '.' + str(ip)
        if self.checkIP(currentIP):
            print('%s \t- %s' %(currentIP, scoketgetfqdn(currentIP)))
            print('scan finished')
        if__name__ == '__main__':
            slan LANScanner()
            
            s
            sLan.startScan()
        

Execute Python-3 Online

# Hello World program in Python
    
print ("Hello World!");

Previous 1 ... 5 6 7 8 9 10 11 ... 204 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.