41
loading...
This website collects cookies to deliver better user experience
open the System Properties window.
Navigate to the Advanced tab and select Environment Variables.
Under System Variables, find and select the Path variable.
Click Edit.
Select the Variable value field. Add the path to the
python.exe file preceded with a semicolon
Click OK and close all windows.
print("Hello World!")
python3 hello.py
Hello World!
input
This is data from an external source (outside environment) that is fed into the program for it to manipulate and process. The various sources may be sensors, keyboard, data from other programs, files e.t.c.
output
This is the result of a program process which is displayed on a screen or stored in a file.
sequential execution
This is an orderly execution of scripted statements.
conditional execution
This is the execution of a given block of statements if a specified condition is met.
repeated execution
Perform some set of statements repeatedly, usually with some variation.
reuse
This involves writing a given set of codes once and then use them in several instances of the program whenever necessary.
#This is a single line comment
'''
Author: Naftal Rainer
Date: 23/07/2021
'''
# X is the variable name and 2 is the value assigned
x = 2
# y is the variable name and 100 is the value assigned
y = 100
# name is the variable name and "Naftal" is the value assigned
name = "Naftal"
x = 'Hello'
y = "World"
m = """My name is Paul Mwasame and
I find learning python to be super exciting."""
Operator | Description |
---|---|
+ | addition |
- | subtraction |
* | multiplication |
/ | division |
** | exponentiation |
% | modulo (remainder) |
// | integer division |
L = [1,2,3]
L2 = [1, 2.718, 'abc', [5,6,7]]
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,20,30,
40,50,60,70,80,90,100,200,300,400,500]
myList = eval(input('Enter a list: '))
print('The first element is ', myList[0])
t = (1,2,3)
t1 = tuple([12,25,93])
t2 = tuple('abcde')
t1 = ();
t1 = (5,)
tuple1 = ('Nairobi', 'New York', 1997, 2000)
tuple2 = (1, 2, 3, 4, 5, 6, 7 )
print ("tup1[0]: ", tup1[0])
print ("tup2[1:5]: ", tup2[1:5])
# Empty dictionary
d = {}
dict = {'A':100, 'B':200}
# To change the value of A to 300
d['A']=300