Julia Tutorial - 6. If Statement and Ternary Operator
Key Takeaways
Demonstrates Julia if statement and ternary operator
Full Transcript
hello and welcome to code Basics coding tutorial today's topic is if statement and Turner operator in Julia if you some programming experience you are already familiar with if statement what it does is it evaluates a condition then executes a certain block of code so for example here I have this variable which I have initialized with a minus value negative value and I want to know if this number is positive number or negative number uh in order to figure out that uh I will use if statement so I will say if x is less than zero then print it is negative else print that is it is positive and remember in Julia to end the if else you have to put and keyword here okay if I execute this this is saying negative it gave me this deprecation warning because of this extra space if I execute again using this play button it will tell me that the number X is negative now if I change this number to a positive number and again execute using the play button and again execute this guy now it is saying it is a positive number uh here uh we are using IF and else which means if it satisfies this condition then it will execute this particular code block otherwise it will execute this line sometimes you might have multiple if condition for example this uh code is not complete you want to check for zero as well in that case you will say else if x greater than zero then print positive so this one is positive number and the last one is else then print zero okay and let me make this one zero so if I execute this again and again this will be zero okay if I make it positive positive it's going to be positive I make it negative it's going to be negative so it's quite simple okay uh now you can do the same thing using a tary operator as well if condition is typically used when you have a bigger block of code to execute here our code is very simple we are checking uh some condition and we're just printing a statement so the same thing I can do you using turn operator so I can say print X less than Z question mark so here the first thing is your condition the second thing is a question mark which means is X less than zero if it is then it means it's a negative number and the SSE condition will be separated using a column so column you will say positive and if you execute this it says it's a negative number if you make it positive it's going to say it's positive inary operator you can write Nary operator so you can enclose this particular condition in a bracket and you can check for zero as well so you will say x is greater than Z if x is greater than Z then it is positive otherwise it is zero so you can do this thing and if you execute right now it is saying positive because my X is a positive number if I make it zero it is going to say it is zero so that was a nice quick introduction on if and tary operator thanks for watching
Original Description
Do you want to learn technology from me? Check https://codebasics.io/ for my affordable video courses.
Website: http://codebasicshub.com/
Facebook: https://www.facebook.com/codebasicshub
Twitter: https://twitter.com/codebasicshub
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from codebasics · codebasics · 25 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
▶
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Python Tutorial - 1. Install python on windows
codebasics
Python Tutorial - 2. Variables
codebasics
Python Tutorial - 3. Numbers
codebasics
Python Tutorial - 4. Strings
codebasics
Python Tutorial - 5. Lists
codebasics
Python Tutorial - 6. Install PyCharm on Windows
codebasics
PyCharm Tutorial - 7. Debug python code using PyCharm
codebasics
Python Tutorial - 8. If Statement
codebasics
Python Tutorial - 9. For loop
codebasics
Python Tutorial - 10. Functions
codebasics
Python Tutorial - 11. Dictionaries and Tuples
codebasics
Python Tutorial - 12. Modules
codebasics
Python Tutorial - 13. Reading/Writing Files
codebasics
How to install Julia on Windows
codebasics
Python Tutorial - 14. Working With JSON
codebasics
Julia Tutorial - 1. Variables
codebasics
Julia Tutorial - 2. Numbers
codebasics
Python Tutorial - 15. if __name__ == "__main__"
codebasics
Julia Tutorial - Why Should I Learn Julia Programming Language
codebasics
Python Tutorial - 16. Exception Handling
codebasics
Julia Tutorial - 3. Complex and Rational Numbers
codebasics
Julia Tutorial - 4. Strings
codebasics
Python Tutorial - 17. Class and Objects
codebasics
Julia Tutorial - 5. Functions
codebasics
Julia Tutorial - 6. If Statement and Ternary Operator
codebasics
Julia Tutorial - 7. For While Loop
codebasics
Python Tutorial - 18. Inheritance
codebasics
Julia Tutorial - 8. begin and (;) Compound Expressions
codebasics
Python Tutorial - 12.1 - Install Python Module (using pip)
codebasics
Julia Tutorial - 9. Tasks (a.k.a. Generators or Coroutines)
codebasics
Julia Tutorial - 10. Exception Handling
codebasics
Python Tutorial - 19. Multiple Inheritance
codebasics
Python Tutorial - 20. Raise Exception And Finally
codebasics
Python Tutorial - 21. Iterators
codebasics
Python Tutorial - 22. Generators
codebasics
Python Tutorial - 23. List Set Dict Comprehensions
codebasics
Python Tutorial - 24. Sets and Frozen Sets
codebasics
Python Tutorial - 25. Command line argument processing using argparse
codebasics
Debugging Tips - What is bug and debugging?
codebasics
Debugging Tips - Conditional Breakpoint
codebasics
Debugging Tips - Watches and Call Stack
codebasics
Python Tutorial - 26. Multithreading - Introduction
codebasics
Git Tutorial 3: How To Install Git
codebasics
Git Tutorial 1: What is git / What is version control system?
codebasics
Git Tutorial 2 : What is Github? | github tutorial
codebasics
Git Tutorial 4: Basic Commands: add, commit, push
codebasics
Git Tutorial 5: Undoing/Reverting/Resetting code changes
codebasics
Git Tutorial 6: Branches (Create, Merge, Delete a branch)
codebasics
Git Github Tutorial 10: What is Pull Request?
codebasics
Git Tutorial 7: What is HEAD?
codebasics
Git Tutorial 9: Diff and Merge using meld
codebasics
Difference between Multiprocessing and Multithreading
codebasics
Python Tutorial - 27. Multiprocessing Introduction
codebasics
Python Tutorial - 28. Sharing Data Between Processes Using Array and Value
codebasics
Git Tutorial 8 - .gitignore file
codebasics
Python Tutorial - 29. Sharing Data Between Processes Using Multiprocessing Queue
codebasics
Python Tutorial - 30. Multiprocessing Lock
codebasics
Python Tutorial - 31. Multiprocessing Pool (Map Reduce)
codebasics
What is code?
codebasics
Python unit testing - pytest introduction
codebasics
Related Reads
📰
📰
📰
📰
AI For Time Management: How Artificial Intelligence Can Help You Get More Done Every Day
Medium · ChatGPT
AI-Ready Infrastructure: A Checklist Before You Scale
Dev.to AI
How I Cut My OpenAI Bill by 97% — The Full Migration Guide
Dev.to · rarenode
Your Website Passed Claude’s Search Test. It Might Still Fail the Other Two
Medium · AI
🎓
Tutor Explanation
DeepCamp AI