ITSECURITYCOMPUTER Telegram 26412
پایتون vs جاوا: کد کدوم کوتاه‌تره؟

با یک مثال ساده (فیبوناچی) می‌بینی پایتون چقدر کد رو کوتاه و خوانا می‌نویسه، درحالی‌که جاوا با نوع‌دهی و ساختار صریح، کنترل بیشتری می‌ده.
نتیجه؟ اگر می‌خوای سریع نمونه‌سازی کنی و اسکریپت بزنی، پایتون انتخاب خوبیه. اگر پروژه‌ی بزرگ و استاندارد سازمانی داری، جاوا می‌درخشه.

📱پایتون :
# Fibonacci up to n
n = int(input("n: "))
a, b = 0, 1
while a <= n:
print(a, end=" ")
a, b = b, a + b

📱جاوا :
import java.util.Scanner;

public class Fib {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("n: ");
long n = sc.nextLong();
long a = 0, b = 1;
while (a <= n) {
System.out.print(a + " ");
long next = a + b;
a = b;
b = next;
}
sc.close();
}
}

#java #python

✈️@ITSecurityComputer
Please open Telegram to view this post
VIEW IN TELEGRAM
❤‍🔥14👍82👎1



tgoop.com/ITSecurityComputer/26412
Create:
Last Update:

پایتون vs جاوا: کد کدوم کوتاه‌تره؟

با یک مثال ساده (فیبوناچی) می‌بینی پایتون چقدر کد رو کوتاه و خوانا می‌نویسه، درحالی‌که جاوا با نوع‌دهی و ساختار صریح، کنترل بیشتری می‌ده.
نتیجه؟ اگر می‌خوای سریع نمونه‌سازی کنی و اسکریپت بزنی، پایتون انتخاب خوبیه. اگر پروژه‌ی بزرگ و استاندارد سازمانی داری، جاوا می‌درخشه.

📱پایتون :

# Fibonacci up to n
n = int(input("n: "))
a, b = 0, 1
while a <= n:
print(a, end=" ")
a, b = b, a + b

📱جاوا :
import java.util.Scanner;

public class Fib {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("n: ");
long n = sc.nextLong();
long a = 0, b = 1;
while (a <= n) {
System.out.print(a + " ");
long next = a + b;
a = b;
b = next;
}
sc.close();
}
}

#java #python

✈️@ITSecurityComputer

BY SecurityComputer




Share with your friend now:
tgoop.com/ITSecurityComputer/26412

View MORE
Open in Telegram


Telegram News

Date: |

Select: Settings – Manage Channel – Administrators – Add administrator. From your list of subscribers, select the correct user. A new window will appear on the screen. Check the rights you’re willing to give to your administrator. A few years ago, you had to use a special bot to run a poll on Telegram. Now you can easily do that yourself in two clicks. Hit the Menu icon and select “Create Poll.” Write your question and add up to 10 options. Running polls is a powerful strategy for getting feedback from your audience. If you’re considering the possibility of modifying your channel in any way, be sure to ask your subscribers’ opinions first. 2How to set up a Telegram channel? (A step-by-step tutorial) Matt Hussey, editorial director at NEAR Protocol also responded to this news with “#meIRL”. Just as you search “Bear Market Screaming” in Telegram, you will see a Pepe frog yelling as the group’s featured image. It’s yet another bloodbath on Satoshi Street. As of press time, Bitcoin (BTC) and the broader cryptocurrency market have corrected another 10 percent amid a massive sell-off. Ethereum (EHT) is down a staggering 15 percent moving close to $1,000, down more than 42 percent on the weekly chart.
from us


Telegram SecurityComputer
FROM American