Posts tonen met het label python. Alle posts tonen
Posts tonen met het label python. Alle posts tonen

zondag 6 februari 2022

SimpleHTTPServer

python3 -m http.server 8080

1. go to the relevant directory in your terminal and type this command
2. type ip and find the 192.168. etc.
3. go to the other computer and type into the browser: 192.168.x.x:8080


zaterdag 22 juli 2017

Polymorphism and inheritance

Inheritance refers to using the structure and behaviour of a super class in a subclass.
Polymorphism refers to changing the behaviour of a super class in the subclass.
https://stackoverflow.com/questions/6308178/what-is-the-main-difference-between-inheritance-and-polymorphism

vrijdag 22 januari 2016

Counting the number of characters in a string

# Counting the total number of the letter "a" in a string.
 
x = ("What shall we do with the drunken sailor?")

i = "a"
print (x.count(i, 0, 40))

Result:
3

Print a line in reversal

# print the text in reversal.
import sys
x = ("What shall we do with the drunken sailor?")

y = (len(x)-1)
print (y)

while y > 0:
    y = y - 1
    sys.stdout.write(x[y])
print("\n")

Result:
40
rolias neknurd eht htiw od ew llahs tahW

Online editors van Codingground

The online editors van Codingground:

http://www.tutorialspoint.com/codingground.htm

Making an error in the text

# Hello World program in Python
 
x ="What shall we do with the drunken sailor?"
print (len(x))
print (x[0:5] +"hs"+ x[7:40])

Result: What hsall we do with the drunken sailor

Editing text with python

# editing text with python
 
x = ("What shall we do with the drunken sailor?\n")

print (x[0:4])
print (len(x))
print (x[40])

Enlarging Libreoffice window completely with command

 You can open the LibreOffice window completely by pressing the CTRL+Shift+J keys together.