Advertisement
here2share

# py_to_cpp_testing.py

Jan 28th, 2021
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.73 KB | None | 0 0
  1. # py_to_cpp_testing.py
  2.  
  3. class TestObject:
  4.     def __init__(self,name,value):
  5.         self.name = name
  6.         self.value = value
  7.     def print_object(self):
  8.         print(self.name)
  9.         print(self.value)
  10. def TestFunction(a,b,c,randfloat):
  11.     x_value = a+a
  12.     y_value = randfloat/2
  13.     print(a)
  14.     print(c,randfloat)
  15.     return x_value,y_value
  16. #Test.py
  17. a=1
  18. e=-2
  19. b=2.2
  20. f=-3.7
  21. c='Hello'
  22. d="World"
  23. g=[2.2,3.3,4.4]
  24. matrix=[[2,2,2],[3,3,3],[4,4,4]]
  25. print('Hello2')
  26. print("Hello3")
  27. if(a==1):
  28.     print(c)
  29.     print(d)
  30.     if(c=='Hello'):
  31.         print('Yay')
  32.     else:
  33.         print('Nay')
  34. elif(b==2):
  35.     print("Test")
  36.     if(d=='World'):
  37.         print('Yay 2')
  38.     else:
  39.         print('Nay 2')
  40. else:
  41.     pass
  42. print('Extra')
  43. value = TestFunction(a,g,c,b)
  44. for i in range(0,5):
  45.     g[i] = 1.1
  46.     g.append(9.9)
  47. test_value = g[1]
  48. g[1] = 5.1
  49. incrementor = 1
  50. boolean = True
  51. while(incrementor<10):
  52.     incrementor+=1
  53.     break
  54. if(boolean == True):
  55.     print('False')
  56. object1 = TestObject('Object_name',7.2)
  57. object1.print_object()
  58. for i in range(0,len(g)):
  59.     print(i)
  60. for element in g:
  61.     print(element)
  62. object2 = TestObject('Object_name_2',3.3)
  63. object2.print_object()
  64. object3 = TestObject('New_Name_1',1.0)
  65. object3.print_object()
  66. for i in reversed(range(0,len(g))):
  67.     print(i)
  68. convert_input_to_int = int(input('Enter your age (years): '))
  69. print(convert_input_to_int)
  70. string_input = raw_input('Enter your name: ')
  71. print(string_input)
  72. empty_list_dec = []
  73. empty_list_dec.append('string_to_push_back')
  74. for i in empty_list_dec:
  75.     print(i)
  76. read_file = open('RWTest.txt','r')
  77. lines = []
  78. for file_line in read_file:
  79.     lines.append(file_line)
  80. read_file.close()
  81. for i in lines:
  82.     print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement