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

maths

def pair1 (x)
    return (x%2==0)
print (pair1(4))

test

# Hello World program in Python
import matplotlib.pyplot as plt
import numpy as np
data1 = 'data1.txt'
box1 = np.loadtxt(data1, skiprows =1)
print "Hello World!\n"

Python

# Hello World program in Python
    
print "Hello World!\n"

Onliner

# Hello World program in Python

import random

print(random.randrange(1000,4999))

anand

# Hello World program in Python
    
print "Hello World!\n"

Execute Python Online

list1 = [10,"rahul",'z']  
print "Elements of List1 are: "  
print list1  
list1.append(10.45)  # Appending the list.
print "\nList1 after appending: "  
print list1  

list2 = [20,"dinesh",10,1354,'kapil']
print "\nElements of List2 are: "
print list2
print "\nMin value of list1: ", min(list1)	#Returns the minimum value from the list given.
print "Max value of list 1:", max(list1)	#Returns the largest value from the given list.
print "length of list 1:", len(list1)
print "length of list2:", len(list2)  #Returns number of elements in a list.
print cmp(list1,list2)	              #Compares the two list.

print list2.index(1354)	#Returns the index value of the object.
print list1.index('rahul')
list2.count('kapil')	#It returns the number of times an object is repeated in list.
"""pop()/pop(index)    #Returns the last object or the specified indexed object. It removes the popped                        object.
insert(index,object)	#Insert an object at the given index.
extend(sequence)	#It adds the sequence to existing list.
remove(object)	#It removes the object from the given List.
reverse()	#Reverse the position of all the elements of a list.
sort()	#It is used to sort the elements of the List.

list1=[101,981,'abcd','xyz','m']  
list2=['aman','shekhar',100.45,98.2]  
list3=[101,981,'abcd','xyz','m']  
print cmp(list1,list2)  
print cmp(list2,list1)  
print cmp(list3,list1)  #list(sequence) #Takes sequence types and converts them to lists."""




菜鳥教程練習:Python一百例

# -*- coding: utf-8 -*-
# 1 1 2 3 5 8 13 21 34 55 89
def Fib(n):
    a, b = 0, 1 # a 是第零項; b 是第一項
    while n:
        a, b = b, a + b
        n -= 1
        print a     #放在迴圈內就會列出所有數值
    #print a         #放在迴圈就只顯示那個最終加成的數值
    # 做第一次之後, a 成為第一項;所以做四次,a 就是第四項
Fib(4)

def printme(str): print str; return;

def printme(str):
print str;
return;

Execute Python Online

# Hello World program in Python
    
print "SHit can this work too"
print ("What the fuck is really happening")

1111

x = int (input ("Enter first num"))
y = int (input ("Enter second num"))
z = x ** y
print ("Result -", z)

Advertisements
Loading...

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