# 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
vrijdag 22 januari 2016
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
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
Perl script: What shall we do with the drunken sailor?
#!/usr/bin/perl
use strict;
use warnings;
my $x = "What shall we do with the drunken sailor?\n";
my $y = "Early in the morning.\n\n";
print "$x" x 3;
print "$y";
my $z = "Heave ho, and up she rises\n";
print $z x 3;
print $y;
Result:
What shall we do with the drunken sailor.
What shall we do with the drunken sailor.
What shall we do with the drunken sailor.
Early in the morning.
Heave ho, and up she rises.
Heave ho, and up she rises.
Heave ho, and up she rises.
Early in the morning.
use strict;
use warnings;
my $x = "What shall we do with the drunken sailor?\n";
my $y = "Early in the morning.\n\n";
print "$x" x 3;
print "$y";
my $z = "Heave ho, and up she rises\n";
print $z x 3;
print $y;
Result:
What shall we do with the drunken sailor.
What shall we do with the drunken sailor.
What shall we do with the drunken sailor.
Early in the morning.
Heave ho, and up she rises.
Heave ho, and up she rises.
Heave ho, and up she rises.
Early in the morning.
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
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])
x = ("What shall we do with the drunken sailor?\n")
print (x[0:4])
print (len(x))
print (x[40])
Abonneren op:
Posts (Atom)
Enlarging Libreoffice window completely with command
You can open the LibreOffice window completely by pressing the CTRL+Shift+J keys together.
-
There is a way to delete empty lines in LibreOffice with regex. It is this command: ^$ But sometimes this doesn't work. Because the a...
-
Als je een goede pdf wilt maken van een Volkskrant artikel, moet je als volgt te werken gaan. Open de Volkskrant pagina, waar je een pdf van...
-
Changing language of keyboard with the command: setxkbmap fr.