473,786 Members | 2,866 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

elif

176 New Member
Hello guys. I was wondering if you could use a thing in python in java. That is an elif statement. It is saying else if. It will execute a block of code if the condition in the if statement is false and the condition in the elif statement is true. So can you do this?
May 13 '08 #1
2 21338
BigDaddyLH
1,216 Recognized Expert Top Contributor
Hello guys. I was wondering if you could use a thing in python in java. That is an elif statement. It is saying else if. It will execute a block of code if the condition in the if statement is false and the condition in the elif statement is true. So can you do this?
That's just a shorthand used in languages like Python because of the way they define blocks and statements. In Java you just write the code:
Expand|Select|Wrap|Line Numbers
  1. if (condition1) {
  2.  
  3. } else if (condition2) {
  4.  
  5. } else {
  6.  
  7. }
In VB, for example, this would be:
Expand|Select|Wrap|Line Numbers
  1. If Condition1 Then
  2.  
  3. ElseIf Condition2 Then
  4.  
  5. Else
  6.  
  7. End If
Note: the ElseIf guarantees that only one End If is required.
May 13 '08 #2
Kid Programmer
176 New Member
That's just a shorthand used in languages like Python because of the way they define blocks and statements. In Java you just write the code:
Expand|Select|Wrap|Line Numbers
  1. if (condition1) {
  2.  
  3. } else if (condition2) {
  4.  
  5. } else {
  6.  
  7. }
In VB, for example, this would be:
Expand|Select|Wrap|Line Numbers
  1. If Condition1 Then
  2.  
  3. ElseIf Condition2 Then
  4.  
  5. Else
  6.  
  7. End If
Note: the ElseIf guarantees that only one End If is required.
Thanks I understand :-)
May 13 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2443
by: Christopher M. Lusardi | last post by:
Hello, Is there anyway to do it other than using : #ifdef VAR1 ... #endif
13
1930
by: Jim | last post by:
Could somebody tell me why I need the "elif char == '\n'" in the following code? This is required in order the pick up lines with just spaces in them. Why doesn't the "else:" statement pick this up? OLD_INDENT = 5 # spaces NEW_INDENT = 4 # spaces print 'Reindent.py:'
3
1963
by: lostsoul | last post by:
Hi All, I am new in learning programming. I am very lost. I read all of the chapters over and over again and I am still lost. I have the program below that I need to modify it to add hint to it when the user couldn't figure out the jumble word. Somehow the program didn't run. Can someone please look at it and enlighten me to see what I am missing? Is there any advise in learning and improving my programming skill? I am very disappointed at...
2
2599
by: Charles Sullivan | last post by:
I'm trying to maintain some older C code (FOSS) which has been patched by various individuals over the years for portability to multiple Unix-like operating systems, to wit: Linux, SunOS, Solaris, Free/Open/NetBSD, Mac OS X, AT&T SysV r4, SCO Unix, AIX, OSF, NextStep. I want to add some conditionals like this: #if defined(USECODE_A) /*use this code */
2
4100
by: juan-manuel.behrendt | last post by:
Hello together, I wrote a script for the engineering software abaqus/CAE. It worked well until I implemented a selection in order to variate the variable "lGwU" through an if elif, else statement. I am going to post the first 82 lines of the script, since the error message points at line 80: from abaqusConstants import * from abaqus import *
7
1702
by: Shawn Minisall | last post by:
I just learned about if, then elif statements and wrote this program. The problem is, it's displaying all of the possibilities even after you enter a 0, or if the fat grams are more then the total number of calories , that is supposed to stop the program instead of continuing on with the print statements that don't apply. Any idea's? thanks #Prompt for calories cal = input("Please enter the number of calories in your food: ") ...
2
1773
bvdet
by: bvdet | last post by:
We are parametrically attaching a bent plate object to the side of a building column for support of a skewed beam. Given a relative rotation between the column and beam and which side of the column to attach to, the following code determines the X and Y direction flags to calculate the exact location and the rotation tuple of the bent plate object. Here's the old code (about 5 years old):if _relrotation > 0.0 and _relrotation < 90.0: ...
6
1520
by: Neil Webster | last post by:
Hi all, I'm sure I'm doing something wrong but after lots of searching and reading I can't work it out and was wondering if anybody can help? I've got the following block of code: if a >= 20 and a < 100: if c == "c": radius = 500 else:
2
3526
by: sbtunx | last post by:
hi the problem is a syntax error that highlights pink the "elif" in the program just that. this code is to water mark picture "test.jpg" with the water mark of "model.jpg" with a mark on a white background the cod is: import Image,math model = Image.open("model.jpg") test = Image.open("test.jpg") x=test.size y=test.size im = Image.new("RGB",(x,y))
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.