|
| 1 | +For Tutorials: https://animevyuh.org/category/python-tutorials |
| 2 | + |
| 3 | +#Program 1: |
| 4 | + |
| 5 | +Write a Program to swap data between two variables |
| 6 | + |
| 7 | +Open your Interactive shell or text editor or IDE anything you are comfortable with it |
| 8 | + |
| 9 | +Method 1 to swap with temp |
| 10 | + |
| 11 | +main_character = "Light yagami" |
| 12 | +loved_character = "L Lawleit" |
| 13 | +print(‘Before Swap:’) |
| 14 | +print(‘Main Character:’,main_character) #light is output |
| 15 | +print(‘Side Character:’,loved_character) #l is output |
| 16 | +temp = main_character #create a temporary variable to store main variable in it |
| 17 | +main_character = loved_character #loved_character name Is successfully swaped to main |
| 18 | +loved_character = temp #temp which had main in it is swaped to loved |
| 19 | +print(‘After Swap:’) |
| 20 | +print(‘Main Character:’,main_character) #l is output |
| 21 | +print(‘Side Character:’,loved_character) #light is output |
| 22 | + |
| 23 | +Results are swapped, run the program to see changes. |
| 24 | + |
| 25 | +Method 2 to swap without temp |
| 26 | + |
| 27 | +main_character = "Light yagami" |
| 28 | +loved_character = "L Lawleit" |
| 29 | +print(‘Before Swap:’) |
| 30 | +print(‘Main Character:’,main_character) #light is output |
| 31 | +print(‘Side Character:’,loved_character) #l is output |
| 32 | +main_character,loved_character = loved_character,main_character #swap successful |
| 33 | +print(‘After Swap:’) |
| 34 | +print(‘Main Character:’,main_character) #l is output |
| 35 | +print(‘Side Character:’,loved_character) #light is output |
| 36 | + |
| 37 | +#Program 2: |
| 38 | + |
| 39 | +Write a Program to convert Dollar to Rupee and add 50 rupee as tip |
| 40 | + |
| 41 | +dollar = 56.76 |
| 42 | +dollar_to_INR = 77.76 |
| 43 | +rupee = dollar * dollar_to_INR |
| 44 | +final_amt = rupee + 50.00 |
| 45 | +print(final_amt) |
| 46 | + |
| 47 | +#Program 3: |
| 48 | + |
| 49 | +You are the owner of restaurant greet your customer with specific inputs |
| 50 | +[user input includes name and dish he could like to eat] |
| 51 | + |
| 52 | +name = input("Enter Customer Name:") |
| 53 | +dish = input("What could you like to it? ") |
| 54 | +print("Welcome to Anime Foods "+name) #you can also use comma, instead of + |
| 55 | +print("We could love to serve "+dish) |
| 56 | +print("Thank you for coming") |
| 57 | + |
| 58 | +#Program 4 |
| 59 | + |
| 60 | +Take two input numbers and perform addition, subtraction, multiplication and division |
| 61 | + |
| 62 | +num1 = int(input("Enter num1: ")) #ask for integer input |
| 63 | +num2 = int(input("Enter num2: ")) |
| 64 | +add = num1+num2 |
| 65 | +sub = num1-num2 |
| 66 | +mul = num1*num2 |
| 67 | +divide = num1/num2 |
| 68 | +print("Sum =",add) |
| 69 | +print("Difference =",sub) |
| 70 | +print("Multiply =",mul) |
| 71 | +print("Division =",divide) |
| 72 | + |
| 73 | + |
| 74 | +#Program 5 |
| 75 | + |
| 76 | +Write a program for a conversation between two people. [USE: input()] |
| 77 | + |
| 78 | +person1 = input("Enter Person1 name:") |
| 79 | +person2 = input("Enter Person2 name:") |
| 80 | +print(person2,":Hello",person1) |
| 81 | +print(person1,":Nice to meet you",person2) |
| 82 | +print(person2,":Can I know your age?") |
| 83 | +age_person1 = int(input()) |
| 84 | +age_person2 = int(input()) |
| 85 | +print(person1,":I am",age_person1,"years old, May I know your age?") |
| 86 | +print(person2,":I am",age_person2) |
| 87 | + |
| 88 | +Check Anime Vyuh: https://animevyuh.org/ For more |
| 89 | +Follow on Twitter to Stay Tuned for new programs https://twitter.com/TRJ_0751 |
0 commit comments