python-2.7


Right now I am writing codes in sublime text software and running them in cmd. But when I run this set of codes nothing happens. why?


I am new to coding in python. Right now I am writing codes in sublime text software and running them in cmd. But when I run this set of codes nothing happens. why??
num = int(raw_input("Enter a number: " ))
print("The number entered by you is" + num)
mod = num % 2
if mod == 0:
print("The number entered is even")
else:
print("The number is odd")
I am a bit rusty with python myself, but this should be easy. Try adding the following line in the beginning of your code:
if __name__ == "__main__":
Or, put your code in the function (let's say, pick_a_number()), and then you could do this:
if __name__ == "__main__":
pick_a_number()

Related Links

evdev module install for Anaconda (Python 2.7) Windows 10
Using lambda functions and dictionaries to show a function can be written in different ways
Dataset transpose ideas using AppEngine python without pandas
I'm using Python to load data points using genfromtxt command but getting error message “data.txt not found”
PhantomJS incompatible to HTML5 and CSS3 web technology
Python evdev equivalent for Windows 10
OpenCV 3.1 + Gstreamer 1.0 + http src = Internal data flow error
Protobuf is installed, but I still get `ImportError: No module named google.protobuf`
Error while connecting to Azure via pymssql on Ubuntu
Python Evaluating 8 > 10 To True
How to create a dotplot of two DNA sequence in python
Python: How to return a list?
Odoo - Large processes always turns to an InternalError at last
I'm getting <__main__.Root object at 0x9b61e880>, instead of just string or unicode string
no module named urllib3 - trying to install pip
Use List comprehension instead of loop in python

Categories

HOME
ionic2
eclipse-plugin
redmine
ios-simulator
header
jint
onvif
graphql-js
timber
port
mutation-testing
azure-graph-api
slide
getopenfilename
circleci
buffer
jquery-select2-4
playframework-2.0
exec-maven-plugin
office-ui-fabric
spam
parceler
cmake-gui
bluemix-mobile-services
amazon-sns
pyspark-sql
monitor
winsock
mongodb-3.4
caesar-cipher
custom-keyboard
cmis
pdfnet
ms-dos
cartopy
strapi
elastica
netapp
cloudera-sentry
optionaldataexception
jqgrid-asp.net
nuclio
webalizer
android-webservice
watir-webdriver
test-data
glassfish-4.1
gmaps.js
ndk-build
system.web.optimization
clp
ftp-client
spring-mongo
fdt
gulp-uglify
bayesglm
http.client
asp.net-web-api-helppages
css-paged-media
postal-code
ngcordova
green-threads
bootstrap-wysiwyg
dos2unix
thoughtworks-go
smacss
xml-signature
nidaqmx
libgcc
windows-taskbar
profiles
assetic
principalcontext
meteorite
django-settings
eclim
ember-table
form-for
bcdedit
jquery-lazyload
arel
significant-digits
cyrillic
onconfigurationchanged
gitx
first-class
image-scanner
kolite
mediacontroller
directshow.net
stretchblt
datagridcolumn
server-load

Resources

Encrypt Message