fa
Feedback
Leetcode with dani

Leetcode with dani

رفتن به کانال در Telegram

Join us and let's tackle leet code questions together: improve your problem-solving skills Preparing for coding interviews learning new algorithms and data structures connect with other coding enthusiasts

نمایش بیشتر
1 259
مشترکین
-124 ساعت
-17 روز
-1130 روز
آرشیو پست ها
which concept is not clear for you until know

for answering all of the question you can leave a comment and share the channel for your friends

# code challenge Create a program that calculates the factorial of a given number using a for loop

#code_challenge Write a program that generates a random number between 1 and 100 and allows the user to guess the number. The program should provide hints (higher or lower) until the user guesses correctly.

#code_challenge write a code that checks if a given input is a palindrome or not. A palindrome is a word, phrase, number, or sequence of characters that reads the same forwards and backwards. For example, words like "level," "radar," and "madam" are palindromes because they are spelled the same way in reverse.

#code_challenge Write a program that checks if a given number is even or odd.

#code_challenge 1. Make a list of five or more usernames, including the name 'admin'. Imagine you are writing code that will print a greeting to each user after they log in to a website. Loop through the list, and print a greeting to each user: If the username is 'admin', print a special greeting, such as Hello admin, would you like to see a status report? Otherwise, print a generic greeting, such as Hello john, thank you for logging in again. .

4. What will be the output of the following code? x = 5 y = 5 print(x != y)
Anonymous voting

3. What will be the output of the following code? numbers = [3, 1, 5, 2, 4] numbers.sort(reverse=True) print(numbers)
Anonymous voting

we can sort the list temporarily numbers = [3, 1, 5, 2, 4] print(sorted(numbers)) #output => [1,2,3,4,5] print(numbers) #output=>[3, 1, 5, 2, 4]

numbers =[ 3, 1, 5, 2, 4] sortednumbers = sorted(numbers) print(sortednumbers)
Anonymous voting

4 #day_note 1. Sorting a List using the sorted() Function: - The sorted() function returns a new sorted list without modifying the original list. - Syntax: sortedlist = sorted(originallist) - Example: numbers = 5, 2, 8, 1, 9 sortednumbers = sorted(numbers) print(sortednumbers) # Output: 1, 2, 5, 8, 9 2. Sorting a List in-place using the sort() Method: - The sort() method sorts the list in-place, modifying the original list. - Syntax: originallist.sort() - Example: numbers = [5, 2, 8, 1, 9] numbers.sort() print(numbers) # Output: [1, 2, 5, 8, 9] 3. Sorting a List in Descending Order: - Both the sorted() function and the sort() method can sort a list in descending order. - Syntax: sortedlist = sorted(originallist, reverse=True) originallist.sort(reverse=True) - Example: numbers = 5, 2, 8, 1, 9 sortednumbers = sorted(numbers, reverse=True) print(sortednumbers) # Output: 9, 8, 5, 2, 1 numbers.sort(reverse=True) print(numbers) # Output: 9, 8, 5, 2, 1

please make sure to read and understand the lecture I provided above. before answer the question

password = input("Enter your password: ") correct_password = "dani1234" if password.lower() == correct_password: print("Congratulations.") else: print("Try again.") What is the out put of the above code if the user gives "DAni1234" as input?
Anonymous voting

3. #day_note the upper, lower, and title methods in Python. 1. Upper Method: The upper() method is used to convert all characters in a string to uppercase. It returns a new string with all uppercase letters. Here's an example: python string = "hello world" uppercase_string = string.upper() print(uppercase_string)  # Output: "HELLO WORLD" 2. Lower Method: The lower() method is the opposite of upper(). It converts all characters in a string to lowercase. Here's an example: python string = "Hello World" lowercase_string = string.lower() print(lowercase_string)  # Output: "hello world" 3. Title Method: The title() method is used to capitalize the first letter of each word in a string. It converts the first character of each word to uppercase and all other characters to lowercase. Here's an example: python string = "hello world" title_string = string.title() print(title_string)  # Output: "Hello World"

#day_note .what is the use of continue statement in python? ,the continue statement is used to skip the rest of the code inside a loop and move on to the next iteration. When the continue statement is encountered, it immediately jumps to the next iteration of the loop without executing any further statements below it in the current iteration for num in range(1, 6): if num == 3: continue print(num) Output: 1 2 4 5 In this example, the loop iterates over numbers from 1 to 5. However, when num equals 3, the continue statement is triggered, causing the program to skip printing that particular number and proceed to the next iteration. The continue statement is commonly used when you want to skip certain iterations based on specific conditions or when you want to exclude certain elements from the loop's processing.

What will be the output of the following code? python my_dict = {'apple': 1, 'banana': 2, 'cherry': 3} for key in my_dict: print(key) A) apple banana cherry B) 1 2 3 C) apple D) Error
Anonymous voting

1. What will be the output of the following code? python i = 0 while i < 5: if i == 2: break print(i) i += 1
Anonymous voting

5. numbers = [2, 4, 6, 8, 10] product = 0 for number in numbers:     product *= number print("The product of numbers is:", product) Output:
Anonymous voting

4.numbers = [1, 2, 3, 4, 5] total = -1 for number in numbers:     if number % 2 == 0:         total += number print("The total is :", total) Output:
Anonymous voting