-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpr.py
More file actions
111 lines (90 loc) · 3.35 KB
/
pr.py
File metadata and controls
111 lines (90 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# 1 prepare a code to check the voters eligibility. Take a variable int age. if age is greater than 18
# print. "eligible" else print " not eligible".
# age=int(input("Enter Your Age:"))
# if age>=18:
# print("You are Eligible to vote")
# else:
# print("You are Not Eligible to vote")
# 2. Create a code to check the length of a string = "Hi I’m learning in PFE, I will become a
# developer". Now if the length is greater than 28 change the string to "I will become a
# developer". and print "Successfully changed."
# str=" Hi I’m learning in PFE, I will become a developer"
# if len(str)>28:
# n=str.replace("Hi I’m learning in PFE, I will become a developer","I will become a developer",28)
# print("Successfully Changed",n)
# 3. Change two strings with using third variable
# str1=str(input("Enter First String:"))
# str2=str(input("Enter Second String:"))
# print("Before change:")
# print("Str 1:"+str1)
# print("Str 2:"+str2)
# temp = str1
# str1 = str2
# str2 = temp
# print("After change:")
# print("Str 1:"+str1)
# print("Str 2:"+str2)
# 4. Change 2 strings without using third variable.
# str1=str(input("Enter First String:"))
# str2=str(input("Enter Second String:"))
# print("Before change:")
# print("Str 1:"+str1)
# print("Str 2:"+str2)
# str1,str2= str2,str1
# print("After change:")
# print("Str 1:"+str1)
# print("Str 2:"+str2)
# 5. Create a Java program to print your details, like name, address, phone number, blood group
# etc.
# def details():
# name = str(input("Your Name"))
# address = str(input("Your Address"))
# phone_number = int(input("Your Phone Number"))
# blood_group = str(input("Your Blood Group"))
# print("Name:", name)
# print("Address:", address)
# print("Phone Number:", phone_number)
# print("Blood Group:", blood_group)
# details()
# 6. Create a Java program to change the value of a given variable, for example a is iniƟalzed as
# 10 and make it to 20.
# n=10
# temp=20
# n=temp
# print(n)
# 7. Write a Java program to print the sum of three numbers.
# a=10
# b=20
# c=30
# print(a+b+c)
# 8. Write a Java program to print square of a number.
# a=int(input("Enter no:"))
# print("Square Of No:",a*a)
# 9. Write a java program which iniƟalizes a variable name and greets with "Hello , have a good
# day
# 10. Try to understand what happens when type casƟng is done from char to int and int to char
# (Hint: Ascii Values)
# 11. Try to print the length of you name and full name, and then print the difference between the
# characters of the first name and last name. For example: F_name - Nilkanth L_name - Java
# f_name="Rohan"
# l_name="Mane"
# print(len(f_name)-len(l_name))
# Output for the above should be 4.
# 12. Check what is the number of leƩer for "K" String: ABCDEFGHIJKLMNOPQRSTUVWXYZ
# str= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
# print(str.index("K")+1)
# Example: for D number should be 4
# 13. Concatenate two Strings Example for two Strings:: String a= Nilkanth String b= Java OutputNilkanthJava
# str1="Rohan"
# str2="Mane"
# print(str1+str2)
# 14. Concatenate one String and one integer. Example for one String and two integer: String a =
# Nilkanth int b = 6197 int c = 1234 Output: Nilkanth619712344
# str1="Rohan"
# phno1=93091
# phno2=60678
# print(str1+str(phno1)+str(phno2))
# 15. Print the mathemaƟcal table for 5.
# for i in range(1,11):
# t=5*i
# print(t)